Skip to main content

PositionParam.sol

PositionParam

struct PositionParam {
uint256 openVersion;
uint256 closeVersion;
int256 qty;
uint256 takerMargin;
uint256 makerMargin;
uint256 openTimestamp;
uint256 closeTimestamp;
IOracleProvider.OracleVersion _entryVersionCache;
IOracleProvider.OracleVersion _exitVersionCache;
}

A struct representing the parameters of a position.

NameTypeDescription
openVersionuint256The version of the position's open transaction
closeVersionuint256The version of the position's close transaction
qtyint256The quantity of the position
takerMarginuint256The margin amount provided by the taker
makerMarginuint256The margin amount provided by the maker
openTimestampuint256The timestamp of the position's open transaction
closeTimestampuint256The timestamp of the position's close transaction
_entryVersionCacheIOracleProvider.OracleVersionCaches the settled oracle version for the position's entry
_exitVersionCacheIOracleProvider.OracleVersionCaches the settled oracle version for the position's exit

PositionParamLib

Library for manipulating PositionParam struct.

entryVersion

function entryVersion(struct PositionParam self) internal pure returns (uint256)

Returns the settled version for the position's entry.

  • Parameters:

    NameTypeDescription
    selfstruct PositionParamThe PositionParam struct.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The settle version for the position's entry.

entryPrice

function entryPrice(struct PositionParam self, struct LpContext ctx) internal view returns (uint256)

Calculates the entry price for a PositionParam.

  • Parameters:

    NameTypeDescription
    selfstruct PositionParamThe PositionParam struct.
    ctxstruct LpContextThe LpContext struct.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The entry price.

entryAmount

function entryAmount(struct PositionParam self, struct LpContext ctx) internal view returns (uint256)

Calculates the entry amount for a PositionParam.

  • Parameters:

    NameTypeDescription
    selfstruct PositionParamThe PositionParam struct.
    ctxstruct LpContextThe LpContext struct.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The entry amount.

entryOracleVersion

function entryOracleVersion(struct PositionParam self, struct LpContext ctx) internal view returns (struct IOracleProvider.OracleVersion)

Retrieves the settled oracle version for the position's entry.

  • Parameters:

    NameTypeDescription
    selfstruct PositionParamThe PositionParam struct.
    ctxstruct LpContextThe LpContext struct.
  • Return Values:

    NameTypeDescription
    [0]struct IOracleProvider.OracleVersionOracleVersion The settle oracle version for the position's entry.

calculateInterest

function calculateInterest(struct PositionParam self, struct LpContext ctx, uint256 until) internal view returns (uint256)

Calculates the interest for a PositionParam until a specified timestamp. It is used only to deduct accumulated accrued interest when close position

  • Parameters:

    NameTypeDescription
    selfstruct PositionParamThe PositionParam struct.
    ctxstruct LpContextThe LpContext struct.
    untiluint256The timestamp until which to calculate the interest.
  • Return Values:

    NameTypeDescription
    [0]uint256uint256 The calculated interest.

clone

function clone(struct PositionParam self) internal pure returns (struct PositionParam)

Creates a clone of a PositionParam.

  • Parameters:

    NameTypeDescription
    selfstruct PositionParamThe PositionParam data struct.
  • Return Values:

    NameTypeDescription
    [0]struct PositionParamPositionParam The cloned PositionParam.

inverse

function inverse(struct PositionParam self) internal pure returns (struct PositionParam)

Creates the inverse of a PositionParam by negating the qty.

  • Parameters:

    NameTypeDescription
    selfstruct PositionParamThe PositionParam data struct.
  • Return Values:

    NameTypeDescription
    [0]struct PositionParamPositionParam The inverted PositionParam.