Battle
Each options pool is contained in a Battle contract. Battle contracts provide core functionalities including minting and burning liquidity, trading options tokens, settling and exercising options, and
init
Inits state variable in storage. It is called only once for a battle.
Params:
Name
Description
DeploymentParams
_updatePosition
Updates a position and flips its upper tick and/or lower tick from initialized to uninitialized, or vice versa.
Params:
Name
Description
UpdatePositionParams
Returns:
Name
Description
PositionInfo
checkTicks
Checks whether the given lower tick and upper tick are within the minimum and maximum tick bounds. Also checks whether the lower tick is less than the upper tick.
Params:
Name
Type
Description
tickLower
int24
The lower tick boundary of the position
tickUpper
int24
The upper tick boundary of the position
_modifyPosition
Helper for computing liquidity delta amounts to the curve when liquidity for a position is modified
Params:
Name
Description
ModifyPositionParams
Returns:
Name
Description
PositionInfo
mint
Create a liquidity NFT for the given parameters. Only called by the non-fungible position Manager.
Params:
Name
Description
BattleMintParams
Returns:
Name
Description
PositionInfo
seed
uint256
burn
Burns a liquidity NFT according to the given parameters. Only called by the non-fungible position manager.
Params:
Name
Description
BattleBurnParams
collect
Collects the specified amounts of collateral, Spear, and Shield tokens. Transfers them to the recipient. Only called by the non-fungible position manager.
Params:
Name
Type
Description
recipient
address
Address of the recipient
cAmount
uint256
Amount of collateral tokens to transfer
spAmount
uint256
Amount of Spear tokens to mint and transfer
shAmount
uint256
Amount of Shield tokens to mint and transfer
trade
Executes a trade by swapping collateral to either Spear or Shield tokens. When the price direction is up (down), an amount of Shield (Spear) token output is sent to the buyer.
Params:
Name
Description
BattleTradeParams
Returns:
Name
Type
Description
cAmount
uint256
Amount of collateral token input spent to be spent for the trade
sAmount
uint256
Amount of Spear or Shield token output to be received for the trade
fAmount
uint256
Amount of fee in collateral token to be spent for the trade
settle
Settles options of a pool after their expiry. It updates the battle outcome based on the underlying price retrieved from an external oracle.
exercise
This function allows a participant to exercise their winning long Spear or long Shield position. Each winning Spear or Shield pays 1 collateral. This payoff is claimed after paying an exerciseFeeAmount
. eg. Alice bought 100 spear. The battle outcome turns out to be spear_win
. By calling this function, she claims 100 collateral tokens less exerciseFeeAmount
.
withdrawObligation
Enables the liquidity provider to withdraw the collateral amount reserved for settlement. Only called by the Manager.
Params:
Name
Type
Description
recipient
address
The liquidity provider address to receive collateral
amount
uint256
The amount of collateral to be received
collectProtocolFee
Collect the protocol fee accrued to the pool. Can only be called by the owner.
collateralBalance
This is a private view function that returns the current balance of collateral tokens held by the contract
Returns:
Type
Description
uint256
Current balance of collateral tokens
positions
Retrieves information about a specific position based on its position key
Params:
Name
Type
Description
positionKeyB32
bytes32
Position key
Returns:
Name
Description
PositionInfo
battleKey
Returns the battle key, which contains information about the battle configuration.
Returns:
Name
Description
BattleKey
startAndEndTS
Returns the start and expiry timestamps of the battle
Returns:
Type
Description
uint256
Start timestamp of the battle
uint256
Expiry timestamp of the battle
spearBalanceOf
Returns the amount of Spear tokens held by an account
Returns:
Name
Type
Description
amount
uint256
Amount of Spear tokens held by the account
shieldBalanceOf
Returns the amount of shield tokens held by an account
Returns:
Name
Type
Description
amount
uint256
Amount of shield tokens held by the account
spearAndShield
This function returns the addresses of the Spear and Shield tokens
Returns:
Name
Type
Description
spear
address
Address of the Spear token
shield
address
Address of the Shield token
getInsideLast
This function returns the growth variables for the specified tick range.
Params:
Name
Type
Description
tickLower
int24
The lower tick boundary of the range
tickUpper
int24
The upper tick boundary of the range
Returns:
Name
Description
GrowthX128
Last updated