JavBorrowingFees
General Description
The JavBorrowingFees contract used for managing borrowing fees, parameters, and related data in LeverageX.
Core Functionalities
setBorrowingPairParams
Updates the parameters of a borrowing pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index._value(BorrowingPairParams): New parameters.
setBorrowingPairParamsArray
Updates the parameters of multiple borrowing pairs.
Parameters:
_collateralIndex(uint8): Collateral index._indices(uint16[]): Array of pair indices._values(BorrowingPairParams[]): Array of new parameters.
setBorrowingGroupParams
Updates the parameters of a borrowing group.
Parameters:
_collateralIndex(uint8): Collateral index._groupIndex(uint16): Group index._value(BorrowingGroupParams): New parameters.
setBorrowingGroupParamsArray
Updates the parameters of multiple borrowing groups.
Parameters:
_collateralIndex(uint8): Collateral index._indices(uint16[]): Array of group indices._values(BorrowingGroupParams[]): Array of new parameters.
handleTradeBorrowingCallback
Handles borrowing fees and open interests when a trade is opened or closed.
Parameters:
_collateralIndex(uint8): Collateral index._trader(address): Trader's address._pairIndex(uint16): Pair index._index(uint32): Trade index._positionSizeCollateral(uint256): Trade position size in collateral tokens._open(bool): True if trade is opened._long(bool): True if trade is long.
resetTradeBorrowingFees
Resets borrowing fees for a trade.
Parameters:
_collateralIndex(uint8): Collateral index._trader(address): Trader's address._pairIndex(uint16): Pair index._index(uint32): Trade index._long(bool): True if trade is long.
getBorrowingPairPendingAccFees
Returns pending accumulated borrowing fees for a pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index._currentBlock(uint256): Current block number.
Returns:
accFeeLong(uint64): Accumulated fees on the long side.accFeeShort(uint64): Accumulated fees on the short side.pairAccFeeDelta(uint64): Fee delta for the changed side.
getBorrowingGroupPendingAccFees
Returns pending accumulated borrowing fees for a group.
Parameters:
_collateralIndex(uint8): Collateral index._groupIndex(uint16): Group index._currentBlock(uint256): Current block number.
Returns:
accFeeLong(uint64): Accumulated fees on the long side.accFeeShort(uint64): Accumulated fees on the short side.groupAccFeeDelta(uint64): Fee delta for the changed side.
getTradeBorrowingFee
Calculates borrowing fees for a trade.
Parameters:
_input(BorrowingFeeInput): Trade input data.
Returns:
feeAmountCollateral(uint256): Borrowing fee in collateral tokens.
getTradeLiquidationPrice
Calculates the liquidation price for a trade.
Parameters:
_input(LiqPriceInput): Trade input data.
Returns:
uint256: Liquidation price.
getPairOisCollateral
Gets open interests for a pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index.
Returns:
longOi(uint256): Long open interest.shortOi(uint256): Short open interest.
getBorrowingPairGroupIndex
Gets the borrowing group index for a pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index.
Returns:
groupIndex(uint16): Group index.
getPairOiCollateral
Gets open interest for a pair on one side.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index._long(bool): True if long side.
Returns:
uint256: Open interest in collateral tokens.
withinMaxBorrowingGroupOi
Checks if a trade is within the max group borrowing open interest.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index._long(bool): True if long side._positionSizeCollateral(uint256): Position size in collateral tokens.
Returns:
bool: True if within max borrowing OI.
getBorrowingGroup
Gets data for a borrowing group.
Parameters:
_collateralIndex(uint8): Collateral index._groupIndex(uint16): Group index.
Returns:
BorrowingData: Group data.
getBorrowingPair
Gets data for a borrowing pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index.
Returns:
BorrowingData: Pair data.
getBorrowingPairOi
Gets open interest data for a borrowing pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index.
Returns:
OpenInterest: Open interest data.
getBorrowingPairGroups
Gets groups data for a borrowing pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index.
Returns:
BorrowingPairGroup[]: Groups data.
getAllBorrowingPairs
Gets all borrowing pair data, open interests, and group data.
Parameters:
_collateralIndex(uint8): Collateral index.
Returns:
BorrowingData[]: Pair data.OpenInterest[]: Open interests.BorrowingPairGroup[][]: Group data.
getBorrowingGroups
Gets borrowing groups’ data and open interest.
Parameters:
_collateralIndex(uint8): Collateral index._indices(uint16[]): Group indices.
Returns:
BorrowingData[]: Group data.OpenInterest[]: Open interests.
getBorrowingInitialAccFees
Gets initial accumulated borrowing fees for a trade.
Parameters:
_collateralIndex(uint8): Collateral index._trader(address): Trader’s address._index(uint32): Trade index.
Returns:
BorrowingInitialAccFees: Initial fees data.
getPairMaxOi
Gets the max open interest for a pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index.
Returns:
uint256: Max open interest.
getPairMaxOiCollateral
Gets the max open interest in collateral tokens for a pair.
Parameters:
_collateralIndex(uint8): Collateral index._pairIndex(uint16): Pair index.
Returns:
uint256: Max open interest in collateral tokens.
Last updated
Was this helpful?