IExchange
SwapParams
SwapResponse
SwapCallbackData
RealizePnlParams
Functions
swap
The actual swap function
can only be called from ClearingHouse
Parameters:
Return Values:
settleFunding
Settle the funding payment for the time interval since the last settlement
This function should be called at the beginning of every high-level function, such as openPosition()
while it doesn't matter who calls this function this function 1. settles personal funding payment 2. updates global funding growth personal funding payment is settled whenever there is pending funding payment the global funding growth update only happens once per unique timestamp (not blockNumber, due to Arbitrum)
Return Values:
getMaxTickCrossedWithinBlock
Get the max ticks allowed to be crossed within a block when reducing position
Parameters:
Return Values:
getAllPendingFundingPayment
Get all the pending funding payment for a trader
Return Values:
Positive value means the trader pays funding, negative value means the trader receives funding.
isOverPriceSpread
Check if current price spread between market price and index twap is over maximum price spread.
Parameters:
Return Values:
getPendingFundingPayment
Get the pending funding payment for a trader in a given market
this is the view version of _updateFundingGrowth()
Return Values:
including liquidity & balance coefficients. Positive value means the trader pays funding, negative value means the trader receives funding.
getSqrtMarkTwapX96
Deprecated function, will be removed in the next release, use getSqrtMarketTwapX96()
instead Get the square root of the market twap price with the given time interval
The return value is a X96 number
Parameters:
Return Values:
getSqrtMarketTwapX96
Get the square root of the market twap price with the given time interval
The return value is a X96 number
Parameters:
Return Values:
getPnlToBeRealized
Get the pnl that can be realized if trader reduce position
This function normally won't be needed by traders, but it might be useful for 3rd party
Parameters:
Return Values:
getOrderBook
Get OrderBook
contract address
Return Values:
getAccountBalance
Get AccountBalance
contract address
Return Values:
getClearingHouseConfig
Get ClearingHouseConfig
contract address
Return Values:
Events
FundingUpdated
Emitted when the global funding growth is updated
Parameters:
MaxTickCrossedWithinBlockChanged
Emitted when maxTickCrossedWithinBlock is updated
Parameters:
AccountBalanceChanged
Emitted when accountBalance is updated
Parameters:
Last updated