Types

Common

BattleKey

Info struct containing a pool's specifications
struct BattleKey {
address collateral;
string underlying;
uint256 expiries;
uint256 strikeValue;
}
Params:
Name
Type
Description
collateral
address
The address of the token used as collateral
underlying
string
The underlying asset symbol
expiries
uint256
The expiry timestamp
strikeValue
uint256
The strike price of options within the pool

Fee

Info struct representing the fee ratios used in a battle
struct Fee {
uint256 transactionFee;
uint256 protocolFee;
uint256 exerciseFee;
}
Params:
Name
Type
Description
transactionFee
uint256
The fee ratio taken on every trade
protocolFee
uint256
The ratio of the transaction fee that goes to the protocol
exerciseFee
uint256
The fee ratio applied when Spear or Shield tokens are exercised at maturity

GrowthX128

Info struct tracking the cumulative amounts of fees and deltas of collateral, Spear and Shield tokens involved in transactions
struct GrowthX128 {
uint256 fee;
uint256 collateralIn;
uint256 spearOut;
uint256 shieldOut;
}
Params:
Name
Type
Description
fee
uint256
The all-time growth in transaction fee, per unit of liquidity, in collateral token
collateralIn
uint256
The all-time growth in the received collateral inputs, per unit of liquidity, as options premium
spearOut
uint256
The all-time growth in Spear token outputs per unit of liquidity
shieldOut
uint256
The all-time growth in Shield token outputs per unit of liquidity

Owed

Info struct tracking the amounts of fees and deltas of collateral, Spear and Shield tokens that are owed to a position
struct Owed {
uint128 fee;
uint128 collateralIn;
uint128 spearOut;
uint128 shieldOut;
}
Params:
Name
Type
Description
fee
uint128
The amount of transaction fee owed to the position as of the last computation
collateralIn
uint128
The collateral inputs owed to the position as of the last computation
spearOut
uint128
The Spear token outputs owed to the position as of the last computation
shieldOut
uint128
The Shield token outputs owed to the position as of the last computation

TickInfo

Info struct tracking the state of a tick
struct TickInfo {
uint128 liquidityGross;
int128 liquidityNet;
GrowthX128 outside;
bool initialized;
}
Params:
Name
Type
Description
liquidityGross
uint128
The total amount of liquidity that the pool uses either at tickLower or tickUpper
liquidityNet
int128
The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)
outside
GrowthX128
The GrowthX128 info recorded on the other side of the tick from the current tick
initialized
bool
Whether the tick is initialized

PositionInfo

Info struct tracking the state of a position
struct PositionInfo {
uint128 liquidity;
GrowthX128 insideLast;
}
Params:
Name
Type
Description
liquidity
uint128
The amount of usable liquidity
insideLast
GrowthX128
The GrowthX128 info per unit of liquidity inside the a position's bound as of the last action

Enums

LiquidityType

Tracks the type of liquidity used by the LP
enum LiquidityType {
COLLATERAL,
SPEAR,
SHIELD
}

Outcome

Tracks the status of a battle
enum Outcome {
ONGOING,
SPEAR_WIN,
SHIELD_WIN
}

TradeType

Tracks the type of trade
enum TradeType {
BUY_SPEAR,
BUY_SHIELD
}

TradeTypes

TradeCache

Represents cached trade information
struct TradeCache {
uint256 feeProtocol;
}
Params:
Name
Type
Description
feeProtocol
uint256
The protocol fee for the trade

TradeState

Represents the state of the trade
struct TradeState {
uint256 amountSpecifiedRemaining;
uint256 amountCalculated;
uint160 sqrtPriceX96;
int24 tick;
GrowthX128 global;
uint128 protocolFee;
uint128 liquidity;
uint256 transactionFee;
}
Params:
Name
Type
Description
amountSpecifiedRemaining
uint256
How much collateral input or SToken output amount is remaining to be swapped in/out
amountCalculated
uint256
The amount of collateral input or SToken output that has been calculated for the swap
sqrtPriceX96
uint160
A fixed point Q64.96 number representing the sqrt of the ratio of shieldPrice/spearPrice
tick
int24
The current tick
global
GrowthX128
The GrowthX128 info per unit of liquidity as of the last update to the pool's global state
protocolFee
uint128
The amount of collateral token to be paid as protocol fee
liquidity
uint128
The amount of usable liquidity
transactionFee
uint256
The transaction fee for the trade

StepComputations

Info struct used in computing the result of swapping some amount in, or amount out, given the parameters of the swap.
struct StepComputations {
uint160 sqrtPriceStartX96;
int24 tickNext;
bool initialized;
uint160 sqrtPriceNextX96;
uint256 amountIn;
uint256 amountOut;
uint256 feeAmount;
int24 tickLower;
int24 tickUpper;
}
Params:
Name
Type
Description
sqrtPriceStartX96
uint160
The sqrtPrice from which to start step computation
tickNext
int24
The next tick up to the max or min tick of the virtual curve
initialized
bool
Whether the next tick is initialized
sqrtPriceNextX96
uint160
The price after swapping the amount in/out, not to exceed the price target
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
feeAmount
uint256
The amount of collateral input that will be taken as a fee
tickLower
int24
The lower tick for the step
tickUpper
int24
The upper tick for the step