# Alcor.exchange

Lego of decentralized finance

<figure><img src="/files/mek2xzJLspfZfiEzmopM" alt=""><figcaption><p>Alcor Robot</p></figcaption></figure>

### This documentation serves as your guide to navigating the exciting world of Alcor, the largest decentralized exchange (DEX) on the WAX blockchain.&#x20;

**Work in Progress**

Just like Alcor itself, these docs are a work in progress, continually evolving to provide you with the latest and most comprehensive information. We appreciate your patience and understanding as we enhance and expand each section.

**Important Note**

While this documentation is designed to assist and inform, it is not intended as financial advice. Please make independent decisions based on your research and understanding.

Thank you for being part of the Alcor journey!


# What is Alcor Exchange?

Alcor Exchange is an extremely flexible decentralized exchange with a focus on self-listing

Alcor Exchange stands out as a highly versatile decentralized exchange, placing a strong emphasis on self-listing capabilities. Fueled by an incredible community, Alcor has rapidly become one of the most dynamic DEX platforms online.&#x20;

Leveraging EOSIO blockchain technology, Alcor seamlessly integrates WAX, BOS, TELOS, EOS, and Proton blockchains, offering you a comprehensive trading experience.

* Liquidity Pools
* Orderbook DEX
* Concentrated liquidity
* Self-Listing Orderbook/Pools
* Yield Farming
* Limit/Market Trading
* OTC Trading
* NFT Trading
* Token Creation
* Market Pair Creation
* Token / NFT Wallet

## No Whitelisting Needed!

Alcor Exchange puts the power in your hands. Say goodbye to the traditional need for whitelisting as Alcor enables you to open new markets independently.


# Home Page Overview

How to navigate through and understand each area of Alcor Exchange on desktop version

## \*Documentation is in progress and incomplete. Please be patient if there are incomplete areas you are trying to view\*

**\*These examples are taken from the WAX mainnet which is currently the most pupular. Other Mainnets may show slightly different information\***

![Top of Alcor Exchange main page](/files/-Mg3vLfwamSM7-raqtq5)

[**Swap**](/main-page-overview/swap) **(Red Box)** - The Swap page serves as a convenient and simplified way to exchange one currency to another. (Swapping is the equivalent of placing a [market order](/definitions-1) in any exchange. If you wish to place a limited order, that will be done under "Markets")  In addition to exchanging, it also provides the capability of adding to and subtracting from the liquidity pool. Finally, it shows simple chart data on the history of the exchange rate of your selected pair, liquidity pool amounts, and volume.&#x20;

[**Markets**](/main-page-overview/markets) **(Yellow Box)** - The Markets tab will bring you to a master list of all of the coin pairs available under your selected Mainnet.&#x20;

[**OTC**](/main-page-overview/otc) **(Green Box)** - OTC or "Over-The-Counter" is a market where any user can offer one currency for another at a price they choose to list it at.&#x20;

[**NFT**](/main-page-overview/nft) **(Blue box)** - Alcor Exchange is not just limited to trading regular cryptocurrency.  NFT or "Non Fungible Token" is a market place where users can list their NFT's for sale as well.&#x20;

[**Wallet**](/main-page-overview/wallet) **(Pink Box)** - This will open your currently connected wallet to show the currencies and FT's (Fungible Tokens) you currently own. (**Note, any tokens you have listed in a buy or sell order will not show up in your wallet until you cancel the order or it is fulfilled**.)

**Docs (Purple Box)** - Docs brings you here, to the Alcor Documentation.

**Mainnet (Orange Box)** - Select the [mainnet](/definitions-1) you wish to trade in.


# Swap

Overview of "Swap" Tab

## The Swap page serves as a convenient and simplified way to exchange one currency to another by utilizing liquidity pools rather than order books. &#x20;

(If you wish to place a limit order or market order, that will be done under "[Markets](/main-page-overview/markets)**"**)&#x20;

It shows a [simple chart data](/main-page-overview/swap/charts) on the history of the exchange rate of your selected pair, liquidity pool amounts, and volume.&#x20;

When you first enter this section, by default it will take you to the swap tab. If you wish to add or subtract liquidity, you must click on [**Pool**](/main-page-overview/swap/+-liquidity)**.**

<figure><img src="/files/9GwQUvLGyR544m28vQxx" alt=""><figcaption><p>Swap</p></figcaption></figure>

Enter the desired amount to get a quote on the current exchange rate of the tokens you are trying to swap. This quoted amount will fluctuate as it is constantly updating with the new market quote data. (You can swap the top and bottom selected tokens easily by clicking the white down pointing arrow in the middle.)

Remember, this is the same as placing a "market order" so depending on the tokens liquidity and order books, the exchange rate will not be perfect.

For more information on buy and sell orders check [**Markets**](/main-page-overview/markets).&#x20;

To see all the tokens you own and have available check [**Wallet**](/main-page-overview/wallet).&#x20;

**Tokens selected** - You can select between the individual tokens you want to exchange. The dropdown menu will only show the tokens with available markets paired with the other token selected. If you cannot find the token you are looking to swap to, it's likely that a market for the specific pair does not exist.&#x20;

**Adjust Settings icon** - This will allow you to automatically set the amount of slippage you will tolerate. Token pairs with low volume and liquidity will likely have a much higher slippage than token pairs with high volume and high liquidity. For information on slippage check [**Definitions**](/definitions-1)**.**\
You can also set the maximum number of hops.

**Additional Quote Information** -&#x20;

* **Price Impact** - The impact that your individual order will have on the price of the token exchange pair. Token pairs with low volume and low liquidity will have a much bigger price impact than token pairs with high volume and liquidity.
* **Minimum Received after slippage** - The minimum amount of token you should received after factoring the current slippage value.


# Swap Charts

## The swap section also provides basic chart data for your selected token pair. For a more advanced chart view go to the [**Markets**](/main-page-overview/markets) section.&#x20;

<figure><img src="/files/juiZopJ8zGfQxkVjQvgW" alt=""><figcaption></figcaption></figure>

**Top Left** - You can choose various statistics such as Price

**Top Right** - You can change the time frame.


# Add Liquidity

## This page is a basic breakdown of the information presented in the "Add Liquidity" section. For a more advanced breakdown visit [**Liquidity Pools**](broken://pages/-MXreMpjFZ0ABKWa1zSP).

<figure><img src="/files/JUTEQEwYvhrHvr3TAzrs" alt=""><figcaption><p>Add Liquidity</p></figcaption></figure>

**In this screen, you can add liquidity to your desired pair.**\
\- Select Pool\
\- Select a Fee Tier\
\- Decide the amount you wish to add (You need both tokens to add to a liquidity pool)\
\- Decide on the range you intend to provide liquidity for.

<figure><img src="/files/963ZW8sbNbyeWxtoltVS" alt=""><figcaption><p>Pool</p></figcaption></figure>

## To manage your existing positions, click on Pool to go to My Positions.

<figure><img src="/files/q8nuKXpMIjlLMbaoddgP" alt=""><figcaption><p>My Positions</p></figcaption></figure>

**In this screen, you can browse an overview of your positions and click to manage them.**\
\
(See [**Liquidity Pools**](broken://pages/-MXreMpjFZ0ABKWa1zSP) for more advanced information)


# Manage Liquidity

## This page is a basic breakdown of the information presented in the "Manage Liquidity" section. For a more advanced breakdown visit [**Liquidity Pools**](broken://pages/-MXreMpjFZ0ABKWa1zSP).

<figure><img src="/files/opIrB4c9AqDGMsRETDwM" alt=""><figcaption><p>Manage Liquidity</p></figcaption></figure>

**In this screen, you can claim any available fees or remove liquidity and claim fees.**\
\- To only claim fees without removing liquidity, click on Claim Fees.\
\- The percentage represents the portion of your position that you wish to remove.\
\- You will see the estimated amount of both tokens you will receive.\
\- If you wish to update your desired price range, you have to close the entire position and open a new one.

(For a more advanced breakdown visit [**Liquidity Pools**](broken://pages/-MXreMpjFZ0ABKWa1zSP).)


# Markets

When you first click on the "Markets" tab, it will being you to a page that looks similar to the image below. This image is showing markets from the WAX mainnet.&#x20;

![This caption is showing markets in the WAX mainnet](/files/-MgB3SuKXm9kFWr9FdLA)

**Red Box** - Select which tokens markets you wish to view

**Pink Box** - Allows you to [**open a new market**](/developers-api/market-creation) for a token pair if it currently does not exist

**Yellow Box** - Shows the token pair in each market

**Blue Box** - Click each column to sort by the labels shown

* Last Price - Shows the most recent price of the market pair
* 24H Vol - The % change in volume within the last 24 hours
* 24H - Shows the % change in exchange price within the last 24 hours
* 7D Volume - The % change in volume within the last 7 days
* 7D Change  - The % change in exchange price within the last 7 days

When you click on any token pair you will go to that token pairs [**Market Exchange**](/main-page-overview/markets/market-exchange).&#x20;


# Market Exchange

When you click on any token pair in [**Markets**](/main-page-overview/markets) it will bring you to that token pairs market exchange. This example uses the TLM to WAX market in the WAX mainnet. The information on token pairs in other mainnets may be slightly different.&#x20;

![TLM to WAX market](/files/-MgBQ7BhtlBTGDTLkU0G)

**Red Box** - Shows all open orders or the "Order books".

**Yellow Box** - Graphical information on your selected token pair.

**Orange Box** - An easy way to switch between markets without going back to the markets page.

**Blue Box** - Shows your [**open orders**](/main-page-overview/markets/market-exchange/order-history) and order history.

**Pink Box** - Place limit orders and market trades.

**Green Box** - Shows all of the recently executed trades.


# Order Books

## \*This is not financial advice\*

## The order books allow you to see all of the orders people have placed at different prices.

![TLM/WAX Order Book](/files/-MgBhWQU9dv0haTr283f)

**Blue Box** - Shows the exchange price all the current limit orders are set at.

**Red Box** - The top red numbers are the orders other people have set to sell.

**Green Box** - The bottom green numbers show all of the orders other people have set to buy.

**Pink Boxes** - Shows how much of each token (and that tokens exchange rate) that is being bought and sold at each price.


# Graph

## \*This is not financial advice\*

The charting software Alcor Exchange uses is provided by TradingView which is an extremely flexible trading software. There is an infinite amount of information to convey and this slide is intended to provide only the basics.&#x20;

For more information about how the chart works and its features visit [www.tradingview.com](https://docs.alcor.exchange/main-page-overview/markets/market-exchange/www.tradingview.com)

![](/files/-MgBizmwZ3_Gp_wwhnQ_)

**Orange Box** - Shows the token pair of the chart you are viewing.

**Green Box** - Toggle the time period each candle represents.

**Purple Box** - A list of different technical indicators to overlay on the chart.&#x20;

**Red Box** - List of tools to manually add your own indicators.

**Yellow Box** - Price indicator of the current token pair you are viewing.

**Pink Box** - Shows relative volume at the time of each candle.

**Blue Arrows** - Various chart information based on your settings.&#x20;


# Open Orders

## \*This is not financial advice\*&#x20;

![](/files/-MgDtJixojl3qg9f_ZVc)

**Brown Box** - View your history of executed orders for your selected token pair.

**Red Box** - Your "ask" order (or your "sell" order).

**Green Box** - Your "bid" order (or your "buy" order).

**Pink Box** - The price you have your bids set for

**Blue Box** - The token you are bidding.&#x20;

**Yellow Box** - Cancel any order as long as it has not been filled.

When placing limit orders in the market, "buying and selling" is referred to as "bid and ask". When you "bid" a token at a specific price, you are "asking" to receive that tokens pair in the market pair you have selected.

Because this is the TLM/WAX pair, you are "bidding" WAX and "asking" for TLM in return (see the blue box in the **bid (green box)** row.

&#x20;But when you want to "sell" your TLM, you are then "bidding" TLM and "asking" for wax in return. (see the blue box lined up the **ask (red box)** row.&#x20;

This can get confusing because the wording can be switched around depending on if you are looking at it from front to back or back to front.&#x20;


# Placing Trades

## \*This is not financial advice\*

This image shows the trade pair for TLM and WAX.&#x20;

![WAX/TLM Trade Pair](/files/-MgD9YIUNJrI7klufAXe)

**Purple Circle** - The default view of trading is a limit order. If you wish to place a market order, click on "Market Trade" (Brown Box)&#x20;

**Green Box** - The left side is the buy menu.

**Red Box** - The Right side is the sell menu.

**Yellow Arrow** - Amount of each token available in your wallet.

**Yellow Box** - A slider to choose % of token in your wallet you wish to use to buy or sell.

**Blue Arrow** - Choose the price you wish to make a trade at. Look at the [**Graph**](/main-page-overview/markets/market-exchange/graph) for more data on where you want to set the price.&#x20;

**Green Arrow** - Choose the amount of your selected token you wish to buy or sell. This will autofill its quoted value in the second token in the pair you are trading (Pink Arrow) at the price you have selected.&#x20;

**Pink Arrow** - The quoted amount of the second token in the pair you wish to trade. Entering the amount of this token will automatically fill the first token with its equivalent amount at the price you have selected.&#x20;

## Unfilled limit orders that are waiting to be filled will not be available in your wallet until that order has either been filled or canceled.&#x20;


# OTC

## Under Construction


# NFT

## Under construction


# Wallet

## Under Construction


# Developers API

Technical description of exchange interfaces.

As a orderbook store onchain, user can view, trade and cancel any of orders using public explorer for example bloks.io or **cleos** for interaction with contract.

**Contracts account in eosio chains:**

1. EOS - **eostokensdex**
2. TELOS - **eostokensdex**
3. WAX **- alcordexmain**
4. BOS - **alcordexmain**
5. PROTON - **alcor**

**Contract tables:**

* [Markets table](https://bloks.io/account/eostokensdex?loadContract=true\&tab=Tables\&table=markets\&account=eostokensdex\&scope=eostokensdex\&limit=100)
* [sell orders table](https://bloks.io/account/eostokensdex?loadContract=true\&tab=Tables\&table=sellorder\&account=eostokensdex\&scope=eostokensdex\&limit=100)
* [buy orders table](https://bloks.io/account/eostokensdex?loadContract=true\&tab=Tables\&table=buyorder\&account=eostokensdex\&scope=eostokensdex\&limit=100)


# Amm Swap Contract API

Swap contract API explanation

All chains have Alcor Swap contract by same account name: **swap.alcor**

**Swap**

There is two types of swap:

**swapexactin:** To swap all input amount to maximum amount of out token.

**swapexactout:** Swap input tokens to exact out token amount and return change from input token.

To swap one token to another, transfer input token to swap contract with specifit memo:

```
<swapexactin/swapexactout>#<Pool ID's>#<Recipient>#<Output Token>#<Deadline>#market

// Example
swapexactin#0#alcordexfund#3.9167 TLM@alien.worlds#0

// OR // where market.contract your market contract to receive market fee
swapexactin#0#alcordexfund#3.9167 TLM@alien.worlds#0#market.contract
```

**Params:**

* **swapexactin/swapexactout** - Swap type
* **Pool ID's**: Sequence of the pools id's that swap will use
* **Recipient:** Account to receive swap output token
* **Output token:** Desired output token amount as extended asset string.
* **Deadline:** limit time in seconds when swap transaction is valid.
* **Market:** account to receive additional swap fee (use **regmarket** action to set your market).


# Formulas

For application development, we recommend to use our [SDK](https://github.com/alcorexchange/alcor-v2-sdk). But here you can find formulas for interaction at a low level.

Here you can find formulas for **swap.alcor** contract.

#### Pool token price calculation

<pre class="language-markup"><code class="lang-markup"><a data-footnote-ref href="#user-content-fn-1">tokenA price in terms of tokenB:</a>
sqrtPriceX64 ** 2 / 2 ** 128 * 10 ** (precisionA-precisionB)

<a data-footnote-ref href="#user-content-fn-1">tokenB price in terms of tokenA:</a>
2 ** 128 / sqrtPriceX64 ** 2 * 10 ** (precisionB-precisionA)
</code></pre>

[^1]:


# Contracts

Contract API explanation

All chains have the same account with Alcor Swap contract on it: **swap.alcor**

To swap token to another, user should send transfer to&#x20;


# Examples

**1) return the current X/Y price of a lp pool ( eg 3.5 TLM/WAX )**

<https://gist.github.com/avral/239e31232eb9a173b77c56dc537ddb6d>

\
**2) Total amount of liquidity provided for a pool by a wallet  ( eg abcde.wam  3500 TLM 1000 wax )**

<https://gist.github.com/avral/43a6dacbad1f3db3fe3b0e56b53ba7e7>


# Market creation

Tools and tips for market creators.

## Alcor Exchange gives you the ability to open a new market for 2 existing coins that do not currently have a market pairing.&#x20;

![](/files/-MgH_gIrNk7HwC7o7QJL)

To do this, first go to the "Markets" tab and look for the button that says "Open new market"

**"Why would I open a new market?"**&#x20;

* If you wanted to exchange any of your tokens for another one that there currently wasnt an exchange for.
* If you were developing your own crypto currency and wanted to give others the ability to purchase it using their existing other coins.&#x20;


# Open new market

To create new market. Follow next steps

## \*This is not financial advice\*

**To Learn How to Navigate to "open new market" click** [**HERE**](/developers-api/market-creation)

## **To create a market for an existing token pair, you will use Auto Select**

![Open New Market Auto Select](/files/-MgHe85AlZ324sRm3I4D)

**Pink Box -** RAM will be included in the cost to facilitate your new market pair.

**Red Box -** Select the base token you want to use for your pair.

**Blue Box** **-** Select the new "quote" token you want to pair with your base token

**Yellow Box -** Switch to Manual token selection&#x20;

Or, if you do not have token that you want to list, you have to use manual mode.

## **To create a market pair Manually**

![Open New Market Manually](/files/-MgHfh2aLTKpWLIOxzFr)

**Green Box -** Select your base token.

**Red Box -** Manually enter your quote tokens contract.

**Yellow Box -** Manually enter symbol for the market pair you are creating.

**Pink Box -** Shows total cost of new market creation fee .

&#x20;

\*Only tokens already in your connected wallet will show in the drop-down token selection menus.&#x20;

\*When creating a new token pair, the exchange value will be calculated automatically.


# Contract actions

Description of contract actions and memo format.

**Open new market**

Transfer 3.0000 EOS to dex contract account with memo:\
\
`new_market|0.<token_precision> <token_symbol>@<token_contract>`

Example memo:

```
new_market|0.00000000 WEED@weedcashnt
```

{% hint style="info" %}
&#x20;Check dex contract account name on Developers API main page.
{% endhint %}

**Submit order**

Send the amoun&#x74;**(bid)** you want to sell to dex contract account, and specify the amount you **ask** in the memo, the price and market will be automatically determined in the contract. Memo format(**ask** token):\
\
`<token_amount> <token_symbol>@<token_contract>`

Example:

```
1000.0000 TKT@eossanguotkt
```

{% hint style="info" %}
Make sure you provide token contract and correct precision!
{% endhint %}

**Order cancelation**

Call action `cancelsell` or `cancelbuy` with parameters

* **executor** - order owner account name
* **market\_id -** id of the order related market
* **order\_id -** order id.

**View actions on bloks.io** (Links)

[Cancelbuy](https://bloks.io/account/eostokensdex?loadContract=true\&tab=Actions\&table=markets\&account=eostokensdex\&scope=eostokensdex\&limit=100\&action=cancelbuy)\
[Cancelsell](https://bloks.io/account/eostokensdex?loadContract=true\&tab=Actions\&table=markets\&account=eostokensdex\&scope=eostokensdex\&limit=100\&action=buyreceipt)


# Contract Tables

Alcor contract tables structure for contracts communication.

#### Markets

```
struct[[eosio::table]] market {
  uint64_t id;

  extended_symbol base_token;
  extended_symbol quote_token;

  asset min_buy;
  asset min_sell;

  bool frozen = false;

  uint8_t fee = 0;

  uint64_t primary_key() const { return id; }
  checksum256 get_secondary_1() const {
    return make256key(
      quote_token.get_contract().value,
      quote_token.get_symbol().code().raw(),
      base_token.get_contract().value,
      base_token.get_symbol().code().raw()
    );
  }

  string get_market_symbol() const {
    return quote_token.get_symbol().code().to_string() + "/" + base_token.get_symbol().code().to_string();
  }
};

typedef eosio::multi_index<"markets"_n, market,
  indexed_by<"bytokens"_n, const_mem_fun<market, checksum256, &market::get_secondary_1 >
> > markets_index;


// Helper function for market 256 id

uint128_t make128key(uint64_t a, uint64_t b) {
    uint128_t aa = a;
    uint128_t bb = b;
    return (aa << 64) + bb;
}

checksum256 make256key(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
  if (make128key(a, b) < make128key(c, d))
    return checksum256::make_from_word_sequence < uint64_t > (a, b, c, d);
  else
    return checksum256::make_from_word_sequence < uint64_t > (c, d, a, b);
}
```

256key **JavaScript** function: <https://github.com/avral/alcor-ui/blob/7bd8483435c26bc3cdd1017d8f6efe1f5b0fe6e2/utils/index.js#L28>

#### Order

in contract it's two same structure tables: **buyorder** and **sellorder**

```
struct [[eosio::table]] sellorder {
    uint64_t id;
    name account;
    asset bid;
    asset ask;
    uint128_t unit_price;
    uint32_t timestamp;
        
    uint64_t primary_key() const { return id; }
    uint64_t get_account() const { return account.value; }
};
    
typedef eosio::multi_index< "buyorder"_n, buyorder, 
  indexed_by<"byprice"_n, const_mem_fun<buyorder, uint128_t, &buyorder::get_price> >,
  indexed_by<"byaccount"_n, const_mem_fun<buyorder, uint64_t, &buyorder::get_account> >
> buyorders_t;


```

#### Swap liquidity pool Pairs table

```
struct[[eosio::table]] pairs_struct {
  uint64_t id;

  asset supply;
  extended_asset pool1;
  extended_asset pool2;

  int fee;
  name fee_contract;

  uint64_t primary_key() const {
    return id;
  }
  
  checksum256 secondary_key() const {
    return make256key( // this function can be find in markets table example above.
      pool1.contract.value, pool1.quantity.symbol.code().raw(),
      pool2.contract.value, pool2.quantity.symbol.code().raw()
    );
  }
};

typedef eosio::multi_index< "pairs"_n, pairs_struct,
indexed_by<"extended"_n, const_mem_fun<pairs_struct, checksum256, 
  &pairs_struct::secondary_key>> > pairs_index;
```


# API

**New API v2 docs can be found here**: [api.alcor.exchange](https://api.alcor.exchange)

Alcor Exchange has HTTP and WebSocket api.

Alcor Exchange provides an API for the UI view reasons charts/lates deals/orderbook. etc.

But as Alcor is DEX any intereation with blockchain, such as new order or order cancel, requires work with blockchain node api directly. Some examples can be found in "None API" page.

**HTTP API URL are separated by chains using following structute:**

```
chain_name: Name of chaing api to interact with.
1. wax
2. proton
3. telos
4. eos (default, no need chain_name to specify)
 
<chain_name>.alcor.exchange/api

// Example
wax.alcor.exchange/api
proton.alcor.exchange/api
```

WebSocket endpoint uses the same structure but has /socket.io/ at the end, example:

```
wss://wax.alcor.exchange/socket.io/
```


# Markets API

Markets status API, prices, volume.

Base data for all market are available on /markets endpoint.

{% embed url="<https://alcor.exchange/api/markets>" %}

{% hint style="info" %}
The api depends on the subdomain assigned to each chain.\
ie: wax.alcor.exchange/api/markets, telos.alcor.exchange/api/markets.
{% endhint %}

Each market has additional api for more information:

## markets

<mark style="color:blue;">`GET`</mark> `https://wax.alcor.exchange/api/markets/:id`

Get full market information

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | number | Market ID   |

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

```
{
  "id": 0,
  "base_token": {
    "contract": "eosio.token",
    "symbol": {
      "name": "WAX",
      "precision": 8
    },
    "str": "WAX@eosio.token"
  },
  "quote_token": {
    "contract": "prospectorsw",
    "symbol": {
      "name": "PGL",
      "precision": 4
    },
    "str": "PGL@prospectorsw"
  },
  "min_buy": "0.00000100 WAX",
  "min_sell": "0.0001 PGL",
  "frozen": 0,
  "fee": 20,
  "last_price": 0.69298836,
  "volume24": 8158.34775445,
  "volumeWeek": 83217.36892045,
  "volumeMonth": 424104.77220562,
  "change24": 6.28655828220858,
  "changeWeek": 19.27600212758915
}
```

{% endtab %}
{% endtabs %}

## Market deals

<mark style="color:blue;">`GET`</mark> `https://wax.alcor.exchange/api/markets/:id/deals`

Get latest deals

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | number | Market ID   |

#### Query Parameters

| Name  | Type   | Description           |
| ----- | ------ | --------------------- |
| limit | number | Default limit is: 200 |

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

```
```

{% endtab %}
{% endtabs %}

## Charts api

<mark style="color:blue;">`GET`</mark> `https://wax.alcor.exchange/api/markets/:id/charts`

Get candles charts for specific market.

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | number | Market ID   |

#### Query Parameters

| Name       | Type   | Description                         |
| ---------- | ------ | ----------------------------------- |
| to         | number | To timestamp                        |
| from       | number | From timestamp                      |
| resolution | string | <p>1/5/15/30/60/240<br>1D/1W/1M</p> |

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

```
```

{% endtab %}
{% endtabs %}


# Account

Retreive data for a specific account

#### History

<mark style="color:blue;">`GET`</mark> `https://wax.alcor.exchange/api/account/:name/deals`

Get deals history for specific account

#### Path Parameters

| Name                                   | Type   | Description  |
| -------------------------------------- | ------ | ------------ |
| name<mark style="color:red;">\*</mark> | String | Account name |

#### Query Parameters

| Name   | Type   | Description            |
| ------ | ------ | ---------------------- |
| market | Number | Filter by market\_id   |
| limit  | Number | Results count limit    |
| skip   | Number | Skip number of results |

#### Liquidity positions

<mark style="color:blue;">`GET`</mark> `https://wax.alcor.exchange/api/account/:name/liquidity_positions`

Get account liquidity pools positions

#### Path Parameters

| Name | Type   | Description  |
| ---- | ------ | ------------ |
| name | String | Account name |


# WebSocket

WebSocket API

Alcor Exchange using Socket.IO for interact via WebSocket technology.

#### There are two commands for subscribing to and channel with specific information.

1. **subscribe:** Subscribing for an specific room.
2. **unsubscribe:** Unsubscribe from sprcific room.

#### Available rooms, and params that they receive.

1. **deals:** chain, market. -> Subscribe to new deals. (first update will be last 200 deals).
2. **ticker:** chain, market, resolution. -> Subscribe to chart updates.
3. **account**: chain, name. -> Subscribe to account notifications. (only order match for now)
4. **orderbook:** chain, side(sell/buy), market(id). -> Subscribe to orderbook updates. (first update is full order book state)

Currect events to receive:

* match: Account new match
* orderbook\_sell: new orderbook update on sell side
* orderbook\_buy: new orderbook update on sell buy
* new\_deals: update on new deal on specific market

#### Example of connection:

```
import { io } from 'socket.io-client'
const socket = io('https://alcor.exchange')

// Subscribe to deals
socket.emit('subscribe', { room: 'deals', params: { chain: 'wax', market: 26 } })

// Unsubscribe from deals (will unsubscribe from all markets)
socket.emit('unsubscribe', { room: 'deals', params: { chain: 'wax' } })

// Subscribe to buy orderbook of 26 (TLM on wax) market.
socket.emit('subscribe', { room: 'orderbook', params: { chain: 'wax', market: 26, side: 'buy' } })

// Unsubscribe from orderbook (all, buy and sell)
socket.emit('unsubscribe', { room: 'orderbook', params: { chain: 'wax', market: 26 } })

// Subscribe to account updates
socket.emit('subscribe', { room: 'account', params: { chain: 'wax', 'name': 'avra.pro' } })


// Listen for updates

// On account new match
socket.on('match', match => { ... })

// On orderbook update (bid for example)
socket.on('orderbook_buy', bids => { ... })

// On new deals of market
socket.on('new_deals', deals => { ... })
```


# Node API

Description on interact directly with node api

Alcor Exchange provides an API for the UI view reasons charts/lates deals/orderbook. etc. But any intereation with blockchain, such as new order or order cancel, we have to work with blockchain now api directly, here we will provide some examples.

We will use EosJS lib to interact with node api. And will use WAX blockchain as example.

#### Submit new order.

```
// Code not tested yet, and provided for explanation reason

import fetch from 'node-fetch'
import { Api, JsonRpc, RpcError, JsSignatureProvider } from 'eosjs'

const rpc = new JsonRpc('https://wax.greymass.com', { fetch })
const signatureProvider = new JsSignatureProvider(['private key of order owner'])
const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });

// Place buy limit order, buying 1000 TLM for 10 WAX
const objTrans = [{
  account: 'eosio', // token contract
  name: 'transfer',
  authorization: [{
    actor: 'useraaaaaaaa', // account placing order (owner)
    permission: 'active',
  }],
  data: {
    from: 'useraaaaaaaa',
    to: 'alcordexmain',
    quantity: `10.0000 WAX`,
    memo: `1000.0000 TLM@alien.worlds`
  }
}]

// Result of transaction
const r = await api.transact(objTrans, { blocksBehind: 3, expireSeconds: 30})
```

#### **Get order from contract table.**

```
// Code not tested yet, and provided for explanation reason

import fetch from 'node-fetch'
import { Api, JsonRpc, RpcError } from 'eosjs'

const rpc = new JsonRpc('https://wax.greymass.com', { fetch })

// Get buy orderbook from conract table

const { rows } = await rpc.get_table_rows({
  code: 'alcordexmain',
  table: 'buyorder',
  limit: 1000,
  scope: 29, // Market id from /api/markets
  key_type: 'i128', // we are using it for getting order sorted by price.
  index_position: 2
})

```


# Public Alcor Data Access

We using MongoDB for collecting history of alcor trades/charts/analytics

You can access every day database back up here: <https://alcor.exchange/backups>


# Alcor Swap

Describes swap page functionality and liquidity pool AMM concept.


# Referral / Custom Market Fee

Referral program for additional earnings for providing UI for Alcor Swap

Register your market

To receive additional commission as a referral or as an additional UI provider. First, you need to register your account  which will receive your additional fee, specifying the amount of the desired fee. The fee will be charged from input token amount and sent to market account.

![](/files/s1UFu70nMmpDfQ1ek7rn)\
<https://wax.bloks.io/account/swap.alcor?loadContract=true&tab=Actions&account=swap.alcor&scope=swap.alcor&limit=100&action=regmarket> (for example WAX contract)

Call **regmarket** action on swap.alcor contract with following parameters:

* **marketName**: account for receiving fee.
* **marketFee:** as part of 10^6

**marketFee** Percent should be part of the 10^6 number. For example:

```
1000 will be 0.1%
500 will be 0.05%

and so on.

MAXIMUM fee is: 10000 (1%).
```

## Chose the UI you want to attract users to.

There are few option for you.

#### 1) Land user to Alcor Swap page directly

Simply add your market(from 1 step) as query parameter to swap url and share this as your referal link.

```
&market=<marketName>

// For example
// The fee will be sent to fees.alcor account

https://alcor.exchange/swap?market=fees.alcor
```

#### 2) User Swap Widget(Iframe) on your web site

Add widget to your site

{% content-ref url="/pages/zRy6Bvwy1Yy5WlSSRS4B" %}
[Swap Widget](/swap-widget)
{% endcontent-ref %}

And add the market query parameter to your iframe URL

```html
<iframe src="http://alcor.exchange/swap-widget?market=<marketAccount>"></iframe>
```

**3) Create custom UI and add your market to swap memo, use following format:**

```
<swapexactin/swapexactout>#<Pool ID's>#<Recipient>#<Output Token>#<Deadline>#<marketAccount>

// Example | fees.alcor is market account thar receives fee
swapexactin#401,1212#alcordexfund#5.3645 USDT@usdt.alcor#0#fees.alcor
```


# Introduction

Alcor Swap AMM is a new decentralized exchange protocol that utilizes concentrated liquidity, a revolutionary approach to liquidity provision. Unlike the traditional constant product AMM model, concentrated liquidity enables liquidity providers to concentrate their funds within a specific price range. This brings numerous benefits, including:

1. Improved capital efficiency: With concentrated liquidity, liquidity providers can allocate their funds more efficiently within a specific price range. This enables them to provide more liquidity with the same amount of capital, resulting in improved capital efficiency.
2. Better price execution: Concentrated liquidity allows trades to be executed at more precise prices than constant product AMMs. This is because liquidity providers can concentrate their funds within a specific price range, resulting in tighter spreads and better price execution.
3. Reduced impermanent loss: Impermanent loss is a common issue faced by liquidity providers in constant product AMMs. However, concentrated liquidity can reduce the impact of impermanent loss by enabling liquidity providers to concentrate their funds within a specific price range.
4. Greater flexibility: With concentrated liquidity, liquidity providers have greater flexibility in managing their liquidity. They can adjust their liquidity provision based on market conditions and their risk appetite, enabling them to optimize their returns.
5. Increased fees income: Alcor Swap AMM offers the ability to set different fee tiers based on the liquidity concentration, which enables liquidity providers to earn more fees as their concentration increases. This incentivizes liquidity providers to concentrate their liquidity and leads to a more efficient market.
6. Range orders: Alcor Swap AMM also provides the opportunity for traders to place range orders, which allow them to execute trades within a specific price range. This is made possible by the liquidity concentration of the protocol, which enables the price of the asset to stay within a specific range, resulting in a more predictable market.

Overall, Alcor Swap AMM provides numerous benefits and opportunities over traditional constant product AMMs. We believe that this new approach to liquidity provision will be a game changer for decentralized exchanges, and we are excited to be at the forefront of this revolution.


# Swap Page

<figure><img src="/files/O3MnLjcOYMtYHx3MY6lZ" alt=""><figcaption></figcaption></figure>

The Alcor Swap swap page is where users can easily trade one EOSIO-based token for another. The page consists of two main sections: the token selection section and the swap execution section.

In the token selection section, users can choose the EOSIO-based tokens they want to trade and receive from a dropdown menu. Users can also see the current price of each token and the estimated amount of the receiving token they will get based on the current exchange rate.

In the swap execution section, users input the amount of the token they want to trade, and the amount of the token they want to receive is automatically calculated based on the current exchange rate.

Once the user is satisfied with the inputted information, they approve the transaction on the EOSIO blockchain using their wallet, and the swap is executed right away. The user can see history of his swap in history section of pool page.


# Locking Liquidity

Sometimes, users might need to lock their liquidity positions permanently. For example, this might be part of the mechanics of a meme token. By doing this, everyone can be assured that the creator of the token will not remove liquidity from the pool and scam users.

#### How to Lock Liquidity:

Open your position and click on the "Transfer Position" button.

<figure><img src="/files/O2FSFDzJOpe4EFqv73xa" alt=""><figcaption></figcaption></figure>

Enter `eosio.null` as the receiver of the position. The `eosio.null` account functions as a "burn" account, meaning nobody has access to it. By transferring ownership to `eosio.null`, the position will be permanently locked, preventing any future transfers, fee claims, or removal of liquidity.


# Providing liquidity

Described detailed explanation on providing liquidity for Alcor Swap AMM

<figure><img src="/files/xSbuxfi4CaHVEjfPdkgu" alt=""><figcaption><p>New position UI</p></figcaption></figure>

The Alcor Swap AMM user interface for creating a new position is designed to be intuitive and user-friendly, with clear guidance and helpful tooltips to assist users throughout the process.

#### Form Fields

Upon navigating to the new position page, users are presented with a form where they can input details about the new liquidity position they want to create. The form includes the following fields:

* Token Pair: A dropdown menu or search bar where users can select the tokens they want to create a liquidity position for. This includes the base and quote tokens.
* Price Range: A slider or input fields where users can set the range of prices they want their liquidity position to cover. The range is typically represented as a graph below the form, showing the potential returns at different price points.
* Liquidity Amount: A field where users can input the amount of liquidity they want to provide for their new position. This can be denominated in either or both of the base and quote tokens, depending on user preference.
* Fee Tier: A dropdown menu or set of radio buttons where users can select the fee tier for their position. This ranges from 0.05% to 1%.
* Estimated Shares and 24H Fees retruning: Approximately the value that reflects the predicted value of profitability, provided that the price is in the range of the position and the liquidity is equal to the current one.

#### Confirmation and Transaction Signing

Once the user has filled out the necessary information, they can review and confirm their new position. This typically involves verifying the details of the position and signing the transaction with their connected wallet.

#### Conclusion

Overall, the Alcor Swap AMM user interface for creating a new position is designed to be straightforward and easy to use, with clear instructions and visual aids to guide users through the process. By providing a customizable range of options, Alcor Swap AMM allows users to create liquidity positions that suit their specific needs and investment strategies.


# How to Add Liquidity on Alcor Exchange

1. Navigate to [Alcor Exchange](https://wax.alcor.exchange/)
2. Click on "Pool"

<figure><img src="/files/YAJq7BG7KZSfRez0psAO" alt=""><figcaption></figcaption></figure>

3. Click on "New position"

<figure><img src="/files/e69vJXULKZ8Q3cfgKPM3" alt=""><figcaption></figcaption></figure>

4. Select your desired pair

<figure><img src="/files/KyjRnIHcEajXncvbg1Bm" alt=""><figcaption></figcaption></figure>

5. Select the fee tier and amount of liquidity you want to contribute

<figure><img src="/files/rF8UK2o5juwEsU3gPPUP" alt=""><figcaption></figcaption></figure>

6. Click "Add Liquidity"

<figure><img src="/files/ptF9Vt9A921RfqNiMqXi" alt=""><figcaption></figcaption></figure>

7. Approve the transaction

<figure><img src="/files/w0AcAzykXKLg5zZXsPZQ" alt=""><figcaption></figcaption></figure>

8. That´s it! You can track your positions on ["Pools"](https://wax.alcor.exchange/positions)

<figure><img src="/files/PGY8dJpFMNX9u83pLYCB" alt=""><figcaption></figcaption></figure>


# Ranges: Everything you need to know

Range orders on Alcor Exchange allow traders to deposit a token within a specified price range. When the market price reaches that range, the token is automatically converted to another token, earning fees in the process.

<figure><img src="/files/PtE9yKd21io88IzQ5AEs" alt=""><figcaption></figcaption></figure>

This feature gives traders more control over their trades. For example, if the price of WAX is below 0.1 USDT, a trader can deposit $1000 worth of WAX within the range of 0.1–0.2 WAX/USDT. Once the price of WAX goes above 0.1$ WAX/USDT, the WAX will start converting to USDT and will be fully converted at a price of 0.2$.&#x20;

To avoid automatic conversion back to WAX, the trader must withdraw the funds or use a third-party service if the price exceeds 0.2.

Range orders give traders more flexibility and control, making them useful for advanced trading strategies. We're excited to see how traders will use this feature to maximize their profits.


# How to set a Range for your Liquidity position

Setting a Price Range has been designed to be easy! Here is a step-by-step guide on how to set up a price range.&#x20;

1. [Provide liquidity](/alcor-swap/providing-liquidity) to any pair

<figure><img src="/files/nVS56zpb9cew3Ek1H80V" alt=""><figcaption></figcaption></figure>

2. Head over to "Set Price Range"

<figure><img src="/files/78EL8enmabBJ4lKAa2jo" alt=""><figcaption></figcaption></figure>

3. Use the <mark style="color:red;">Red</mark> and <mark style="color:green;">Green</mark> Bars to determine your Liquidity Range. You can also use "Min Price" and "Max Price below"

<figure><img src="/files/WGzbb5xBFTrFbCGVw1au" alt=""><figcaption></figcaption></figure>

4. Once you have chosen your ideal Liquidity Range, complete the process by choosing how much Liquidity you want to provide.&#x20;

<figure><img src="/files/Y3hGw4ArN8ZK4ugGWPSn" alt=""><figcaption></figcaption></figure>

5. Sign the transaction and that´s it! You can track your positions on ["Pools"](https://wax.alcor.exchange/positions)


# Pool Page

The Pool page contains a list of the user's current open positions. With position ranges, yield (P\&L) and position amount. There is also a section of the history of interaction with Alcor Swap AMM and a button for creating a new position.


# Liquidity Provider FAQ

**Q: How do I benefit from providing liquidity in a concentrated pool?** A: By concentrating your liquidity in specific ranges, you can potentially earn higher trading fees compared to traditional liquidity pools. This targeted approach allows you to capitalize on areas of the market where trading activity is expected to be higher or where you anticipate significant price movements.

**Q: Why do I need to choose specific ranges?** A: Choosing specific ranges enables you to strategically allocate your funds to areas where you believe there will be increased trading activity or where you want to optimize your exposure to potential price movements. This targeted approach can potentially lead to higher returns on your investment.

**Q: How do fee tiers benefit me as a liquidity provider?** A: Fee tiers offer different fee rates charged to traders based on the range they trade within. By providing liquidity in ranges with higher fee tiers, you have the opportunity to earn greater rewards from trading activity within those ranges, enhancing your overall returns.\
\
**Q: What happens if the price moves beyond my chosen range, and my position becomes out of range?** The liquidity at that range would be depleted, meaning you would hold 100% of either tokenA or tokenB. And your position would no longer earn any fees until it goes back into your defined range.

**Q: How do I create a position in a concentrated liquidity pool?** A: To create a position, select the specific range you want to provide liquidity to and deposit your desired amount of assets into the pool. By strategically choosing ranges and managing your position, you can potentially maximize your earnings from trading fees.

**Q: Can I withdraw my funds from the pool at any time?** A: Yes, you can withdraw your funds from the pool at any time.

{% hint style="info" %}
Please be aware that the token provider may have complete control over the token contract, which could result in withdrawal failures (due to issues on the side of the token contract), rug pulls, or other fraudulent schemes. Additionally, anyone can create a token, establish a pool with that token, and manipulate its supply to defraud others. It is crucial to conduct thorough research before engaging with any tokens.
{% endhint %}


# Concentrated liquidity FAQ

**Q: What is a Concentrated liquidity AMM?**

A: A Concentrated liquidity AMM (automated market maker) is a type of decentralized exchange (DEX) that allows liquidity providers (LPs) to concentrate their liquidity in a specific price range rather than spread it out across the entire price curve. This can improve capital efficiency and reduce slippage for traders.

**Q: How does a Concentrated liquidity AMM work?**

A: In a Concentrated liquidity AMM, LPs deposit equal values of two different assets into a liquidity pool, and then specify a price range, or "range order," in which they want their assets to be traded. The AMM algorithm then adjusts the price curve in that range to maintain a constant ratio of the two assets. When traders execute trades within that price range, the AMM algorithm adjusts the price curve to ensure that the ratio remains constant.

**Q: What are the benefits of Concentrated liquidity AMMs?**

A: Concentrated liquidity AMMs can improve capital efficiency by allowing LPs to concentrate their liquidity in a specific price range, reducing the amount of capital required to provide liquidity. They can also reduce slippage for traders by providing more accurate pricing within the specified price range.

**Q: Are there any drawbacks to using Concentrated liquidity AMMs?**

A: One potential drawback is that Concentrated liquidity AMMs may be less liquid outside of the specified price range, as there may be fewer LPs providing liquidity in those areas. Additionally, traders may need to be more mindful of the specified price range when executing trades, as trading outside of that range could result in higher slippage.

**Q: Can Concentrated liquidity AMMs be used for any asset?**

A: Yes, Concentrated liquidity AMMs can be used for any asset or pair of assets, including stablecoins, cryptocurrencies, and other tokens. However, the liquidity and trading volume of a specific asset or pair may affect the effectiveness of a Concentrated liquidity AMM.

**Q: How can I become a liquidity provider in a Concentrated liquidity AMM?**

A: To become a liquidity provider in a Concentrated liquidity AMM, you need to deposit equal values of two different assets into the liquidity pool and specify a price range for your liquidity.

**Q: Which fee tier should I choose when providing liquidity in a Concentrated liquidity AMM?**

A: The fee tier you choose when providing liquidity in a Concentrated liquidity AMM depends on your personal preferences and trading strategies. Alcor Swap AMM offer multiple fee tiers, with higher fee tiers offering higher trading fees but also higher earnings for liquidity providers.

If you are a long-term liquidity provider who is primarily interested in earning passive income from trading fees, you may want to choose a higher fee tier that offers higher earnings. However, if you are a more active trader who frequently enters and exits positions, you may want to choose a lower fee tier that offers lower trading fees, as these can add up over time.

It's also important to consider the trading volume of the asset or pair you are providing liquidity for. If the asset or pair has low trading volume, choosing a higher fee tier may not result in significantly higher earnings, as there may not be enough trading activity to generate significant

**Q: How can I increase my income as a liquidity provider in a Concentrated liquidity AMM?**

A: You can increase your income as a liquidity provider in a Concentrated liquidity AMM by choosing a higher fee tier, using a liquidity provision optimizer tool, or participating in liquidity mining or yield farming programs that offer additional rewards. Additionally, one effective strategy to maximize your income is to provide liquidity within a more profitable price range.

A more profitable price range is a price range that has higher trading volume and lower price volatility, resulting in lower impermanent loss and higher trading fees earned.

However, it's important to note that providing liquidity within a more profitable price range also involves a higher level of risk, as the price range may shift due to market volatility or sudden changes in trading patterns. Therefore, it's important to carefully monitor the market conditions and adjust your liquidity provision strategy accordingly to minimize risks and maximize your earnings.


# AlcorSwap v2 Price Oracles

Time-weighted average price (TWAP) overview

<figure><img src="/files/2o0FvIO8e7vio9eTSavJ" alt=""><figcaption></figcaption></figure>

By drawing inspiration from [**Uniswap V3 Price Oracle**](https://blog.uniswap.org/uniswap-v3-oracles), Alcor introduces a decentralized solution to provide accurate asset prices on the blockchain.

Alcor Price Oracle is a mechanism that provides asset prices on the blockchain. Since blockchains are isolated ecosystems, there is no direct way of querying external data, and there are difficulties in ensuring data validity and authenticity.&#x20;

DelphiOracle is presented as one of the first working solutions to these problems on EOSIO(Antelope). It runs a decentralized network of oracles that fetch asset prices from centralized exchanges via APIs, average them, and provide them on-chain.&#x20;

DelphiOracle is essentially a smart contract with one state variable, asset price, that can be read by anyone but can only be written to by oracles (top block producers). However, DelphiOracle only provides the last price while the Defi Dapp needs the price by timestamp for various purposes. Furthermore, DelphiOracle exclusively supports a limited number of well-known tokens: BTC/USD, ETH/USD, WAX/USD, EOS/USD, whereas there is a multitude of tokens available on WAX/EOS that require price data for integration with the Defi Dapp.

**AlcorSwap v2 facilitated the creation of on-chain price oracles known as time-weighted average price (**[**TWAP**](https://en.wikipedia.org/wiki/Time-weighted_average_price)**) oracles**. These oracles are highly decentralized and provide a solution for many of the challenges involved in creating robust blockchain protocols.&#x20;

Manipulation on most AlcorSwap v2 TWAP oracles isn’t currently feasible, bad actors both need to source incredibly high levels of capital and then need to make enough money back to make up for money lost to fees. Make sure that your Dapps use a rolling time window for TWAP to calculate the price because spot prices are easy and relatively cheap to manipulate.

In Alcor, historical price data is stored as an array of observations. Initially, each pool tracks only one observation, overwriting it as new blocks are added. As a result, the data can only be accessed for a limited period. However, **any party can expand the period of data availability by paying RAM to increase the number of tracked observations and the maximum of observations is unlimited.**

<br>


# Alcor Price Oracle vs DelphiOracle

Comparison between TWAP and DelphiOracle

| **Aspect**                              | **Alcor Price Oracle**                                                                                                                  | **DelphiOracle**                                               |
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| Data Source                             | Extracts data directly from Alcor Swap decentralized exchange.                                                                          | Aggregated from multiple centralized exchanges                 |
| Price Calculation Method                | Time-weighted average price                                                                                                             | Average of prices fetched from exchanges                       |
| Price Availability                      | Provides prices by timestamp and unlimited historical data availability.                                                                | Provides only the last price                                   |
| Freshness/Accuracy                      | May not reflect the current spot price during high volatility                                                                           | Provides current spot price but may lag during high volatility |
| Manipulation Susceptibility             | There is currently not enough economic incentive to manipulate TWAP. refer [**here**](https://blog.uniswap.org/uniswap-v3-oracles)**.** | Very hard to manipulate                                        |
| Data Storage                            | Historical data is stored as an array of observations                                                                                   | Only stores recent historical data                             |
| RAM Cost for Extended Data Availability | Requires RAM payment to extend data availability period                                                                                 | N/A                                                            |
| Token Pairs                             | Provides for all token pairs available and trading on Alcor Swap                                                                        | Provides only some pairs like WAX/USD, BTC/USD, ETH/USD        |


# Expanding Price Availability with RAM Purchase

To extend the availability of historical price data within the Alcor Price Oracle, users can purchase additional RAM. The cost of purchasing RAM is determined by the current market price on the EOSIO blockchain, which can vary based on supply and demand. To calculate the RAM required for the desired data availability period, users can use the following formula:&#x20;

| RAM Required (in bytes) = Number of Observations \* Size of Each Observation |
| ---------------------------------------------------------------------------- |

For instance, if a user wishes to have the price data available for 3 hours and each observation requires 160 bytes of RAM, they would need to calculate:&#x20;

| <p>RAM Required = 160 bytes \* 3 hours \* 60 minutes \* 60 seconds = 1.728 MB.<br><br>WAX Token = 0.4073 \* 1728 = 703.81440000 WAX (with RAM price is 0.4073 WAX per KB)</p> |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

Once users have determined the required RAM size, they can proceed with the RAM purchase process by following:

| Transfer WAX to the swap.alcor account with the memo: "addoraclerow#poolId". |
| ---------------------------------------------------------------------------- |

Additionally, users can easily track the number of observations they have purchased by reviewing their [**transaction history**](https://wax.bloks.io/transaction/8430511460ddd7232cd35461fe0088966e3d71346cf5f860dee168561dca0dba)


# How to Use Alcor Price Oracle

In 4 easy steps!

We've made it even easier for you to get started with the Alcor Price Oracle! You can find the full interface project at this **GitHub repository:** <https://github.com/alcorexchange/alcor-oracle-price>

Here's a step-by-step guide to help you effectively utilize the Alcor Price Oracle:

**Step 1**: Copy the hpp folder from our repository where we've provided a full interface for using the Alcor Price Oracle and paste it into your own project.&#x20;

**Step 2:** Access the Alcor Price Oracle within your cpp project by simply adding the following line of code:

| uint128\_t AlcorPriceOracle::getPriceTwapX64(poolId, twapInterval) |
| ------------------------------------------------------------------ |

Note: Most protocols use a 30-minute running TWAP, but it's essential to understand the trade-offs involved. Longer TWAPs are more tamper-resistant but may provide less accurate data during volatility. Shorter TWAPs offer more accurate data during volatility but may be less tamper-resistant. Consider your project needs and risks when selecting the TWAP length.&#x20;

**Step 3:** Modify and adapt it to work with your DApp's architecture and requirements.&#x20;

**Step 4:** Collaborate with the [**Community**](https://t.me/alcorexchange) We encourage you to join our community and engage with developers who are using the Alcor Price Oracle in their projects. Collaboration and knowledge-sharing are essential for building a stronger WAX Defi ecosystem.

By following these steps and using our provided interface, you can effortlessly integrate the Alcor Price Oracle into your project and leverage accurate and reliable asset prices on the WAX blockchain.

<br>


# Alcor Farms: Unlocking DeFi Opportunities

Alcor Farms are a cornerstone of decentralized finance (DeFi) within the Alcor Exchange ecosystem. Designed to empower users, Alcor Farms provides a unique opportunity to participate in yield farming. Users can contribute liquidity to various token pairs and earn rewards, fostering a vibrant and engaged community.

**Key Features:**

1. **Liquidity Provision:** Users can contribute their assets to liquidity pools, enhancing the overall trading experience on Alcor Exchange.
2. **Reward Generation:** By participating in Alcor Farms, users earn rewards in various tokens, creating an additional income stream.
3. **Diverse Token Pairs:** Alcor Farms support a range of token pairs, allowing users to choose and participate in the pools that align with their preferences.
4. **Community Engagement:** Alcor Farms promote community engagement by encouraging users to actively participate in the decentralized ecosystem.

**Purpose:**

* **Liquidity Boost:** Alcor Farms play a vital role in boosting liquidity across different token pairs on the Alcor Exchange, creating a more dynamic and efficient trading environment.
* **Community Incentives:** The primary purpose is to incentivize community members to contribute to the liquidity and growth of the Alcor ecosystem.
* **Yield Farming Opportunities:** Users can engage in yield farming, capitalizing on opportunities to earn rewards through their contributions to liquidity pools.

Alcor Farms embody the principles of decentralization, community-driven growth, and user empowerment within the Alcor Exchange ecosystem.


# Creating Farm Incentives - Quick Tutorial

Ready to boost liquidity and earn rewards on Alcor Farms? Here's a quick guide on how to create farm incentives:

**Step 1: Access the Farm** Visit <https://wax.alcor.exchange/farm/create> to access the Farm Incentive Creation interface.

**Step 2: Ensure Token Availability** Make sure you have access to one of the tokens contract in the swap pair you intend to use for the farm. This is crucial for creating a seamless experience.

**Step 3: Token Whitelisting** Currently, only whitelisted tokens are eligible to be added as rewards in the farm. If your desired token is not whitelisted, don't worry! You can apply for its inclusion by reaching out to us in the Telegram chat at [@alcorexchange](https://t.me/alcorexchange).

**Note:** For any assistance or queries during the process, our Telegram and Discord chat are here to help. Happy farming! 🌾💰


# Project Farms Unique Link

To get link, that will open list with project only farms. Just set **contracts** query parameter for /farm page. User "," for separation if you want set multiple contracts.\
\
For example:

```
// Will show only farms with martia token pools
https://alcor.exchange/farm?contracts=martia

// OR Multiple contracts
https://alcor.exchange/farm?contracts=eosio.token,usdt.alcor
```


# Technical details

**Onchain Farming:** Alcor Farming operates entirely on-chain, leveraging a reward calculation algorithm without relying on any backend services. This ensures transparency and security throughout the farming process.

**Claiming Rewards:** Users have the flexibility to claim accumulated rewards at any time. Additionally, they can easily finish or resume their participation in farming as per their preferences.

**Farm Parameters:** Each farm is characterized by two main parameters:

1. **Reward Amount:** Calculated proportionally to the liquidity value in the position, offering fair compensation for your contribution.
2. **Duration:** Specifies the timeframe during which users can participate in farming and earn rewards.

**Key Tables in swap.alcor Contract:** Understanding the backend, there are three essential tables within the swap.alcor contract related to farming:

1. **Incentives:** Contains details about reward incentives.
2. **Stakingpos:** Maps positions to corresponding arrays of incentives, illustrating the staked positions.
3. **Stakes:** Scoped by incentive ID, this table holds the state of farming positions.

**Whitelisting Tokens:** To enhance the farming experience, Alcor maintains a whitelist containing available tokens that users can earn as rewards.


# LSW- Liquid Staked WAX

Liquid staking allows users to stake their native tokens, receive a liquid token (LSW) in return, and actively participate in DeFi applications, enhancing liquidity and flexibility.

**Liquid Staking**

<figure><img src="/files/9bKkNtfw6IVElUj4BtPY" alt=""><figcaption></figcaption></figure>

Liquid staking empowers users to stake native tokens without locking them, providing a liquid token for use in various DeFi applications. This paper introduces $LSW, aiming to revolutionize staking on the WAX blockchain.

**Benefits**

1. Liquidity and Flexibility: $LSW allows users to earn staking rewards while retaining the flexibility to trade or use staked assets instantly, eliminating the trade-off between staking for APR and engaging in DeFi activities.
2. Improved Network Security: Encouraging more token holders to stake enhances overall blockchain network security.
3. Capital Efficiency: $LSW provides a more capital-efficient solution for blockchain projects and DeFi applications, avoiding having to constantly claim WAX tokens and vote for a set of proxies or validators.

**$LSW Use Cases**

1. DEX LiquiditY: The WAX/LSW facilitates liquid staking and immediate access to locked fund from staking contracts.&#x20;
2. Lending: LSW as collateral in lending protocols “cough cough”
3. Staking Derivatives: Creation of staking derivatives such as stakers’ baskets and leveraged staking positions.


# How it works

**Key Terms**

**-WAX:** The native coin on WAX.

**-LSW**: A reward-bearing token received when staking WAX with Alcor DEX.

**-Staker Multisig:** Account on Alcor holding stakers’ funds.

**Process Overview**

1. **Initiation:** User stakes WAX and deposits it into an Alcor Staking Contract.2.&#x20;
2. **Calculation and Minting:** The contract calculates LSW based on WAX´s exchange rate, mints LSW, and sends it to the user's WAX account.
3. **Stake:** Alcor contract uniformly stakes across the top 21 Guilds on WAX using the liquid.alcor account.
4. **Compound:** Alcor constantly claims revenue from WAX DeFi and retakes the profits, ensuring capital efficiency in terms of voting power and resource availability.&#x20;

<br>


# Exchange rate

The exchange rate of LSW:WAX ensures accuracy and fairness in liquid staking. It starts at 1:1, dynamically updating based on accrued staking rewards.

$$
Exchange   Rate =Total LiquidStakedWAX/ TotalNativeWAX
$$

TotalNativeWAX = Staked WAX+ accrued staking reward from DeFi

TotalLiquidStakedWAX = LSW minted

**For example:**

The pool will initially start at a 1:1 ratio and will be dynamically updated based on the accrued staking rewards. To understand how this works, let’s consider an example:

Avral is LSWs first user and he stakes 100 WAX, he then receives 100 LSW in return.

$$
ExchangeRate: 100/100=1
$$

Let’s assume that time has passed and 10 rewards in WAX were accrued.

Now, the new exchange rate would be:

$$
ExchangeRate: 100/100+10= 0.91
$$

If Avral decides to withdraw his WAX, he will receive 110 WAX for 100 LSW based on the new exchange rate.

\ <br>


# Withdrawal process

<figure><img src="/files/3dDisuyhm8JpM9BHEATs" alt=""><figcaption></figcaption></figure>

Users can choose to withdraw their WAX on Alcor which involves the 3-day unbonding time mandated by WAX, or swap their LSW for WAX on Alcor or other listed DEXes for instant withdrawal.

There are currently no fees involved for Liquid Staked WAX.&#x20;

<br>


# Alcor USDT Proxy:

Seamless USDT Transactions on WAX

Alcor USDT Proxy, meticulously crafted by the Alcor team, revolutionizes the process of withdrawing and depositing USDT from/to Centralized exchanges by seamlessly integrating with EOS Inter Blockchain Communication (IBC) technology.

**How It Works:**

1. **EOS Network Integration:**
   * Alcor leverages the EOS network as a USDT provider. To initiate a deposit or withdrawal, users must select the EOS network.
2. **Effortless Deposit or Withdrawal on EOS:**
   * Once the USDT is deposited or withdrawn on the EOS blockchain, Alcor takes the reins. Using the IBC protocol, Alcor bridges the tokens to or from EOS, facilitating a swift and secure swap.
3. **Automated Transaction Handling:**
   * All transactions are meticulously handled by Alcor, ensuring that your tokens arrive seamlessly in your WAX wallet or your preferred Centralized Exchange (CEX).
4. **Deposit Instructions:**
   * Users are advised to thoroughly read the provided instructions before initiating a deposit to ensure a smooth transaction experience.
5. **Minimal Deposit Fee:**
   * Alcor USDT Proxy incurs a minimal deposit fee of 0.05 USDT, making it an economical and user-friendly choice for USDT transactions on the WAX blockchain.


# Depositing USDT to WAX

Deposit USDT to WAX: A Step-by-Step Guide

**Prerequisites:**

* Ensure you have a valid WAX wallet.
* The withdrawal should be initiated from a Centralized Exchange (CEX) such as Binance or KuCoin.

**Instructions:**

1. **Select EOS Network for Withdrawal:**

<figure><img src="/files/FdiBXnR3OsSJEDbqOhLo" alt=""><figcaption><p>Binance is provided as an example, although you can use any Centralized Exchange</p></figcaption></figure>

* **When withdrawing USDT from your CEX, ensure that you select the EOS network as the destination. This is crucial for the subsequent steps.**

1. **Read Carefully:**
   * Carefully read the instructions provided here before proceeding. Any oversight in this process can lead to a potential loss of funds.
2. **Supported CEX Platforms:**
   * We support USDT deposits from various CEX platforms, including Binance, KuCoin, and others.
3. **Address Details:**

<figure><img src="/files/MFwwkMJ5MyE0DHM9iJop" alt=""><figcaption></figcaption></figure>

* Use the following details for the withdrawal:
  * **Address:** `w.ibc.alcor`
  * **MEMO:** (Refer to the memo provided by the interface at the time of withdrawal)

1. **Fill in Exchange Fields:**
   * On the exchange platform, fill in the withdrawal form with the provided address and memo. Pay close attention to accuracy, as errors can result in fund loss.
2. **MEMO Variation:**
   * Note that the MEMO may vary between different wallets. Always refer to the interface for the correct MEMO associated with your transaction.
3. **Double-Check Information:**
   * Before confirming the withdrawal, double-check all the information you've entered. Ensure that the address and MEMO match the details provided.
4. **Complete Withdrawal:**
   * Confirm and complete the withdrawal process on the CEX platform.

**Important Note:**

* An incorrectly filled MEMO can lead to the loss of funds. Exercise caution and verify all details before finalizing the withdrawal.


# Withdrawing USDT from WAX

Withdraw USDT from WAX: A Step-by-Step Guide

**Prerequisites:**

* Ensure you have a valid WAX wallet with the required USDT balance.
* The deposit destination should be a Centralized Exchange (CEX) such as Binance or KuCoin.

**Instructions:**

1. **Select EOS Network for Deposit:**

<figure><img src="/files/QD4PAPLdLwY9xXVfRtkM" alt=""><figcaption></figcaption></figure>

* When depositing USDT to your chosen CEX, ensure that you select the EOS network as the source. This is a critical step for a successful transaction.

1. **Read Carefully:**
   * Carefully read the instructions provided here before initiating the deposit. Pay attention to details such as the CEX deposit address and the memo for deposits.
2. **Include CEX Deposit Details:**

<figure><img src="/files/9xNHvXcEL2RyuWB4lTdx" alt=""><figcaption></figcaption></figure>

* Make sure to include the correct CEX deposit address and the associated memo during the deposit process. This information is essential for proper fund crediting.

3. **Deposit Fee:**

* Note that there is a deposit fee of 0.05 USDT. Account for this fee in your deposit amount.

4. **Fill in MEMO on Exchange:**

* On the exchange platform, fill in the MEMO exactly as provided above. Accuracy in entering the MEMO is crucial to avoid potential fund loss.
* Be aware that the MEMO may vary between different wallets or exchanges. Always refer to the interface for the correct MEMO associated with your transaction.

5. **Double-Check Information:**

* Before confirming the deposit, double-check that you've included the correct CEX deposit address, memo, and accounted for the deposit fee.

6. **Complete Deposit:**

* Confirm and complete the deposit process on the WAX blockchain.

**Important Note:**

* An incorrectly filled MEMO can lead to the loss of funds. Exercise caution and verify all details before finalizing the deposit.


# Adding Token Information

Introduction

<div align="left"><figure><img src="/files/KRrtwI5x3NZEPBrm1uPb" alt="" width="563"><figcaption></figcaption></figure></div>

Each project can add information about its token, also via a Pull Request on GitHub, as well as the token icon. We use **JSON** format for that.

Our github: <https://github.com/avral/alcor-ui>

The provided format is designed to store information about a cryptocurrency or token, including its name, website, and associated GitHub repository.

The file in which you need to add information about your token is divided into different blockchains.

The file for each blockchain is located in the folder: [**assets/fundamentals**](https://github.com/avral/alcor-ui/tree/master/assets/fundamentals) and is called **<:chain>.json** according to its chain (wax.json, eos.json, telos.json, proton.json)

#### Format:

There is a one object(not an array) that stores each tokens as **key: value,** where is **key** is id of token in format <**SYMBOL**@**contract**>.

```json
  "FWW@farmerstoken": {
    "name": "Farmers World",
    "website": {
      "link": "https://farmersworld.io/",
      "name": "farmersworld.io"
    },
    "tags": [
      "Gaming",
      "P2E",
      "NFT"
    ],
    "socials": [
      "https://t.me/farmersworldofficial",
      "https://twitter.com/FarmersWorldNFT",
      "https://discord.com/invite/V2pdyGdB9V"
    ],
    "github": "https://github.com/shivsriv/FarmersWorld",
    "description": "FarmersWorld is the first farming game to function on the NFTs platform. Pick for yourself suitable tools, exploit various resources, buy land to build enormous farms, and enjoy the fascinating experiences of a farmer working in Farmersworld’s Ecosystem."
  }

```

{% hint style="info" %}
Make sure symbol is in upper case and you pushing requests with valid JSON.
{% endhint %}


# Token logo

How To Add Token Logo

At Alcor Exchange, we believe in flexibility, allowing projects to seamlessly integrate their tokens into our UI application for broader visibility. Here's a quick guide to get your token listed:

1. **Video Tutorial:**
   * Watch this helpful video tutorial by MikeDCrypto: [Alcor Token Listing Tutorial](https://www.youtube.com/watch?v=pL68Llsr9pA).
   * This video provides step-by-step guidance on adding your token to the eos-airdrops repository.
2. **Fast Track – Direct Pull Request:**
   * For a quicker approach, you can directly submit a pull request in the alcor-ui repository (<https://github.com/alcorexchange/alcor-ui>).
   * Navigate to `assets/tokens/<:chain>/` and add your token following this structure: "<:symbol>\_<:contract>.png" (both names in lowercase).
   * Ensure your token image is 64x64 in size and in .png format.
3. **Legacy Token Information Provider:**
   * Alcor Exchange uses the eos-airdrops repository (<https://github.com/eoscafe/eos-airdrops>) as the default token information provider.
   * To have your project's token listed, simply add it to the eos-airdrops repository. Please note that PR approvals may take some time.
4. **Non-Technical Option – Telegram Request:**
   * If you're not tech-savvy, don't worry! Request token addition in the Alcor Telegram chat: [@alcorexchange](https://t.me/alcorexchange).
   * Our community is here to assist you in the process.


# USD Price

To have token price showing on Alcor UI and tokens API. Token should have Pool to WAX or USDT with TVL not less then 1$.


# Swap Widget

Html widget for integration in your website.

![](/files/Gb98ZRFHhpamVgHCs1NI)

**Chose link for your chain:**

* WAX: <http://wax.alcor.exchange/swap-widget>
* EOS: <http://eos.alcor.exchange/swap-widget>
* TELOS: <http://telos.alcor.exchange/swap-widget>
* XPR: <http://proton.alcor.exchange/swap-widget>

Now you can easily integrate Alcor Exchange into your app.

```html
<iframe src="http://alcor.exchange/swap-widget" width="445" height="600"></iframe>
```

Just insert an iframe into your html page.

For example:

```html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
  <h1>Alcor Iframe<h1/>
  <iframe src="http://alcor.exchange/swap-widget" width="445" height="600"></iframe>
</body>
</html>
```

**Query parameters:** (for the widget link)

token id format is: **symbol-coontract** (e.g: **wax-eosio.token**)

* input: default input token
* output: default output token
* only: set available tokens for dropdown: set, with "," as delimeter. (e.g: "wax-eosio.token, tlm-alien.worlds")
* market: cursont market fee (check Referal / Custom market fee page)


# Swap Chart Widget

Widget are available by url: /chart-widget\
\
it receives required parameters:\
\
`input: token id of input`\
`output: token id of output`

\
example: /chart-widget?output=TLM-alien.worlds\&input=WAX-eosio.token


# Networks Features


# WAX


# Alcor USDT

USDT on WAX provided by Alcor

Try it on [Alcor Bridge UI](https://alcor.exchange/bridge)!

WAX Network support USDT token, using [IBC technology](https://ibc-docs.uxnetwork.io/). Original USDT are bridged to WAX using **ibc.alcor** bridge contract. and **usdt.alcor** contract for WAX wrapped USDT token. IBC is a secure, decentralized, audited cryptographic protocol that allows you to transfer tokens without having to trust any party.


# Definitions

Common Market Terminology Defined

## \*This is not financial advice\*

## Page Still Under Construction

**Mainnet** - is the term used to describe when a blockchain protocol is fully developed and deployed

**Market Order -** is an order to buy or sell immediately. This type of order guarantees that the order will be executed, but does not guarantee the execution price. A market order generally will execute at or near the current buy or sell price. However, it is important to remember that the current trade price is not necessarily the price at which a market order will be executed.

**Slippage -** refers to the difference between the expected price of a trade and the price at which the trade is executed. Slippage can occur at any time but is most prevalent during periods of higher volatility when market orders are used


# FAQ

Frequently Asked Questions


# Does Alcor Exchange Have Fees?

Alcor Exchange different exchange fees based on the kind of transaction you are trying to accomplish

**Swap** - When using the swap there is a .3% liquidity provider fee. This fee gets distributed between those providing liquidity in the pool.

**Market Exchange** - When placing a market or limit order it is a .2% exchange fee on only 4 markets. This exchange fee goes towards the Alcor development fund&#x20;

* WAX/TLM
* WAX/Aether
* WAX/Void
* WAX/PGL

**OTC Transaction** - Each exchange is charged a commission of 0.25% for both tokens if the transaction amount is sufficient. Otherwise, for small amounts, no commission will be charged This fee also goes towards the Alcor development fund.


# Whats the difference between using Swap, Market Trade, and OTC?

**What's the difference between using Swap, Market Trade, and OTC?**

* [**Swap**](/main-page-overview/swap) utilizes a [**liquidity pool**](/faq/what-is-a-liquidity-pool) to fulfill a token exchange.
* [**Market trades**](/main-page-overview/markets/market-exchange) use that token pairs [**order books**](/main-page-overview/markets/market-exchange/order-books) to fill trades.
* [**OTC**](/main-page-overview/otc) (Over-The-Counter) is a direct sale to another user without having to rely on the pricing and swap value in market exchanges and liquidity pools.&#x20;


# What is a liquidity Pool?

Liquidity pools provide liquidity in decentralized exchanges rather than relying on order books.&#x20;

The advantage of using liquidity pools is that it does not require a buyer and a seller to decide to exchange two assets for a given price, and instead leverages a pre-funded liquidity pool. This allows for trades to happen with limited slippage even for the most illiquid trading pairs, as long as there is a big enough liquidity pool.


# Social Media/Contact

### [Telegram](https://t.me/alcorexchange) - <https://t.me/alcorexchange>

### [Twitter](https://twitter.com/alcorexchange) - <https://twitter.com/alcorexchange>

### Discord - <https://discord.gg/kAYNMAKU>


