๐Ÿ—ƒ๏ธ Types, structs and enums

Documentation on types, structs and enums used across different contracts.

Types

MarketId

Alias for bytes32. It's a hash of the properties of MarketKey struct.

struct MarketKey {
    string sourceName;
    string instrumentName;
    string tag;
    uint16 version;
    address underlying;
}

function id(MarketKey memory self) internal pure returns (MarketId) {
    return
      MarketId.wrap(
        keccak256(abi.encode(self.sourceName, self.instrumentName, self.tag, self.version, self.underlying))
      );
}


FutureId

Alias for bytes32. It's a hash of the properties of FutureKey struct.

struct FutureKey {
    MarketId marketId;
    uint64 termStart;
    uint64 termLength;
}

function id(FutureKey memory self) internal pure returns (FutureId) {
    return FutureId.wrap(keccak256(abi.encode(self.marketId, self.termStart, self.termLength)));
}

Structs

OraclePackage

Defines the format for passing an updated index value from the oracle for a given market.

struct OraclePackage {
  MarketId marketId;
  uint64 timestamp;
  bytes signature;
  SD59x18 indexValue;
}

Margin.Value

struct Value {
    ProfitAndLoss.Value profitAndLoss;
    SD59x18 collateral;
}

ProfitAndLoss.Value

struct Value {
    SD59x18 netFutureValue;
    UD60x18 accruedLPFee;
    UD60x18 incurredFee;
}

FixedAndFloatTokensPair.Value

Struct for passing the amount of fixed and float tokes in a future's vAMM.

struct Value {
    SD59x18 fixedTokenAmount;
    SD59x18 floatTokenAmount;
}

TradeInfo

Provides detailed insights into the outcome of a trade

struct TradeInfo {
  RiskDirection.Value direction;
  FixedAndFloatTokensPair.Value tokensPair;
  SD59x18 marketRateBefore;
  SD59x18 marketRateAfter;
  SD59x18 tradeRate;
  UD60x18 lpFee;
  UD60x18 protocolFee;
  SD59x18 floatIndex;
  SD59x18 floatTradeValue;
}

ProvisionDistribution

Struct to show how liquidity is distributed between payer and receiver sides

struct ProvisionDistribution {
  UD60x18 total;
  UD60x18 payer;
  UD60x18 receiver;
}

Enums

RiskDirection.Value

Indicates the direction of a trader, whether the user is a receiver or payer of fixed rates.

enum Value {
    RECEIVER,
    PAYER
}

Last updated