Manager
Sets up the necessary state variables, mappings, and inheritance to handle position NFTs, manage liquidity, and interact with the battle contracts
addLiquidity
Adds liquidity to a battle contract, mints a new token representing the liquidity position, and records the position information for later reference.
Params:
Name
Type
Description
Returns:
Name
Type
Description
tokenId
uint256
The ID of the NFT that represents the liquidity position
liquidity
uint128
The amount of liquidity for this position
updateInsideLast
Updates the growth of fees and token deltas as of the last action on the individual position
Params:
Name
Type
Description
pb
PositionInfo
The position info struct
pm
Position
The position owed info struct
removeLiquidity
Removes liquidity from the pool, given the tokenId of a position. Only to be called once by the liquidity provider.
Params:
Name
Type
Description
tokenId
uint256
The ID of the NFT that represents the liquidity position
Returns:
Name
Type
Description
collateral
uint256
The amount of collateral to be received by the liquidity provider
spear
uint256
The amount of Spear to be received by the liquidity provider
shield
uint256
The amount of Shield to be received by the liquidity provider
spearObligation
uint256
The obligatory reserve of collateral amount for settling Spear tokens sold by the position
shieldObligation
uint256
The obligatory reserve of collateral amount for settling shield tokens sold by the position
getObligation
Calculates the obligatory reserve of collateral amounts for settling sold Spear and Shield amounts, and the remaining collateral/Spear/Shield token amounts receivable for a given position.
Params:
Name
Type
Description
pm
Position
The position for which to calculate the obligation amounts and receivable token amounts
Returns:
Name
Type
Description
collateral
uint256
The amount of collateral that can be received by the liquidity provider
spear
uint256
The remaining Spear amount that can be received by the liquidity provider, after adjusting for obligations
shield
uint256
The remaining shield amount that can be received by the liquidity provider, after adjusting for obligations
spearObligation
uint256
The obligatory reserve of collateral amount for settling Spear tokens sold by the position
shieldObligation
uint256
The obligatory reserve of collateral amount for settling Shield tokens sold by the position
withdrawObligation
Returns the amount of collateral reserved for options that settle out-of-money. Can be called once after expiry by the liquidity provider and must be called after liquidity has been removed.
Params:
Name
Type
Description
tokenId
uint256
The ID of the NFT that represents the liquidity position
redeemObligation
Returns the amount of collateral reserved for the liquidity providers' open short interest in call or put options, after the pool receives the equavalent amount of call or put option tokens. Can be called once before expiry and must be called when liquidity has been removed.
Params:
Name
Type
Description
tokenId
uint256
The ID of the NFT that represents the liquidity position
trade
Calls the battle contract to execute a trade
Params:
Name
Type
Description
Returns:
Name
Type
Description
amountIn
uint256
The collateral amount to be swapped in based on the direction of the swap
amountOut
uint256
The amount to be received, of either Spear or Shield token, based on the direction of the swap
amountFee
uint256
The amount of fee in collateral token to be spent for the trade
tradeCallback
Called to msg.sender after executing a swap via Manager.
Params:
Name
Type
Description
cAmount
uint256
The amount of collateral transferred in the trade
sAmount
uint256
The amount of Spear or Shield transferred in the trade
_data
bytes
Data passed through by the caller
positions
Retrieves the position data for the given TokenId
Params:
Name
Type
Description
tokenId
uint256
The ID of the NFT that represents the liquidity position
Returns:
Type
Description
Position
The position data
handlePosition
Retrieves and updates the position data
Params:
Name
Type
Description
tokenId
uint256
The ID of the NFT that represents the liquidity position
Returns:
Name
Type
Description
p
Position
The position data
accountPositions
Retrieves all the positions associated with an account
Params:
Name
Type
Description
account
address
The address of the account for which to retrieve the positions
Returns:
Name
Type
Description
p
Position
The positions owned by the account
Last updated