OptionAMMPool
The contract pool responsible for trade, add and remove liquidity of a pair PodOption:ERC20.
Properties
input name
Type
Required
Description
tokenA
address
PodOption contracts
Must be an option token (PodOption)
tokenB
address
ERC20 token
The ERC20 will be used as the pair of the option. Will be easier if the price of the option is denominated in any stablecoin.
priceProvider
address
-
Contract address of the PriceProvider contract for spotPrice
priceMethod
address
-
Contract address of the PriceMethod contract (E.g: BlackScholes)
impliedVolatility
address
-
Contract address of the sigma (Implied Volatility - IV)
feePoolA
address
Contract address of the fee pool related to the tokenA
feePoolB
address
Contract address of the fee pool related to the tokenB
priceProperties
struct
All the properties related to the pricing calculation:
option expiration
option strikePrice
option underlyingAsset
option type
pool current sigma (IV)
pool current risk-free rate
pool last sigma initial guess
Methods
addLiquidity
This function is used to add new liquidity to the pool. Since we use a single-sided AMM, amountOfA or amountOfB can be 0 if you want to add liquidity to just one side of the pool. This function can only be called before option expiration.
input name
Type
Required
Description
amountOfA
uint256
-
Amount of Token A to add
amountOfB
uint256
-
Amount of Token B to add
owner
address
-
Add on behalf of someone
removeLiquidity
This function is used to remove liquidity from the pool. Since we use a single-sided AMM, percentA or percentB can be 0 if you want to remove liquidity from just one side of the pool. The percentA and percentB represent the percentage of the exposition in each asset you want to remove. If you want to check upfront what the amount represent certain exposition, you can call getRemoveLiquidityAmounts.
input name
Type
Required
Description
percentA
uint256
0 - 100
Percent of the exposition of amount of Token A to remove (Eg: 100 = 100% available)
percentB
uint256
0 - 100
Exposition of amount of Token B to remove
tradeExactAInput
This function represents "selling token A to the pool" or "buying token B from the pool". msg.sender is able to trade exact amount of token A in exchange for minimum amount of token B and send the tokens B to the owner. After that, this function also updates the priceProperties.currentSigma.
input name
Type
Required
Description
exactAmountAIn
uint256
-
Exact amount of A token that will be transfer from msg.sender
minAmountBOut
uint256
-
Minimum acceptable amount of token B to transfer to owner
owner
address
address that will receive the token in exchange
sigmaInitialGuess
uint256
!= 0
For gas cost-saving purpose, it is possible to run getOptinTradedDDetails before the trade in order to send the best sigma possible
tradeExactAOutput
This function represents "buying token A from the pool" or "selling token B to the pool". owner is able to receive exact amount of token A in exchange of a max acceptable amount of token B transfer from the msg.sender. After that, this function also updates the priceProperties.currentSigma
input name
Type
Required
Description
exactAmountAOut
uint256
-
Exact amount of token A that will be transfer to owner
maxAmountBIn
uint256
-
Maximum acceptable amount of token B to transfer from msg.sender
owner
address
address that will receive the token in exchange
sigmaInitialGuess
uint256
!= 0
For gas cost-saving purpose, it is possible to run getOptionTradedDDetails before the trade in order to send the best sigma possible
tradeExactBInput
This function represents "selling token B to the pool" or "buying token A from the pool". msg.sender is able to trade exact amount of token B in exchange for minimum amount of token A and send the tokens B to the owner. After that, this function also updates the priceProperties.currentSigma.
input name
Type
Required
Description
exactAmountBIn
uint256
-
Exact amount of A token that will be transfer from msg.sender
minAmountAOut
uint256
-
Minimum acceptable amount of token B to transfer to owner
owner
address
address that will receive the token in exchange
sigmaInitialGuess
uint256
!= 0
For gas cost-saving purpose, it is possible to run getOptionTradedDDetails before the trade in order to send the best sigma possible
tradeExactBOutput
This function represents "selling token A to the pool" or "buying token B from the pool". owner is able to receive exact amount of token B in exchange of a max acceptable amount of token A transfer from the msg.sender. After that, this function also updates the priceProperties.currentSigma
input name
Type
Required
Description
exactAmountBOut
uint256
-
Exact amount of token B that will be transfer to owner
maxAmountAIn
uint256
-
Maximum acceptable amount of token A to transfer from msg.sender
owner
address
address that will receive the token in exchange
sigmaInitialGuess
uint256
!= 0
For gas cost-saving purpose, it is possible to run getOptionTradedDDetails before the trade in order to send the best sigma possible
getPoolBalances
Check the current pool amount of Token A and Token B.
Return Values
Input name
Type
Description
totalTokenA
uint256
Pool total balance of token A
totalTokenB
uint256
Pool total balance of token B
getUserDepositSnapshot
Check the original balance of a user, returning its original deposit of Token A, the original balance of Token B, and the opening value factor at the moment of the deposit.
Input Parameters
Input name
Type
Description
user
uint256
Address to consult the balance
Return Values
Input name
Type
Description
tokenABalance
uint256
Exact amount of token B that will be transfer to owner
tokenBBalance
uint256
Maximum acceptable amount of token A to transfer from msg.sender
fImpUser
uint256
address that will receive the token in exchange
getOptionTradeDetailsExactAInput
View function that simulates a trade, in order the preview amountBOut, the new sigma (IV), that will be used as the sigmaInitialGuess if the caller wants to perform a trade in the sequence. Also returns the amount of Fees that will be paid to liquidity pools A and B.
Input Parameters
Input name
Type
Description
exactAmountAIn
uint256
amount of token A that will be transfer from msg.sender to the pool
Return Values
Input name
Type
Description
amountBOut
uint256
amount of B in exchange of the exactAmountAIn
newIV
uint256
New sigma that this trade will result
feesTokenA
uint256
Amount of fees of collected by token A
feesTokenB
uint256
amount of fees of collected by token B
getOptionTradeDetailsExactAOutput
View function that simulates a trade, in order the preview the amountBIn, the new sigma (IV), that will be used as the sigmaInitialGuess if the caller wants to perform a trade in the sequence. Also returns the amount of Fees that will be paid to liquidity pools A and B.
Input Parameters
Input name
Type
Description
exactAmountAOut
uint256
amount of token A that will be transfer from the pool to the owner
Return Values
Input name
Type
Description
amountBIn
uint256
amount of B that will be transfer from msg.sender to the pool
newIV
uint256
New sigma that this trade will result
feesTokenA
uint256
Amount of fees of collected by token A
feesTokenB
uint256
amount of fees of collected by token B
getOptionTradeDetailsExactBInput
View function that simulates a trade, in order the preview the amountAOut, the new sigma (IV), that will be used as the sigmaInitialGuess if the caller wants to perform a trade in the sequence. Also returns the amount of Fees that will be paid to liquidity pools A and B.
Input Parameters
Input name
Type
Description
exactAmountBIn
uint256
amount of token B that will be transfer from msg.sender to the pool
Return Values
Input name
Type
Description
amountAOut
uint256
amount of A in exchange of the exactAmountAIn
newIV
uint256
New sigma that this trade will result
feesTokenA
uint256
Amount of fees of collected by token A
feesTokenB
uint256
amount of fees of collected by token B
getOptionTradeDetailsExactBOutput
View function that simulates a trade, in order the preview the amountAIn, the new sigma (IV), that will be used as the sigmaInitialGuess if the caller wants to perform a trade in the sequence. Also returns the amount of Fees that will be paid to liquidity pools A and B.
Input Parameters
Input name
Type
Description
exactAmountBOut
uint256
amount of token B that will be transfer from the pool to the owner
Return Values
Input name
Type
Description
amountAIn
uint256
amount of A that will be transfer from msg.sender to the pool
newIV
uint256
New sigma that this trade will result
feesTokenA
uint256
Amount of fees of collected by token A
feesTokenB
uint256
amount of fees of collected by token B
Last updated