BinPendingPosition.sol
BinPendingPosition
struct BinPendingPosition {
uint256 openVersion;
int256 totalQty;
uint256 totalMakerMargin;
uint256 totalTakerMargin;
AccruedInterest accruedInterest;
}
Represents a pending position within the LiquidityBin
Name | Type | Description |
---|---|---|
openVersion | uint256 | The oracle version when the position was opened. |
totalQty | int256 | The total quantity of the pending position. |
totalMakerMargin | uint256 | The total maker margin of the pending position. |
totalTakerMargin | uint256 | The total taker margin of the pending position. |
accruedInterest | AccruedInterest | The accumulated interest of the pending position. |
BinPendingPositionLib
Library for managing pending positions in the LiquidityBin
settleAccruedInterest
function settleAccruedInterest(struct BinPendingPosition self, struct LpContext ctx) internal
Settles the accumulated interest of the pending position.
Parameters:
Name Type Description self struct BinPendingPosition The BinPendingPosition storage. ctx struct LpContext The LpContext.
onOpenPosition
function onOpenPosition(struct BinPendingPosition self, struct LpContext ctx, struct PositionParam param) internal
Handles the opening of a position.
Throws an error with the code Errors.INVALID_ORACLE_VERSION
if the openVersion
is not valid.
Parameters:
Name Type Description self struct BinPendingPosition The BinPendingPosition storage. ctx struct LpContext param struct PositionParam The position parameters.
onClosePosition
function onClosePosition(struct BinPendingPosition self, struct LpContext ctx, struct PositionParam param) internal
Handles the closing of a position.
Throws an error with the code Errors.INVALID_ORACLE_VERSION
if the openVersion
is not valid.
Parameters:
Name Type Description self struct BinPendingPosition The BinPendingPosition storage. ctx struct LpContext The LpContext. param struct PositionParam The position parameters.
unrealizedPnl
function unrealizedPnl(struct BinPendingPosition self, struct LpContext ctx) internal view returns (int256)
Calculates the unrealized profit or loss (PnL) of the pending position.
Parameters:
Name Type Description self struct BinPendingPosition The BinPendingPosition storage. ctx struct LpContext The LpContext. Return Values:
Name Type Description [0] int256 uint256 The unrealized PnL.
currentInterest
function currentInterest(struct BinPendingPosition self, struct LpContext ctx) internal view returns (uint256)
Calculates the current accrued interest of the pending position.
Parameters:
Name Type Description self struct BinPendingPosition The BinPendingPosition storage. ctx struct LpContext The LpContext. Return Values:
Name Type Description [0] uint256 uint256 The current accrued interest.
entryPrice
function entryPrice(struct BinPendingPosition self, struct LpContext ctx) internal view returns (uint256)
Calculates the entry price of the pending position.
Parameters:
Name Type Description self struct BinPendingPosition The BinPendingPosition storage. ctx struct LpContext The LpContext. Return Values:
Name Type Description [0] uint256 uint256 The entry price.