Skip to main content

BinPosition.sol

BinPosition

struct BinPosition {
int256 totalQty;
uint256 totalEntryAmount;
uint256 _totalMakerMargin;
uint256 _totalTakerMargin;
BinPendingPosition _pending;
AccruedInterest _accruedInterest;
}

Represents a position in the LiquidityBin

NameTypeDescription
totalQtyint256The total quantity of the LiquidityBin
totalEntryAmountuint256The total entry amount of the LiquidityBin
_totalMakerMarginuint256The total maker margin of the LiquidityBin
_totalTakerMarginuint256The total taker margin of the LiquidityBin
_pendingBinPendingPositionThe pending position of the LiquidityBin
_accruedInterestAccruedInterestThe accumulated interest of the LiquidityBin

BinPositionLib

Library for managing positions in the LiquidityBin

settlePendingPosition

function settlePendingPosition(struct BinPosition self, struct LpContext ctx) internal

Settles pending positions for a liquidity bin position.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe BinPosition storage struct.
    ctxstruct LpContextThe LpContext data struct.

onOpenPosition

function onOpenPosition(struct BinPosition self, struct LpContext ctx, struct PositionParam param) internal

Handles the opening of a position for a liquidity bin.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe BinPosition storage.
    ctxstruct LpContextThe LpContext data struct.
    paramstruct PositionParamThe PositionParam containing the position parameters.

onClosePosition

function onClosePosition(struct BinPosition self, struct LpContext ctx, struct PositionParam param) internal

Handles the closing of a position for a liquidity bin.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe BinPosition storage struct.
    ctxstruct LpContextThe LpContext data struct.
    paramstruct PositionParamThe PositionParam data struct containing the position parameters.

totalMakerMargin

function totalMakerMargin(struct BinPosition self) internal view returns (uint256)

Returns the total maker margin for a liquidity bin position.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe BinPosition storage struct.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The total maker margin.

totalTakerMargin

function totalTakerMargin(struct BinPosition self) internal view returns (uint256)

Returns the total taker margin for a liquidity bin position.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe BinPosition storage struct.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The total taker margin.

unrealizedPnl

function unrealizedPnl(struct BinPosition self, struct LpContext ctx) internal view returns (int256)

Calculates the unrealized profit or loss for a liquidity bin position.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe BinPosition storage struct.
    ctxstruct LpContextThe LpContext data struct.
  • Return Values:

    NameTypeDescription
    [0]int256int256 The unrealized profit or loss.

pendingPosition

function pendingPosition(struct BinPosition self) internal view returns (struct PendingPosition)

Retrieves the pending position information.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe reference to the BinPosition struct.
  • Return Values:

    NameTypeDescription
    [0]struct PendingPositionpendingPosition An instance of PendingPosition representing the pending position information.

currentInterest

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

Calculates the current interest for a liquidity bin position.

  • Parameters:

    NameTypeDescription
    selfstruct BinPositionThe BinPosition storage struct.
    ctxstruct LpContextThe LpContext data struct.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The current interest.