setBorrowingPairParams
setBorrowingPairParamsArray
setBorrowingGroupParams
setBorrowingGroupParamsArray
handleTradeBorrowingCallback
resetTradeBorrowingFees
getBorrowingPairPendingAccFees
getBorrowingGroupPendingAccFees
getTradeBorrowingFee
getTradeLiquidationPrice
getPairOisCollateral
getBorrowingPairGroupIndex
getPairOiCollateral
withinMaxBorrowingGroupOi
getBorrowingGroup
getBorrowingGroupOi
getBorrowingPair
getBorrowingPairOi
getBorrowingPairGroups
getAllBorrowingPairs
getBorrowingGroups
getBorrowingInitialAccFees
getPairMaxOi
getPairMaxOiCollateral
_getSlot
_getStorage
_getMultiCollatDiamond
validCollateralIndex
_getBorrowingPairPendingAccFee
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
| _currentBlock | uint256 | current block number |
| _long | bool | true if long side |
Return Values
| Name | Type | Description |
|---|---|---|
| accFee | uint64 | new pair acc borrowing fee |
_getBorrowingGroupPendingAccFee
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _groupIndex | uint16 | index of the borrowing group |
| _currentBlock | uint256 | current block number |
| _long | bool | true if long side |
Return Values
| Name | Type | Description |
|---|---|---|
| accFee | uint64 | new group acc borrowing fee |
_getBorrowingPendingAccFees
Parameters
| Name | Type | Description |
|---|---|---|
| _input | IBorrowingFees.PendingBorrowingAccFeesInput | input data (last acc fees, OIs, fee per block, current block, etc.) |
Return Values
| Name | Type | Description |
|---|---|---|
| newAccFeeLong | uint64 | new acc borrowing fee on long side |
| newAccFeeShort | uint64 | new acc borrowing fee on short side |
| delta | uint64 | delta with current acc borrowing fee (for side that changed) |
_getTradeLiquidationPrice
Parameters
| Name | Type | Description |
|---|---|---|
| _openPrice | uint256 | trade open price (1e10 precision) |
| _long | bool | true if long, false if short |
| _collateral | uint256 | trade collateral (collateral precision) |
| _leverage | uint256 | trade leverage (1e3 precision) |
| _feesCollateral | uint256 | closing fees + borrowing fees amount (collateral precision) |
| _collateralPrecisionDelta | uint256 | collateral precision delta (10^18/10^decimals) |
| _liquidationParams | IPairsStorage.GroupLiquidationParams | liquidation parameters for the trade |
| _contractsVersion | enum ITradingStorage.ContractsVersion | contracts version of the trade |
| _pairSpreadP | uint256 | pair spread percentage (1e10) |
_setBorrowingPairParams
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the pair |
| _value | IBorrowingFees.BorrowingPairParams | new pair params |
_setBorrowingGroupParams
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _groupIndex | uint16 | index of the borrowing group |
| _value | IBorrowingFees.BorrowingGroupParams | new group params |
_updateOi
Parameters
| Name | Type | Description |
|---|---|---|
| _oiStorage | IBorrowingFees.OpenInterest | open interest storage reference |
| _long | bool | true if long, false if short |
| _increase | bool | true if increase, false if decrease |
| _amountCollateral | uint256 | amount of collateral to increase/decrease (collateral precision) |
| _collateralPrecision | uint128 | collateral precision (10^decimals) |
Return Values
| Name | Type | Description |
|---|---|---|
| newOiLong | uint72 | new long open interest (1e10) |
| newOiShort | uint72 | new short open interest (1e10) |
| delta | uint72 | difference between new and current open interest (1e10) |
_updatePairOi
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _pairIndex | uint16 | index of the borrowing group |
| _long | bool | true if long, false if short |
| _increase | bool | true if increase, false if decrease |
| _amountCollateral | uint256 | amount of collateral to increase/decrease (collateral precision) |
_updateGroupOi
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _groupIndex | uint16 | index of the borrowing group |
| _long | bool | true if long, false if short |
| _increase | bool | true if increase, false if decrease |
| _amountCollateral | uint256 | amount of collateral to increase/decrease (collateral precision) |
_getBorrowingPairGroupAccFeesDeltas
Parameters
| Name | Type | Description |
|---|---|---|
| _collateralIndex | uint8 | index of the collateral |
| _i | uint256 | index of the borrowing pair group |
| _pairGroups | IBorrowingFees.BorrowingPairGroup[] | all pair’s historical borrowing groups |
| _initialFees | IBorrowingFees.BorrowingInitialAccFees | trade initial borrowing fees |
| _pairIndex | uint16 | index of the pair |
| _long | bool | true if long, false if short |
| _currentBlock | uint256 | current block number |
Return Values
| Name | Type | Description |
|---|---|---|
| deltaGroup | uint64 | difference between new and current group acc borrowing fee |
| deltaPair | uint64 | difference between new and current pair acc borrowing fee |
| beforeTradeOpen | bool | true if pair group was set before trade was opened |
_setPairPendingAccFees
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 (1e10 precision) |
| accFeeShort | uint64 | new pair acc borrowing fee on short side (1e10 precision) |
_setGroupPendingAccFees
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 (1e10 precision) |
| accFeeShort | uint64 | new group acc borrowing fee on short side (1e10 precision) |
