IBorrowingFeesUtils
Interface for GNSBorrowingFees facet (inherits types and also contains functions, events, and custom errors)
setBorrowingPairParams
Updates borrowing pair params of a pair
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
setBorrowingPairParamsArray
Updates borrowing pair params of multiple pairs
Parameters
_collateralIndex
uint8
index of the collateral
_indices
uint16[]
indices of the pairs
setBorrowingGroupParams
Updates borrowing group params of a group
Parameters
_collateralIndex
uint8
index of the collateral
_groupIndex
uint16
index of the borrowing group
setBorrowingGroupParamsArray
Updates borrowing group params of multiple groups
Parameters
_collateralIndex
uint8
index of the collateral
_indices
uint16[]
indices of the groups
handleTradeBorrowingCallback
Callback after a trade is opened/closed to store pending borrowing fees and adjust open interests
Parameters
_collateralIndex
uint8
index of the collateral
_trader
address
address of the trader
_pairIndex
uint16
index of the pair
_index
uint32
index of the trade
_positionSizeCollateral
uint256
position size of the trade in collateral tokens
_open
bool
true if trade has been opened, false if trade has been closed
_long
bool
true if trade is long, false if trade is short
resetTradeBorrowingFees
Resets a trade borrowing fee to 0 (useful when new trade opened or when partial trade executed)
Parameters
_collateralIndex
uint8
index of the collateral
_trader
address
address of the trader
_pairIndex
uint16
index of the pair
_index
uint32
index of the trade
_long
bool
true if trade is long, false if trade is short
getBorrowingPairPendingAccFees
Returns the pending acc borrowing fees for a pair on both sides
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
_currentBlock
uint256
current block number
Return Values
accFeeLong
uint64
new pair acc borrowing fee on long side
accFeeShort
uint64
new pair acc borrowing fee on short side
pairAccFeeDelta
uint64
pair acc borrowing fee delta (for side that changed)
getBorrowingGroupPendingAccFees
Returns the pending acc borrowing fees for a borrowing group on both sides
Parameters
_collateralIndex
uint8
index of the collateral
_groupIndex
uint16
index of the borrowing group
_currentBlock
uint256
current block number
Return Values
accFeeLong
uint64
new group acc borrowing fee on long side
accFeeShort
uint64
new group acc borrowing fee on short side
groupAccFeeDelta
uint64
group acc borrowing fee delta (for side that changed)
getTradeBorrowingFee
Returns the borrowing fee for a trade
Parameters
_input
input data (collateralIndex, trader, pairIndex, index, long, collateral, leverage)
Return Values
feeAmountCollateral
uint256
borrowing fee (collateral precision)
getTradeLiquidationPrice
Returns the liquidation price for a trade
Parameters
_input
input data (collateralIndex, trader, pairIndex, index, openPrice, long, collateral, leverage)
getPairOisCollateral
Returns the open interests for a pair
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
Return Values
longOi
uint256
open interest on long side
shortOi
uint256
open interest on short side
getBorrowingPairGroupIndex
Returns the borrowing group index for a pair
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
Return Values
groupIndex
uint16
borrowing group index
getPairOiCollateral
Returns the open interest in collateral tokens for a pair on one side
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
_long
bool
true if long side
withinMaxBorrowingGroupOi
Returns whether a trade is within the max group borrowing open interest
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
_long
bool
true if long side
_positionSizeCollateral
uint256
position size of the trade in collateral tokens
getBorrowingGroup
Returns a borrowing group's data
Parameters
_collateralIndex
uint8
index of the collateral
_groupIndex
uint16
index of the borrowing group
getBorrowingGroupOi
Returns a borrowing group's oi data
Parameters
_collateralIndex
uint8
index of the collateral
_groupIndex
uint16
index of the borrowing group
getBorrowingPair
Returns a borrowing pair's data
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
getBorrowingPairOi
Returns a borrowing pair's oi data
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
getBorrowingPairGroups
Returns a borrowing pair's oi data
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
getAllBorrowingPairs
Returns all borrowing pairs' borrowing data, oi data, and pair groups data
Parameters
_collateralIndex
uint8
index of the collateral
getBorrowingGroups
Returns borrowing groups' data and oi data
Parameters
_collateralIndex
uint8
index of the collateral
_indices
uint16[]
indices of the groups
getBorrowingInitialAccFees
Returns borrowing groups' data
Parameters
_collateralIndex
uint8
index of the collateral
_trader
address
address of trader
_index
uint32
index of trade
getPairMaxOi
Returns the max open interest for a pair
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
getPairMaxOiCollateral
Returns the max open interest in collateral tokens for a pair
Parameters
_collateralIndex
uint8
index of the collateral
_pairIndex
uint16
index of the pair
BorrowingPairParamsUpdated
Emitted when a pair's borrowing params is updated
Parameters
collateralIndex
uint8
pairIndex
uint16
index of the pair
groupIndex
uint16
index of its new group
feePerBlock
uint32
new fee per block
feeExponent
uint48
new fee exponent
maxOi
uint72
new max open interest
BorrowingPairGroupUpdated
Emitted when a pair's borrowing group has been updated
Parameters
collateralIndex
uint8
pairIndex
uint16
index of the pair
prevGroupIndex
uint16
previous borrowing group index
newGroupIndex
uint16
new borrowing group index
BorrowingGroupUpdated
Emitted when a group's borrowing params is updated
Parameters
collateralIndex
uint8
groupIndex
uint16
index of the group
feePerBlock
uint32
new fee per block
maxOi
uint72
new max open interest
feeExponent
uint48
new fee exponent
BorrowingInitialAccFeesStored
Emitted when a trade's initial acc borrowing fees are stored
Parameters
collateralIndex
uint8
trader
address
address of the trader
pairIndex
uint16
index of the pair
index
uint32
index of the trade
long
bool
initialPairAccFee
uint64
initial pair acc fee (for the side of the trade)
initialGroupAccFee
uint64
initial group acc fee (for the side of the trade)
TradeBorrowingCallbackHandled
Emitted when a trade is executed and borrowing callback is handled
Parameters
collateralIndex
uint8
trader
address
address of the trader
pairIndex
uint16
index of the pair
index
uint32
index of the trade
open
bool
true if trade has been opened, false if trade has been closed
long
bool
true if trade is long, false if trade is short
positionSizeCollateral
uint256
position size of the trade in collateral tokens
BorrowingPairAccFeesUpdated
Emitted when a pair's borrowing acc fees are updated
Parameters
collateralIndex
uint8
pairIndex
uint16
index of the pair
currentBlock
uint256
current block number
accFeeLong
uint64
new pair acc borrowing fee on long side
accFeeShort
uint64
new pair acc borrowing fee on short side
BorrowingGroupAccFeesUpdated
Emitted when a group's borrowing acc fees are updated
Parameters
collateralIndex
uint8
groupIndex
uint16
index of the borrowing group
currentBlock
uint256
current block number
accFeeLong
uint64
new group acc borrowing fee on long side
accFeeShort
uint64
new group acc borrowing fee on short side
BorrowingPairOiUpdated
Emitted when a borrowing pair's open interests are updated
Parameters
collateralIndex
uint8
pairIndex
uint16
index of the pair
long
bool
true if long side
increase
bool
true if open interest is increased, false if decreased
delta
uint72
change in open interest in collateral tokens (1e10 precision)
newOiLong
uint72
new open interest on long side
newOiShort
uint72
new open interest on short side
BorrowingGroupOiUpdated
Emitted when a borrowing group's open interests are updated
Parameters
collateralIndex
uint8
groupIndex
uint16
index of the borrowing group
long
bool
true if long side
increase
bool
true if open interest is increased, false if decreased
delta
uint72
change in open interest in collateral tokens (1e10 precision)
newOiLong
uint72
new open interest on long side
newOiShort
uint72
new open interest on short side
BorrowingZeroGroup
BorrowingWrongExponent
Last updated