IPoolCore
Inherits: IPoolInternal
Functions
marketPrice
Get the current market price as normalized price
function marketPrice() external view returns (UD60x18);
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | The current market price as normalized price |
takerFee
Calculates the fee for a trade based on the size
and premium
of the trade
function takerFee(address taker, UD60x18 size, uint256 premium, bool isPremiumNormalized, bool isOrderbook)
external
view
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
taker | address | The taker of a trade |
size | UD60x18 | The size of a trade (number of contracts) (18 decimals) |
premium | uint256 | The total cost of option(s) for a purchase (poolToken decimals) |
isPremiumNormalized | bool | Whether the premium given is already normalized by strike or not (Ex: For a strike of 1500, and a premium of 750, the normalized premium would be 0.5) |
isOrderbook | bool | Whether the fee is for the fillQuoteOB function or not |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The taker fee for an option trade denormalized (poolToken decimals) |
_takerFeeLowLevel
Calculates the fee for a trade based on the size
and premiumNormalized
of the trade.
WARNING: It is recommended to use takerFee
instead of this function. This function is a lower level
function here to be used when a pool has not yet be deployed, by calling it from the diamond contract
directly rather than a pool proxy. If using it from the pool, you should pass the same value as the pool
for strike
and isCallPool
in order to get the accurate takerFee
function _takerFeeLowLevel(
address taker,
UD60x18 size,
UD60x18 premium,
bool isPremiumNormalized,
bool isOrderbook,
UD60x18 strike,
bool isCallPool
) external view returns (UD60x18);
Parameters
Name | Type | Description |
---|---|---|
taker | address | The taker of a trade |
size | UD60x18 | The size of a trade (number of contracts) (18 decimals) |
premium | UD60x18 | The total cost of option(s) for a purchase (18 decimals) |
isPremiumNormalized | bool | Whether the premium given is already normalized by strike or not (Ex: For a strike of 1500, and a premium of 750, the normalized premium would be 0.5) |
isOrderbook | bool | Whether the fee is for the fillQuoteOB function or not |
strike | UD60x18 | The strike of the option (18 decimals) |
isCallPool | bool | Whether the pool is a call pool or not |
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | The taker fee for an option trade denormalized. (18 decimals) |
getPoolSettings
Returns all pool parameters used for deployment
function getPoolSettings()
external
view
returns (address base, address quote, address oracleAdapter, UD60x18 strike, uint256 maturity, bool isCallPool);
Returns
Name | Type | Description |
---|---|---|
base | address | Address of base token |
quote | address | Address of quote token |
oracleAdapter | address | Address of oracle adapter |
strike | UD60x18 | The strike of the option (18 decimals) |
maturity | uint256 | The maturity timestamp of the option |
isCallPool | bool | Whether the pool is for call or put options |
ticks
Returns all ticks in the pool, including net liquidity for each tick
function ticks() external view returns (IPoolInternal.TickWithRates[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | IPoolInternal.TickWithRates[] | ticks All pool ticks with the liquidityNet (18 decimals) of each tick |
claim
Updates the claimable fees of a position and transfers the claimed fees to the operator of the position. Then resets the claimable fees to zero.
function claim(Position.Key calldata p) external returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
p | Position.Key | The position key |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of claimed fees (poolToken decimals) |
getClaimableFees
Returns total claimable fees for the position
function getClaimableFees(Position.Key calldata p) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
p | Position.Key | The position key |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The total claimable fees for the position (poolToken decimals) |
writeFrom
Underwrite an option by depositing collateral. By default the taker fee and referral are applied to the underwriter, if the caller is a registered vault the longReceiver is used instead.
function writeFrom(address underwriter, address longReceiver, UD60x18 size, address referrer) external;
Parameters
Name | Type | Description |
---|---|---|
underwriter | address | The underwriter of the option (Collateral will be taken from this address, and it will receive the short token) |
longReceiver | address | The address which will receive the long token |
size | UD60x18 | The number of contracts being underwritten (18 decimals) |
referrer | address | The referrer of the user doing the trade |
annihilate
Annihilate a pair of long + short option contracts to unlock the stored collateral.
This function can be called post or prior to expiration.
function annihilate(UD60x18 size) external;
Parameters
Name | Type | Description |
---|---|---|
size | UD60x18 | The size to annihilate (18 decimals) |
annihilateFor
Annihilate a pair of long + short option contracts to unlock the stored collateral on behalf of another account.
msg.sender must be approved through UserSettings.setAuthorizedAddress
by the owner of the long/short contracts.
This function can be called post or prior to expiration.
function annihilateFor(address owner, UD60x18 size) external;
Parameters
Name | Type | Description |
---|---|---|
owner | address | The owner of the shorts/longs to annihilate |
size | UD60x18 | The size to annihilate (18 decimals) |
exercise
Exercises all long options held by caller
function exercise() external returns (uint256 exerciseValue, uint256 exerciseFee);
Returns
Name | Type | Description |
---|---|---|
exerciseValue | uint256 | The exercise value as amount of collateral paid out to long holder (poolToken decimals) |
exerciseFee | uint256 | The fee paid to protocol (poolToken decimals) |
exerciseFor
Batch exercises all long options held by each holder
, caller is reimbursed with the cost deducted from
the proceeds of the exercised options. Only authorized agents may execute this function on behalf of the
option holder.
function exerciseFor(address[] calldata holders, uint256 costPerHolder)
external
returns (uint256[] memory exerciseValues, uint256[] memory exerciseFees);
Parameters
Name | Type | Description |
---|---|---|
holders | address[] | The holders of the contracts |
costPerHolder | uint256 | The cost charged by the authorized operator, per option holder (poolToken decimals) |
Returns
Name | Type | Description |
---|---|---|
exerciseValues | uint256[] | The exercise value as amount of collateral paid out per holder, ignoring costs applied during automatic exercise, but excluding protocol fees from amount (poolToken decimals) |
exerciseFees | uint256[] | The fees paid to protocol (poolToken decimals) |
settle
Settles all short options held by caller
function settle() external returns (uint256 collateral);
Returns
Name | Type | Description |
---|---|---|
collateral | uint256 | The amount of collateral left after settlement (poolToken decimals) |
settleFor
Batch settles all short options held by each holder
, caller is reimbursed with the cost deducted from
the proceeds of the settled options. Only authorized operators may execute this function on behalf of the
option holder.
function settleFor(address[] calldata holders, uint256 costPerHolder) external returns (uint256[] memory);
Parameters
Name | Type | Description |
---|---|---|
holders | address[] | The holders of the contracts |
costPerHolder | uint256 | The cost charged by the authorized operator, per option holder (poolToken decimals) |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256[] | The amount of collateral left after settlement per holder, ignoring costs applied during automatic settlement (poolToken decimals) |
settlePosition
Reconciles a user's position
to account for settlement payouts post-expiration.
function settlePosition(Position.Key calldata p) external returns (uint256 collateral);
Parameters
Name | Type | Description |
---|---|---|
p | Position.Key | The position key |
Returns
Name | Type | Description |
---|---|---|
collateral | uint256 | The amount of collateral left after settlement (poolToken decimals) |
settlePositionFor
Batch reconciles each position
to account for settlement payouts post-expiration. Caller is reimbursed
with the cost deducted from the proceeds of the settled position. Only authorized operators may execute
this function on behalf of the option holder.
function settlePositionFor(Position.Key[] calldata p, uint256 costPerHolder) external returns (uint256[] memory);
Parameters
Name | Type | Description |
---|---|---|
p | Position.Key[] | The position keys |
costPerHolder | uint256 | The cost charged by the authorized operator, per position holder (poolToken decimals) |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256[] | The amount of collateral left after settlement per holder, ignoring costs applied during automatic settlement (poolToken decimals) |
transferPosition
Transfer a LP position to a new owner/operator
function transferPosition(Position.Key calldata srcP, address newOwner, address newOperator, UD60x18 size) external;
Parameters
Name | Type | Description |
---|---|---|
srcP | Position.Key | The position key |
newOwner | address | The new owner |
newOperator | address | The new operator |
size | UD60x18 | The size to transfer (18 decimals) |
tryCacheSettlementPrice
Attempts to cache the settlement price of the option after expiration. Reverts if a price has already been cached
function tryCacheSettlementPrice() external;
getSettlementPrice
Returns the settlement price of the option.
function getSettlementPrice() external view returns (UD60x18);
Returns
Name | Type | Description |
---|---|---|
<none> | UD60x18 | The settlement price of the option (18 decimals). Returns 0 if option is not settled yet. |
getStrandedArea
Gets the lower and upper bound of the stranded market area when it exists. In case the stranded market area does not exist it will return the stranded market area the maximum tick price for both the lower and the upper, in which case the market price is not stranded given any range order info order.
function getStrandedArea() external view returns (UD60x18 lower, UD60x18 upper);
Returns
Name | Type | Description |
---|---|---|
lower | UD60x18 | Lower bound of the stranded market price area (Default : PoolStorage.MAX_TICK_PRICE + ONE = 2e18) (18 decimals) |
upper | UD60x18 | Upper bound of the stranded market price area (Default : PoolStorage.MAX_TICK_PRICE + ONE = 2e18) (18 decimals) |
getTokenIds
Returns the list of existing tokenIds with non zero balance
function getTokenIds() external view returns (uint256[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256[] | tokenIds The list of existing tokenIds |