Create a Piggy
Last updated
Last updated
Refer back to Parts of a Piggy as required.
To create a piggy, select the New Piggy button on the menu bar. This will open a model which will allow a choice between creating a piggy or requesting a piggy.
Choose Create to create a piggy (Requesting a piggy is detailed in the next section).
Selecting Create will navigate to a form in which each parameter can be specified.
Click on the drop down menu to choose an underlying. SmartPiggies maintains a set of curated underlyings on the platform. In this example, the Ethereum price in dollars serves as the underlying for the piggy. The underlying selection will also detail the oracle providing the price upon settlement. In this example SmartPiggies will provide the price, as denoted by SP. There are other oracle services to choose from, some on-chain, some off-chain. See the Oracles section for more details.
Next, select the type of collateral that will be deposited into the piggy.
Click the drop down menu and select a listed collateral. SmartPiggies also maintains a curated set of collateral ERC20 tokens available to be deposited. The collateral choices available on the platform conform to the ERC20 standard, and have been tested. If you would like to choose from a collateral token not listed, contact the team to see if it is possible to add. The SmartPiggies smart contract can also be interacted with directly to supply any parameters not available on the platform at a specific time. The contract is public and permissionless.
For this piggy, the Truffle Stable Token is chosen.
Collateral must be approved in order to deposit collateral into a piggy. This is a common design pattern in Ethereum, and has to do with the SmartPiggies smart contract depositing the collateral into a piggy on behalf of the user. The contract can only deposit what you confirm, but an approval transaction is needed before a piggy can be created.
If approval has not yet been completed for a desired collateral token, use the wallet drop down menu on the top right of the page, and toggle the collateral choices listed. This will initiate an approval transaction.
include picture of this, Toby's laptop can't see this section of the website.
We make a single, high-value approval. (Amount?)
TODO: Picture from PP.
The approval can be revoked at any time using the associated wallet switch. (Or by using https://approved.zone/ or https://etherscan.io/tokenapprovalchecker.)
Following the collateral, the next set of execution parameters can be selected.
Select a Strike Price for the piggy. This will determine the direction of the piggy. If the strike price is above the spot price of the underlying, the piggy will execute as a CALL option. If the strike price is set below the spot price, the piggy will execute as a PUT option. The current example will be a PUT, as the date it is being created the spot price of ETH/USD is $2000. As the piggy is in-the-money when the price descends below $1500, this piggy will execute as a classic PUT option would.
The Max Loss is the total amount of collateral that will be deposited into the piggy. Please be sure that your wallet has approved this collateral transfer to the SmartPiggies smart contract, and that you have enough collateral described by the parameters. Otherwise the transaction will fail.
Next choose the Lot Size and Expiration.
Lot Size is the multiplier for the piggy. This represents the contracts covered by the piggy, and during settlement will factor into the payout. In the current example, the piggy will execute as a PUT option, with a strike at $1500. The Max Loss is $1000, this is the total amount of payout available to holder of this piggy. If the price of Ethereum went to $1000, and the holder settles the piggy, the payout would be ((Strike - Spot) * Lot Size) and in our example equate to $500 ((1500-1000) * 1). If the Lot Size had been 2, the payout would have been $1000. Note that this is the Max Loss of the piggy. The holder gets the full collateral deposited into the piggy and the write receives no difference.
If the Lot Size had been 4, the Max Loss is reached much faster. When the Lot Size is 4 the collateral is depleted when the Ethereum price hits $1250 ((1500 - 1250) * 4). This means the holder could have executed the piggy at $1250 for a payout of the Max Loss, or could have still executed at $1000, but the payout would be the same. The maximum payout of the piggy is $1000.
To visualize how a piggy pays out, when creating a piggy, the Payout Triangle can be used.
Payout with a Max Loss of $1000 and a Lot Size of 1
Payout with a Max Loss of $1000 and a Lot Size of 2
Payout with a Max Loss of $1000 and a Lot Size of 4
The payouts react differently depending on the Lot Size.
The piggy is only valid for a certain duration of time. There is no limit to this time frame, only that it needs to be in the future. The expiration is represented as a Unix Timestamp. Click on the Contact Expiration Date field to set a date. This prompts with a calendar for easy selection.
A piggy does have second resolution, but keep in mind that the timestamp is extracted from the block, so there will be small gaps between the time a piggy may expire in seconds, and the block representing the passage of that time. See the Expiry section in Creating your first Piggy for more information.
The piggy isn't going to do any good if no one can see it. To offer the piggy to anyone who may need it, the piggy must be placed on auction.
To auction the a piggy specify the start price, reserve price, and auction expiration date:
A piggy undergoes a dutch auction, where by the price starts high, and decreases over the duration of the auction. Here, the Start Price is $100 and will decrease to $20, the reserve. If no one buys the piggy before the reserve is hit, the piggy will remain at a price of $20, until someone does buy it, or the auction expires. This auction will be valid until May 31st, 2021. After the expiration no one will be able to purchase the piggy.
You can protect the piggy from price movements during the auction by setting a Protection Limit. This will make the piggy un-purchasable if the price gets too close or exceeds the Strike Price during an auction. Select the toggle next to the Create & Auction button to activate the fields.
In this example, the piggy executes as a PUT option with a Strike Price of $1500. If the piggy is on auction, and there is an extreme market event that drops the price below $1600, this piggy can't be purchased. The price must be above $1699 in order for someone else to buy it. Of course if someone is already the holder of a piggy and there is a market event that moves the price of Ethereum to $1000, the holder, already owning the piggy, can execute. But if this situation occurred and the piggy was on auction, the piggy is insulated from this event, and the writer protected against this volatility prior to a counterparty purchasing it.
Click on the Create & Auction button to send the transaction to the network. The user wallet will pop up to confirm the transaction.
Note that it is possible for a malicious application to approve a large amount of tokens on behalf of a user, and attempt to trick the user into transferring more tokens than expected, or having a large approval can open the user to attacks if the contract is exploited. The SmartPiggies platform does approve a large amount, this is done for convenience so that user doesn't have to make an approval every time a piggy is created. However, the user must confirm any transaction, firstly, and second, please be aware of the transfer amount listed on the transaction. Confirm the token amount being transferred. If something looks wrong, do not confirm the transaction on MetaMask.