# Intro

### Introduction

The A-DEX is a peer-to-peer system designed for exchanging cryptocurrencies on the Antelope(EOSIO) blockchains.

### How does the A-DEX protocol compare to a typical market?

To understand how the A-DEX protocol differs from a traditional exchange, it is helpful to first look at two subjects: how the Automated Market Maker design deviates from traditional central limit order book-based exchanges, and how permissionless systems depart from conventional permissioned systems.

### Order Book VS AMM

Most publicly accessible markets use a central limit order book style of exchange, where buyers and sellers create orders organized by price level that are progressively filled as demand shifts. Anyone who has traded stocks through brokerage firms will be familiar with an order book system.

The A-DEX protocol takes a different approach, using an Automated Market Maker (AMM), sometimes referred to as a Constant Function Market Maker, in place of an order book.

At a very high level, an AMM replaces the buy and sell orders in an order book market with a liquidity pool of two assets, both valued relative to each other. As one asset is traded for the other, the relative prices of the two assets shift, and a new market rate for both is determined. In this dynamic, a buyer or seller trades directly with the pool, rather than with specific orders left by other parties. The advantages and disadvantages of Automated Market Makers versus their traditional order book counterparts are under active research by a growing number of parties.

### Permissionless Systems

The second departure from traditional markets is the permissionless and immutable design of the A-DEX protocol. These design decisions were inspired by EOSIO's core tenets and our commitment to the ideals of permissionless access and immutability as indispensable components of a future in which anyone in the world can access financial services without fear of discrimination or counter-party risk.

Permissionless design means that the protocol's services are entirely open for public use, with no ability to selectively restrict who can or cannot use them. Anyone can swap, provide liquidity. This is a departure from traditional financial services, which typically restrict access based on geography, wealth status, and age.

The protocol is also preparing to be immutable, in other words not upgradeable. No party is able to pause the contracts, reverse trade execution, or otherwise change the behavior of the protocol in any way. It is worth noting that A-DEX Governance has the right (but no obligation) to divert a percentage of swap fees on any pool to a specified address. However, this capability is known to all participants in advance, and to prevent abuse, the percentage is constrained to 0.05%.


# Audits

## Antelope(EOSIO) Audit Reports

**A-DEX Swap**

* [Sentnl security audit of A-DEX Swap](https://www.sentnl.io/audits/a-dex_1) (October 2023)

{% file src="/files/JmXOUBSs55UIBYRwMfwW" %}


# Roadmap

Updated on August 1, 2025

{% hint style="warning" %}
We don’t publicly commit to specific timelines, so we can organize our development priorities based on market changes and developer resources.
{% endhint %}

### Ongoing

* UI/UX, Bug Fixes, Product Upgrades

## 2025

* More Defi products to come!

## Backlog

* N/A

## Done

* Swap(AMM)
* Multichain Expansion
* Analytics
* Oracle
* Signals


# Brand

Guidelines and brand assets

## Intro

Please be sure to read these guidelines first, downloads are available at the bottom of this page.

## What you may do?

You may use A-DEX Brand Assets when you are:

* 👌 Referring to our products and services
* 👌 Linking to our official site and products, such as "Trade our token on A-DEX"
* 👌 Announcing an official partnership, but only if you have **official approval** from a qualified member of the A-DEX team

## What you may not do?

**Protecting the A-DEX brand is extremely important for our users' security** so that users know what is a genuine product/endorsement and what isn't.

Here are a few examples of forbidden uses of our Brand Assets:

* ⛔️ **Don't use our Brand Assets in your products' name, logo, NFTs, etc.**&#x20;
  * For example, making an app called "A-DEX Engine" are not allowed.
  * Don't use the A-DEX logo in whole or in part as part of your products' logos, marketing material, website, or other.
  * Logos with a strong resemblance to the A-DEX Icon are also forbidden.
* ⛔️ **Don't use our Brand Assets to create digital or physical products for sale, including but not limited to:**
  * Merchandise
  * NFTs
  * Other products
* ⛔️ **Don't create derivative names that imply official endorsement**\
  For exampl&#x65;**,** don't make a social media group called "A-DEX Korea" - this sounds official. "A-DEX Fans of Korea" may be permitted.
* ⛔️ **Don't change or adapt our Brand Assets in any way**\
  Use the logos and other assets exactly as provided. Do not change the colors, reassemble, abbreviate, or change these assets in any way.
* Merchandise

## A-DEX Brand Assets Downloads

Once you have read all the above, download A-DEX Brand Assets below.

{% file src="/files/BuAwc85R9s6sZmECXfZw" %}

By downloading this file, you confirm that you will only use it to the extent permitted by the terms detailed on this page.


# Services

As Multichain Block Producer we are providing Dedicated Commercial Solutions for Blockchain Services.

We are able to host or operate your own infrastructure for the following:

* Chain API Node
* State History Node
* P2P Node
* Hyperion History
* Atomic Assets API
* Light API
* IPFS

Contact us at:

* Email: <business@a-dex.io>
* Telegram: @Avm07

## Public Endpoints

### WAX Tesnet

| Service          | URL                                                                      | Note      |
| ---------------- | ------------------------------------------------------------------------ | --------- |
| Hyperion History | <https://hyperion-wax-testnet.a-dex.xyz/v2/docs/>                        | Full data |
| Chain API        | <https://wax-testnet.a-dex.xyz>                                          |           |
| P2P Node         | [p2p-wax-testnet.a-dex.xyz:9878](http://p2p-wax-testnet.a-dex.xyz:9878/) |           |

### WAX Mainnet

| Service           | URL                                                      | Note           |
| ----------------- | -------------------------------------------------------- | -------------- |
| Hyperion History  | <https://hyperion-wax.a-dex.xyz/v2/docs/>                | Latest 6 weeks |
| Atomic Assets API | <https://atomic-wax.a-dex.xyz>                           |                |
| Light API         | <https://light-api-wax.a-dex.xyz>                        |                |
| Chain API         | [https://wax.a-dex.xyz](https://wax.a-dex.xyz/)          |                |
| P2P Node          | [p2p-wax.a-dex.xyz:9876](http://p2p-wax.a-dex.xyz:9876/) |                |
| IPFS              | <https://ipfs.a-dex.xyz>                                 |                |

### Vaulta Mainnet

| Service   | URL                                                            | Note |
| --------- | -------------------------------------------------------------- | ---- |
| Chain API | [https://vaulta.a-dex.xyz](https://vaulta.a-dex.xyz/)          |      |
| P2P Node  | [p2p-vaulta.a-dex.xyz:9876](http://p2p-vaulta.a-dex.xyz:9876/) |      |

### Telos Testnet

| Service   | URL                                                                          | Note |
| --------- | ---------------------------------------------------------------------------- | ---- |
| Chain API | [https://telos-testnet.a-dex.xyz](https://telos-testnet.a-dex.xyz/)          |      |
| P2P Node  | [p2p-telos-testnet.a-dex.xyz:9876](http://p2p-telos-testnet.a-dex.xyz:9876/) |      |

### Telos Mainnet

| Service   | URL                                                          | Note |
| --------- | ------------------------------------------------------------ | ---- |
| Chain API | [https://telos.a-dex.xyz](https://telos.a-dex.xyz/)          |      |
| P2P Node  | [p2p-telos.a-dex.xyz:9976](http://p2p-telos.a-dex.xyz:9976/) |      |


# Contacts

## 📩 Email

* 💰 Listing (<listing@a-dex.io>)
* 👔 Business (<business@a-dex.io>)
* 🆘 Support (<support@a-dex.io>)
* ❤️ Feedback (<feedback@a-dex.io>)

## 🐦 Twitter

<https://twitter.com/a_dex_official>

## 📰 Medium

<https://medium.com/a-dex>

## 🤖Discord

<https://discord.com/invite/3jRWnX7eQs>

## 💬 Telegram

<http://t.me/a_dex_official>

{% hint style="danger" %}
**Admins will NEVER send you a direct message. If anybody approaches you directly on e.g. Telegram pretending to represent customer support, please block them and report spam.**
{% endhint %}

{% hint style="danger" %}
**NEVER, under any situation, should you ever give someone your private key or recovery phrases. Immediately block and report anyone that asks for them.**
{% endhint %}


# Swap

## What is Swap?

Swap is **AMM**(automated market maker) for providing liquidity and trading EOSIO tokens on EOS. It eliminates trusted intermediaries and unnecessary forms of rent extraction, allowing for safe, accessible, and efficient exchange activity. The protocol is non-upgradable and designed to be censorship resistant.

## How swap works?

![](https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2FtDKWnBUXmWaPRINQwh6Q%2Foverview.svg?alt=media\&token=0e7a18fb-e7a8-4961-981f-d2ad27037dde)

Swap is an *automated liquidity protocol* powered by a [constant product formula](https://docs.uniswap.org/protocol/V2/concepts/protocol-overview/glossary#constant-product-formula) and implemented in a system of non-upgradeable smart contracts on the [EOSIO](https://eos.io/) blockchain. It obviates the need for trusted intermediaries, prioritizing **decentralization**, **censorship resistance**, and **security**.&#x20;

Smart contract manages a liquidity pools made up of reserves of two EOSIO tokens.

Anyone can become a liquidity provider (LP) for a pool by depositing an equivalent value of each underlying token in return for pool tokens. These tokens track pro-rata LP shares of the total reserves and can be redeemed for the underlying assets at any time.<br>

![](https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2F9fHvzbvgzMV197yEGt2w%2Fliquidity.svg?alt=media\&token=348334f2-5400-451e-90f8-fbc2f037cee3)

Pairs act as automated market makers, standing ready to accept one token for the other as long as the “constant product” formula is preserved. This formula, most simply expressed as `x * y = k`, states that trades must not change the product (`k`) of a pair’s reserve balances (`x` and `y`). Because `k` remains unchanged from the reference frame of a trade, it is often referred to as the invariant. This formula has the desirable property that larger trades (relative to reserves) execute at exponentially worse rates than smaller ones.\
\
In practice, Swap applies a 0.25% fee to trades, 0.20% is added to reserves and the remaning 0.05% withheld as a protocol-wide charge. As a result, each trade actually increases `k`. This functions as a payout to LPs, which is realized when they burn their pool tokens to withdraw their portion of total reserves.

![](https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2Fo12mSYkkOR8wh4X48hy0%2Fswap.svg?alt=media\&token=8dbc42e6-48af-4fbf-ba2f-dc04ebf8665d)

Because the relative price of the two pair assets can only be changed through trading, divergences between the Swap price and external prices create arbitrage opportunities. This mechanism ensures that Swap prices always trend toward the market-clearing price.

## Further reading

\ <br>


# Analytics

## What is Analytics?

## Pools

## Tokens

## Transactions


# Signals

Real time DeFi & Whales activity alerts:

* 🐋 Transfer
* 🔄 Swap
* 🔃 Spot
* 🆕 Listing
* ⬇️ Inflow
* ⬆️ Outflow

Supported networks:

* ✅ WAX
* ✅ XPR

Supported contracts:

* ✅ XPR Swap
* ✅ Alcor Swap
* ✅ Alcor Spot
* ✅ A-DEX Swap
* ✅ Taco Swap
* ✅ Defibox Swap
* ✅ Neftyblocks Swap

Join now:\
<https://t.me/xprsignals>\
<https://t.me/waxsignals>


# Oracle

## What is Oracle?

Oracles play a foundational role in the creation of the verifiable web, connecting blockchains that would otherwise be isolated to offchain data and compute, and enabling interoperability between blockchains.

## How oracle works?

Oracle provide tokens price from major liquidity pools(AMM) sorted by highest liquidity by cron job every hour. Data available from A-DEX GraphQL API via REST or WebSocket.

Supported networks:

* ✅ EOS
* ✅ WAX
* ✅ XPR

Supported DEXes:

* ✅ Alcor Swap
* ✅ A-DEX Swap
* ✅ Proton Swap
* ✅ Taco Swap
* ✅ PayCash Swap
* ✅ DefiBox

## Examples:

{% tabs %}
{% tab title="cURL" %}

<pre class="language-javascript"><code class="lang-javascript"><strong>curl -X POST https://wax.a-dex.io/v1/graphql \
</strong>-H "Content-Type: application/json" \
-d '{
    "query": "query MyQuery { adex_oracle { contract precision price_amount price_contract price_precision price_symbol_code sha256 symbol_code updated_at } }"
}'
</code></pre>

{% endtab %}

{% tab title="Javascript" %}

```python
const query = `
   query MyQuery {
  adex_oracle {
    contract
    precision
    price_amount
    price_contract
    price_precision
    price_symbol_code
    sha256
    symbol_code
    updated_at
  }
}`;
    
const response = await fetch('https://wax.a-dex.io/v1/graphql', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ query })
});

const responseData = await response.json();
```

{% endtab %}
{% endtabs %}


# Swap


# How to login?

<figure><img src="https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2FHF25HuzOrCuXLKPk04QL%2Fhow-to-login.svg?alt=media&amp;token=627c86e2-75dc-40ae-81f7-a2406447067c" alt=""><figcaption></figcaption></figure>


# How to swap?

<figure><img src="https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2FLl0REbdRCYeGV6o81oma%2Fhow-to-swap-1.svg?alt=media&amp;token=22e167df-727b-4a79-8271-148e46c80e6e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2FvJr1QHKCpvRhAIPuTu58%2Fhow-to-swap-2.svg?alt=media&amp;token=4c572a98-8671-4f1c-a2be-be7ad0199864" alt=""><figcaption></figcaption></figure>


# How to add liquidity?

<figure><img src="https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2FHk2aDv3bB6K50cKlsVbz%2Fhow-to-add-liquidity.svg?alt=media&amp;token=024924b9-3c22-454a-bc23-0f5737b62982" alt=""><figcaption></figcaption></figure>


# How to remove liquidity?

<figure><img src="https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2FYKT9ruDdjcRDUt4WUpIp%2Fhow-to-remove-liquidity.svg?alt=media&amp;token=5fbc933f-df7c-4536-b482-2e635c0fb00c" alt=""><figcaption></figcaption></figure>


# How to get pools info?

<figure><img src="https://2168315623-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVvuZm18V3EtEwblZll%2Fuploads%2FNUlPMT0tVWFH8CenkMEP%2Fhow-to-get-pools-info.svg?alt=media&amp;token=72fbdb0a-80c8-4c84-9f17-a651cf6a34a3" alt=""><figcaption></figcaption></figure>


# Smart Contracts


# Swap


# Tables

## accounts

````
```cpp
#pragma once
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>

using namespace eosio;

struct [[eosio::contract("adex.swap"), eosio::table]] account
{
    asset balance;

    uint64_t primary_key() const
    {
        return balance.symbol.code().raw();
    }
};
using accounts = multi_index<name("accounts"), account>;
```
````

## deposits

````
```cpp
#pragma once
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
#include "resources.hpp"

using namespace eosio;

struct [[eosio::contract("adex.swap"), eosio::table]] deposit_row
{
    name owner;
    extended_asset base_token;
    extended_asset quote_token;
    
    uint64_t primary_key() const {
        return owner.value;
    }
};
using deposits = multi_index<name("deposits"), deposit_row>;
```
````

## pools

````
```cpp
#pragma once
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
#include "resources.hpp"

using namespace eosio;

struct [[eosio::contract("adex.swap"), eosio::table]] pool
{
    uint64_t id;
    symbol_code code;
    extended_asset base_token;
    extended_asset quote_token;
    asset pool_fee;
    asset platform_fee;
    time_point created_at;
    time_point updated_at;
    
    uint64_t primary_key() const {
        return id;
    }

    uint64_t code_key() const {
        return code.raw();
    }
    
    std::string to_string(const extended_symbol &token)
    {
        std::string str = std::to_string(token.get_symbol().precision()) + "," + token.get_symbol().code().to_string() + "@" + token.get_contract().to_string();
        return str;
    }

    checksum256 to_pair_hash(const extended_symbol &base_token, const extended_symbol &quote_token)
    {
        std::string str = to_string(base_token) + "/" + to_string(quote_token);
        return sha256(str.data(), str.size());
    }

    checksum256 pair_key() const {
        return to_pair_hash(base_token.get_extended_symbol(), quote_token.get_extended_symbol());
    }
};
using by_code = indexed_by<name("bycode"), const_mem_fun<pool, uint64_t, &pool::code_key>>;
using by_pair_key = indexed_by<name("bypair"), const_mem_fun<pool, checksum256, &pool::pair_key>>;
using pools = multi_index<name("pools"), pool, by_code, by_pair_key>;
```
````

## stat

````
```cpp
#pragma once
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>

using namespace eosio;

struct [[eosio::contract("adex.swap"), eosio::table]] currency_stats
{
	asset supply;
	asset max_supply;
	name issuer;

	uint64_t primary_key() const
	{
		return supply.symbol.code().raw();
	}
};

using stats = multi_index<name("stat"), currency_stats>;
```
````


# Actions

***

## open

#### Parameters:

* @param owner - owner of the account
* @param symbol - token symbol
* @param ram\_payer - ram payer

#### Description:

Open zero balance account.

#### Required Authorization:

**ram\_payer** account.

***

## close

#### Parameters:

* @param owner - owner of the account
* @param symbol - token symbol

#### Description:

Close zero balance account.

#### Required Authorization:

**owner** account.

***

## withdraw

#### Parameters:

* @param owner - owner of the account
* @param quantity - quantity

#### Description:

Withdraw liquidity by burning liquidity tokens.

#### Required Authorization:

**owner** account.

***

## create

#### Parameters:

* @param issuer - issuer account
* @param maximum\_supply - maximum supply of the token

#### Description:

Create new token.

#### Required Authorization:

**contract** account.

***

## issue

#### Parameters:

* @param to - receiver of tokens
* @param quantity - quantity of tokens
* @param memo - memo description

#### Description:

Issue new tokens.

#### Required Authorization:

**issuer** account.

***

## retire

#### Parameters:

* @param from - account
* @param quantity - quantity of deflate
* @param memo - memo description

#### Description:

Burn tokens.

#### Required Authorization:

**issuer** account.

***

## transfer

#### Parameters:

* @param from - sender account
* @param to - receiver account
* @param quantity - quantity
* @param memo - memo description

#### Description:

Transfer tokens.

#### Required Authorization:

**from** account.

***

## createpool

#### Parameters:

* @param base\_token - base token
* @param quote\_token - quote token

#### Description:

Create liquidity pool.

#### Required Authorization:

**listing.adex** account.

***

## removepool

#### Parameters:

* @param base\_token - base token
* @param quote\_token - quote token

#### Description:

Remove the empty liquidity pool.

#### Required Authorization:

**listing.adex** account.

***


# Examples


# How to open liquidity account?

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

```typescript
import { SwapActionGenerator } from "@a-dex/a-dex-sdk";

const actionsGen = new SwapActionGenerator("swap.adex");

const act = await actionsGen.open(
  [
    {
      actor: "trader.adex",
      permission: "active",
    },
  ],
  "swap.adex",
  "trader.adex",
  "0,LPA",
  "trader.adex"
);
```

{% endtab %}

{% tab title="cleos" %}

```bash
cleos -u https://eos.greymass.com push transaction '{
  "delay_sec": 0,
  "max_cpu_usage_ms": 0,
  "actions": [
    {
      "account": "swap.adex",
      "name": "open",
      "data": {
        "owner": "trader.adex",
        "symbol": "0,LPA",
        "ram_payer": "trader.adex"
      },
      "authorization": [
        {
          "actor": "trader.adex",
          "permission": "active"
        }
      ]
    }
  ]
}'
```

{% endtab %}

{% tab title="eosjs" %}

```javascript
const result = await api.transact({
  actions: [{
    account: 'swap.adex',
    name: 'open',
    authorization: [{
      actor: 'trader.adex',
      permission: 'active',
    }],
    data: {
      owner: 'trader.adex',
      symbol: '0,LPA',
      ram_payer: 'trader.adex'
    },
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
```

{% endtab %}
{% endtabs %}


# How to close liquidity account?

{% hint style="info" %}
Closing account allowed for 0 balances
{% endhint %}

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

```typescript
import { SwapActionGenerator } from "@a-dex/a-dex-sdk";

const actionsGen = new SwapActionGenerator("swap.adex");

const action = await actionsGen.close(
  [
    {
      actor: "trader.adex",
      permission: "active",
    },
  ],
  "trader.adex",
  "0,LPA"
);
```

{% endtab %}

{% tab title="cleos" %}

```bash
cleos -u https://eos.greymass.com push transaction '{
  "delay_sec": 0,
  "max_cpu_usage_ms": 0,
  "actions": [
    {
      "account": "swap.adex",
      "name": "close",
      "data": {
        "owner": "trader.adex",
        "symbol": "0,LPA"
      },
      "authorization": [
        {
          "actor": "trader.adex",
          "permission": "active"
        }
      ]
    }
  ]
}'
```

{% endtab %}

{% tab title="eosjs" %}

```javascript
const result = await api.transact({
  actions: [{
    account: 'swap.adex',
    name: 'close',
    authorization: [{
      actor: 'trader.adex',
      permission: 'active',
    }],
    data: {
      owner: 'trader.adex',
      symbol: '0,LPA'
    },
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
```

{% endtab %}
{% endtabs %}


# How to add liquidity?

{% hint style="info" %}
Before adding liquidity make sure to open a liquidity token account related to the pool code
{% endhint %}

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

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

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

const trx = await trxGen.addLiquidity(
  new Name("trader.adex"),
  new Sym("LPA", 0),
  0,
  new ExtendedAsset(new Asset("1.0000 EOS"), new Name("eosio.token")),
  new ExtendedAsset(new Asset("4.0000 USDT"), new Name("tethertether"))
);

```

{% 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": "deposit:1"
      },
      "authorization": [
        {
          "actor": "trader.adex",
          "permission": "active"
        }
      ]
    },
    {
      "account": "tethertether",
      "name": "transfer",
      "data": {
        "from": "trader.adex",
        "to": "swap.adex",
        "quantity": "4.0000 USDT",
        "memo": "deposit:1"
      },
      "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: 'deposit:1'
      },
    },
    {
      account: 'tethertether',
      name: 'transfer',
      authorization: [{
        actor: 'trader.adex',
        permission: 'active',
      }],
      data: {
        from: 'trader.adex',
        to: 'swap.adex',
        quantity: '4.0000 USDT',
        memo: 'deposit:1'
      }
    }]
  }, {
    blocksBehind: 3,
    expireSeconds: 30,
  });
```

{% endtab %}
{% endtabs %}


# How to remove liquidity?

{% hint style="info" %}
Both tokens accounts should be opened
{% endhint %}

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

```typescript
import { SwapActionGenerator } from "@a-dex/a-dex-sdk";

const actionsGen = new SwapActionGenerator("swap.adex");

const action = await actionsGen.withdraw(
  [
    {
      actor: "trader.adex",
      permission: "active",
    },
  ],
  "trader.adex",
  "1000 LPA"
);

```

{% endtab %}

{% tab title="cleos" %}

```bash
cleos -u https://eos.greymass.com push transaction '{
  "delay_sec": 0,
  "max_cpu_usage_ms": 0,
  "actions": [
    {
      "account": "swap.adex",
      "name": "withdraw",
      "data": {
        "owner": "trader.adex",
        "quantity": "1000 LPA"
      },
      "authorization": [
        {
          "actor": "trader.adex",
          "permission": "active"
        }
      ]
    }
  ]
}'
```

{% endtab %}

{% tab title="eosjs" %}

```javascript
const result = await api.transact({
  actions: [{
    account: 'swap.adex',
    name: 'withdraw',
    authorization: [{
      actor: 'trader.adex',
      permission: 'active',
    }],
    data: {
      owner: 'trader.adex',
      lq_tokens: '1000 LQA'
    },
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
```

{% endtab %}
{% endtabs %}


# How to swap by market price?

{% hint style="warning" %}

* Tokens will be swapped by the current pool price
* 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.swapByMarketPrice(
  new Name("tester"),
  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"
      },
      "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'
    },
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
```

{% endtab %}
{% endtabs %}


# 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 %}


# How to cross-swap tokens by market price?

{% hint style="warning" %}

* Fees will be taken on each hoop
* 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.swapByMarketPrice(
  new Name("tester"),
  new ExtendedAsset(new Asset("1.0000 EOS"), new Name("eosio.token")),
  new ExtendedAsset(new Asset("4.0000 USDT"), new Name("tethertether")),
  "1-2-3"
);
```

{% 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-3"
      },
      "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-3'
    },
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
```

{% endtab %}
{% endtabs %}


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

{% hint style="warning" %}

* 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
  {% 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-2-3"
  );

```

{% 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-3;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-3;min:40000'
    },
  }]
}, {
  blocksBehind: 3,
  expireSeconds: 30,
});
```

{% endtab %}
{% endtabs %}


# SDK

🛠 An SDK for building applications on top of A-DEX

## [Official npm package link](https://www.npmjs.com/package/@a-dex/a-dex-sdk)

## SwapActionGenerator

Helper class to construct swap contract actions which can be signed and pushed on the chain.

## SwapTransactionGenerator

Helper class to construct swap contract transactions that can be signed and pushed on the chain.

## ChainApi

Chain API client.

## RpcApi

Native A-DEX RPC API client.

## Interfaces

Custom typescript interfaces.

## Types

Custom typescript types.

## Utils

Helper functions for math calculations and data formatting.


# API

🤖 An GraphQL API of A-DEX

## Vaulta Mainnet

[https://vaulta.a-dex.io/v1/graphql](https://cloud.hasura.io/public/graphiql?endpoint=https://vaulta.a-dex.io/v1/graphql)

## WAX Mainnet

[https://wax.a-dex.io/v1/graphql](https://cloud.hasura.io/public/graphiql?endpoint=https://wax.a-dex.io/v1/graphql)

## Telos Mainnet

[https://telos.a-dex.io/v1/graphql](https://cloud.hasura.io/public/graphiql?endpoint=https://telos.a-dex.io/v1/graphql)

## XPR Mainnet

[https://xpr.a-dex.io/v1/graphql](https://cloud.hasura.io/public/graphiql?endpoint=https://xpr.a-dex.io/v1/graphql)


