setBorrowingPairParams
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
| _value | IBorrowingFees.BorrowingPairParams | new value |
setBorrowingPairParamsArray
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _indices | uint16[] | indices of the pairs |
| _values | IBorrowingFees.BorrowingPairParams[] | new values |
setBorrowingGroupParams
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _groupIndex | uint16 | index of the borrowing group |
| _value | IBorrowingFees.BorrowingGroupParams | new value |
setBorrowingGroupParamsArray
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _indices | uint16[] | indices of the groups |
| _values | IBorrowingFees.BorrowingGroupParams[] | new values |
handleTradeBorrowingCallback
Parameters
| Name | Type | Description |
|---|---|---|
| _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
Parameters
| Name | Type | Description |
|---|---|---|
| _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
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
| _currentBlock | uint256 | current block number |
Return Values
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _groupIndex | uint16 | index of the borrowing group |
| _currentBlock | uint256 | current block number |
Return Values
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| _input | IBorrowingFees.BorrowingFeeInput | input data (collateralIndex, trader, pairIndex, index, long, collateral, leverage) |
Return Values
| Name | Type | Description |
|---|---|---|
| feeAmountCollateral | uint256 | borrowing fee (collateral precision) |
getTradeLiquidationPrice
Parameters
| Name | Type | Description |
|---|---|---|
| _input | IBorrowingFees.LiqPriceInput | input data (collateralIndex, trader, pairIndex, index, openPrice, long, collateral, leverage) |
getPairOisCollateral
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
Return Values
| Name | Type | Description |
|---|---|---|
| longOi | uint256 | open interest on long side |
| shortOi | uint256 | open interest on short side |
getBorrowingPairGroupIndex
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
Return Values
| Name | Type | Description |
|---|---|---|
| groupIndex | uint16 | borrowing group index |
getPairOiCollateral
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
| _long | bool | true if long side |
withinMaxBorrowingGroupOi
Parameters
| Name | Type | Description |
|---|---|---|
| _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
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _groupIndex | uint16 | index of the borrowing group |
getBorrowingGroupOi
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _groupIndex | uint16 | index of the borrowing group |
getBorrowingPair
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
getBorrowingPairOi
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
getBorrowingPairGroups
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
getAllBorrowingPairs
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
getBorrowingGroups
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _indices | uint16[] | indices of the groups |
getBorrowingInitialAccFees
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _trader | address | address of trader |
| _index | uint32 | index of trade |
getPairMaxOi
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
getPairMaxOiCollateral
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
BorrowingPairParamsUpdated
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| collateralIndex | uint8 | |
| pairIndex | uint16 | index of the pair |
| prevGroupIndex | uint16 | previous borrowing group index |
| newGroupIndex | uint16 | new borrowing group index |
BorrowingGroupUpdated
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parameters
| Name | Type | Description |
|---|---|---|
| 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 |
