@soku-dex/sdk
    Preparing search index...

    Class Dex

    Dex class for interacting with decentralized exchange contracts on TON Provides functionality for liquidity operations, swaps, and simulation

    Index

    Constructors

    • Creates a new Dex instance

      Parameters

      • client: TonClient

        The TON client instance

      • address: Address

        The address of the Dex contract

      Returns Dex

    Accessors

    • get address(): Address

      Returns the address of this Dex contract instance

      Returns Address

      The TON address of the Dex contract

    Methods

    • Fetches the latest state of the Dex contract from the blockchain

      Returns Promise<
          {
              balance: bigint;
              blockId: { seqno: number; shard: string; workchain: number };
              data: null | Dex$Data;
              lastTransaction: null | { hash: string; lt: string };
              state: "active" | "uninitialized" | "frozen";
              timestamp: number;
          },
      >

      Contract state including parsed contract data, balance and last transaction

      Dex$Data

    • Simulates a swap using the current state of this Dex instance

      Parameters

      • amountIn: string | number | bigint

        Amount of input token to swap

      • directionIn: boolean

        Direction flag: true for token0 to token1 swap, false for token1 to token0 swap

      Returns Promise<SwapSimulationOutput>

      Simulation result

      If unable to fetch the DEX state

    • Builds a payload for swapping Jetton tokens

      Parameters

      • minOutput: bigint

        Minimum amount of output tokens to receive

      • destination: Address

        Destination address for output tokens

      • OptionalforwardTonAmount: bigint = 0n

        TON to forward with output tokens

      • OptionalforwardPayload: Slice

        Optional payload to forward

      Returns Slice

      Slice containing the payload for the Jetton swap

      SwapOpPayload

    • Builds a message body for swapping TON to tokens

      Parameters

      • minOutput: bigint

        Minimum amount of tokens to receive

      • destination: Address

        Destination address for output tokens

      • amountIn: bigint

        Amount of TON to swap

      • OptionalforwardTonAmount: bigint = 0n

        TON to forward with output tokens

      • OptionalforwardPayload: Slice

        Optional payload to forward

      • OptionalqueryId: bigint = 1n

        Query ID for the operation

      Returns Cell

      Cell containing the message body for the TON swap

      SwapOpPayload

    • Static method to fetch the latest state of a Dex contract without instantiating the class

      Parameters

      • client: TonClient

        The TON client instance

      • address: Address

        The address of the Dex contract

      Returns Promise<
          {
              balance: bigint;
              blockId: { seqno: number; shard: string; workchain: number };
              data: null | Dex$Data;
              lastTransaction: null | { hash: string; lt: string };
              state: "active" | "uninitialized" | "frozen";
              timestamp: number;
          },
      >

      Contract state including parsed contract data, balance and last transaction

      Dex$Data