aftermath-ts-sdk - v3.3.3
    Preparing search index...

    Encodes and decodes perpetuals order IDs.

    An order ID stores a fixed-point price in the high bits and a counter in the low bits. Ask IDs store the price directly. Bid IDs store the 64-bit price complement, which lets isAsk distinguish the side from the highest bit.

    Index
    • Determines whether an encoded order ID represents an ask order.

      Parameters

      • orderId: bigint

        Encoded perpetuals order ID.

      Returns boolean

      true when the ID is below the protocol's 2^127 ask threshold.

    • Encodes a fixed-point order price, counter, and side as an order ID.

      Parameters

      • price: bigint

        Fixed-point price integer, usually scaled by 1e9.

      • counter: bigint

        Per-market order counter stored in the low bits.

      • side: PerpetualsOrderSide

        PerpetualsOrderSide.Ask or PerpetualsOrderSide.Bid.

      Returns bigint

      The encoded order ID as a bigint.

    • Extracts the fixed-point price from an encoded order ID.

      Parameters

      • orderId: bigint

        Encoded perpetuals order ID.

      Returns bigint

      The original fixed-point price integer as a bigint.