BinPosition.sol
BinPosition
struct BinPosition {
int256 totalQty;
uint256 totalEntryAmount;
uint256 _totalMakerMargin;
uint256 _totalTakerMargin;
BinPendingPosition _pending;
AccruedInterest _accruedInterest;
}
Represents a position in the LiquidityBin
Name | Type | Description |
---|---|---|
totalQty | int256 | The total quantity of the LiquidityBin |
totalEntryAmount | uint256 | The total entry amount of the LiquidityBin |
_totalMakerMargin | uint256 | The total maker margin of the LiquidityBin |
_totalTakerMargin | uint256 | The total taker margin of the LiquidityBin |
_pending | BinPendingPosition | The pending position of the LiquidityBin |
_accruedInterest | AccruedInterest | The 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:
Name Type Description self struct BinPosition The BinPosition storage struct. ctx struct LpContext The 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:
Name Type Description self struct BinPosition The BinPosition storage. ctx struct LpContext The LpContext data struct. param struct PositionParam The 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:
Name Type Description self struct BinPosition The BinPosition storage struct. ctx struct LpContext The LpContext data struct. param struct PositionParam The 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:
Name Type Description self struct BinPosition The BinPosition storage struct. Return Values:
Name Type Description [0] uint256 uint256 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:
Name Type Description self struct BinPosition The BinPosition storage struct. Return Values:
Name Type Description [0] uint256 uint256 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:
Name Type Description self struct BinPosition The BinPosition storage struct. ctx struct LpContext The LpContext data struct. Return Values:
Name Type Description [0] int256 int256 The unrealized profit or loss.
pendingPosition
function pendingPosition(struct BinPosition self) internal view returns (struct PendingPosition)
Retrieves the pending position information.
Parameters:
Name Type Description self struct BinPosition The reference to the BinPosition struct. Return Values:
Name Type Description [0] struct PendingPosition pendingPosition 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:
Name Type Description self struct BinPosition The BinPosition storage struct. ctx struct LpContext The LpContext data struct. Return Values:
Name Type Description [0] uint256 uint256 The current interest.