How To Exercise
In order to exercise an option, is pretty simple. You just need to have the options address and PodOption interface. Do not forget to approve first the underlying
PodOption Interface below:
Solidity
1
pragma solidity 0.6.12;
2
3
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
4
5
interface IPodOption is IERC20 {
6
enum OptionType { PUT, CALL }
7
enum ExerciseType { EUROPEAN, AMERICAN }
8
9
event Mint(address indexed minter, uint256 amount);
10
event Unmint(address indexed minter, uint256 amount);
11
event Exercise(address indexed exerciser, uint256 amount);
12
event Withdraw(address indexed minter, uint256 amount);
13
14
function mint(uint256 amountOfOptions, address owner) external;
15
16
function exercise(uint256 amountOfOptions) external;
17
18
function withdraw() external;
19
20
function unmint(uint256 amountOfOptions) external;
21
22
function optionType() external view returns (OptionType);
23
24
function exerciseType() external view returns (ExerciseType);
25
26
function underlyingAsset() external view returns (address);
27
28
function underlyingAssetDecimals() external view returns (uint8);
29
30
function strikeAsset() external view returns (address);
31
32
function strikeAssetDecimals() external view returns (uint8);
33
34
function strikePrice() external view returns (uint256);
35
36
function strikePriceDecimals() external view returns (uint8);
37
38
function expiration() external view returns (uint256);
39
40
function endOfExerciseWindow() external view returns (uint256);
41
42
function hasExpired() external view returns (bool);
43
44
function isAfterEndOfExerciseWindow() external view returns (bool);
45
46
function strikeToTransfer(uint256 amountOfOptions) external view returns (uint256);
47
48
function getSellerWithdrawAmounts(address owner)
49
external
50
view
51
returns (uint256 strikeAmount, uint256 underlyingAmount);
52
53
function underlyingReserves() external view returns (uint256);
54
55
function strikeReserves() external view returns (uint256);
56
}
57
Copied!
After allowing the PodOption to transfer the underlying token on your behalf, then you can perform the exercise. Example below:
Solidity
1
// 1) Instantiate the Option token using the optionAddress
2
// You can get a current optionAddress from the deployedContracts
3
// section
4
IPodOption option = IPodOption(optionAddress);
5
6
// 2) Approve option contract to spend yours underlyingToken
7
IERC20 underlyingToken = IERC20(underlyingTokenAddress);
8
9
underlyingToken.approve(optionAddress, amountOfUnderlying);
10
11
// 3) Call the exercise function giving the amount of options
12
// to exercise as an input.
13
option.exercise(amountOfOptions);
Copied!
Last modified 7mo ago
Copy link