Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InstantTradesManager

Contains methods to calculate instant trades.

Hierarchy

  • InstantTradesManager

Index

Constructors

Properties

lifiProvider: LifiProvider = ...
tradeProviders: Readonly<Record<BlockchainName, Partial<Record<"ACRYPTOS" | "ALDRIN_EXCHANGE" | "ALGEBRA" | "ANNEX" | "APE_SWAP" | "ARTH_SWAP" | "BABY_SWAP" | "BALANCER" | "BEAM_SWAP" | "BI_SWAP" | "CREMA_FINANCE" | "CRONA_SWAP" | "CROPPER_FINANCE" | "CROW_FI" | "CRO_DEX" | "CURVE" | "DEFI_PLAZA" | "DEFI_SWAP" | "DFYN" | "DODO" | "DYSTOPIA" | "HONEY_SWAP" | "JET_SWAP" | "JOE" | "J_SWAP" | "KYBER_SWAP" | "LUA_SWAP" | "MAVERICK" | "MDEX" | "MESH_SWAP" | "MM_FINANCE" | "MOJITO_SWAP" | "ONE_INCH" | "ONE_MOON" | "ONE_SOL" | "OOLONG_SWAP" | "OPEN_OCEAN" | "ORCA_SWAP" | "OSMOSIS_SWAP" | "PANCAKE_SWAP" | "PANGOLIN" | "PARA_SWAP" | "POLYDEX" | "QUICK_SWAP" | "RAYDIUM" | "REF_FINANCE" | "SABER_STABLE_SWAP" | "SAROS_SWAP" | "SERUM" | "SHIBA_SWAP" | "SMOOTHY" | "SOLAR_BEAM" | "SPIRIT_SWAP" | "SPL_TOKEN_SWAP" | "SPOOKY_SWAP" | "STELLA_SWAP" | "SUSHI_SWAP" | "TRISOLARIS" | "UBE_SWAP" | "UNISWAP_V2" | "UNI_SWAP_V3" | "VIPER_SWAP" | "VOLTAGE_SWAP" | "VVS_FINANCE" | "WANNA_SWAP" | "WAULT_SWAP" | "WOO_FI" | "WRAPPED" | "ZAPPY" | "ZIP_SWAP" | "ZRX" | "AURORA_SWAP" | "JUPITER" | "REN_BTC", InstantTradeProvider>>>> = ...

List of all instant trade providers, combined by blockchains.

defaultCalculationTimeout: 10000 = 10_000

Methods

  • Calculates instant trades, sorted by output amount.

    example
    const blockchain = BLOCKCHAIN_NAME.ETHEREUM;
    // ETH
    const fromTokenAddress = '0x0000000000000000000000000000000000000000';
    const fromAmount = 1;
    // USDT
    const toTokenAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7';

    const trades = await sdk.instantTrades.calculateTrade(
    { blockchain, address: fromTokenAddress },
    fromAmount,
    toTokenAddress
    );
    const bestTrade = trades[0];

    Object.entries(trades).forEach(([tradeType, trade]) =>
    console.log(tradeType, `to amount: ${trade.to.tokenAmount.toFormat(3)}`)
    )

    Parameters

    • fromToken: Token | { address: string; blockchain: BlockchainName }

      Token to sell.

    • fromAmount: string | number

      Amount to sell.

    • toToken: string | Token

      Token to get.

    • Optional options: SwapManagerCalculationOptions

      Additional options.

    Returns Promise<(InstantTrade | InstantTradeError)[]>

    List of calculated instant trades.

Generated using TypeDoc