How to cross-swap tokens with min out required amount?

  • Fees will be taken on each hoop

  • Minimum amount defined in min units (4.0000 USDT = 40000)

  • Amount out will be greater or equal to min units in the memo

  • Both token balances should be opened

import {
  SwapActionGenerator,
  SwapTransactionGenerator,
} from "@a-dex/a-dex-sdk";
import { ExtendedAsset, Name, Asset } from "eos-common";

const actionsGen = new SwapActionGenerator("swap.adex");
const trxGen = new SwapTransactionGenerator(
  [
    {
      actor: "trader.adex",
      permission: "active",
    },
  ],
  actionsGen
);

const trx = await trxGen.swapWithMinReceived(
    new Name("trader.adex"),
    new ExtendedAsset(new Asset("1.0000 EOS"), new Name("eosio.token")),
    new ExtendedAsset(new Asset("4.0000 USDT"), new Name("tethertether")),
    "1-2-3"
  );

Last updated