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:
_updatePosition
Updates a position and flips its upper tick and/or lower tick from initialized to uninitialized, or vice versa.
Params:
Returns:
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:
_modifyPosition
Helper for computing liquidity delta amounts to the curve when liquidity for a position is modified
Params:
Returns:
mint
Create a liquidity NFT for the given parameters. Only called by the non-fungible position Manager.
Params:
Returns:
burn
Burns a liquidity NFT according to the given parameters. Only called by the non-fungible position manager.
Params:
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:
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:
Returns:
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:
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:
positions
Retrieves information about a specific position based on its position key
Params:
Returns:
battleKey
Returns the battle key, which contains information about the battle configuration.
Returns:
startAndEndTS
Returns the start and expiry timestamps of the battle
Returns:
spearBalanceOf
Returns the amount of Spear tokens held by an account
Returns:
shieldBalanceOf
Returns the amount of shield tokens held by an account
Returns:
spearAndShield
This function returns the addresses of the Spear and Shield tokens
Returns:
getInsideLast
This function returns the growth variables for the specified tick range.
Params:
Returns:
Last updated