How To Create Your Own Option
You will need 4 steps to create your own option:
    1.
    Get the OptionFactoryaddress
    2.
    Get either the OptionFactory ABI (web3) or the OptionFactory interface (solidity)
    3.
    Define the parameters of your option
    4.
    Call the createOption() function with the parameters

1. Get the OptionFactory address

You can find the OptionFactory address using two ways:
1) Check our deployed contracts page here.
2) Instantiate our ConfigurationManager contract and call the function getOptionFactory().

2. Get OptionFactory ABI or Interface

You can find both ABI and interface of OptionFactory in our Github repo. Always check if you are on the master branch to get our latest live update.

3. Define your options parameters

In order to deploy a new option series, we need to define if the option will be a put, or call, expiration date and exercise size window are some of the option properties.
Below you can find all the parameters that you will need to define:
Input Name
Type
Required
Description
name
string
any
The option token name (e.g., Pod BTC:USDC 300)
symbol
string
any
The option token symbol (e.g., "PodPutBTC")
optionType
uint8
0 / 1
0 for Put, 1 for Call
exerciseType
uint8
0 / 1
0 for American / 1 for European
underlyingAsset
address
contract address
Underlying asset address
strikeAsset
address
contract address
Strike asset address. Works with interest-bearing tokens aToken from Aave.
strikePrice
uint256
any
Strike price (units of strikeAsset that buy 1 unit of underlying) (e.g., 12000000000 means you need 12000000000 units of strike asset to exercise 1 unit of WBTC.)
expiration
uint256
higher than current block timestamp
Expiration option date in UNIX timestamp (e.g., 1609401600)
exerciseWindowSize
uint256
higher than 86400 (24h)
Duration of the exercise windows in seconds.
isAave
bool
If true, deploys a different contract version that supports liquidity mining on Aave (claim rewards)

4. Call the createOption() function

Now that we have the OptionFactory address, ABI, interface and we have also defined the initial parameters, its time call the createOption()function.
Solidity
Web3
1
/// Instantiate Option Factory
2
OptionFactory optionFactory = OptionFactory("/*address*/");
3
4
// Parameters example
5
string name = "WBTC:USDC 12000 31Dec 2020";
6
string symbol = "PodPut WBTC:USDC";
7
uint8 optionType = 0; // 0 for Put, 1 for Call
8
uint8 exerciseType = 0; // 0 for American, 1 for European
9
//WBTC
10
address underlyingAsset = 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599;
11
// USDC
12
address strikeAsset = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48;
13
uint256 strikePrice = 12000000000; // Using 6 decimals, equal to strikeAsset decimals
14
uint256 expiration = 1609401600; // timestamp in seconds: 31 Dec 2020 08AM
15
uint256 exerciseWindowSize = 86400; // 24H in seconds
16
uint256 isAave = false; // if the collateral token is not aTokens
17
18
19
optionFactory.createOption(
20
name,
21
symbol,
22
optionType,
23
exerciseType,
24
underlyingAsset,
25
strikeAsset,
26
strikePrice,
27
expiration,
28
exerciseWindowSize,
29
isAave
30
)
31
32
// OptionFactory.sol
33
/**
34
* @notice creates a new PodPut Contract
35
* @param _name The option token name. Eg. "Pods Put WBTC-USDC 5000 2020-02-23"
36
* @param _symbol The option token symbol. Eg. "podWBTC:20AA"
37
* @param _optionType The option type. Eg. "0 for Put, 1 for Call"
38
* @param _exerciseType The exercise type. Eg. "0 for European, 1 for American"
39
* @param _underlyingAsset The underlying asset. Eg. "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
40
* @param _strikeAsset The strike asset. Eg. "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
41
* @param _strikePrice The option strike price including decimals (strikePriceDecimals == strikeAssetDecimals), Eg, 5000000000
42
* @param _expiration The Expiration Option date in UNIX timestamp. E.g 1600178324
43
* @param _exerciseWindowSize The Expiration Window Size duration in UNIX timestamp. E.g 24*60*60 (24h)
44
* @param _isAave True if the collateral token is aToken
45
*/
46
function createOption(
47
string memory _name,
48
string memory _symbol,
49
PodOption.OptionType _optionType,
50
PodOption.OptionType _exerciseType,
51
address _underlyingAsset,
52
address _strikeAsset,
53
uint256 _strikePrice,
54
uint256 _expiration,
55
uint256 _exerciseWindowSize,
56
bool isAave
57
) public returns (address) {}
Copied!
1
// Parameters example
2
const optionFactoryAddress = '0x3c...'
3
4
const constructParameters = [
5
"WBTC:USDC 12000 31Dec 2020"; // name
6
"PodPut WBTC:USDC"; // symbol
7
0; // OptionType: 0 for Put, 1 for Call
8
0; // ExerciseType: 0 for American, 1 for European
9
"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599"; // strikeAsset address
10
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"; // underlyingAsset address
11
"12000000000"; // StrikePrice: Using 6 decimals, equal to strikeAsset decimals
12
1609401600; // timestamp in seconds: 31 Dec 2020 08AM
13
86400; // exercise window size
14
false; // if the collateral is Aave and you want to have liquidity mining support
15
]
16
17
/////////////
18
// Web3.js
19
20
// Instantiate contract
21
const optionFactory = await web3.eth.Contract('Contract ABI', optionFactoryAddress)
22
23
await optionFactory.methods.createOption(...constructorParameters).send({})
24
25
/////////////
26
// Ethers.js
27
28
// Instantiate contract
29
const optionFactory = await ethers.getContractAt(optionFactoryAddress, 'Contract ABI')
30
31
await optionFactory.createOption(...constructorParameters)
Copied!

Last modified 3mo ago