Quoter

Gets the expected token deltas without executing a swap or providing liquidity. Returns position information for liquidity providers.

tradeCallback

Callback function that handles the result of a trade. It reverts with the trade amounts.

function tradeCallback(uint256 cAmount, uint256 sAmount, bytes calldata data) external pure override 

Params:

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

data

bytes

Data passed through by the caller

parseRevertReason

Parses a revert reason that should contain the numeric quote

function parseRevertReason(bytes memory reason) private pure returns (uint256, uint256)  

Params:

Name

Type

Description

reason

bytes

The revert reason bytes

Returns:

Type

Description

uint256

The first parsed value

uint256

The second parsed value

quoteExactInput

Returns the amounts to spend or receive for a given exact input swap without executing the swap

function quoteExactInput(BattleTradeParams memory params, address battleAddr) public returns (uint256 spend, uint256 get) 

Params:

Name

Type

Description

BattleTradeParams

memory

Parameters for a trade action. See Params

battleAddr

address

The address of the battle contract

Returns:

Name

Type

Description

spend

uint256

The amount of collateral to spend

get

uint256

The amount of Spear or shield to receive

getSTokenByLiquidity

Calculates the amount of Spear or shield tokens based on the given liquidity

function getSTokenByLiquidity(AddLiqParams calldata params) external view returns (uint256)

Params:

Name

Type

Description

AddLiqParams

params

Params required for adding liquidity. See Params

Returns:

Name

Type

Description

SToken

uint256

The amount of Spear or Shield token calculated based on the given liquidity

getSTokenByLiquidityWhenCreate

Calculates the amount of Spear or shield tokens based on the given amount of seed collateral when a liquidity position is created

function getSTokenByLiquidityWhenCreate(uint160 sqrtPriceX96, int24 tickLower, int24 tickUpper, uint256 amount) public pure returns (uint256)

Params:

Name

Type

Description

sqrtPriceX96

uint160

The current sqrt price

tickLower

int24

The lower tick boundary of the position

tickUpper

int24

The upper tick boundary of the position

amount

uint256

The seed collateral amount for minting the liquidity position

Returns:

Type

Description

uint256

The amount of Spear or Shield token calculated based on the given liquidity

positions

Gets the position information for the given token ID

function positions(uint256 tokenId) external view override returns (Position memory)

Params:

Name

Type

Description

tokenId

uint256

The ID of the NFT that represents the liquidity position

Returns:

Type

Description

Position

The position data

handlePosition

Gets the position information for the given token ID

function handlePosition(uint256 tokenId) private view returns (Position memory p)

Params:

Name

Type

Description

tokenId

uint256

The ID of the NFT that represents the liquidity position

Returns:

Type

Description

Position

The position data

accountPositions

Gets the positions for the given account

function accountPositions(address account) external view override returns (Position[] memory)

Params:

Name

Type

Description

account

address

The account address

Returns:

Name

Type

Description

Position

memory

Position details

Last updated