Skip to main content

BinPendingPosition.sol

BinPendingPosition

struct BinPendingPosition {
uint256 openVersion;
int256 totalQty;
uint256 totalMakerMargin;
uint256 totalTakerMargin;
AccruedInterest accruedInterest;
}

Represents a pending position within the LiquidityBin

NameTypeDescription
openVersionuint256The oracle version when the position was opened.
totalQtyint256The total quantity of the pending position.
totalMakerMarginuint256The total maker margin of the pending position.
totalTakerMarginuint256The total taker margin of the pending position.
accruedInterestAccruedInterestThe 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:

    NameTypeDescription
    selfstruct BinPendingPositionThe BinPendingPosition storage.
    ctxstruct LpContextThe 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:

    NameTypeDescription
    selfstruct BinPendingPositionThe BinPendingPosition storage.
    ctxstruct LpContext
    paramstruct PositionParamThe 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:

    NameTypeDescription
    selfstruct BinPendingPositionThe BinPendingPosition storage.
    ctxstruct LpContextThe LpContext.
    paramstruct PositionParamThe 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:

    NameTypeDescription
    selfstruct BinPendingPositionThe BinPendingPosition storage.
    ctxstruct LpContextThe LpContext.
  • Return Values:

    NameTypeDescription
    [0]int256uint256 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:

    NameTypeDescription
    selfstruct BinPendingPositionThe BinPendingPosition storage.
    ctxstruct LpContextThe LpContext.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 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:

    NameTypeDescription
    selfstruct BinPendingPositionThe BinPendingPosition storage.
    ctxstruct LpContextThe LpContext.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The entry price.