# How to swap tokens with min out required amount?

{% hint style="warning" %}

* Minimal amount defined in min units receiving(4.0000 USDT = 40000)
* Swapped tokens amount will be greater or equal to min units in the memo
* Both token balances should be opened
  {% endhint %}

{% tabs %}
{% tab title="@a-dex/a-dex-sdk" %}

```typescript
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"
  );

```

{% endtab %}

{% tab title="cleos" %}

```bash
cleos -u https://eos.greymass.com push transaction '{
  "delay_sec": 0,
  "max_cpu_usage_ms": 0,
  "actions": [
    {
      "account": "eosio.token",
      "name": "transfer",
      "data": {
        "from": "trader.adex",
        "to": "swap.adex",
        "quantity": "1.0000 EOS",
        "memo": "swap:1;min:40000"
      },
      "authorization": [
        {
          "actor": "trader.adex",
          "permission": "active"
        }
      ]
    }
  ]
}'
```

{% endtab %}

{% tab title="eosjs" %}

```javascript
const result = await api.transact({
  actions: [{
    account: 'eosio.token',
    name: 'transfer',
    authorization: [{
      actor: 'trader.adex',
      permission: 'active',
    }],
    data: {
      from: 'trader.adex',
      to: 'swap.adex',
      quantity: '1.0000 EOS',
      memo: 'swap:1;min:40000'
    },
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
```

{% endtab %}
{% endtabs %}
