Deployment Tutorial
This tutorial will demonstrate how to deploy a KPI Option using the launch-lsp
repository.
Deployment process
The following is an overview of the deployment steps below.
Set up LSP deployment prerequisites
Decide on your contract parameters
Run the deployment on testnet (Kovan)
Run the deployment on mainnet (Ethereum)
LSP Prerequisites
Please follow the instructions here to set up your dev environment for deploying an LSP.
Setting your parameters
For our deployment tutorial, we are going to use the example KPI Option based on UMA's TVL tracked on DefiLlama (UMA-TVL-1222) as a reference when setting the LSP parameters and customizing the deployment script.
Mandatory deployment parameters
Each deployment requires the following parameters to be set at the point of deployment:
gasprice:
The gas price used for your contract deployment.url:
your node URL.mnemonic:
Your 12 word seed phrase.expirationTimestamp:
Unix timestamp when the KPI Options expire. The UMA team wants to incentivize a TVL over $1 billion by the end of 2022. Therefore, the UMA-TVL-1222 contract uses 1672473600 which represents the Unix timestamp for December 31, 2022.collateralPerPair:
The amount of collateral required to mint each long and short pair. The UMA-TVL-1222 contract uses 1 $UMA, meaning 1 $UMA mints 1 long and 1 short token. If 4 $UMA was used as collateral to mint, the minter would receive 4 long and 4 short tokens.priceIdentifier:
Should be set toGeneral_KPI
.collateralToken:
Approved collateral currency to be used. The UMA-TVL-1222 contract uses the UMA token as collateral.pairName:
The desired name of the token pair. The UMA-TVL-1222 contract uses 'UMA TVL KPI Option December 2022'.longSynthName:
The full-length name of the long token. The UMA-TVL-1222 contract uses 'UMA TVL KPI Option December 2022'.longSynthSymbol:
The ticker name of the long token. The UMA-TVL-1222 contract uses 'UMA-TVL-1222'.shortSynthName:
The full-length name of the short token. The UMA-TVL-1222 contract uses 'UMA TVL KPI Option Short Token December 2022'.shortSynthSymbol:
The ticker name of the short token or ticker symbol. The UMA-TVL-1222 contract uses 'UMA-TVL-1222s'.
Optional deployment parameters
proposerReward:
Proposal reward to be forwarded to the created contract to be used to incentivize price proposals. This defaults to zero if not provided.optimisticOracleLivenessTime:
Time in seconds, the proposed expiration price can be disputed. This generally should be at least a couple of hours for KPI options but might require longer time for more complex KPI options target metric calculations. This defaults to 2 hours if not provided.optimisticOracleProposerBond:
Additional bond a proposer must post with the optimistic oracle. This defaults to match the final fee if not provided.
Ancillary Data Specifications
The customAncillaryData
parameter is used for KPI Options to instruct voters on how to resolve a price request for the price identifier and request timestamp. The ancillary data used for the UMA-TVL-1222 KPI Option is shown below for example purposes. Please reference the section on KPI Option Configuration for more details on constructing ancillary data for your contract.
Key-value pairs above are formatted just for readability, but no white-spaces should be used in real application. When this ancillary data dictionary (without white-spaces) is stored as bytes, the result would be:
FPL deployment parameters
The fpl
parameter determines the type of financial product library (FPL) used for the payout function based on a resolved target KPI metric as documented in supported payout functions section. The most applicable FPLs for KPI options might be:
BinaryOption
to select Binary Options type that would either pay out nothing or maximum amount (set incollateralPerPair
) to KPI options token holders depending on whether the target metric threshold is met.Linear
to select Linear type that would pay out nothing when lower bound of target metric threshold is not met, a maximum amount (set incollateralPerPair
) when upper bound of target metric threshold is met, and proportional payout when target metric is between its lower and upper bounds.
The UMA-TVL-1222 contract uses Linear
as the FPL parameter which instructs voters on how to resolve a price request for the price identifier and request timestamp.
The Linear
FPL requires lowerBound
and upperBound
parameters to be set to determine the payout function. Based on the desired UMA-TVL-1222 payout logic, the lowerBound
parameter should be set to 0 and the upperBound
parameter should be set to 1000 (scaled up by 18 decimals) interpreted as reaching 1 billion USD (one thousand millions).
Simulating Deployment
Before running this command, you should customize the parameters to your needs and passing --simulate
parameter. YOUR_NODE_URL
should be filled in with a url for the network that you wish to deploy to. The deployment script has been pre-filled with the parameters for the UMA-TVL-1222 contract.
If using Infura for mainnet simulation, YOUR_NODE_URL
will follow this format:
Run the simulation script with your specific parameters.
Deploying to Mainnet
The method to deploy onto mainnet is the exact same as with simulation, except for skipping --simulate
parameter.
You can now run the deployment script. From within the launch-lsp
directory, run:
Once deployed, the script will list the address of your newly deployed LSP. A successful output will look like this:
Last updated