Skip to main content

BinClosingPosition.sol

BinClosingPosition

struct BinClosingPosition {
uint256 closeVersion;
int256 totalQty;
uint256 totalEntryAmount;
uint256 totalMakerMargin;
uint256 totalTakerMargin;
AccruedInterest accruedInterest;
}

Represents the closing position within an LiquidityBin.

NameTypeDescription
closeVersionuint256The oracle version when the position was closed.
totalQtyint256The total quantity of the closing position.
totalEntryAmountuint256The total entry amount of the closing position.
totalMakerMarginuint256The total maker margin of the closing position.
totalTakerMarginuint256The total taker margin of the closing position.
accruedInterestAccruedInterestThe accumulated interest of the closing position.

BinClosingPositionLib

A library that provides functions to manage the closing position within an LiquidityBin.

settleAccruedInterest

function settleAccruedInterest(struct BinClosingPosition self, struct LpContext ctx) internal

Settles the accumulated interest of the closing position.

  • Parameters:

    NameTypeDescription
    selfstruct BinClosingPositionThe BinClosingPosition storage.
    ctxstruct LpContextThe LpContext.

onClosePosition

function onClosePosition(struct BinClosingPosition 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 closeVersion is not valid.

  • Parameters:

    NameTypeDescription
    selfstruct BinClosingPositionThe BinClosingPosition storage.
    ctxstruct LpContextThe LpContext.
    paramstruct PositionParamThe position parameters.

onClaimPosition

function onClaimPosition(struct BinClosingPosition self, struct LpContext ctx, struct PositionParam param) internal

Handles the claiming of a position.

Throws an error with the code Errors.INVALID_ORACLE_VERSION if the closeVersion is not valid.

  • Parameters:

    NameTypeDescription
    selfstruct BinClosingPositionThe BinPendingPosition storage.
    ctxstruct LpContextThe LpContext.
    paramstruct PositionParamThe position parameters.

currentInterest

function currentInterest(struct BinClosingPosition self, struct LpContext ctx) internal view returns (uint256)

Calculates the current accrued interest of the closing position.

  • Parameters:

    NameTypeDescription
    selfstruct BinClosingPositionThe BinClosingPosition storage.
    ctxstruct LpContextThe LpContext.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The current accrued interest.