# Create a token on Telos (/adding-token-information/create-a-token-on-telos) A token on Telos is a standard Antelope token: the `eosio.token` contract deployed to an account you control. The account's name becomes the token's contract, so a token `ABC` deployed to `mytokenacct` is `ABC@mytokenacct` everywhere — in wallets, on Alcor and in block explorers. It takes four transactions from one account, and about 10 TLOS of RAM. Nothing has to be approved by Alcor: once the token has a pool, it trades. ## What you need [#what-you-need] * A Telos account whose key you can sign with in [cleos](https://docs.eosnetwork.com/manuals/leap/latest/cleos/). A dedicated account is best, since its name is the token's contract name and it holds the contract from now on. * Some TLOS on that account for RAM, and enough CPU and NET for a few transactions. * An RPC endpoint, for example `https://telos.greymass.com` or `https://mainnet.telos.net`. The commands below use these names — replace them with yours: ```bash TELOS=https://telos.greymass.com ACCOUNT=mytokenacct ``` ## 1. Get the token contract [#1-get-the-token-contract] Copy the code the network's own `TLOS` token runs: ```bash mkdir token cleos -u $TELOS get code eosio.token --wasm -c token/eosio.token.wasm -a token/eosio.token.abi ``` You can also build it from the [reference contracts](https://github.com/AntelopeIO/reference-contracts). Use the token contract as it is: wallets and Alcor read the standard `stat` and `accounts` tables and the standard `transfer` action. ## 2. Buy RAM [#2-buy-ram] The contract's code is stored in the account's RAM, about 160 KB. Buy a little more for the token's own rows: ```bash cleos -u $TELOS system buyram $ACCOUNT $ACCOUNT 180 --kbytes -p $ACCOUNT@active ``` At the time of writing that costs about 10 TLOS. If the next step fails with `insufficient ram`, the error says how many bytes are missing — buy them and run it again. ## 3. Deploy the contract [#3-deploy-the-contract] ```bash cleos -u $TELOS set contract $ACCOUNT ./token eosio.token.wasm eosio.token.abi -p $ACCOUNT@active ``` ## 4. Create the token [#4-create-the-token] ```bash cleos -u $TELOS push action $ACCOUNT create '["mytokenacct", "1000000000.0000 ABC"]' -p $ACCOUNT@active ``` * The first argument is the **issuer**, the account allowed to issue new tokens. Here it is the token account itself. * The second is the **maximum supply**. Its symbol — 1 to 7 capital letters, `A` to `Z` — and its number of decimals become the token's for good. Four decimals, as `TLOS` has, is the common choice. The symbol, the decimals and the maximum supply cannot be changed after `create`. One contract can hold many tokens, each with its own symbol. ## 5. Issue the supply [#5-issue-the-supply] Issue to the issuer, then send the tokens wherever they go: ```bash cleos -u $TELOS push action $ACCOUNT issue '["mytokenacct", "1000000000.0000 ABC", "initial supply"]' -p $ACCOUNT@active cleos -u $TELOS push action $ACCOUNT transfer '["mytokenacct", "myteamwallet", "1000000.0000 ABC", ""]' -p $ACCOUNT@active ``` Newer versions of the contract refuse to issue to anyone but the issuer, so issuing to the issuer works with any version. You can issue the whole supply now or part of it now and more later, up to the maximum. ## 6. Check it [#6-check-it] ```bash cleos -u $TELOS get currency stats $ACCOUNT ABC cleos -u $TELOS get currency balance $ACCOUNT mytokenacct ABC ``` ## List it on Alcor [#list-it-on-alcor] A Telos token trades on Alcor as soon as it has a pool: 1. Open **Pool → New position** on [Alcor Exchange](https://app.alcor.exchange/v/telos/swap/positions/new) or [alcor.exchange](https://alcor.exchange/v/telos/swap/positions/new). 2. Pick your token by its contract, pair it with `TLOS` or `USDC`, set the starting price and add liquidity. From then on anyone can swap it. A pool against `TLOS` or a stablecoin also gives the token a [USD price](/adding-token-information/usd-price). To show its logo and description, see [Token logo](/adding-token-information/token-logo) and [Adding Token Information](/adding-token-information). ### A token from another network [#a-token-from-another-network] A token that lives on another network reaches Alcor Exchange over the bridge, which Alcor sets up. Send its network, contract and symbol in the Alcor Telegram chat: [@alcorexchange](https://t.me/alcorexchange). ## For scripts and agents [#for-scripts-and-agents] | | | |---|---| | Network | Telos mainnet | | Chain ID | `4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11` | | RPC | `https://telos.greymass.com`, `https://mainnet.telos.net` | | System token | `TLOS@eosio.token`, 4 decimals | | Token code | `eosio.token`'s own (`get code eosio.token --wasm`) | | RAM for the code | about 160 KB; buy 180 KB | The actions, in order, all signed by the token account's `active` permission: 1. `eosio::buyrambytes` — `{ payer, receiver: , bytes: 184320 }` 2. `eosio::setcode` and `eosio::setabi` on `` — what `cleos set contract` sends 3. `::create` — `{ issuer, maximum_supply: "1000000000.0000 ABC" }` 4. `::issue` — `{ to: , quantity, memo }`, signed by the issuer Steps 1 and 2 can be one transaction; RAM is checked at the end of it. # Adding Token Information (/adding-token-information) Any project can add information about its token — name, website, socials, tags and description — with a pull request to the [alcor-ui repository](https://github.com/alcorexchange/alcor-ui). Alcor shows it on the token's analytics page (`/v//analytics/tokens/`). To add a logo, see [Token logo](/adding-token-information/token-logo). ## Where to add it [#where-to-add-it] Token information lives in [`assets/fundamentals`](https://github.com/alcorexchange/alcor-ui/tree/master/assets/fundamentals), one file per network: | Network | File | |---|---| | WAX | `wax.json` | | XPR Network | `proton.json` | | Vaulta (EOS) | `eos.json` | | Telos | `telos.json` | ## Format [#format] Each file is one JSON object (not an array). Each key is a token id in the form `SYMBOL@contract`, and its value describes the token: ```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." } ``` The symbol must be upper case, and the file must stay valid JSON after your change. # Token logo (/adding-token-information/token-logo) ## Pull request to alcor-ui (recommended) [#pull-request-to-alcor-ui-recommended] Add the logo to the [alcor-ui repository](https://github.com/alcorexchange/alcor-ui) with a pull request: * Folder: `assets/tokens//`, where `` is `wax`, `proton` (XPR Network), `eos` (Vaulta) or `telos`. * File name: `_.png`, both in lower case, joined by an underscore — for example `assets/tokens/wax/tlm_alien.worlds.png`. * Format: a square PNG image. You can add the token's description and links in the same pull request, see [Adding Token Information](/adding-token-information). ## Other sources [#other-sources] If a token has no logo in alcor-ui, Alcor falls back to: * on XPR Network, the logo registered in the network's own token registry (`token.proton`); * the [eos-airdrops](https://github.com/eoscafe/eos-airdrops) repository. Adding a token there takes a pull request to that repository; this [video tutorial](https://www.youtube.com/watch?v=pL68Llsr9pA) walks through it. ## No GitHub account? [#no-github-account] Ask in the Alcor Telegram chat: [@alcorexchange](https://t.me/alcorexchange). # USD Price (/adding-token-information/usd-price) Alcor prices tokens on each network from its own pools and order books. A token gets a USD price when it has a pool on Alcor Swap against the network's system token or one of its stablecoins: | Network | System token | Stablecoins (priced at $1) | |---|---|---| | WAX | `WAX@eosio.token` | `USDT@wrap.alcor`, `USDC@wrap.alcor`, `USDT@usdt.alcor` | | XPR Network | `XPR@eosio.token` | `USDT@wrap.alcor`, `USDC@wrap.alcor`, `XUSDT@xtokens`, `XUSDC@xtokens` | | Vaulta (EOS) | `EOS@eosio.token` | `USDT@tethertether` | | Telos | `TLOS@eosio.token` | `USDT@wrap.alcor`, `USDC@wrap.alcor` | ## How the price is calculated [#how-the-price-is-calculated] * When a token has several such pools, its price is the median of their prices, weighted by the liquidity on the system-token or stablecoin side. * A token that has no pool at all takes its price from the last trade in its order book market against the system token, if that trade is at most 7 days old and worth at least $10. ## Price used for values [#price-used-for-values] The price used to value balances, positions and pools is stricter: * only pools whose system-token or stablecoin side holds at least $150 count; * the token must be trusted — the system token, a stablecoin, a token on Alcor's trusted list, or one with a high enough Alcor token score; * tokens marked as scam are always priced at $0. So the most reliable way to get a USD price shown for your token is a pool against the system token or a stablecoin with real liquidity on the paired side. # Creating a Farm (/alcor-farms-unlocking-defi-opportunities/creating-farm-incentives-quick-tutorial) A farm pays a reward token to the staked positions of one pool over a fixed duration. The pool must already exist. ## Who can create a farm [#who-can-create-a-farm] - The **issuer of either token of the pool** (the account that issued the token in its token contract) creates farms for free. - **Anyone else** must first pay a farm creation fee. The fee is set per chain in the `incentivefee` table of `swap.alcor` and can change, so check it before you pay. Any token can be used as a reward. ## Using the farm creation page [#using-the-farm-creation-page] The farm creation page is on the classic interface of each chain: `wax.alcor.exchange/farm/create` (or `proton.`, `eos.`, `telos.alcor.exchange`). It is meant for token issuers. 1. Connect the issuer account. 2. Select the base and quote token of the pool, then its fee tier. 3. Add one or more rewards: the reward token and the total amount to distribute. 4. Select the duration: 1, 7, 30, 60, 90, 180, 240 or 360 days. The page shows the resulting daily reward. 5. Click **Create Farm** and sign the transaction. ## Creating a farm directly with the contract [#creating-a-farm-directly-with-the-contract] All actions go to `swap.alcor` and can be sent in one transaction: 1. **Creation fee** (not needed for token issuers): transfer exactly the amount in the `incentivefee` table to `swap.alcor` with the memo `activeincent`. The prepaid fee is used by your next farm. 2. **Create the farm**: call `newincentive` with: - `creator`: your account; - `poolId`: the pool to reward; - `rewardToken`: the reward token as an extended asset with a zero amount, for example `{"quantity": "0.0000 TLM", "contract": "alien.worlds"}`; - `duration`: in seconds, one of `86400`, `604800`, `2592000`, `5184000`, `7776000`, `15552000`, `20736000`, `31104000` (1 to 360 days). 3. **Fund the farm**: transfer the reward tokens to `swap.alcor` with the memo `incentreward#`. The farm starts distributing when it receives rewards. ## Adding rewards later [#adding-rewards-later] Only the farm's creator can add rewards, with another `incentreward#` transfer. The new amount and whatever was still undistributed are spread over a fresh full duration starting from that moment. Questions: [Alcor Telegram](https://t.me/alcorexchange). # Farms (/alcor-farms-unlocking-defi-opportunities) A farm (an "incentive" in the contract) pays a set amount of a reward token to the liquidity positions of one Alcor Swap pool over a fixed period. Projects create farms to attract liquidity to their pools. Liquidity providers stake their positions in a farm to earn its rewards on top of swap fees. Farms run entirely on-chain, in the `swap.alcor` contract. ## Farming in the app [#farming-in-the-app] Farms are at `alcor.exchange/v//swap/farms`, where `` is `wax`, `xpr`, `vaulta` (EOS) or `telos`. - **My Farms**, **All** and **Ended** filter the list. Search by token, contract or reward, and **Hide low TVL** hides small pools. - Each pool shows its farms with APR, end date, total staked, and your share, daily reward and earned amount. - If you have no position in a farmed pool, **Add liquidity** opens the [new position form](/alcor-swap/providing-liquidity). When the pool has running farms, the form stakes the new position in them in the same transaction (you can opt out). - **Stake All** stakes every in-range position you have that is not yet staked in a running farm. **Claim All** claims all your rewards. You can also stake, claim and unstake from a [position's page](/alcor-swap/pool-page#position-page). ## Rules [#rules] - **Only in-range positions can be staked.** A position's staking weight is √(amount A × amount B) of the tokens it holds. A position outside its range holds only one token, so its weight is zero and the contract refuses to stake it. - The weight is calculated when the position is staked, and recalculated when liquidity is added to or removed from it. - A farm releases its rewards evenly over its duration. At every moment, each staked position gets a share in proportion to its weight. - Rewards can be claimed at any time. Unstaking also pays out the rewards earned so far. - A position can be staked in up to 15 farms at once. - A position must be unstaked from all farms before it can be [locked permanently](/alcor-swap/locking-liquidity). # Link to Your Project's Farms (/alcor-farms-unlocking-defi-opportunities/project-farms-unique-link) Add the `q` query parameter to the farms page to open it with a search already applied: ``` https://alcor.exchange/v//swap/farms?q= ``` `` is `wax`, `xpr`, `vaulta` (EOS) or `telos`. The search matches token symbols and contracts of the pool, the reward token and the pool ID. ``` // Farms of pools or rewards involving the martia contract https://alcor.exchange/v/wax/swap/farms?q=martia // Farms on the WAX/TLM pools https://alcor.exchange/v/wax/swap/farms?q=WAX%20TLM ``` Several words must all match, so a link cannot list several unrelated contracts at once. # Technical Details (/alcor-farms-unlocking-defi-opportunities/technical-details) Farms are part of the `swap.alcor` contract. Rewards are calculated on-chain, without a backend. ## Tables [#tables] - `incentives`: one row per farm: creator, pool, reward token and amount, duration, end time, reward rate, total staking weight and number of stakes. - `stakingpos`: for each staked position, the list of farms it is staked in. - `stakes`: scoped by farm ID; one row per staked position, with its staking weight and rewards earned. - `incentivefee`: the farm creation fee for accounts that are not token issuers. ## Actions [#actions] | Action | What it does | | --- | --- | | `newincentive` | Creates a farm for a pool. | | `stake(incentiveId, posId)` | Stakes a position in a farm. | | `stakelastpos(incentiveId)` | Stakes the newest position of the farm's pool; used to open and stake a position in one transaction. | | `getreward(incentiveId, posId)` | Pays out the rewards earned so far. | | `unstake(incentiveId, posId)` | Unstakes the position and pays out its rewards. | Rewards are paid from the `reward.alcor` account, which holds the farms' reward tokens. ## Reward calculation [#reward-calculation] The calculation follows the Synthetix staking-rewards model: - **Reward rate** = reward amount / duration, paid per second until the end time. - **Staking weight** of a position = √(amount A × amount B), from the token amounts the position holds when it is staked. It is recalculated when liquidity is added to or removed from the position. An out-of-range position holds one token only, has zero weight and cannot be staked. - Each staked position earns the reward rate × its weight / the total weight of the farm, for every second it is staked. - When the creator adds rewards, the new amount plus the undistributed remainder is spread over a new full duration from that moment. - A position can be staked in at most 15 farms at once. # Alcor Price Oracle vs DelphiOracle (/alcor-swap/alcorswap-v2-price-oracles/alcor-price-oracle-vs-delphioracle) DelphiOracle is an oracle contract on Antelope chains. Block producers fetch prices from centralized exchanges and write them on-chain, and the contract publishes the latest values for a small set of pairs. The Alcor Price Oracle is computed from trading in Alcor Swap pools. | | Alcor Price Oracle | DelphiOracle | | --- | --- | --- | | Data source | Trades in Alcor Swap pools, on-chain | Prices from centralized exchanges, written by block producers | | Price type | Time-weighted average over any window, or spot | Latest reported price | | History | As many observations as the pool keeps; can be extended by paying for RAM | Recent values only | | Pairs | Every Alcor Swap pool | A few major pairs, such as WAX/USD | | Freshness | Lags the market during fast moves, by design of the averaging window | Follows external markets, updated as producers report | | Manipulation | Requires holding the pool price off-market for the whole window; safer with deep liquidity and a longer window | Requires compromising the reporting producers | | Cost to extend | RAM for extra observations | None for users | # Expanding Price Availability with RAM Purchase (/alcor-swap/alcorswap-v2-price-oracles/expanding-price-availability-with-ram-purchase) A pool keeps only as many observations as its `maxObservationNum` (in the pool's row of the `pools` table, under `currSlot`). A new pool keeps one. Anyone can raise this number by paying for the RAM the extra observations need. ## How many observations you need [#how-many-observations-you-need] Each observation takes 160 bytes of RAM. At most one observation is written per second, and only when the price tick or the in-range liquidity changes. So `N` observations always cover at least the last `N` seconds of trading, and usually much more in quiet pools. To be sure of a full window regardless of activity, buy one observation per second of the window: ``` RAM (bytes) = window in seconds × 160 30 minutes: 1,800 × 160 = 288,000 bytes ≈ 288 KB 3 hours: 10,800 × 160 = 1,728,000 bytes ≈ 1.7 MB ``` Multiply by the current RAM price of the chain to get the cost. RAM prices change, so check them before you send. ## Buying observations [#buying-observations] Transfer the chain's core token (for example WAX on WAX) to `swap.alcor` with the memo: ``` addoraclerow# ``` The pool must be active. The contract buys RAM with the whole amount, divides the bytes it received by 160, adds that many observations to the pool's `maxObservationNum` and logs the result with a `logaddoracle` action (`poolId`, `payer`, `rows`). The RAM purchase includes the chain's RAM fee. Check the pool's `maxObservationNum`, or the `logaddoracle` action in your transaction, to see how many observations you added. New slots fill up as trading continues. Until they do, the history covers only the time since you bought them. # How to Use the Alcor Price Oracle (/alcor-swap/alcorswap-v2-price-oracles/how-to-use-alcor-price-oracle) The interface and an example contract are in [alcorexchange/alcor-oracle-price](https://github.com/alcorexchange/alcor-oracle-price) on GitHub. 1. Copy the `include` folder of the repository into your contract project. It reads the `pools` and `observations` tables of `swap.alcor` directly, so no call to Alcor is needed. 2. Include `alcorpriceoracle_interface.hpp` and call: ```cpp uint128_t priceX64 = AlcorPriceOracle::getPriceTwapX64(poolId, twapInterval); ``` - `poolId`: the Alcor Swap pool to read. - `twapInterval`: the averaging window in seconds. `0` returns the current spot price. - The result is the price of the pool's `tokenA` in `tokenB`, in raw token units (without decimals), as a Q64.64 fixed-point number: divide by 2^64 to get the ratio. 3. Make sure the pool keeps enough history for your window. `AlcorPriceOracle::getOldestObservationSecondsAgo(poolId)` returns the age of the oldest stored observation. If it is shorter than your window, [buy more observations](/alcor-swap/alcorswap-v2-price-oracles/expanding-price-availability-with-ram-purchase). The interface also has `consult(poolId, secondsAgo)`, which returns the tick change and the harmonic mean liquidity over a window. ## Choosing the window [#choosing-the-window] Many protocols use a 30-minute TWAP. A longer window is harder to manipulate but follows the market more slowly during volatility. A shorter window tracks the market more closely but is cheaper to manipulate. Choose according to your protocol's risks, and use a pool with deep liquidity. Questions: [Alcor Telegram](https://t.me/alcorexchange). # Price Oracle (TWAP) (/alcor-swap/alcorswap-v2-price-oracles) ![Alcor TWAP price oracle](/images/s2M3INZV0HwWhcBtO1qy-image.png) Every Alcor Swap pool works as an on-chain price oracle, following the design of the [Uniswap v3 oracle](https://blog.uniswap.org/uniswap-v3-oracles). Other contracts can read a pool's time-weighted average price (TWAP) directly from the `swap.alcor` tables, for any pair that trades on Alcor Swap. ## How it works [#how-it-works] Each pool stores a list of observations in the `observations` table (scoped by pool ID). An observation records a timestamp and cumulative values of the price tick and of seconds per liquidity. A new observation is written, at most once per second, when a swap moves the price to a new tick or liquidity changes at the current price. The average price between two moments is calculated from the difference between their cumulative values. A contract usually asks for the average over the last N seconds, for example 30 minutes. ## Observation history [#observation-history] A new pool keeps one observation, overwritten as new ones arrive, so on its own it gives little history. Anyone can raise the number of observations a pool keeps by paying for the RAM: see [Expanding Price Availability](/alcor-swap/alcorswap-v2-price-oracles/expanding-price-availability-with-ram-purchase). There is no upper limit. ## Manipulation risk [#manipulation-risk] A spot price can be moved cheaply within one transaction. A TWAP can only be moved by holding the pool price away from the market for the whole averaging window, paying swap fees and losing to arbitrage the entire time. The cost grows with the pool's liquidity and the length of the window. Use a rolling TWAP rather than the spot price, and prefer pools with deep liquidity. # Alcor Swap (/alcor-swap) Alcor Swap is the AMM of Alcor Exchange. It runs as the `swap.alcor` contract on WAX, XPR Network, EOS and Telos, and works like Uniswap v3: liquidity providers choose a price range for their liquidity, and every pool has a fixed fee tier. In the app, swapping is at `alcor.exchange/v//swap` and liquidity is under the **Pool** tab at `alcor.exchange/v//swap/positions`. `` is `wax`, `xpr`, `vaulta` (EOS) or `telos`. # Introduction (/alcor-swap/introduction) Alcor Swap is a concentrated-liquidity AMM, modelled on Uniswap v3. It is deployed as the `swap.alcor` contract on WAX, XPR Network, EOS and Telos. ## Concentrated liquidity [#concentrated-liquidity] In a classic constant-product AMM, liquidity is spread over every price from zero to infinity. In Alcor Swap, a liquidity provider (LP) chooses a price range, and their liquidity is used only while the pool price is inside it: - Inside the range, the position holds both tokens and earns a share of the swap fees in proportion to its liquidity. - Below or above the range, the position holds only one of the two tokens and earns no fees until the price returns to the range. A narrower range puts the same capital to work more intensively, so it earns more fees per dollar while the price stays inside it. It also leaves the range sooner and sits fully in one token when it does. A full-range position (**Infinity** in the app) behaves like a classic AMM position. Because a position converts from one token to the other as the price crosses its range, a narrow range also works as a limit-style order. See [Ranges](/alcor-swap/ranges-everything-you-need-to-know). ## Fee tiers [#fee-tiers] Each pool is a pair of tokens plus a fee tier, so the same pair can have several pools. The fee is charged on every swap through the pool. | Fee tier | Suggested for | | --- | --- | | 0.01% | Stable pairs | | 0.05% | High-volume pairs | | 0.3% | Most pairs | | 1% | Exotic pairs | By default the whole swap fee goes to the pool's liquidity providers. The contract can direct a share of a pool's fee (1/3, 1/4 or 1/10) to the protocol. ## Positions [#positions] Every liquidity position belongs to one pool and has its own price range. Fees build up in the position until you collect them. You can add liquidity or remove it (unless the position is locked) at any time, but you cannot change a position's range: to move it, close the position and open a new one. Positions can also be: - staked in [farms](/alcor-farms-unlocking-defi-opportunities) to earn extra rewards; - [locked](/alcor-swap/locking-liquidity) until a date or permanently. ## Who can create pools [#who-can-create-pools] Anyone can create a pool for any two tokens at any fee tier, as long as a pool for that pair and fee tier does not exist yet. The creator sets the starting price. Anyone can also create tokens, so check a token before you trade it or provide liquidity for it. # Liquidity Provider FAQ (/alcor-swap/liquidity-provider-faq) ### What is a concentrated-liquidity AMM? [#what-is-a-concentrated-liquidity-amm] An AMM in which each liquidity provider chooses the price range their liquidity covers, instead of spreading it over all prices. Within that range the same capital gives deeper liquidity, so traders get less slippage and LPs earn more fees per dollar. See [Introduction](/alcor-swap/introduction). ### How do I earn as a liquidity provider? [#how-do-i-earn-as-a-liquidity-provider] A position earns a share of the swap fees of its pool while the price is inside its range, in proportion to its liquidity. If the pool has [farms](/alcor-farms-unlocking-defi-opportunities), staking the position earns farm rewards on top. ### Do I need to deposit equal values of both tokens? [#do-i-need-to-deposit-equal-values-of-both-tokens] No. The ratio depends on where the current price is within your range. A range centred on the current price takes roughly equal values. A range above or below the current price takes only one token. The app calculates the second amount for you. ### Which fee tier should I choose? [#which-fee-tier-should-i-choose] The fee tier belongs to the pool, not to your position: every swap through a 0.3% pool pays 0.3%, wherever the price is. Use the tier where the pair's trading happens. The new position form shows each tier's share of the pair's TVL. As a rule of thumb, 0.01% suits stable pairs, 0.05% high-volume pairs, 0.3% most pairs and 1% exotic or volatile pairs. ### Why choose a narrow range? [#why-choose-a-narrow-range] A narrow range earns more fees per dollar while the price stays inside it. It also leaves the range more easily, and then earns nothing until the price returns. A wide range earns less per dollar but stays active longer. ### What happens if the price leaves my range? [#what-happens-if-the-price-leaves-my-range] The position ends up holding 100% of one token: the one that lost value relative to the other. It stops earning fees until the price comes back into the range. You can leave it, or remove the liquidity and open a new position around the current price. ### Can I change the range of a position? [#can-i-change-the-range-of-a-position] No. Remove the liquidity and open a new position with the new range. ### What is impermanent loss? [#what-is-impermanent-loss] As the price moves, a position sells the rising token and buys the falling one. Compared with simply holding the two tokens, this can leave you with less value. The loss becomes permanent when you withdraw. A narrower range concentrates this effect as well as the fees. ### Can I withdraw at any time? [#can-i-withdraw-at-any-time] Yes, unless you [locked](/alcor-swap/locking-liquidity) the position. Removing liquidity also collects the position's fees. A token's issuer may have full control of the token contract. Withdrawals can fail because of the token contract, and a token can be used for a rug pull or other fraud. Anyone can create a token and a pool for it, so research a token before you provide liquidity for it. # Locking Liquidity (/alcor-swap/locking-liquidity) A locked position shows everyone that its liquidity cannot be pulled from the pool. Token teams use this, for example, to prove that the launch liquidity of a new token stays in place. There are two kinds of lock. Both are on the position's page (`alcor.exchange/v//swap/positions/`), below the price range, and only the owner sees them. ## Lock until a date [#lock-until-a-date] Click **Lock until a date** and pick 1W, 1M, 3M, 6M, 1Y or a custom date, then sign the transaction. This calls the contract's `lockpos` action. While the lock is active: - liquidity cannot be removed and the position cannot be transferred; - fees can still be collected, and the position can still be staked in farms and claim farm rewards. A lock can be extended (**Extend lock**) but never shortened. Once the date passes, the position works normally again. ## Lock permanently [#lock-permanently] Click **Lock liquidity permanently** and confirm. The position is transferred to `eosio.null`, an account nobody controls. This cannot be undone: from then on nobody can remove the liquidity, collect its fees or claim farm rewards for it. Unstake the position from all farms before you lock it permanently. The option is not available while the position is staked or time-locked. # Pool Page (/alcor-swap/pool-page) The **Pool** tab of the swap card opens your positions at `alcor.exchange/v//swap/positions`. The page has three tabs. ## Positions [#positions] - **Summary**: total value, PnL, APR (fees and farming), how much of your liquidity is in range, fees earned in the last 24 hours, and unclaimed fees. - **Position list** (cards or table): pair and fee tier, price range, token amounts, value, farm rewards, fees and pool share. Sort by value, fees or newest, or search by token. - **Claim All** collects the fees and farm rewards of all your positions in one transaction. - **New** opens the [new position form](/alcor-swap/providing-liquidity). ## Position page [#position-page] Click a position to open `alcor.exchange/v//swap/positions/`. From there you can: - add liquidity to the position, at the same range; - remove liquidity (25%, 50%, 75%, 100% or any share), which also collects its fees; - collect fees; - stake the position in the pool's farms, claim rewards and unstake; - [lock the position](/alcor-swap/locking-liquidity) until a date or permanently; - see the position's history of adds, removals and fee collections. ## Farms and Activity [#farms-and-activity] - **Farms** opens the [farms](/alcor-farms-unlocking-defi-opportunities) page. - **Activity** lists your liquidity history across all pools: adds, removals and fee collections, each linked to its transaction. # Providing Liquidity (/alcor-swap/providing-liquidity) New positions are opened at `alcor.exchange/v//swap/positions/new` (the **Pool** tab, then the button for a new position). `` is `wax`, `xpr`, `vaulta` (EOS) or `telos`. ## Steps [#steps] 1. **Select Pool**: pick the two tokens. 2. **Fee Tier**: pick 0.01%, 0.05%, 0.3% or 1%. Each tier shows its share of the pair's TVL, or **No pool** if that pool does not exist yet. See [fee tiers](/alcor-swap/introduction#fee-tiers). 3. **Set Starting Price** (new pools only): if you are the first to create this pool, enter its starting price. The app suggests a **Recommended price** you can click to use. 4. **Price range**: choose a preset or enter **Min Price** and **Max Price**, or drag the range on the chart. See [Ranges](/alcor-swap/ranges-everything-you-need-to-know). 5. **Deposit**: enter the amount of one token; the app calculates the other from the range and the current price. If the range is entirely above or below the current price, the position takes only one token. 6. **Stake into farm**: shown only when the pool has running [farms](/alcor-farms-unlocking-defi-opportunities). When it is ticked, the new position is staked in those farms in the same transaction. If you untick it, the position earns only swap fees, and you can stake it later from the position page. 7. Click **Add Liquidity** and sign the transaction. The new position appears on the [Pool page](/alcor-swap/pool-page). Anyone can create a token and a pool for it, and a token's issuer may control its contract. Withdrawals can fail because of the token contract, and a token can be used for a rug pull. Check a token before you provide liquidity for it. # Ranges (/alcor-swap/ranges-everything-you-need-to-know) Every Alcor Swap position has a price range: a **Min Price** and a **Max Price**. The position earns swap fees only while the pool price is inside its range. For the basics, see [Concentrated liquidity](/alcor-swap/introduction#concentrated-liquidity). ## Setting a range [#setting-a-range] The range is set while [opening a position](/alcor-swap/providing-liquidity): - **Presets** depend on the fee tier. **Infinity** is the full range. The others are set around the current price, for example ±1%, ±5%, ±10%, −5/+20% and −20/+5% in a 0.3% pool. Lower fee tiers offer narrower presets and the 1% tier offers wider ones. - **Min Price** and **Max Price** can be typed or stepped with the +/− buttons. - **Chart**: the range can be dragged on the liquidity chart. **Advanced** shows the pool's liquidity and price history; **Simple** is a basic range selector. The arrow button switches which token the prices are quoted in. At the minimum price the position is made up entirely of one token, and at the maximum price entirely of the other. The form shows which. A range cannot be edited later. To move it, remove the liquidity and open a new position. ## Range orders [#range-orders] A range placed entirely above or below the current price holds only one token. When the price moves into the range, that token is gradually swapped into the other one, and the swaps through your liquidity pay you fees. This works like a limit order that also earns fees. For example, WAX trades at 0.08 USDT. You add 10,000 WAX to a WAX/USDT position with a range of 0.10–0.20: - At 0.10 the position is 100% WAX. - Between 0.10 and 0.20 it is a mix of WAX and USDT. - At 0.20 and above it is 100% USDT: about 1,414 USDT plus the fees earned on the way. The average sale price of a range is the geometric mean of its bounds, here √(0.10 × 0.20) ≈ 0.1414. If the price falls back into the range, the USDT is swapped back into WAX. To keep the USDT, remove the liquidity once the price is above the range. # Referral / Custom Market Fee (/alcor-swap/referral-custom-market-fee) Any account can register as a "market" on the `swap.alcor` contract with its own fee. When a swap names that market, the contract charges the market fee on top of the pool fee and sends it to the market account. ## 1. Register your market [#1-register-your-market] Call the `regmarket` action of `swap.alcor`, signed by the market account itself: - `marketName`: the account that receives the fee. - `marketFee`: the fee in millionths (parts of 10^6). ``` 1000 = 0.1% 500 = 0.05% 10000 = 1% (maximum) ``` Calling `regmarket` again with the same account changes its fee. The market fee is charged in every pool the swap passes through, in that pool's input token, and is sent to the market account in the same transaction. ## 2. Send swaps through your market [#2-send-swaps-through-your-market] A swap names the market as the last field of its transfer memo. There are two ways to get it there. ### Swap widget [#swap-widget] Embed the [Swap Widget](/swap-widget) and add your market as the `market` query parameter: ```html ``` Use the domain of your chain: `wax.alcor.exchange`, `proton.alcor.exchange`, `eos.alcor.exchange` or `telos.alcor.exchange`. ### Your own interface [#your-own-interface] Build the swap transfer yourself and put the market account at the end of the memo. The transfer goes to `swap.alcor`: ``` ##### // fees.alcor is the market account that receives the fee swapexactin#401,1212#alcordexfund#5.3645 USDT@usdt.alcor#0#fees.alcor ``` The route and memo for a swap can be requested from the API: see [Swap API](/api/swap). The swap page at `alcor.exchange` does not read a `market` parameter, so a plain link to it does not earn a market fee. # Swap Page (/alcor-swap/swap-page) The swap page is at `alcor.exchange/v//swap`, where `` is `wax`, `xpr`, `vaulta` (EOS) or `telos`. ## Making a swap [#making-a-swap] 1. Connect your wallet. 2. Pick the token to sell in **Sell** and the token to get in **Buy**, then enter an amount in either field. If you type in **Buy**, the swap is calculated for that exact output. 3. Check the quote: **Expected Output**, **Price Impact** and **Min. Received** (the least you will get at your slippage setting). 4. Confirm and sign the transaction in your wallet. The swap executes in that transaction. Alcor finds the route for you. A swap can pass through several Alcor Swap pools, and part of it can be filled on Alcor's order book markets. ## Swap settings [#swap-settings] The settings menu on the swap card holds: - **Slippage %**: how far the result may fall below the quote before the transaction fails. Choose Auto, 0.5%, 1% or type your own value. - **Max Hops**: the most pools a route may pass through (1, 2 or 3). - **Recalculate On Price Change**: refresh the quote when the pools on the route change. - **Split Into Order Book**: allow part of the swap to be filled on order book markets. # Account (/api/account) History and positions of one account on the chain of the host you call. ## Spot trades [#spot-trades] Spot trades the account took part in, as buyer or seller, newest first. `GET https://wax.alcor.exchange/api/v2/account//deals` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | account | string | yes | Account name, in the path | | market | number | no | Only trades of this spot market id | | from | number | no | Range start, unix seconds. Used only together with `to` | | to | number | no | Range end, unix seconds | | limit | number | no | Number of trades. Default `500` | | skip | number | no | Trades to skip, for paging | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/account/alcordexfund/deals?limit=1" ``` ```json [ { "_id": "6ac07c9e48ec8ec3f10389bc", "market": 26, "type": "buymatch", "trx_id": "4cbcefed8b0608063fb2001bfc3527e7eee19bfa8c612a3df882524f42177e81", "unit_price": 0.2699, "ask": 1148.4228, "bid": 309.95930066, "asker": "jjrbg.wam", "bidder": "alcordexfund", "time": "2026-10-03T03:55:10.500Z" } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | _id | string | Trade id | | market | number | Spot market id | | type | string | `buymatch`: a buy order took the trade. `sellmatch`: a sell order took it | | trx_id | string | Transaction id | | unit_price | number | Trade price | | bidder | string | Account of the order that took the trade | | asker | string | Account of the resting order it matched | | bid | number | Amount the bidder paid | | ask | number | Amount the bidder received | | time | string | Trade time, ISO 8601 | ## Positions [#positions] Open AMM liquidity positions of the account, with their value and fees. `GET https://wax.alcor.exchange/api/v2/account//positions` **Example** ```shell curl https://wax.alcor.exchange/api/v2/account/alcordexfund/positions ``` ```json [ { "id": 152287, "owner": "alcordexfund", "pool": 12397, "tickLower": -100, "tickUpper": 100, "liquidity": "800386663698", "inRange": true, "amountA": "3763.075641 USDC", "amountB": "4220.481815 USDT", "feesA": "0.220932 USDC", "feesB": "0.369956 USDT", "totalValue": 7984.15, "totalFeesUSD": 0.59, "depositedUSDTotal": 7983.4609, "collectedFees": { "tokenA": 0, "tokenB": 0, "inUSD": 0, "lastCollectTime": null }, "pNl": 0.59, "closed": false, "lockedUntil": null, "isLocked": false } ] ``` The fields are those of [Pool positions](/api/swap#pool-positions). ## Position history [#position-history] Liquidity events of the account's positions (deposits, withdrawals and fee collections), newest first. `GET https://wax.alcor.exchange/api/v2/account//positions-history` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | account | string | yes | Account name, in the path | | limit | number | no | Number of events. Default `200` | | skip | number | no | Events to skip, for paging | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/account/alcordexfund/positions-history?limit=1" ``` ```json [ { "_id": "6acdedec428d9e14968e17b8", "id": 152287, "pool": 12397, "owner": "alcordexfund", "type": "burn", "tokenA": 918.880068, "tokenB": 1077.024205, "tokenAUSDPrice": 1, "tokenBUSDPrice": 1, "totalUSDValue": 1995.9043, "trx_id": "6fb2c3280f4cbdc1f5d799ca67916c89ab1ebde126af808d96f766addde1c75a", "time": "2026-10-13T08:38:04.000Z" } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | _id | string | Record id | | id | number | Position id | | pool | number | Pool id | | owner | string | Position owner | | type | string | `mint` (liquidity added), `burn` (liquidity removed) or `collect` (fees collected) | | tokenA, tokenB | number | Token amounts of the event | | tokenAUSDPrice, tokenBUSDPrice | number | USD prices of the tokens at the time | | totalUSDValue | number | Event value, USD | | trx_id | string | Transaction id | | time | string | Event time, ISO 8601 | ## Swap history [#swap-history] AMM swaps the account sent or received, newest first. `GET https://wax.alcor.exchange/api/v2/account//swap-history` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | account | string | yes | Account name, in the path | | limit | number | no | Number of swaps. Default `200` | | skip | number | no | Swaps to skip, for paging | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/account/alcordexfund/swap-history?limit=1" ``` ```json [ { "_id": "6acd57da428d9e14961928bf", "pool": 12501, "trx_id": "71d2fced1fe31e5b4219e4abe79a2cc4a4161a0ae8ea87dc9b73901b39a85195", "sender": "alcordexfund", "sqrtPriceX64": "138046174607188499", "totalUSDVolume": 5.5362025, "tokenA": 1000, "tokenB": -5.600885, "time": "2026-10-12T21:57:41.000Z" } ] ``` The fields are those of [Pool swaps](/api/swap#pool-swaps). # Analytics (v3) (/api/analytics) The analytics API behind Alcor's token, pool and market pages. Lists are paged, sortable and computed over a time window. All values are in USD. Common parameters: | Name | Description | | --- | --- | | window | `24h`, `7d`, `30d`, `90d` or `all`. Default `30d` | | page | Page number, from `1`. Default `1` | | limit | Items per page. Default `50`, maximum `500` | | order | `asc` or `desc`. Default `desc` | | hide_scam | `true` leaves out items with a token on the scam lists | Every answer carries `meta`: `chain`, `ts` (server time), `window`, `baseToken` (the system token) and `usdToken`. Paged lists add `page`, `limit` and `total`. ## Overview [#overview] Exchange totals for the window, their charts, and the top 10 pools, tokens and spot markets. `GET https://wax.alcor.exchange/api/v3/analytics/overview` **Parameters**: `window`, and `include=incentives` to add farm rewards to the top pools. **Example** ```shell curl "https://wax.alcor.exchange/api/v3/analytics/overview?window=24h" ``` ```json { "meta": { "chain": "wax", "ts": "2026-10-15T12:46:52.967Z", "window": "24h", "baseToken": "wax-eosio.token", "usdToken": "usdt-usdt.alcor" }, "stats": { "tvl": 2207753.66, "volume": 22724.75, "fees": 66.77, "swapVolume": 21791.28, "spotVolume": 933.46, "swapFees": 49.78, "spotFees": 16.99, "swapTx": 152064, "spotTx": 1157, "dauAvg": 426.52, "poolsTotal": 12783, "spotPairsTotal": 978 }, "charts": { "tvl": [{ "t": "2026-10-14T12:00:00.000Z", "v": 2202926.18 }], "volume": [], "...": "" }, "topPools": [], "topTokens": [], "topSpotPairs": [] } ``` `charts` holds `tvl`, `volume`, `fees`, `swapVolume`, `spotVolume`, `swapFees` and `spotFees` as `[{t, v}]` series, and `items` with all of them per point. The top lists hold items as in [Tokens](#tokens), [Pools](#pools) and [Spot pairs](#spot-pairs). ## Tokens [#tokens] Tokens with price, liquidity, volume and score. `GET https://wax.alcor.exchange/api/v3/analytics/tokens` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | sort | string | no | `score` (default), `volume`, `tvl`, `locked`, `holders`, `age`, `tx` or `price` | | search | string | no | Match on symbol, contract or token id | | window, page, limit, order | | no | See above | **Example** ```shell curl "https://wax.alcor.exchange/api/v3/analytics/tokens?sort=volume&limit=1" ``` ```json { "meta": { "chain": "wax", "window": "30d", "...": "" }, "items": [ { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "name": null, "decimals": 4, "logo": "https://wax.alcor.exchange/api/v2/tokens/tlm-alien.worlds/logo", "price": { "usd": 0.00123483, "change24h": -0.16 }, "liquidity": { "tvl": 15099.21, "locked": { "amount": 24709.4665, "usd": 30.51, "positions": 6, "share": 0.2, "nextUnlockAt": 1792707511, "lastUnlockAt": 1820464659 } }, "volume": { "swap": 57278.54, "spot": 12216.18, "total": 69494.73 }, "pairs": { "pools": 256, "spots": 12 }, "tx": { "swap": 226964, "spot": 4448, "total": 231412 }, "holders": { "count": 2550784, "change1h": -2, "change6h": -2, "change24h": 22, "truncated": false }, "createdAt": "2020-10-18T20:11:26.000Z", "scores": { "total": 93 } } ], "page": 1, "limit": 1, "total": 2103 } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id, symbol, contract, decimals | | The token | | name, logo | string | Display name (or `null`) and logo URL | | price.usd, price.change24h | number | USD price and 24-hour change, percent | | liquidity.tvl | number | Value of the token held in AMM pools | | liquidity.locked | object | Liquidity in locked AMM positions: `amount`, `usd`, `positions`, `share` (percent of `tvl`), `nextUnlockAt` and `lastUnlockAt` (unix seconds) | | volume | object | Volume over the window: `swap`, `spot`, `total` | | pairs | object | Number of AMM pools (`pools`) and spot markets (`spots`) trading the token | | tx | object | Trades over the window: `swap`, `spot`, `total` | | holders | object | Holder count and its change | | createdAt | string | When the token was first seen | | scores.total | number | Token score, see [Token score](/api/tokens#token-score) | ## Token [#token] One token, with its pools and spot markets. `GET https://wax.alcor.exchange/api/v3/analytics/tokens/` **Parameters**: `window`, `hide_scam`. ```shell curl https://wax.alcor.exchange/api/v3/analytics/tokens/tlm-alien.worlds ``` Answers `{ meta, token, pools, spotPairs }`. `token` has the fields of [Tokens](#tokens), plus `fundamental` (project name, website, description, tags and socials, or `null`) and `scores.details` (the full [Token score](/api/tokens#token-score)). `pools` and `spotPairs` are as in [Pools](#pools) and [Spot pairs](#spot-pairs). ## Pools [#pools] AMM pools with TVL, volume and APR. `GET https://wax.alcor.exchange/api/v3/analytics/pools` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | sort | string | no | `volume` (default), `tvl` or `apr` | | search | string | no | Token symbol, contract or id. `A/B` or two words match a pair | | account | string | no | Only pools where this account holds an open position | | include | string | no | `incentives` adds farm rewards to each pool and sorts `apr` by total APR | | window, page, limit, order, hide_scam | | no | See above | **Example** ```shell curl "https://wax.alcor.exchange/api/v3/analytics/pools?sort=tvl&limit=1" ``` ```json { "meta": { "chain": "wax", "window": "30d", "...": "" }, "items": [ { "id": 0, "fee": 3000, "tokenA": { "contract": "alien.worlds", "decimals": 4, "symbol": "TLM", "id": "tlm-alien.worlds", "quantity": 3922224.122 }, "tokenB": { "contract": "eosio.token", "decimals": 8, "symbol": "WAX", "id": "wax-eosio.token", "quantity": 897629.65344264 }, "price": { "aPerB": 0.250077, "bPerA": 3.99877, "change24h": -0.16 }, "liquidity": { "tvl": 9275.61 }, "volume": { "usd": 57526.8 }, "apr": { "periodDays": 7, "fee": 8.84, "farm": null, "total": 8.84 }, "tx": { "swaps": null } } ], "page": 1, "limit": 1, "total": 12786 } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id | number | Pool id | | fee | number | Swap fee in hundredths of a basis point: `3000` is 0.3% | | tokenA, tokenB | object | The tokens, with `quantity` held by the pool | | price.aPerB, price.bPerA | number | Price of token A in token B, and the reverse | | price.change24h | number | 24-hour price change, percent | | liquidity.tvl | number | Pool TVL | | volume.usd | number | Volume over the window | | apr | object | Annualized APR over the last `periodDays` days, percent: from swap fees (`fee`), farm rewards (`farm`) and both (`total`) | | tx.swaps | number | Swaps over the window. In the list, only with `include=tx` | ## Pool [#pool] One pool, with the fields of [Pools](#pools) and its swap count. `GET https://wax.alcor.exchange/api/v3/analytics/pools/` **Parameters**: `window`; `include=incentives` with `incentives=active|finished|all` (default `active`) to add farms. ```shell curl https://wax.alcor.exchange/api/v3/analytics/pools/0 ``` Answers `{ meta, pool }`. ## Spot pairs [#spot-pairs] Spot order book markets with price, spread, volume and depth. `GET https://wax.alcor.exchange/api/v3/analytics/spot-pairs` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | sort | string | no | `volume` (default) or `price` | | window, page, limit, order, hide_scam | | no | See above | **Example** ```shell curl "https://wax.alcor.exchange/api/v3/analytics/spot-pairs?limit=1" ``` ```json { "meta": { "chain": "wax", "window": "30d", "...": "" }, "items": [ { "id": 26, "base": { "id": "tlm-alien.worlds", "contract": "alien.worlds", "symbol": { "name": "TLM", "precision": 4 }, "str": "TLM@alien.worlds" }, "quote": { "id": "wax-eosio.token", "contract": "eosio.token", "symbol": { "name": "WAX", "precision": 8 }, "str": "WAX@eosio.token" }, "price": { "last": 0.247012, "change24h": -1.69 }, "spread": 1.61, "volume": { "usd": 12215.32 }, "orders": { "bidDepthUsd": 2016.76, "askDepthUsd": 1302.48 }, "tx": { "matches": 3933 } } ], "page": 1, "limit": 1, "total": 978 } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id | number | Spot market id | | base, quote | object | The tokens. Prices are in quote per base | | price.last, price.change24h | number | Last trade price and 24-hour change, percent | | spread | number | Best ask minus best bid, as a percent of the last price | | volume.usd | number | Volume over the window | | orders | object | USD value of the orders near the current price, per side | | tx.matches | number | Trades over the window | `GET https://wax.alcor.exchange/api/v3/analytics/spot-pairs/` answers one market as `{ meta, market }`. ## Global charts [#global-charts] Exchange-wide TVL, volume and fees as time series. `GET https://wax.alcor.exchange/api/v3/analytics/global/charts` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | window | string | no | See above. Default `30d` | | resolution | string | no | Point spacing: `1h`, `4h`, `1d` or `1w`. Default `1d` | **Example** ```shell curl "https://wax.alcor.exchange/api/v3/analytics/global/charts?window=24h&resolution=4h" ``` ```json { "meta": { "chain": "wax", "window": "24h", "...": "" }, "charts": { "tvl": [{ "t": "2026-10-14T12:00:00.000Z", "v": 2202926.18 }], "volume": [{ "t": "2026-10-14T12:00:00.000Z", "v": 2220.85 }], "...": "" }, "items": [ { "t": "2026-10-14T12:00:00.000Z", "tvl": 2202926.18, "volume": 2220.85, "fees": 3.67, "swapVolume": 2192.22, "spotVolume": 28.62, "swapFees": 3.5, "spotFees": 0.17 } ] } ``` `charts` holds `tvl`, `volume`, `fees`, `swapVolume`, `spotVolume`, `swapFees` and `spotFees` as `[{t, v}]` series; `items` holds the same values per point. `t` is the point's start time. Every bucket of the window is present, oldest first: TVL carries over from the last snapshot into a quiet bucket, while volume and fees are 0 there. The window starts on a bucket boundary, so the first point is a whole bucket and the last one is the bucket in progress. Weekly buckets start on Monday 00:00 UTC. A request for more than 5000 points (such as `window=all&resolution=1h`) answers `400`. # Bridge (/api/bridge) The Alcor bridge moves tokens between Ethereum, BNB Smart Chain, Polygon, Telos, WAX, XPR Network, Vaulta, Sui, NEAR and TON. Telos is the hub: every route runs between Telos and one other chain, and a transfer between two other chains passes through Telos on its own — the user signs once. There are five ways to bring it into your project: | Way | Best when | Your code | | --- | --- | --- | | **[Deposit addresses](#deposit-addresses)** | Your users fund an account from other chains, often straight from an exchange | One API call per user | | **[Deposit link](#deposit-link)** | You send users to the Alcor bridge page with the transfer filled in | None | | **[Deposit widget](#deposit-widget)** | The bridge opens over your own page | A script tag | | **[Bridge API](#bridge-api)** | You show routes, limits and transfer status yourself | HTTP reads | | **[Bridge contracts](#bridge-contracts)** | A bot, wallet or exchange signs the transactions itself | Contract calls | This page explains each way. The complete reference — every endpoint and field, every chain's transaction, written to be handed to a developer or an AI agent — is served by the bridge itself: /docs (the API), /docs/bot (signing on every chain) and /openapi.yaml. Supported assets: USDC, USDT, ETH, BNB, POL, WAX, XPR, A (Vaulta), EASY, SUI, NEAR and GRAM (TON). Which pairs are open right now, with minimums and maximums, is always [Routes](#bridge-api). ## Deposit addresses [#deposit-addresses] Each of your users gets an address of their own. Whatever they send there — from a wallet or straight from an exchange, the native coin included — reaches the account you named on Telos, WAX, XPR Network or Vaulta. The user needs no wallet connection, no signature and no gas. The address is permanent and works again and again. ```text user sends USDC on BNB Smart Chain to their address → forwarded into the bridge (≈15 s) ← the gas, out of the deposit, at most 1% → Telos (≈30 s) → paid out on WAX to your account, with your memo (≈2 min) ``` ### Get an address [#get-an-address] ```shell curl -X POST https://telos.alcor.exchange/api/bridge/v1/deposit-addresses \ -H 'content-type: application/json' \ -d '{ "chain": "wax", "to": "yourproject", "memo": "user-42" }' ``` | Field | Description | | --- | --- | | chain | Where it is paid out: `telos`, `wax`, `xpr` or `vaulta` | | to | The account paid. It must exist | | memo | Optional. The memo every payout carries, so one account of yours tells its users apart. 1–64 characters of `A-Z a-z 0-9 . _ - :`. Another memo is another address | The same request always answers the same address, so call it whenever you show one. The answer has: * `address` — the user's address on **Ethereum, BNB Smart Chain and Polygon** (one address on all three); * `ton.address`, `near.address`, `sui.address` — their addresses on **TON, NEAR and Sui**. Show the NEAR one only while `near.ready` is true; * per network, the `tokens` it takes, each with `min` and `max` in the token's raw units. Show only these. A new address costs a registration: 20 an hour from one client. If you register from your server for many users, ask us to raise it. ### Show it to the user [#show-it-to-the-user] * The address, a copy button and a QR of the **plain** address (exchanges scan plain addresses). * The networks it works on, by name, and plainly: **sending on any other network (Arbitrum, Base, Tron…) may lose the money.** * Per network, the tokens and the minimum. Less waits at the address until more arrives. * "You can withdraw straight from an exchange to this address." ### What it costs [#what-it-costs] There is no bridge fee. The only cost is the gas to forward the deposit into the bridge, taken out of the deposit and **never more than 1%** of it. The payout on Telos, WAX, XPR and Vaulta is on us. `GET /v1/fees` shows the current forward cost per network and token, and `forwardsFrom`, the least worth sending now — it matters on Ethereum, where gas is dear. ### How it arrives [#how-it-arrives] On WAX, XPR and Vaulta: a `transfer` from `bridge.alcor` with the memo exactly as you set it — `wrap.alcor` for USDC, USDT, ETH, BNB and POL, the chain's own token contract for its coin. On Telos the memo is `|:`; read it up to the first `|`. If to is a contract: check that the transfer's first receiver is the token contract you expect and that it comes from bridge.alcor — anyone can notify you of a fake token. And never fail our transfer: a refused payout goes back to the deposit address and waits there for support. Accept it and settle with your user your own way. ### Follow it and handle problems [#follow-it-and-handle-problems] * `GET /v1/deposit-addresses/
` shows what has arrived and is not forwarded yet (`pending`), the last forwards and anything that came back (`held`). Poll it every 10 s or so while you wait. * After the forward it is an ordinary transfer: [Transfer status](#transfer-status) with `party=`. * Nothing is ever sent back to the sender — an exchange would not credit it. What cannot be delivered waits at the deposit address for support: a token the address does not take, a payout your contract refused. The full reference — every field, the address computed on your side to check the API's answer, addresses that swap into another token — is the *Deposit addresses* section of [/docs](https://telos.alcor.exchange/api/bridge/docs). ## Deposit link [#deposit-link] ```text https://alcor.exchange/v/wax/bridge?from=ethereum&to=wax&recipient=alice.wam&token=USDC&amount=50&partner=mygame&return_url=https://mygame.io/play ``` A plain URL to the bridge page with the transfer already filled in. No code is needed on your side. | Parameter | Example | Description | | --- | --- | --- | | from | `ethereum` | Chain to start on. The user can still change it. | | to | `wax` | Chain the tokens land on. | | recipient | `alice.wam` | Receiving account or address, prefilled. The user can edit it on this page. | | token | `USDC` | Asset, by the symbol the bridge lists. | | amount | `50` | Prefilled amount, in token units. | | partner | `mygame` | Your id, so the deposits you bring are attributed to you. | | return_url | `https://mygame.io/play` | Shows a "← Back to mygame.io" link. `https` only (`http` is allowed on `localhost`). | Chains are `ethereum`, `bsc`, `polygon`, `telos`, `wax`, `xpr`, `vaulta`, `sui`, `near` and `ton`. All parameters are optional. A malformed value is ignored rather than guessed at. ## Deposit widget [#deposit-widget] ```javascript // document.getElementById('deposit').onclick = function () { AlcorBridge.open({ to: 'wax', recipient: 'alice.wam', // fixed: the user cannot change it token: 'USDC', amount: '50', partner: 'mygame', onSent: function (e) { console.log('on its way', e.transactions) }, onFinished: function (e) { if (e.outcome === 'delivered') refreshBalance() }, onClose: function () {}, }) } ``` ```html ``` Load `https://alcor.exchange/sdk/bridge/v1.js` and call one of its functions. The script is tiny and has no dependencies. The path is versioned: `v1.js` keeps its options and events for as long as anyone uses it. ### Functions [#functions] | Function | Shows | Returns | | --- | --- | --- | | `AlcorBridge.open(options)` | Modal over your page | `{ close() }` | | `AlcorBridge.popup(options)` | Separate window. Call it from a click handler. | `{ close() }`, or `null` if the popup was blocked | | `AlcorBridge.mount(element, options)` | Inline iframe that grows with its content | `{ destroy() }` | | `AlcorBridge.url(options)` | Nothing. Returns the widget address for your own iframe or link. | `string` | Browser extension wallets (MetaMask, Rabby) and WalletConnect work in all modes. In the popup the user's existing Alcor session and wallet connection carry over. ### Options [#options] | Option | Required | Description | | --- | --- | --- | | to | true | Chain the tokens land on, as in the [Deposit link](#deposit-link). Into Telos, WAX, XPR and Vaulta the bridge pays out by itself. Into an EVM chain, Sui, NEAR or TON the last step is a release on that chain, which the widget shows when its turn comes. | | recipient | false | Receiving account. When given, it is **fixed** in the widget. For WAX, the widget checks that the account exists before anything is signed. | | from | false | Chain to start on. | | token | false | Asset symbol, e.g. `USDC`. | | amount | false | Prefilled amount, in token units. | | partner | false | Your id, for attribution. | | origin | false | Where the widget is served from. Defaults to the origin of the script itself. | | onReady, onSent, onFailed, onFinished, onClose | false | Event callbacks, see below. | ### Events [#events] `onSent` receives: ```json { "direction": "hop", "from_chain": "ethereum", "to_chain": "wax", "token": "USDC", "amount": "50", "sender": "0x285202c8db763db06ab42e0705104cb7919ef95e", "recipient": "alice.wam", "partner": "mygame", "embed": "iframe", "transactions": [ { "chain": "Ethereum", "label": "Send", "ref": "0x0af8…2917", "url": "https://etherscan.io/tx/0x0af8…2917" } ] } ``` `onFinished` receives: ```json { "key": "d:1:12", "outcome": "delivered", "token": "USDC", "amount": "50", "transactions": [ … ] } ``` | Callback | When | Data | | --- | --- | --- | | onReady | The widget has loaded and is prefilled | `{ to, recipient }` | | onSent | The user signed and the transfer is on its way | Transfer details and the first transaction | | onFailed | The transfer could not be started, e.g. rejected in the wallet | Transfer details plus `errorCode`, `error` | | onFinished | The transfer reached its end | `{ key, outcome, token, amount, transactions }` | | onClose | The user closed the widget | `{}` | `outcome` is `delivered`, or `returned` if the destination refused the tokens and they went back. `key` identifies the transfer in [Transfer status](#transfer-status). Credit nothing in your app on onSent. Wait for outcome: "delivered", or better, check the balance on chain. onFinished only fires while the widget is open. A transfer the user walked away from still completes, and you can follow it with Transfer status. ### Messages [#messages] If you embed the iframe yourself, listen for `postMessage` events from `https://alcor.exchange`: `{ source: "alcor-bridge", version: 1, type, data }` | Type | Data | | --- | --- | | ready, sent, failed, finished, close | Same as the callbacks above | | resize | `{ height }`, the content height in pixels, so you can size the iframe | Add `mode=inline` to the widget URL to hide its close button. Everything in the messages is public on-chain data. ## Bridge API [#bridge-api] ```text https://telos.alcor.exchange/api/bridge/v1/ ``` Read-only HTTP, no key, open to any origin (CORS `*`). Chains are named by id: `mainnet` (Ethereum), `bsc`, `polygon`, `telos`, `wax`, `xpr`, `vaulta`, `sui`, `near`, `ton`. Amounts are integers in the token's smallest unit: divide by `10^precision`. Every field of every answer is in [/docs](https://telos.alcor.exchange/api/bridge/docs). | Endpoint | What it answers | | --- | --- | | `GET /v1/routes` | Every pair of chains each asset can travel between now: `open`, `min`, `max`, and `how` to start it | | `GET /v1/chains` | Each chain: contracts, limits, whether each direction is open, and `timing` — how long a transfer takes, measured on recent ones | | `GET /v1/hops/`, `GET /v1/hops?party=…` | A transfer between two chains through Telos, as one journey | | `GET /v1/transfers/`, `GET /v1/transfers?party=…` | Each leg on its own | | `GET /v1/stream?party=…` | The same as events, pushed as they happen (server-sent events) | | `GET /v1/swap/plan` | Any token on one chain to any token on another, swaps included, ready to sign | | `GET /v1/fees` | What a deposit address forward and a delivered withdrawal cost now | ### Transfer status [#transfer-status] ```shell curl https://telos.alcor.exchange/api/bridge/v1/hops/d:1:12 curl "https://telos.alcor.exchange/api/bridge/v1/hops?party=alice.wam" ``` ```json { "key": "d:1:12", "status": "delivered", "progress": { "stage": "Arrived on WAX", "percent": 100, "etaSeconds": null }, "from": { "chain": "mainnet", "address": "0x285202c8db763db06ab42e0705104cb7919ef95e" }, "to": { "chain": "wax", "recipient": "alice.wam" }, "back": { "chain": "mainnet", "recipient": "0x285202c8db763db06ab42e0705104cb7919ef95e" }, "memo": null, "deposit": { "symbol": "USDC", "amount": "50000000", "precision": 6, "src_tx": "0x0af8…2917" } } ``` A transfer between two chains by its key (the `key` from the widget's `onFinished`), or every one an account or address took part in, newest first. `progress.stage` is a sentence to show as it is. | Status | Meaning | | --- | --- | | arriving | On its way to Telos | | sending | Passed through Telos, on its way to the destination | | delivered | Paid out to the recipient | | bounced | Refused on the way, sent back | | returning | Coming back to the sender | | returned | Back with the sender | ## Bridge contracts [#bridge-contracts] Everything the page and the widget do is a public contract call. Bots, wallets and exchanges can make the same calls themselves: no API key, no allowlist, no Alcor page involved. The guide with every chain's transaction, written for a bot or an AI agent, is [/docs/bot](https://telos.alcor.exchange/api/bridge/docs/bot). How the bridge works: * **Telos holds the ledger**, `bridge.alcor`. Every route runs between Telos and one other chain. Two other chains are joined by the `hop.alcor` contract on Telos. * **A deposit** is locked in the vault on its chain, proved on Telos by the bridge's relayer and paid to the recipient there. You send one transaction. * **A withdrawal** is burned on Telos and proved on the destination chain. Into WAX, XPR and Vaulta the relayer pays it out. Into an EVM chain, Sui, NEAR or TON someone sends the proof there: the recipient, or our courier when the withdrawal pays it a small fee. * **Keys** name each leg: `d::` for a deposit, `w:` for a withdrawal. Every endpoint of the [Bridge API](#bridge-api) takes them. Do not hardcode addresses in a bot. Read them from GET /v1/chains (sources[].contracts) and GET /v1/routes (how). They are listed below for orientation, as of 2026-11-12. ### Addresses [#addresses] | Chain | Contract | Address | What it is | | --- | --- | --- | --- | | Ethereum | `AlcorVault` | `0x3e447d533321ad6a8412f97034ac295a9ff8d858` | Deposits in, withdrawals paid out | | Ethereum | `AlcorWithdrawals` | `0xb0a50dd6d0be3bfc089e0f92fa4605bb495584cd` | Verifies a withdrawal proof and tells the vault to pay | | BSC | `AlcorVault`, `AlcorWithdrawals` | `0x53f18eaa8bf8099b5ba21bb7e11ed311b677690e`, `0xef672a458d71d170edd2f2735da2dd5ebc8278b8` | The same contracts. BNB is native | | Polygon | `AlcorVault`, `AlcorWithdrawals` | `0x15bbd21148f98c4daeb30450eb05666f7859993d`, `0x46b078ae68fe63b647879d9267c5233fb2c2a532` | The same contracts. POL is native | | Telos | `bridge.alcor` | | The ledger: credits deposits, opens withdrawals | | Telos | `wrap.alcor` | | Every bridged token on Telos | | Telos | `hop.alcor` | | Carries a transfer between two chains through Telos | | WAX, XPR, Vaulta | `bridge.alcor` | | The vault: holds the chain's coin, mints and burns the mirrors | | WAX, XPR, Vaulta | `wrap.alcor` | | Mirror tokens: USDC, USDT, ETH, and BNB, POL where listed | | Sui | vault | `0x9ed73de17914b0c146f0699774e014c4b529b55a65fedc9f4a5a521152ec682a` | Package `0x959e269b63de523d759e6b0ea57a963207f7aab07cfc28d4623daf557f80655c` | | NEAR | vault | `alcor-bridge.near` | | | TON | vault | `0:35f5af9bc4e525499c8930a24cdb7c5f2eea36c5bdc0a48846dd03d8509075c7` | | On an EVM chain the native coin is token `0x0000000000000000000000000000000000000000`. ### Domains and units [#domains-and-units] | Chain | Domain | | --- | --- | | Ethereum | `1` | | BSC | `56` | | Polygon | `137` | | WAX | `1181148696416462999` | | XPR Network | `4057084141687023600` | | Vaulta | `12439917377594391589` | | Sui | `3856007665771390095` | | NEAR | `14338890689662875897` | | TON | `1703391080095596199` | The domain names the far chain in every memo and key: an EVM chain id, or for the others the first 8 bytes of the chain's id. It is a decimal string in the API: most are larger than a JSON number holds exactly. **Amounts.** The ledger counts in Telos units (the token's precision on Telos). On an EVM chain `amount = canonical × scale`: `scale` is `1` for USDC and USDT and `10^10` for ETH, BNB and POL (18 decimals there, 8 on Telos). A remainder below `scale` is not taken. **Telos accounts on EVM.** `telosTo` is an Antelope account name packed into a `uint64`, the standard Antelope encoding. With [wharfkit](https://wharfkit.com): `BigInt(Name.from('hop.alcor').value.toString())`. ### Deposit from an EVM chain [#deposit-from-an-evm-chain] ```javascript import { Contract, toUtf8Bytes, hexlify } from 'ethers' // ethers v6 import { Name } from '@wharfkit/antelope' const API = 'https://telos.alcor.exchange/api/bridge/v1' const vaultAbi = [ 'function deposit(address token, uint256 amount, uint64 telosTo, address refundTo, uint64 fillFee, uint64 filler, bytes memo)', 'function depositNative(uint64 telosTo, address refundTo, uint64 fillFee, uint64 filler, bytes memo) payable', ] const { sources } = await (await fetch(`${API}/chains`)).json() const vault = new Contract(sources.find(s => s.id === 'mainnet').contracts.vault, vaultAbi, signer) const telosName = n => BigInt(Name.from(n).value.toString()) const me = await signer.getAddress() // ETH to the WAX account alice.wam, back to me if WAX never pays const memo = hexlify(toUtf8Bytes(`1181148696416462999:alice.wam|1:${me}`)) await vault.depositNative(telosName('hop.alcor'), me, 0, 0, memo, { value: 10n ** 16n }) // 50 USDC to the Telos account alice (approve the vault first) const USDC = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' await vault.deposit(USDC, 50_000000n, telosName('alice'), me, 0, 0, '0x') ``` | Parameter | Type | Description | | --- | --- | --- | | token | address | ERC-20 address from [Routes](#bridge-api) (`how.deposit.token`) | | amount | uint256 | Raw token units | | telosTo | uint64 | Who receives on Telos: an account, or `hop.alcor` to go on to another chain | | refundTo | address | Where the deposit goes back if it cannot be delivered. Must not be zero | | fillFee, filler | uint64 | Reserved. Pass `0` | | memo | bytes | Up to 256 bytes, see below | **Where it lands** depends on `telosTo` and `memo`: * **A Telos account, no memo**: paid to it on Telos, nothing to collect. * **A Telos account or contract, with a memo**: delivered to it as a `wrap.alcor` transfer carrying that memo. This is how a deposit pays a contract. * **Another chain**: `telosTo = hop.alcor`, memo `:|:` — where it goes, then where it comes back if it is never paid there. On WAX, XPR and Vaulta the tokens arrive by themselves; check first that the account exists. USDT on Ethereum refuses to change a non-zero allowance: set it to `0` first. A refused deposit reverts with a custom error: `DepositsPaused`, `AssetDisabled`, `BelowMinimum(minDeposit)`, `CapExceeded`, `AmountTooSmall`, `MemoTooLong`, `ZeroAccount`, `ZeroRefundAddress`, `UseDepositNative`. The `Deposit` event gives the key: `d::`. Deposits from Sui, NEAR and TON are one call from the user's wallet there; each is in [/docs](https://telos.alcor.exchange/api/bridge/docs). ### Deposit from WAX, XPR or Vaulta [#deposit-from-wax-xpr-or-vaulta] ```shell # 100 USDC from WAX to the Telos account alice cleos -u https://wax.greymass.com push action wrap.alcor transfer \ '["bob.wam", "bridge.alcor", "100.000000 USDC", "alice"]' -p bob.wam # 100 USDC from WAX to an address on BNB Smart Chain, delivered by the courier cleos -u https://wax.greymass.com push action wrap.alcor transfer \ '["bob.wam", "bridge.alcor", "100.000000 USDC", "hop.alcor:56:0x285202c8db763db06ab42e0705104cb7919ef95e:|1181148696416462999:bob.wam"]' -p bob.wam ``` A plain transfer to `bridge.alcor` on that chain. The token is the route's `antelopeToken` in `GET /v1/chains`. The memo says where it goes: * ``: paid to it on Telos. * `:`: delivered to that account as a transfer with `` as its memo. * `hop.alcor::[:]|:`: on to another chain. With `` — the `withdrawal` of `GET /v1/fees` for that chain and token — our courier delivers it on an EVM chain, Sui, NEAR or TON; without it the recipient releases it there. The second half is where it comes back if it is never delivered. ### Withdraw from Telos [#withdraw-from-telos] ```shell # 50 USDT from Telos to an Ethereum address cleos -u https://mainnet.telos.net push action wrap.alcor transfer \ '["alice", "bridge.alcor", "50.000000 USDT", "1:0x285202c8db763db06ab42e0705104cb7919ef95e"]' -p alice # 10 WAX from Telos to the WAX account bob.wam cleos -u https://mainnet.telos.net push action wrap.alcor transfer \ '["alice", "bridge.alcor", "10.00000000 WAX", "1181148696416462999:bob.wam"]' -p alice ``` A transfer of a `wrap.alcor` token to `bridge.alcor` on Telos, with the destination in the memo: `:[:[:]]`. * **Into WAX, XPR or Vaulta** the relayer pays it out in about two minutes. A memo after a fee of `0` — an exchange's deposit memo — is the payout's memo. * **Into an EVM chain, Sui, NEAR or TON** with a `fee` from `GET /v1/fees` our courier delivers it; without one it waits for the recipient to release it there (next section). To NEAR the memo field is the account id; to TON it is sent as a comment. * The amount must not exceed `withdrawableNow` of the route in `GET /v1/chains`: each vault lets only so much out per day. The withdrawal id is in the inline `bridge.alcor::wdlog` action of your transaction. The key is `w:`. ### Release on an EVM chain [#release-on-an-evm-chain] ```javascript import { Contract } from 'ethers' const withdrawalsAbi = [ 'function release((uint64 id, uint64 domain, address token, address recipient, uint64 amount, uint64 deadline, uint64 fee, bytes memo, uint64 recvSequence, bytes32 witness, bytes32[] actionSiblings, uint256 actionPath, bytes32 actionMroot, uint32 majorVersion, uint32 minorVersion, uint32 blockNum, uint32 timestamp, uint32 parentTimestamp, bytes32 finalityDigest, bytes32[] treeSiblings, uint256 treePath, bytes32 finalityMroot) p)', 'function submitAndRelease((uint32 majorVersion, uint32 minorVersion, uint32 activeGeneration, uint32 lastPendingGeneration, bytes32 finalityMroot, bytes32 lastPendingPolicyDigest, uint32 lastPendingPolicyStart, bytes32 reversibleBlocksMroot, uint32 qcClaimBlockNum, bytes32 qcClaimFinalityDigest, uint32 qcClaimTimestamp, uint32 timestamp, bytes32 baseDigest) f, bytes bits, bytes signature, bytes32[] policyKeys, (bytes policy, bytes bits, bytes signature) pending, (uint64 id, uint64 domain, address token, address recipient, uint64 amount, uint64 deadline, uint64 fee, bytes memo, uint64 recvSequence, bytes32 witness, bytes32[] actionSiblings, uint256 actionPath, bytes32 actionMroot, uint32 majorVersion, uint32 minorVersion, uint32 blockNum, uint32 timestamp, uint32 parentTimestamp, bytes32 finalityDigest, bytes32[] treeSiblings, uint256 treePath, bytes32 finalityMroot) p)', ] const p = await (await fetch(`${API}/proofs/w:${id}`)).json() // 404 until the proof exists if (p.track === 'light') { // a root covering this burn is already trusted: ~145–180k gas await new Contract(p.light.releaseTo, withdrawalsAbi, signer).release(p.light.release) } else { // the root is submitted in the same transaction: ~2.6M gas const s = p.hard.submitRoot await new Contract(p.hard.releaseTo, withdrawalsAbi, signer) .submitAndRelease(s.finality, s.bits, s.signature, s.policyKeys, s.pending, p.hard.release) } ``` Anyone may send the proof: every field is checked against a root signed by Telos finalizers, and the tokens go only to the recipient the burn named. 1. Wait until `GET /v1/transfers/w:` shows `hasProof: true`, about a minute after the burn. 2. Fetch `GET /v1/proofs/w:` and pass its objects through unchanged. 3. Send `release` on the `light` track or `submitAndRelease` on the `hard` track. Past the `deadline` (about a week after the burn) `release` reverts with `PastDeadline`; send the same body to `expire` (or `submitAndExpire`) and the tokens come back on Telos. A release over the vault's daily allowance reverts with `OutflowLimited` and works once it refills. A withdrawal's `fee` goes to whoever sends the release. Release on Sui, NEAR and TON is in [/docs](https://telos.alcor.exchange/api/bridge/docs). ### Telos actions [#telos-actions] | Action | Who may call | What it does | | --- | --- | --- | | `bridge.alcor::forward(domain, nonce)` | Anyone | Delivers a deposit that carried a memo. The relayer does it; call it if you do not want to wait | | `bridge.alcor::bounce(domain, nonce)` | Anyone, an hour after arrival | Sends an undeliverable deposit back to its `refundTo` | | `bridge.alcor::claim(owner, sym_code)` | The owner | Collects what waits in the `claims` table for an account. Rare: deposits are paid out directly | | `hop.alcor::recover(id)` | Anyone | Sends a hop that came back from its destination on to its way-back address | | `::credit` | Anyone, with a proof | Credits a deposit. The relayer does it. To do it yourself, send the `actions` of `GET /v1/proofs/d::` in one transaction | ### Contract events [#contract-events] | Contract | Event | Meaning | | --- | --- | --- | | `AlcorVault` | `Deposit(token, from, amount, canonical, telosTo, nonce, refundTo, fillFee, filler, memo)` | Deposit locked. Key `d::` | | `AlcorVault` | `Released(id, token, to, amount, feeTo, fee)` | Withdrawal `w:` paid out, raw units | | `AlcorVault` | `Voided(id)` | Withdrawal `w:` expired, refunded on Telos | | `AlcorWithdrawals` | `Released(id, token, to, amount, memo)` | The same payout with the Telos memo, in Telos units | | WAX, XPR, Vaulta `bridge.alcor` | action `deplog(…)` | Deposit from that chain. Key `d::` | | Telos `bridge.alcor` | action `wdlog(id, domain, vault, token, recipient, amount, deadline, fee, memo)` | Withdrawal opened. Key `w:` | ### Typical times [#typical-times] Measured on recent transfers; the live figures are `timing` in `GET /v1/chains`. | From → to Telos | Time | | From Telos → | Time | | --- | --- | --- | --- | --- | | Ethereum | about 17 min (3 min on the fast path) | | Ethereum | about 1 min to the proof | | BNB Smart Chain | about 30 s | | BNB Smart Chain | about 30 s | | Polygon | about 40 s | | Polygon | about 35 s | | WAX | about 50 s | | WAX | about 2 min | | XPR Network | about 3 min | | XPR Network | about 2 min | | Vaulta | seconds | | Vaulta | seconds | | Sui, NEAR, TON | seconds | | Sui, NEAR, TON | about 20 s | A transfer between two other chains adds the two: BNB Smart Chain → WAX is about 3 minutes. Poll every 10–15 seconds, or follow `GET /v1/stream`. # CPU Payer (WAX only) (/api/cpu-payer) On WAX, Alcor pays the CPU of transactions that interact with its contracts. The transaction starts with a `liquid.alcor::noop` action authorized by `liquid.alcor@bw`; with `ONLY_BILL_FIRST_AUTHORIZER`, the chain bills the CPU to that first authorizer instead of the user. The service only cosigns: the user still signs the transaction, and the client pushes it. The service runs on WAX only. Both endpoints take `POST` and allow any origin. ## How it works [#how-it-works] 1. Call [Status](#status) to see whether the service is signing. 2. Build the transaction with `liquid.alcor::noop` as the first action, authorized by `liquid.alcor@bw`, followed by the user's actions. 3. The user signs the transaction. 4. Send the serialized transaction to [Cosign](#cosign). The service checks it and returns its signature. 5. Push the transaction with both signatures. The CPU is billed to `liquid.alcor`. ## Status [#status] Whether the service is up and signing, and how much of its CPU is used. `POST https://wax.alcor.exchange/api/v2/cpu/status` **Example** ```shell curl -X POST https://wax.alcor.exchange/api/v2/cpu/status ``` ```json { "available": true, "signing": true, "throttled": false, "cpu": { "used": 2988810, "max": "13859878911", "percent": 0.0215 }, "lastCheck": 1792068283798 } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | available | boolean | Whether the service answers | | signing | boolean | `false` while throttled | | throttled | boolean | CPU usage is above 70%: rate limits are halved | | cpu.used | number | CPU used by `liquid.alcor`, microseconds | | cpu.max | string | CPU available to `liquid.alcor`, microseconds | | cpu.percent | number | CPU used, percent | | lastCheck | number | Time of the last CPU check, unix milliseconds. CPU is checked every 2 minutes | `cpu` and `lastCheck` are `null` until the first check. ## Cosign [#cosign] Checks a transaction and signs it as `liquid.alcor@bw`. `POST https://wax.alcor.exchange/api/v2/cpu/cosign` **Request body** | Name | Type | Required | Description | | --- | --- | --- | --- | | serializedTransaction | string | yes | The serialized transaction, hex-encoded | **Example** ```shell curl -X POST https://wax.alcor.exchange/api/v2/cpu/cosign \ -H "Content-Type: application/json" \ -d '{"serializedTransaction": ""}' ``` Answers HTTP 201: ```json { "signature": "SIG_K1_..." } ``` **Checks** * The first action is `liquid.alcor::noop`, authorized by `liquid.alcor@bw`. * Every other action is either an action of an allowed contract, or a `transfer` to one: `alcordexmain` (spot DEX), `swap.alcor` (AMM), `otc.alcor` and `alcorotcswap` (OTC), `liquid.alcor`. * The user is the first authorizer of the second action. Rate limits count per user account and per IP. A transaction that fails a check, or goes over a limit, answers HTTP 400 with `{"error": ""}`, for example: * `First action must be noop from payer` * `Contract is not allowed` * `Transfer recipient is not allowed` * `Hourly IP limit exceeded` * `Daily account limit exceeded` ## Rate limits [#rate-limits] | Limit | Requests | | --- | --- | | Per IP, hourly | 500 | | Per account, hourly | 300 | | Per IP, daily | 5000 | | Per account, daily | 2000 | | All users, hourly | 10000 | | All users, daily | 80000 | While throttled (CPU usage above 70%), every limit except the global daily one is halved. # Market Feed (/api/feed) One feed for aggregators (CoinGecko, CoinMarketCap and the like): every market Alcor runs on WAX, XPR, Vaulta (EOS) and Telos, AMM pools and order books alike, in the shape of the CoinGecko integration spec, which CoinMarketCap accepts too. Base URL: `https://api.alcor.exchange/v3/feed`. It answers the same on any Alcor host (`https://wax.alcor.exchange/api/v3/feed/...` too). No key is needed; responses are refreshed every minute. **What is in it** - AMM pools and order book markets holding at least $1,000: a pool's TVL, or for an order book the orders resting within 10% of the mid price, valued in its quote token. - No markets of tokens flagged as scam. **Identifiers** | Field | Format | Example | | --- | --- | --- | | currency | `:-` | `wax:tlm-alien.worlds` | | ticker_id | `_` | `wax:tlm-alien.worlds_wax:wax-eosio.token` | | pool_id | `::` | `wax:orderbook:26` | The chain is part of every id because one contract name can exist on several chains (`usdt-wrap.alcor` is on WAX, XPR and Telos). Chains: `wax`, `xpr`, `eos`, `telos`. Several pools can share a ticker_id (one pair, different fee tiers); `pool_id` tells them apart. **One chain** `/pairs` and `/tickers` take `chain` to list one chain's markets only, for a page per chain: `https://api.alcor.exchange/v3/feed/tickers?chain=telos`. Without it they list every chain. `/orderbook` and `/historical_trades` need no filter: the chain is in the `ticker_id`. ## Pairs [#pairs] `GET https://api.alcor.exchange/v3/feed/pairs` ```json [ { "ticker_id": "wax:tlm-alien.worlds_wax:wax-eosio.token", "base": "wax:tlm-alien.worlds", "target": "wax:wax-eosio.token", "pool_id": "wax:orderbook:26" } ] ``` ## Tickers [#tickers] `GET https://api.alcor.exchange/v3/feed/tickers` ```json [ { "ticker_id": "wax:tlm-alien.worlds_wax:wax-eosio.token", "base_currency": "wax:tlm-alien.worlds", "target_currency": "wax:wax-eosio.token", "pool_id": "wax:orderbook:26", "type": "orderbook", "chain": "wax", "last_price": 0.25251933, "base_volume": 456391.87, "target_volume": 115877.58, "liquidity_in_usd": 1603.12, "bid": 0.24701200, "ask": 0.25100000, "high": 0.25653127, "low": 0.25025, "volume_usd_24h": 568.4, "base_cmc_ucid": 9119, "target_cmc_ucid": 2300, "global_ticker_id": "TLM-WAXP", "trade_url": "https://alcor.exchange/v/wax/spot/tlm-alien.worlds_wax-eosio.token" } ] ``` | Name | Type | Description | | --- | --- | --- | | ticker_id, base_currency, target_currency, pool_id | string | See Identifiers | | type | string | `amm` or `orderbook` | | chain | string | `wax`, `xpr`, `eos` or `telos` | | last_price | number | Last price of the base in the target | | base_volume, target_volume | number | 24h volume in each token | | liquidity_in_usd | number | Pool TVL, or order book depth within 10% of mid | | bid, ask | number | Best bid and ask. Order books only | | high, low | number or null | 24h range, null without a trade in 24h | | volume_usd_24h | number | 24h volume in USD | | base_cmc_ucid, target_cmc_ucid | number or null | CoinMarketCap ids of the tokens, when known | | global_ticker_id | string or null | `BASE-TARGET` in CoinMarketCap symbols, when both tokens have a CoinMarketCap id | | trade_url | string | The market on alcor.exchange | ## Order book [#order-book] Order book markets only; an AMM pool has no book. `GET https://api.alcor.exchange/v3/feed/orderbook?ticker_id=wax:tlm-alien.worlds_wax:wax-eosio.token&depth=100` | Name | Type | Required | Description | | --- | --- | --- | --- | | ticker_id | string | yes | A ticker of type `orderbook` | | depth | number | no | Levels on both sides together: `100` is 50 bids and 50 asks. `0` (default) is the full book | ```json { "ticker_id": "wax:tlm-alien.worlds_wax:wax-eosio.token", "pool_id": "wax:orderbook:26", "timestamp": 1792069684465, "bids": [["0.24701200", "14224.8352"]], "asks": [["0.25100000", "154048.5865"]] } ``` Levels are `[price, base quantity]`, best first. ## Historical trades [#historical-trades] Swaps in the pair's pools and fills on its order book, merged, oldest first. `GET https://api.alcor.exchange/v3/feed/historical_trades?ticker_id=wax:tlm-alien.worlds_wax:wax-eosio.token&limit=200` | Name | Type | Required | Description | | --- | --- | --- | --- | | ticker_id | string | yes | Any ticker of the feed | | type | string | no | `buy` or `sell` | | limit | number | no | The latest N trades. Default 200, at most 1000 | | start_time, end_time | number | no | Unix seconds | ```json [ { "trade_id": "wax:swap:110408849349", "ticker_id": "wax:waxusdc-eth.token_wax:parausd-parareserves", "pool_id": "wax:amm:10336", "price": 1.0025, "base_volume": 0.00198, "target_volume": 0.001985, "trade_timestamp": 1792045247, "type": "buy", "trx_id": "886cdd7c78f64f9febaf558bd076bb82ece83b4171986eb2b58f13922d8b4976" } ] ``` `type` is the side of the base token: `buy` took it out of the pool or the book, `sell` put it in. ## Merged by asset (CoinMarketCap) [#merged-by-asset-coinmarketcap] `https://api.alcor.exchange/v3/feed/cmc/{pairs,tickers,orderbook,historical_trades}` is the same feed with one market per pair of assets instead of one per pool. Every pool, fee tier, order book and chain that trades the same two assets is one market: - A token is its asset, named by the CoinMarketCap symbol. A token bridged through the Alcor Bridge or Metal X counts as its origin: `usdc-wrap.alcor` on WAX, XPR and Telos and `xusdc-xtokens` on XPR are all `USDC`. - Only pairs of two tokens with a known CoinMarketCap id are listed. - The pair is quoted in a stablecoin first, then in a chain coin (`TLM_WAXP`, `WAXP_USDT`); otherwise its assets go in alphabetical order. A pool trading one asset on both sides (`usdc-wrap.alcor` / `xusdc-xtokens`) is a bridge and is left out. ```json { "ticker_id": "USDC_USDT", "base_currency": "USDC", "target_currency": "USDT", "base_cmc_ucid": 3408, "target_cmc_ucid": 825, "global_ticker_id": "USDC-USDT", "last_price": 1.00057, "base_volume": 3874.18, "target_volume": 3854.25, "liquidity_in_usd": 15222.38, "high": null, "low": null, "volume_usd_24h": 3864.21, "pool_id": "wax:amm:12397", "pools": ["wax:amm:12397", "wax:amm:12498", "xpr:amm:0"], "trade_url": "https://alcor.exchange/v/wax/swap/usdc-wrap.alcor_usdt-wrap.alcor" } ``` Volumes and liquidity are the sums over `pools`. `last_price`, `pool_id` and `trade_url` are the most liquid pool's; `bid`, `ask` and `/orderbook` are the most liquid order book's. `/historical_trades` merges the trades of every pool in `pools`, each naming its own `pool_id`. # Global Data (/api/global-data) Exchange-wide figures for one chain, built from hourly snapshots. All values are in USD. ## Stats [#stats] TVL at the latest snapshot, and volumes, fees and activity summed over the last day, week or month. `GET https://wax.alcor.exchange/api/v2/analytics/global` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | resolution | string | no | Period to sum over: `1D`, `1W` or `1M`. Default `1D` | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/analytics/global?resolution=1W" ``` ```json { "_id": "wax", "totalValueLocked": 2207753.66, "swapValueLocked": 2146988.54, "spotValueLocked": 60289.68, "swapTradingVolume": 21791.28, "spotTradingVolume": 933.46, "swapFees": 49.78, "spotFees": 16.99, "dailyActiveUsers": 426.52, "swapTransactions": 152064, "spotTransactions": 1157, "totalLiquidityPools": 12783, "totalSpotPairs": 978, "totalTradingVolume": 22724.75 } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | _id | string | Chain | | totalValueLocked | number | Total value locked: AMM pools plus open spot orders | | swapValueLocked | number | Value locked in AMM pools | | spotValueLocked | number | Value locked in open spot orders | | swapTradingVolume | number | AMM volume over the period | | spotTradingVolume | number | Spot volume over the period | | totalTradingVolume | number | AMM plus spot volume | | swapFees | number | AMM fees over the period | | spotFees | number | Spot fees over the period | | dailyActiveUsers | number | Average daily active users over the period | | swapTransactions | number | AMM swaps over the period | | spotTransactions | number | Spot trades over the period | | totalLiquidityPools | number | Number of AMM pools | | totalSpotPairs | number | Number of spot markets | ## Volume [#volume] Volume and fees over an exact time range. Made for daily volume reports: ask for one UTC day at a time. `GET https://wax.alcor.exchange/api/v2/analytics/volume` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | start_time | number | yes | Range start, unix seconds | | end_time | number | yes | Range end, unix seconds. Must be greater than `start_time` | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/analytics/volume?start_time=1791936000&end_time=1792022400" ``` ```json { "start_time": 1791936000, "end_time": 1792022400, "volume": 11183.93, "fees": 23.49, "swapVolume": 11031.92, "spotVolume": 152.0, "swapFees": 20.72, "spotFees": 2.76, "buckets": 24 } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | start_time, end_time | number | The range asked for | | volume | number | AMM plus spot volume | | fees | number | AMM plus spot fees | | swapVolume, spotVolume | number | Volume per venue | | swapFees, spotFees | number | Fees per venue | | buckets | number | Hourly snapshots in the range. 24 for a full day; fewer means the range is not fully covered | ## Charts [#charts] The snapshots behind [Stats](#stats), as a time series, oldest first. `GET https://wax.alcor.exchange/api/v2/analytics/charts` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | resolution | string | yes | Range: `1D`, `1W`, `1M` (one point per hourly snapshot) or `ALL` (one point per day) | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/analytics/charts?resolution=1D" ``` ```json [ { "_id": "2026-10-14T12:59:02.400Z", "totalValueLocked": 2218094.70, "swapValueLocked": 2156358.47, "spotValueLocked": 61249.61, "swapTradingVolume": 710.27, "spotTradingVolume": 1.05, "swapFees": 0.81, "spotFees": 0.02, "dailyActiveUsers": 399, "swapTransactions": 3860, "spotTransactions": 25, "totalLiquidityPools": 12780, "totalSpotPairs": 978 } ] ``` Each point has the fields of [Stats](#stats), with `_id` holding the point's time. Volumes, fees and transaction counts are per point. # API Reference (/api) The Alcor API serves market data for the spot order book DEX and the AMM: tokens, prices, tickers, order books, trades, candles, pools, positions and account history, over HTTP and WebSocket. It is read-only and needs no key. Placing orders and swapping are blockchain transactions, signed by the user and sent to a node (see [Trade API](/api/trade-api) and [Swap route](/api/swap#swap-route)). ## Chains and base URLs [#chains-and-base-urls] Each chain has its own host. The chain of a request is taken from the host name. | Chain | Base URL | | --- | --- | | WAX | `https://wax.alcor.exchange/api/` | | EOS | `https://eos.alcor.exchange/api/` | | Telos | `https://telos.alcor.exchange/api/` | | XPR Network | `https://proton.alcor.exchange/api/` | All examples use WAX; change the host for another chain. `https://alcor.exchange/api/...` redirects to WAX, so call the chain's host directly. An unknown chain name answers HTTP 404. ## Conventions [#conventions] * **Token id**: `-` in lower case, e.g. `tlm-alien.worlds`. Any contract can issue any symbol, so the contract is part of the id. * **Ticker id**: two token ids, base first, `_`, e.g. `tlm-alien.worlds_wax-eosio.token`. * **Time**: units differ between endpoints (unix seconds, unix milliseconds or ISO 8601 strings). Each endpoint states its own. * **Errors**: most v2 endpoints answer errors as plain text with an HTTP status; v3 endpoints answer `{"error": ""}`. * **Rate limits**: requests are rate-limited per IP address. Over the limit, the API answers HTTP 429. ## Sections [#sections] ## Contracts [#contracts] Writing to Alcor means calling its contracts through any node API, with a library such as [Wharf](https://wharfkit.com) or [eosjs](https://github.com/EOSIO/eosjs). | Chain | Spot DEX | AMM | | --- | --- | --- | | WAX | `alcordexmain` | `swap.alcor` | | EOS | `eostokensdex` | `swap.alcor` | | Telos | `eostokensdex` | `swap.alcor` | | XPR Network | `alcor` | `swap.alcor` | Contract actions and tables are described in [Developers](/developers-api). # Market API (/api/market-api) Prices, depth, pools and order books for bots and apps, computed from on-chain state that is updated every block, with the swap contracts' own math. Use it to know what tokens are worth, what a pair trades at, what a given amount fetches, and how much a market takes before its price gives way. To build a swap transaction, use [Swap route v3](/api/swap#swap-route-v3). `https://.alcor.exchange/api/v3/market/`, with `` one of `wax`, `eos`, `telos`, `proton`. | Endpoint | What it answers | | --- | --- | | [`GET tokens`](#market-tokens) | Every token with its price in the system token and in USD | | [`GET tokens/`](#market-token) | One token | | [`GET price`](#pair-price) | A pair's mid price, and what selling and buying an amount fetches | | [`GET depth`](#depth) | How much a pair takes at each price impact level | | [`GET pools`](#market-pools), `pools/` | AMM pools with price, reserves and TVL | | [`GET orderbooks`](#market-order-books), `orderbooks/` | Order book markets with best bid and ask, and orders | | [`WSS stream`](#market-stream) | All of the above pushed after every block that changes it | ## Conventions [#conventions] * Every answer carries `block`: the last block the data reflects. * Prices and values are decimal strings with 8 significant digits. Amounts are decimal strings in the token's precision, e.g. `1000.0000` for a token with 4 decimals. * Token ids are `-` in lower case, e.g. `tlm-alien.worlds`. * A field with no value is `null`, never left out. Only `sell` and `buy` of [Pair price](#pair-price) without `amount`, and `bids` and `asks` of the order book list, are left out. * Errors are JSON, `{"error": ""}`: | Status | When | Messages | | --- | --- | --- | | 400 | A bad parameter of `price` or `depth`, including a token id that does not exist | `Unknown token`, `Invalid amount`, `Invalid impact`, `Base and quote are the same token`, `Input and output are the same token` | | 404 | An unknown network, or an id in the path that does not exist | `Unknown network`, `Unknown token`, `Unknown pool`, `Unknown order book` | | 429 | Over the rate limit | | Requests are rate-limited per IP address, with the same limits as the swap route. To follow prices all the time, open one [stream](#market-stream) instead of polling: a stream is one request, however long it stays open. #### How token prices are made [#how-token-prices-are-made] Prices are in the chain's system token (WAX, EOS, TLOS, XPR), read off the AMM pools' spot prices. The system token is worth 1; every other token is priced through a pool whose other side is already priced. Of all the paths from the system token to a token, the price comes through the one whose weakest pool holds the most value, and a path through a pool below the liquidity threshold does not price at all, so a thin pool cannot set a token's price. The threshold is set per network, about $150 worth of the system token on the priced side of the pool. A token traded only on order books, or only in thin pools, has no price. USD prices multiply by the system token's USD price from CoinGecko, refreshed every minute. When CoinGecko has not answered for an hour, USD prices are `null` until it does. Prices are recomputed with every block that changes a pool. ## Market tokens [#market-tokens] Every token: the system token first, then the priced tokens by `liquidity`, then the unpriced ones by id. `GET https://wax.alcor.exchange/api/v3/market/tokens` The list is large: on WAX about 2,100 tokens and 370 KB. To follow it, subscribe to the stream's [`tokens`](#channels) channel, which sends it once and then only the tokens whose price moved. **Example** ```shell curl https://wax.alcor.exchange/api/v3/market/tokens ``` ```json { "block": 461732168, "systemToken": "wax-eosio.token", "systemUsdPrice": "0.00456392", "tokens": [ { "id": "wax-eosio.token", "symbol": "WAX", "contract": "eosio.token", "decimals": 8, "price": "1", "priceUsd": "0.00456392", "liquidity": null, "liquidityUsd": null, "pools": 3313, "orderbooks": 833 }, { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "decimals": 4, "price": "0.24765637", "priceUsd": "0.0011302838", "liquidity": "890719.54", "liquidityUsd": "4065.1727", "pools": 257, "orderbooks": 12 }, { "id": "a-ilbau.wam", "symbol": "A", "contract": "ilbau.wam", "decimals": 6, "price": null, "priceUsd": null, "liquidity": null, "liquidityUsd": null, "pools": 1, "orderbooks": 0 } ] } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | block | number | Last block the data reflects | | systemToken | string | Token every `price` is quoted in | | systemUsdPrice | string | USD price of the system token, `null` when unknown | | tokens | array | Tokens, see below | **Each token** | Name | Type | Description | | --- | --- | --- | | id, symbol, contract, decimals | | The token | | price | string | System tokens per one token, `null` when unpriced | | priceUsd | string | USD per one token, `null` when unpriced or the USD price is unknown | | liquidity | string | What backs the price: the system-token value of the priced side of the weakest pool on the path the price comes through. `null` for the system token and for unpriced tokens | | liquidityUsd | string | The same in USD | | pools | number | Pools trading the token | | orderbooks | number | Order book markets trading the token | ## Market token [#market-token] One token, as in [Market tokens](#market-tokens). An unknown id answers HTTP 404. `GET https://wax.alcor.exchange/api/v3/market/tokens/` **Example** ```shell curl https://wax.alcor.exchange/api/v3/market/tokens/tlm-alien.worlds ``` ```json { "block": 461732168, "token": { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "decimals": 4, "price": "0.24765637", "priceUsd": "0.0011302838", "liquidity": "890719.54", "liquidityUsd": "4065.1727", "pools": 257, "orderbooks": 12 } } ``` ## Pair price [#pair-price] The price of a pair, and with `amount`, the price of trading that much of it. `mid` is the ratio of the two token prices. With `amount` (in base), `sell` sells it for quote, and `buy` spends what the sell receives to buy base back. Both go through the AMM and the order books, split across routes, exactly as a swap would, so the gap between their prices is what a round trip of that size costs. `GET https://wax.alcor.exchange/api/v3/market/price` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | base | string | yes | Base token id | | quote | string | yes | Quote token id | | amount | string | no | Amount of base to sell, e.g. `1000`, at most the token's decimals | **Example** ```shell curl "https://wax.alcor.exchange/api/v3/market/price?base=tlm-alien.worlds"e=wax-eosio.token&amount=1000" ``` ```json { "block": 461732115, "base": { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "decimals": 4 }, "quote": { "id": "wax-eosio.token", "symbol": "WAX", "contract": "eosio.token", "decimals": 8 }, "mid": "0.24765637", "sell": { "input": "1000.0000", "output": "247.36208632", "price": "0.24736209", "priceImpact": "0.64" }, "buy": { "input": "247.36208632", "output": "995.7290", "price": "0.2484231", "priceImpact": "0.31" } } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | block | number | Last block the data reflects | | base, quote | object | The tokens: `id`, `symbol`, `contract`, `decimals` | | mid | string | Quote per one base, from the token prices. `null` when either token is unpriced | | sell | object | Only with `amount`: selling it. `null` when no route can | | buy | object | Only with `amount`: buying base back with what the sell receives. `null` when no route can | **sell and buy** | Name | Type | Description | | --- | --- | --- | | input | string | Amount spent: base for `sell`, quote for `buy` | | output | string | Amount received: quote for `sell`, base for `buy` | | price | string | Quote per one base, as executed, fees included | | priceImpact | string | Percent below the spot prices of the routes taken, as in the route API | ## Depth [#depth] How much `input` the market takes before its price gives way. For each impact level, in percent, about the largest trade of `input` whose average price, fees included, is at most that far below `reference`. The reference is the pair's mid price; for a pair without one, it is the price of a small trade. Trades are routed through the AMM and the order books, split across routes, as a swap would. A level's amounts are `null` when not even a small trade stays within it: a level below the cheapest route's fee never does. Amounts are accurate to about 1%. A depth search takes about a second, so answers are cached for 10 seconds per pair and levels. Asking again within that time answers the same `block`. `GET https://wax.alcor.exchange/api/v3/market/depth` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | input | string | yes | Token id to sell | | output | string | yes | Token id to receive | | impact | string | no | Comma-separated levels in percent, up to 10, each above 0 and below 100. Default `0.5,1,2,5` | **Example** ```shell curl "https://wax.alcor.exchange/api/v3/market/depth?input=wax-eosio.token&output=tlm-alien.worlds&impact=0.5,1,2,5" ``` ```json { "block": 461732117, "input": { "id": "wax-eosio.token", "symbol": "WAX", "contract": "eosio.token", "decimals": 8 }, "output": { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "decimals": 4 }, "reference": "4.037853", "referenceKind": "mid", "levels": [ { "impact": "0.5", "input": "6654.20397186", "output": "26734.3509" }, { "impact": "1", "input": "24250.57497775", "output": "96941.0229" }, { "impact": "2", "input": "81250.75297357", "output": "321516.8950" }, { "impact": "5", "input": "318725.96867490", "output": "1222617.5391" } ] } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | block | number | Last block the data reflects | | input, output | object | The tokens | | reference | string | Output per one input that impact is measured against. `null` when there is no route | | referenceKind | string | `mid` (the pair's mid price) or `smallTrade` (the price of a small trade); `null` when there is no route | | levels | array | One per requested level, in the order asked: `impact`, and the `input` sold and `output` received at that level | ## Market pools [#market-pools] Every AMM pool, or the pools trading `token`, by id. `GET https://wax.alcor.exchange/api/v3/market/pools` answers `{"block", "pools"}`. `GET https://wax.alcor.exchange/api/v3/market/pools/` answers one pool as `{"block", "pool"}`, or HTTP 404. **Parameters of the list** | Name | Type | Required | Description | | --- | --- | --- | --- | | token | string | no | Only pools trading this token id | **Example** ```shell curl https://wax.alcor.exchange/api/v3/market/pools/0 ``` ```json { "block": 461732115, "pool": { "id": 0, "tokenA": { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "decimals": 4 }, "tokenB": { "id": "wax-eosio.token", "symbol": "WAX", "contract": "eosio.token", "decimals": 8 }, "fee": "0.3", "tickSpacing": 60, "active": true, "price": "0.24765637", "sqrtPriceX64": "918003784128374099714", "tick": 78150, "liquidity": "5723638121470", "reserveA": "3974114.3644", "reserveB": "890719.54153255", "tvl": "1874934.3", "tvlUsd": "8557.05" } } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id | number | Pool id | | tokenA, tokenB | object | The tokens, in the pool's order | | fee | string | Fee in percent | | tickSpacing | number | Tick spacing | | active | boolean | Whether the pool is active | | price | string | Token B per one token A, the pool's own spot price | | sqrtPriceX64 | string | Current sqrt price, Q64.64, in raw units | | tick | number | Current tick | | liquidity | string | In-range liquidity | | reserveA, reserveB | string | Token balances the pool holds | | tvl | string | Both reserves in system tokens; `null` unless both tokens are priced | | tvlUsd | string | The same in USD | ## Market order books [#market-order-books] Order book markets. The list comes without orders; a single market comes with its best 20 orders on each side. `GET https://wax.alcor.exchange/api/v3/market/orderbooks` answers `{"block", "orderbooks"}`. `GET https://wax.alcor.exchange/api/v3/market/orderbooks/` answers `{"block", "orderbook"}`, or HTTP 404. **Parameters of the list** | Name | Type | Required | Description | | --- | --- | --- | --- | | token | string | no | Only markets trading this token id | **Example** ```shell curl https://wax.alcor.exchange/api/v3/market/orderbooks/26 ``` ```json { "block": 461732115, "orderbook": { "id": 26, "base": { "id": "wax-eosio.token", "symbol": "WAX", "contract": "eosio.token", "decimals": 8 }, "quote": { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "decimals": 4 }, "fee": "0.2", "frozen": false, "bestBid": "0.24725901", "bestAsk": "0.24950131", "bids": [ { "price": "0.24725901", "amount": "470.8472" }, { "price": "0.247012", "amount": "18000.0000" } ], "asks": [ { "price": "0.24950131", "amount": "500.0000" }, { "price": "0.24950131", "amount": "500.0000" } ] } } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id | number | Market id | | base, quote | object | The tokens, named as the DEX contract names them | | fee | string | Fee in percent | | frozen | boolean | Whether the market is frozen | | bestBid, bestAsk | string | Best buy and sell prices, in base per one quote; `null` when the side is empty | | bids, asks | array | Single market only: `{price, amount}`, best first, one entry per order (two orders at one price are two entries). Price in base per one quote, amount in quote | Here `base` and `quote` follow the DEX contract, which is the reverse of the [Market Data](/api/market-data) tickers: the contract's base (WAX in market 26) is the ticker's target. ## Market stream [#market-stream] A plain WebSocket (not Socket.IO) that pushes the market API as the chain moves: subscribe to a pair's price, a pool, an order book or the token list, get its current state at once, then a message after every block that changes it. `wss://.alcor.exchange/api/v3/market/stream`, e.g. `wss://wax.alcor.exchange/api/v3/market/stream`. An unknown network answers the handshake with HTTP 404. Requests and messages are JSON text frames; binary frames are ignored. #### Requests [#requests] ```json {"op": "subscribe", "channel": "price", "base": "tlm-alien.worlds", "quote": "wax-eosio.token"} {"op": "subscribe", "channel": "pool", "id": 0} {"op": "subscribe", "channel": "orderbook", "id": 26} {"op": "subscribe", "channel": "tokens"} {"op": "unsubscribe", "channel": "pool", "id": 0} ``` | Name | Type | Description | | --- | --- | --- | | op | string | `subscribe` or `unsubscribe` | | channel | string | `price`, `pool`, `orderbook` or `tokens` | | base, quote | string | `price` only: the pair's token ids | | id | number | `pool` and `orderbook` only: the pool id or the market id | * A subscription is answered at once with the channel's current state (its snapshot). * Subscribing again to a channel already subscribed sends the snapshot again and does not count as a new subscription. Use it to resynchronise one channel. * An unsubscription is not answered. Unsubscribing from a channel not subscribed does nothing. * Answers come in the order of the requests. #### Channels [#channels] | Channel | Subscribe with | Snapshot and updates carry | Sent after a block when | | --- | --- | --- | --- | | price | `base`, `quote` | `mid`: quote per one base, as in [Pair price](#pair-price); `null` when either token is unpriced | Either token's price moved and the mid differs from the last one sent | | pool | `id` | `pool`, as in [Market pools](#market-pools); `null` once the pool is gone | The pool changed in the block and differs from the last one sent | | orderbook | `id` | `orderbook` with its orders, as in [Market order books](#market-order-books); `null` once the market is gone | The market changed in the block and differs from the last one sent | | tokens | | `tokens`: every token on subscribe, as in [Market tokens](#market-tokens); afterwards the tokens whose price moved | Some token's price moved | A block that leaves a channel as it was sends nothing on it, so a quiet pool or pair can go minutes without a message. #### Messages [#messages] Every message names its channel, the fields it was subscribed with, and the `block` it reflects. The channel's data is in the field named in the table above. ```json {"channel": "price", "base": "tlm-alien.worlds", "quote": "wax-eosio.token", "block": 461732254, "mid": "0.25123696"} {"channel": "pool", "id": 0, "block": 461732254, "pool": {"id": 0, "price": "0.24765637", "...": "as in Market pools"}} {"channel": "orderbook", "id": 26, "block": 461732254, "orderbook": {"id": 26, "bestBid": "0.24725901", "...": "as in Market order books"}} {"channel": "tokens", "block": 461732254, "tokens": [{"id": "tlm-alien.worlds", "price": "0.24765637", "...": "as in Market tokens"}]} ``` Each message carries the whole state of what it names, not a diff: replace the pool, the order book or the mid you hold with what arrives. A `tokens` message lists whole token entries; update the tokens it lists by `id` and keep the others. When the server falls behind a connection, or reloads a chain's state, it checks every channel of the connection again and sends what changed. Then `tokens` sends every token once more, as on subscribe. The `tokens` snapshot is the whole [Market tokens](#market-tokens) list: on WAX about 370 KB in one message. Later messages are small, usually a few tokens. #### Errors [#errors] A bad request is answered with `{"error": ""}`, and the connection stays open. The error does not repeat the request; match it by order, as answers come in the order of the requests. | Message | When | | --- | --- | | `Invalid request` | Not JSON, an unknown `op` or `channel`, or a missing or wrong-typed field | | `Unknown token` | `price` names a token id that does not exist | | `Unknown pool` | `pool` names a pool id that does not exist | | `Unknown order book` | `orderbook` names a market id that does not exist | | `Too many subscriptions` | The connection already holds 100 subscriptions | #### Connection [#connection] * One connection holds up to 100 subscriptions. For more, open more connections. * The server sends a WebSocket ping every 30 seconds, which keeps a quiet connection open through proxies; WebSocket clients answer it on their own. * The server keeps no subscriptions across connections. On a disconnect, reconnect with a backoff and subscribe again: the snapshots bring the state up to date. #### Example [#example] ```javascript const SUBSCRIPTIONS = [ { op: 'subscribe', channel: 'price', base: 'tlm-alien.worlds', quote: 'wax-eosio.token' }, { op: 'subscribe', channel: 'pool', id: 0 }, { op: 'subscribe', channel: 'orderbook', id: 26 }, ] function connect(delay = 1000) { const ws = new WebSocket('wss://wax.alcor.exchange/api/v3/market/stream') ws.onopen = () => { delay = 1000 for (const subscription of SUBSCRIPTIONS) ws.send(JSON.stringify(subscription)) } ws.onmessage = ({ data }) => { const message = JSON.parse(data) if (message.error) return console.error(message.error) if (message.channel === 'price') console.log(message.block, 'TLM/WAX', message.mid) if (message.channel === 'pool') console.log(message.block, 'pool', message.id, message.pool?.price) if (message.channel === 'orderbook') console.log(message.block, 'book', message.id, message.orderbook?.bestBid, message.orderbook?.bestAsk) } ws.onclose = () => setTimeout(() => connect(Math.min(delay * 2, 30000)), delay) } connect() ``` ```python import asyncio import json import websockets # pip install websockets URL = "wss://wax.alcor.exchange/api/v3/market/stream" SUBSCRIPTIONS = [ {"op": "subscribe", "channel": "price", "base": "tlm-alien.worlds", "quote": "wax-eosio.token"}, {"op": "subscribe", "channel": "tokens"}, ] async def main(): prices = {} # token id -> price in WAX async for ws in websockets.connect(URL, max_size=None): # reconnects with a backoff; no limit on the tokens snapshot try: for subscription in SUBSCRIPTIONS: await ws.send(json.dumps(subscription)) async for data in ws: message = json.loads(data) if "error" in message: print("error:", message["error"]) elif message["channel"] == "tokens": prices.update((token["id"], token["price"]) for token in message["tokens"]) elif message["channel"] == "price": print(message["block"], "TLM/WAX", message["mid"]) except websockets.ConnectionClosed: continue asyncio.run(main()) ``` # Market Data (/api/market-data) Alcor has two venues: **spot** order book markets and **AMM** pools. Both are described with the same ticker format. A token id is `-` in lower case, because any contract can issue a token with any symbol. A ticker id joins two token ids, base first: `_`, e.g. `tlm-alien.worlds_wax-eosio.token`. Prices are in target per one base. The spot endpoints and the AMM feed follow the CoinGecko and CoinMarketCap DEX integration format, so they can be read by the same code. ## Pairs [#pairs] All spot markets. `GET https://wax.alcor.exchange/api/v2/pairs` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | base | string | no | Only markets with this base token id | | target | string | no | Only markets with this target token id | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/pairs?base=tlm-alien.worlds&target=wax-eosio.token" ``` ```json [ { "base": { "id": "tlm-alien.worlds", "contract": "alien.worlds", "symbol": "TLM", "precision": 4 }, "target": { "id": "wax-eosio.token", "contract": "eosio.token", "symbol": "WAX", "precision": 8 }, "ticker_id": "tlm-alien.worlds_wax-eosio.token" } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | ticker_id | string | Ticker id, `_` | | base, target | object | The tokens: `id`, `contract`, `symbol`, `precision` | ## Tickers [#tickers] Price and 24-hour volume of every spot market. `GET https://wax.alcor.exchange/api/v2/tickers` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | hide_scam | boolean | no | `true` leaves out markets with a token on the scam lists | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/tickers?hide_scam=true" ``` Answers an array of tickers, as in [Ticker](#ticker). ## Ticker [#ticker] Price and 24-hour volume of one spot market. `GET https://wax.alcor.exchange/api/v2/tickers/` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | ticker_id | string | yes | Ticker id, in the path | **Example** ```shell curl https://wax.alcor.exchange/api/v2/tickers/tlm-alien.worlds_wax-eosio.token ``` ```json { "ticker_id": "tlm-alien.worlds_wax-eosio.token", "market_id": 26, "pool_id": "26", "base_currency": "tlm-alien.worlds", "target_currency": "wax-eosio.token", "base_cmc_ucid": 9119, "target_cmc_ucid": 2300, "global_ticker_id": "TLM-WAX", "last_price": 0.247012, "change24": -1.69, "high24": 0.25251933, "low24": 0.247012, "high": 0.25251933, "low": 0.247012, "bid": 0.247012, "ask": 0.251, "base_volume": 1207270.74, "target_volume": 301555.69152662, "volumeUSD24": 2146.47, "volume90d": 10404146.15519762, "base_amm_liquidity": 3945319.8557, "target_amm_liquidity": 902460.1896641699, "min_buy": 0.5, "min_sell": 1, "frozen": false, "fee": 20, "trade_url": "https://alcor.exchange/v/wax/spot/tlm-alien.worlds_wax-eosio.token" } ``` An unknown ticker answers HTTP 404. **Response fields** | Name | Type | Description | | --- | --- | --- | | ticker_id | string | Ticker id | | market_id | number | Spot market id on the DEX contract | | pool_id | string | The same market id, as a string (CoinGecko field name) | | base_currency, target_currency | string | Token ids | | base_cmc_ucid, target_cmc_ucid | number | CoinMarketCap ids, or `null` | | global_ticker_id | string | `BASE-TARGET` when CoinMarketCap lists both tokens, otherwise `null` | | last_price | number | Price of the last trade | | change24 | number | 24-hour price change, percent | | high24, low24 | number | 24-hour price range | | high, low | number | The same range, `null` for a market that has not traded | | bid | number | Best buy order price | | ask | number | Best sell order price | | base_volume, target_volume | number | 24-hour volume in each token, spot trades plus the AMM pools of the same pair | | volumeUSD24 | number | 24-hour volume in USD, spot plus AMM | | volume90d | number | 90-day spot volume, in target | | base_amm_liquidity, target_amm_liquidity | number | Tokens held by the AMM pools of the same pair | | min_buy | number | Smallest buy order, in target | | min_sell | number | Smallest sell order, in base | | frozen | boolean | Trading is frozen | | fee | number | Market fee in hundredths of a percent: `20` is 0.2% | | trade_url | string | Market page on Alcor | ## Order book [#order-book] Price levels of a spot market, best first. `GET https://wax.alcor.exchange/api/v2/tickers//orderbook` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | ticker_id | string | yes | Ticker id, in the path | | depth | number | no | Price levels per side. Default `300` | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/tickers/tlm-alien.worlds_wax-eosio.token/orderbook?depth=2" ``` ```json { "ticker_id": "tlm-alien.worlds_wax-eosio.token", "timestamp": 1792068184805, "bids": [ ["0.24701200", "14224.8352"], ["0.24625802", "500.0000"] ], "asks": [ ["0.25100000", "154048.5865"], ["0.25150125", "116243.9926"] ] } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | ticker_id | string | Ticker id | | timestamp | number | Server time, unix milliseconds | | bids | array | Buy levels, highest price first: `[price, quantity]` | | asks | array | Sell levels, lowest price first: `[price, quantity]` | Prices are in target per base, quantities in base. Orders at the same price are merged into one level. ## Historical trades [#historical-trades] The most recent trades of a spot market, oldest first. `GET https://wax.alcor.exchange/api/v2/tickers//historical_trades` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | ticker_id | string | yes | Ticker id, in the path | | type | string | no | `buy` or `sell` | | limit | number | no | Number of trades. Default `200`, maximum `1000`; `0` returns the maximum | | start_time | number | no | Only trades at or after this time, unix seconds | | end_time | number | no | Only trades at or before this time, unix seconds | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/tickers/tlm-alien.worlds_wax-eosio.token/historical_trades?limit=2" ``` ```json [ { "trade_id": "6ad0881529945be352b4a651", "price": 0.25, "base_volume": 0.7387, "target_volume": 0.18465495, "trade_timestamp": 1792051221, "type": "sell", "trx_id": "996734af8d0c193c69940c745efa35fd34028f7b24461db7caf7507278ec2d92" } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | trade_id | string | Trade id | | price | number | Trade price, target per base | | base_volume | number | Amount of base traded | | target_volume | number | Amount of target traded | | trade_timestamp | number | Trade time, unix seconds | | type | string | `buy` or `sell`, from the taker's side | | trx_id | string | Transaction id | ## Candles [#candles] OHLCV candles of a spot market, oldest first. Periods without trades are filled with flat candles at the last price. `GET https://wax.alcor.exchange/api/v2/tickers//charts` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | ticker_id | string | yes | Ticker id, in the path | | resolution | string | yes | Candle size: `1`, `5`, `15`, `30`, `60`, `240` (minutes), `1D`, `1W`, `1M` | | from | number | yes | Start time, unix milliseconds | | to | number | no | End time, unix milliseconds | | limit | number | no | Most candles to return. Maximum and default `5000` | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/tickers/tlm-alien.worlds_wax-eosio.token/charts?resolution=60&from=1792057410000&to=1792068210000" ``` ```json [ { "time": 1792054800000, "open": 0.247012, "high": 0.247012, "low": 0.247012, "close": 0.247012, "volume": 0 }, { "time": 1792058400000, "open": 0.247012, "high": 0.247012, "low": 0.247012, "close": 0.247012, "volume": 0.02573648 } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | time | number | Candle start, unix milliseconds | | open, high, low, close | number | Prices, target per base | | volume | number | Volume in target | ## AMM pairs [#amm-pairs] Active AMM pools, one entry per pool. A pool's ticker id follows its token order, `_`, so pools of the same pair with different fees share a ticker id and are told apart by `pool_id`. `GET https://wax.alcor.exchange/api/v2/amm/pairs` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | min_liquidity_usd | number | no | Only pools with at least this TVL, in USD | | hide_scam | boolean | no | `true` leaves out pools with a token on the scam lists | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/amm/pairs?min_liquidity_usd=10000" ``` ```json [ { "ticker_id": "wax-eosio.token_nbg-gkniftyheads", "base": { "id": "wax-eosio.token", "contract": "eosio.token", "symbol": "WAX", "precision": 8 }, "target": { "id": "nbg-gkniftyheads", "contract": "gkniftyheads", "symbol": "NBG", "precision": 8 }, "pool_id": "9107" } ] ``` ## AMM tickers [#amm-tickers] Price, volume and liquidity of every active AMM pool, by TVL (highest first). Takes the same parameters as [AMM pairs](#amm-pairs). `GET https://wax.alcor.exchange/api/v2/amm/tickers` **Example** ```shell curl "https://wax.alcor.exchange/api/v2/amm/tickers?min_liquidity_usd=10000&hide_scam=true" ``` ```json [ { "ticker_id": "parausd-parareserves_usdt-wrap.alcor", "base_currency": "parausd-parareserves", "target_currency": "usdt-wrap.alcor", "base_cmc_ucid": null, "target_cmc_ucid": 825, "global_ticker_id": null, "pool_id": "12468", "last_price": 0.999038, "base_volume": 232.622545, "target_volume": 232.340836, "liquidity_in_usd": 99908.95, "high": null, "low": null, "volume_usd_24h": 232.36, "fee_percent": 0.05, "trade_url": "https://alcor.exchange/v/wax/swap/parausd-parareserves_usdt-wrap.alcor" } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | ticker_id | string | `_` | | base_currency, target_currency | string | Token ids of token A and token B | | base_cmc_ucid, target_cmc_ucid | number | CoinMarketCap ids, or `null` | | global_ticker_id | string | `BASE-TARGET` when CoinMarketCap lists both tokens, otherwise `null` | | pool_id | string | Pool id | | last_price | number | Current pool price, target per base | | base_volume, target_volume | number | 24-hour volume in each token | | liquidity_in_usd | number | Pool TVL in USD | | high, low | number | 24-hour price range, `null` when the pool has not traded | | volume_usd_24h | number | 24-hour volume in USD | | fee_percent | number | Pool fee, percent | | trade_url | string | Swap page on Alcor | ## AMM historical trades [#amm-historical-trades] The most recent swaps of all active pools of one ticker, oldest first. `GET https://wax.alcor.exchange/api/v2/amm/historical_trades` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | ticker_id | string | yes | `_`, as in [AMM pairs](#amm-pairs) | | type | string | no | `buy` or `sell`, the base token's side | | limit | number | no | Number of trades. Default `200`, maximum `1000`; `0` returns the maximum | | start_time | number | no | Only trades at or after this time, unix seconds | | end_time | number | no | Only trades at or before this time, unix seconds | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/amm/historical_trades?ticker_id=wax-eosio.token_usdt-usdt.alcor&limit=1" ``` ```json [ { "trade_id": "110411821387", "ticker_id": "wax-eosio.token_usdt-usdt.alcor", "pool_id": "1095", "price": 0.004925598210938818, "base_volume": 87.80659353, "target_volume": 0.4325, "trade_timestamp": 1792065005, "type": "buy", "trx_id": "096bbefb42fe7e43580c68d05c02b95682b5c722b1fd01fb90fadf29e0abb90e" } ] ``` The fields are those of spot [Historical trades](#historical-trades), plus `ticker_id` and `pool_id`. `trade_id` is the swap action's global sequence. A ticker without an active pool answers HTTP 404. # On-chain Data (/api/onchain-data) Markets and orders can be read directly from the DEX contract with any node API, without Alcor's servers. The table layouts are described in [Contract tables](/developers-api/contract-tables). The DEX contract per chain: | Chain | DEX contract | | --- | --- | | WAX | `alcordexmain` | | EOS | `eostokensdex` | | Telos | `eostokensdex` | | XPR | `alcor` | ## Markets [#markets] Markets are stored in the `markets` table, with the contract itself as scope. ```shell cleos -u https://wax.greymass.com get table alcordexmain alcordexmain markets ``` ```javascript import { JsonRpc } from 'eosjs' const rpc = new JsonRpc('https://wax.greymass.com', { fetch }) const { rows } = await rpc.get_table_rows({ code: 'alcordexmain', // DEX contract scope: 'alcordexmain', // same as the contract table: 'markets', limit: 1000, }) ``` ```json { "rows": [ { "id": 0, "base_token": { "sym": "8,WAX", "contract": "eosio.token" }, "quote_token": { "sym": "4,PGL", "contract": "prospectorsw" }, "min_buy": "0.00000100 WAX", "min_sell": "0.0001 PGL", "frozen": 0, "fee": 0 } ], "more": true } ``` The contract names the sides the other way round from the API: its `base_token` is the API's **target** (the token prices are quoted in) and its `quote_token` is the API's **base**. | Field | Description | | --- | --- | | id | Market id: the scope of the market's order tables, and the `market_id` of the API tickers | | base_token | Target token: the token prices are quoted in | | quote_token | Base token: the token being traded | | min_buy | Smallest buy order | | min_sell | Smallest sell order | | frozen | `1` when trading is frozen | | fee | Market fee in hundredths of a percent | ## Orders [#orders] Orders are stored in the `buyorder` and `sellorder` tables, with the market id as scope. ```shell cleos -u https://wax.greymass.com get table alcordexmain 26 buyorder -l 2 ``` ```javascript const { rows } = await rpc.get_table_rows({ code: 'alcordexmain', scope: 26, // market id table: 'buyorder', // or 'sellorder' key_type: 'i128', index_position: 2, // secondary index: sorted by price limit: 1000, }) ``` ```json { "rows": [ { "id": 28, "account": "pxawpxawpxaw", "bid": "10.00000000 WAX", "ask": "1999.9560 TLM", "unit_price": "500012", "timestamp": 1603653505 } ], "more": true, "next_key": "558" } ``` | Field | Description | | --- | --- | | id | Order id, used to cancel the order | | account | Order owner | | bid | What the order offers | | ask | What the order wants in return | | unit_price | Price as an integer: the price in target per base multiplied by 10^8 | | timestamp | Order creation time, unix seconds | # Order book (/api/order-book) The order book indexer reads `book.alcor` from irreversible blocks and serves it over HTTP and WebSocket. Each network has its own host: | Network | Base URL | WebSocket | | --- | --- | --- | | Telos | `https://telos.alcor.exchange/api/v2/orderbook` | `wss://telos.alcor.exchange/api/v2/orderbook/ws` | | WAX | `https://wax.alcor.exchange/api/v2/orderbook` | `wss://wax.alcor.exchange/api/v2/orderbook/ws` | | XPR Network | `https://proton.alcor.exchange/api/v2/orderbook` | `wss://proton.alcor.exchange/api/v2/orderbook/ws` | Examples use Telos; change the host for another network. The API is public and read-only and allows any origin. 64-bit numbers are strings in JSON. Prices are minimal quote units per lot and quantities are lots, as in the contract — see [Units](/developers-api/order-book#units). Contract, actions and the swap memo: [Order book (book.alcor)](/developers-api/order-book). A local order book kept by this API's events: [SDK](/developers-api/order-book/sdk#local-order-book). ## Status [#status] `GET /status` — the last processed block, the chain head and LIB, and how far the indexer is behind (`lag`, blocks). ```json {"block": 495732770, "head": 495732772, "lib": 495732770, "time": 1792889210860, "lag": 0} ``` ## Markets [#markets] `GET /markets`, `GET /markets/:id` — markets with their tokens, the last trade price and 24-hour statistics. ```json { "id": "2", "base_id": "3", "quote_id": "1", "lot_size": "100000", "tick_size": "100", "min_notional": "5000000", "maker_bps": 0, "taker_bps": 0, "paused": 0, "event_seq": "3264", "base": {"id": "3", "contract": "wrap.alcor", "symbol": "BNB", "precision": 8, "paused": 0, "held": "10000000"}, "quote": {"id": "1", "contract": "wrap.alcor", "symbol": "USDC", "precision": 6, "paused": 0, "held": "303000000"}, "last_price": null, "last_trade_time": null, "day": {"trades": 0, "volume": "0", "quote_volume": "0", "high": null, "low": null, "open": null} } ``` `day.volume` is in lots, `day.quote_volume` in minimal quote units. ## Depth [#depth] `GET /markets/:id/depth?levels=20` — price levels and the `seq` they are current at. Expired orders are left out. `levels` is 1–1000, default 20. ```json { "market_id": "2", "seq": "3264", "bids": [{"price": "739100", "qty": "33", "orders": 1}, {"price": "738300", "qty": "33", "orders": 1}], "asks": [{"price": "739900", "qty": "33", "orders": 1}, {"price": "740600", "qty": "33", "orders": 1}] } ``` With a lot of 0.001 BNB, the best bid `739100` is 739.1 USDC per BNB for 0.033 BNB. ## Book [#book] `GET /markets/:id/book` — every open order and the `seq` it is current at: the snapshot for a local book that you then keep with the events of the `market:` channel. ```json { "seq": "3264", "orders": [{"id": "562949953422943", "market_id": "2", "side": 0, "owner": "telosmmbot11", "price": "738300", "qty": "33", "qty_rem": "33", "fee_bps": 0, "created_at": 1792889184, "expires_at": 1792889244}] } ``` The snapshot includes orders that have expired but are not yet removed. Drop those whose `expires_at` is not zero and not in the future. ## Trades [#trades] `GET /markets/:id/trades?limit=100&before=` — trades, newest first. Page back with `before`, the `seq` of the oldest trade you have. `limit` is 1–1000, default 100. ```json [{"market_id": "1", "seq": "7", "block_num": 495114469, "trx_id": "8c9374b5…", "time": 1792580010, "maker_order_id": "422212465065986", "maker": "avraldigital", "taker": "chasterpiece", "taker_side": 0, "price": "10000", "qty": "200", "quote": "2000000", "maker_fee": "0", "taker_fee": "0", "trigger_id": "0"}] ``` ## Candles [#candles] `GET /markets/:id/candles?interval=60&from=&to=&limit=500` — candles, newest first. `interval` is one of 60, 300, 900, 3600, 14400, 86400 seconds; another value is a `400`. ## Events [#events] `GET /events?market=&after=&limit=100` — the event stream of a market in order, from `after` (exclusive). `market=0` is the stream of deposits and withdrawals. Event types and fields: [Tables and events](/developers-api/order-book/tables-and-events#events). Each event also has `block_num` and `trx_id`. ```json [{"type": 2, "market_id": "2", "seq": "1", "time": 1792876410, "trigger": "0", "id": "562949953421313", "owner": "telosmmbot11", "taker": "", "side": 0, "flags": 0, "reason": 0, "price": "730200", "limit_price": "0", "qty": "34", "qty_rem": "34", "maker_fee": "0", "taker_fee": "0", "sibling": "0", "expires_at": 1792876469, "fee_bps": 0, "locked": "0", "block_num": 495707171, "trx_id": "ccdc1006…"}] ``` ## Accounts [#accounts] | Endpoint | Returns | | --- | --- | | `GET /accounts/:owner/orders?status=open\|all` | The account's orders, newest first; `status` defaults to `open` | | `GET /accounts/:owner/triggers?status=open\|all` | The account's triggers | | `GET /accounts/:owner/trades` | Trades where the account is maker or taker | | `GET /accounts/:owner/swaps` | [Swaps](/developers-api/order-book/swap) where the account is sender or recipient; their trades are in `/trades` | | `GET /accounts/:owner/ledger` | Deposits and withdrawals | All take `limit` (1–1000, default 100) and `before` for paging: an order or trigger ID for orders and triggers, a `seq` for the ledger, a time in seconds for trades and swaps. ```json {"id": "703687441778274", "market_id": "2", "side": 1, "owner": "telosmmbot11", "price": "740600", "qty": "33", "qty_rem": "33", "filled": "0", "fee_bps": 0, "status": "open", "reason": null, "trigger_id": "0", "expires_at": 1792889263, "created_at": 1792889205, "updated_at": 1792889205} ``` ## WebSocket [#websocket] `wss://.alcor.exchange/api/v2/orderbook/ws` — see the table at the top. Subscribe to one or more channels: ```json {"op": "subscribe", "channel": "market:2"} ``` | Channel | Events | | --- | --- | | `market:` | Every event of the market | | `account:` | Events where the account is the `owner` or the `taker`: its orders, fills on both sides, deposits, withdrawals, swaps | | `ledger` | All deposits and withdrawals | The server confirms with `{"op": "subscribe", "channel": "market:2", "ok": true}` and then pushes one message per block that touches the channel: ```json {"channel": "market:2", "block": 495707171, "events": [{"type": 2, "seq": "1", "...": "..."}]} ``` `{"op": "unsubscribe", "channel": "..."}` stops a channel. A malformed message gets `{"error": "bad json"}` or `{"error": "bad channel"}`. The server pings every 30 seconds so that proxies keep a quiet connection open. To keep a local book: subscribe first, then load `GET /markets/:id/book` and apply the events with a `seq` above the snapshot's. If a `seq` is missing, load the snapshot again. After a reconnect, subscribe again and reload the snapshot. # Swap (/api/swap) Alcor Swap is a concentrated-liquidity AMM on the `swap.alcor` contract. These endpoints read its pools and positions and find swap routes. How the AMM works: [Alcor Swap](/alcor-swap/introduction) and the [AMM swap contract API](/developers-api/amm-swap-contract-api). To compute prices, positions and routes locally, without the API, use the [Alcor Swap SDK](https://github.com/alcorexchange/alcor-v2-sdk). ## Pools [#pools] All AMM pools, including inactive ones. `GET https://wax.alcor.exchange/api/v2/swap/pools` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | tokenA | string | no | Only pools with this token as token A. With `tokenB`, the pools of that pair in either order | | tokenB | string | no | Only pools with this token as token B | | hide_scam | boolean | no | `true` leaves out pools with a token on the scam lists | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/swap/pools?tokenA=wax-eosio.token&tokenB=usdt-usdt.alcor" ``` Answers an array of pools, as in [Pool](#pool). ## Pool [#pool] One pool by id. An unknown id answers `null`. `GET https://wax.alcor.exchange/api/v2/swap/pools/` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | pool_id | number | yes | Pool id, in the path | **Example** ```shell curl https://wax.alcor.exchange/api/v2/swap/pools/1095 ``` ```json { "id": 1095, "chain": "wax", "active": true, "fee": 3000, "feeProtocol": 0, "tickSpacing": 60, "tokenA": { "contract": "eosio.token", "decimals": 8, "symbol": "WAX", "id": "wax-eosio.token", "quantity": 222783.8554093 }, "tokenB": { "contract": "usdt.alcor", "decimals": 4, "symbol": "USDT", "id": "usdt-usdt.alcor", "quantity": 790.0321 }, "sqrtPriceX64": "12931342024590619", "tick": -145268, "liquidity": "9024147348", "maxLiquidityPerTick": "1247497401346422", "feeGrowthGlobalAX64": "2905065159736797300513", "feeGrowthGlobalBX64": "6373171825477389", "protocolFeeA": 0, "protocolFeeB": 0, "priceA": 0.00491414, "priceB": 203.494, "tvlUSD": 1891.74, "volumeA24": 17221.18436066, "volumeB24": 86.1053, "volumeUSD24": 85.59, "volumeAWeek": 67484.19683699, "volumeBWeek": 359.4608, "volumeUSDWeek": 361.04, "volumeAMonth": 519984.02878347, "volumeBMonth": 2951.5294, "volumeUSDMonth": 2981.59, "volumeA90": 2443181.00916112, "volumeB90": 11536.0987, "volumeUSD90": 11562.55, "change24": -3.47, "changeWeek": -6.76, "firstSeenAt": "2023-05-06T08:05:51.500Z" } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id | number | Pool id | | active | boolean | Whether the pool is active | | fee | number | Swap fee in hundredths of a basis point: `3000` is 0.3% | | feeProtocol | number | Protocol fee setting of the pool | | tickSpacing | number | Tick spacing | | tokenA, tokenB | object | The tokens: `id`, `contract`, `symbol`, `decimals`, and `quantity` held by the pool | | sqrtPriceX64 | string | Current price as a Q64.64 square root | | tick | number | Current tick | | liquidity | string | In-range liquidity | | maxLiquidityPerTick | string | Most liquidity a tick can hold | | feeGrowthGlobalAX64, feeGrowthGlobalBX64 | string | Accumulated fees per unit of liquidity, Q64.64 | | protocolFeeA, protocolFeeB | number | Protocol fees accrued and not yet collected | | priceA | number | Price of token A in token B | | priceB | number | Price of token B in token A | | tvlUSD | number | Total value locked, USD | | volumeA24, volumeB24, volumeUSD24 | number | 24-hour volume in token A, token B and USD | | volumeAWeek, volumeBWeek, volumeUSDWeek | number | 7-day volume | | volumeAMonth, volumeBMonth, volumeUSDMonth | number | 30-day volume | | volumeA90, volumeB90, volumeUSD90 | number | 90-day volume | | change24, changeWeek | number | Price change over 24 hours and 7 days, percent | | firstSeenAt | string | When the pool was created | ## Pool positions [#pool-positions] Open liquidity positions of a pool, with their value and fees. `GET https://wax.alcor.exchange/api/v2/swap/pools//positions` **Example** ```shell curl https://wax.alcor.exchange/api/v2/swap/pools/12397/positions ``` ```json [ { "id": 152287, "owner": "alcordexfund", "pool": 12397, "tickLower": -100, "tickUpper": 100, "liquidity": "800386663698", "feeGrowthInsideALastX64": "160181032180210", "feeGrowthInsideBLastX64": "125798765051241", "inRange": true, "amountA": "3763.075641 USDC", "amountB": "4220.481815 USDT", "feesA": "0.220932 USDC", "feesB": "0.369956 USDT", "totalValue": 7984.15, "totalFeesUSD": 0.59, "depositedUSDTotal": 7983.4609, "collectedFees": { "tokenA": 0, "tokenB": 0, "inUSD": 0, "lastCollectTime": null }, "pNl": 0.59, "closed": false, "lockedUntil": null, "isLocked": false } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id | number | Position id | | owner | string | Owner account | | pool | number | Pool id | | tickLower, tickUpper | number | Price range of the position, in ticks | | liquidity | string | Position liquidity | | feeGrowthInsideALastX64, feeGrowthInsideBLastX64 | string | Fee growth inside the range at the last update, Q64.64 | | inRange | boolean | Whether the current price is inside the range | | amountA, amountB | string | Tokens in the position now, as assets | | feesA, feesB | string | Fees earned and not yet collected, as assets | | totalValue | number | Tokens plus uncollected fees, USD | | totalFeesUSD | number | Uncollected fees, USD | | depositedUSDTotal | number | USD value of deposits minus withdrawals, valued at the time of each | | collectedFees | object | Fees already collected: `tokenA`, `tokenB`, `inUSD`, `lastCollectTime` | | pNl | number | Earned fees in USD, collected plus uncollected. Price movement of the deposit is not included | | closed | boolean | Whether all liquidity has been withdrawn | | lockedUntil | number | Unix seconds the position is locked until, or `null` | | isLocked | boolean | Whether the position is locked now. A locked position cannot be withdrawn | ## Pool swaps [#pool-swaps] Swaps of a pool, newest first. `GET https://wax.alcor.exchange/api/v2/swap/pools//swaps` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | pool_id | number | yes | Pool id, in the path | | from | number | no | Only swaps at or after this time, unix milliseconds | | to | number | no | Only swaps at or before this time, unix milliseconds | | sender | string | no | Only swaps sent by this account | | recipient | string | no | Only swaps received by this account | | limit | number | no | Number of swaps. Default `200` | | skip | number | no | Swaps to skip, for paging | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/swap/pools/1095/swaps?limit=1" ``` ```json [ { "_id": "6ad0bded29945be352deacb2", "pool": 1095, "trx_id": "096bbefb42fe7e43580c68d05c02b95682b5c722b1fd01fb90fadf29e0abb90e", "sender": "eldrinvale12", "recipient": "eldrinvale12", "sqrtPriceX64": "12931342024590619", "totalUSDVolume": 0.4345, "tokenA": -87.80659353, "tokenB": 0.4325, "time": "2026-10-15T11:50:05.000Z" } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | _id | string | Record id | | pool | number | Pool id | | trx_id | string | Transaction id | | sender | string | Account that sent the swap | | recipient | string | Account that received the output | | sqrtPriceX64 | string | Pool price after the swap, Q64.64 square root | | totalUSDVolume | number | Swap value, USD | | tokenA, tokenB | number | Token amounts, signed from the pool's side: positive went into the pool, negative came out | | time | string | Swap time, ISO 8601 | ## Pool candles [#pool-candles] OHLCV candles of a pool, oldest first. Periods without swaps are filled with flat candles at the last price. `GET https://wax.alcor.exchange/api/v2/swap/pools//candles` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | pool_id | number | yes | Pool id, in the path | | resolution | string | yes | Candle size: `1`, `5`, `15`, `30`, `60`, `240` (minutes), `1D`, `1W`, `1M` | | from | number | no | Start time, unix milliseconds. Used together with `to` | | to | number | no | End time, unix milliseconds | | limit | number | no | Most candles to return | | reverse | boolean | no | `true` gives prices of token B in token A. Default: token A in token B | | volumeField | string | no | `volumeUSD` (default), `volumeA` or `volumeB` | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/swap/pools/1095/candles?resolution=60&from=1792057410000&to=1792068210000" ``` ```json [ { "time": 1792058400000, "open": "0.00489139", "high": "0.00493338", "low": "0.00488846", "close": "0.00489139", "volume": 3.6053 }, { "time": 1792062000000, "open": "0.00489139", "high": "0.00491414", "low": "0.00489288", "close": "0.00491414", "volume": 1.4758 } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | time | number | Candle start, unix milliseconds | | open, high, low, close | string | Prices | | volume | number | Volume in the unit chosen by `volumeField` | To get candles by token pair rather than by pool, use `GET https://wax.alcor.exchange/api/v2/swap/candles?tokenA=&tokenB=` with the same parameters. It picks the pair's main pool (the active pool with the highest TVL), prices token A in token B as asked, and answers `{ "candles": [...], "poolId": 1095, "isReversed": false }`, where `isReversed` tells that the pool holds the tokens in the other order. ## Swap route [#swap-route] The best way to swap one token for another through the AMM pools, ready to be sent as transfers to `swap.alcor`. `GET https://wax.alcor.exchange/api/v2/swapRouter/getRoute` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | trade_type | string | yes | `EXACT_INPUT`: `amount` is what you send. `EXACT_OUTPUT`: `amount` is what you receive | | input | string | yes | Token id you send | | output | string | yes | Token id you receive | | amount | string | yes | Amount in token units, e.g. `1.5`. No more decimals than the token has | | slippage | number | no | Tolerance in percent. Default `0.3` | | receiver | string | no | Account written into the memos. Default is the literal ``, to replace before signing | | maxHops | number | no | Most pools per route. Default and maximum `3` | | v2 | any | no | Any non-empty value splits the trade across up to 5 routes. Without it, one route | | includePoolDetails | boolean | no | `true` adds `pools`: fee and tokens of every pool used | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/swapRouter/getRoute?trade_type=EXACT_INPUT&input=wax-eosio.token&output=tlm-alien.worlds&amount=10&slippage=0.3&receiver=alcordexfund&maxHops=2" ``` ```json { "route": [12501, 12406], "memo": "swapexactin#12501,12406#alcordexfund#39.7961 TLM@alien.worlds#0", "swaps": [ { "input": "10.00000000 WAX", "route": [12501, 12406], "output": "39.9155 TLM", "percent": 100, "memo": "swapexactin#12501,12406#alcordexfund#39.7961 TLM@alien.worlds#0", "maxSent": "10.00000000", "minReceived": "39.7961" } ], "input": "10.00000000", "output": "39.9155", "minReceived": "39.7961", "maxSent": "10.00000000", "priceImpact": "0.31", "executionPrice": { "numerator": "399155", "denominator": "1000000000" } } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | swaps | array | One transfer per split, see below | | input | string | Total amount sent | | output | string | Total amount expected | | minReceived | string | Exact input: the least the trade may return, after slippage | | maxSent | string | Exact output: the most the trade may take, after slippage | | priceImpact | string | Percent below the pools' spot prices | | executionPrice | object | Raw output per raw input, as a fraction | | route, memo | array, string | Pools and memo of the first swap only. Kept for old clients; use `swaps` | | pools | object | Only with `includePoolDetails=true`: pool id to `fee`, `tokenA`, `tokenB` | **Each swap** | Name | Type | Description | | --- | --- | --- | | input | string | Asset to transfer | | output | string | Asset this swap is expected to return | | percent | number | Share of the trade | | route | array | Pool ids the swap goes through | | memo | string | Memo for the transfer | | minReceived, maxSent | string | This swap's bounds | To swap, put one `transfer` of the input token per element of `swaps` into a single transaction: `to: "swap.alcor"`, `quantity: swap.input`, `memo: swap.memo` with `` replaced by the user's account. Errors are plain text: HTTP 403 with `Invalid request`, `Invalid amount`, `Invalid slippage` or `Invalid input/output`, and HTTP 404 with `No trading route available. Try again in a few moments.` ## Swap route v3 [#swap-route-v3] Routes through the AMM pools and the spot order books together. Answers with the transfers to send and, given the user's account, the actions ready to sign. Use it for new integrations. `GET https://wax.alcor.exchange/api/v3/swapRouter/getRoute` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | tradeType | string | yes | `exactIn`: `amount` is what you send. `exactOut`: `amount` is what you receive (AMM only) | | input | string | yes | Token id you send | | output | string | yes | Token id you receive | | amount | string | yes | Amount in token units, e.g. `1.5` | | slippage | number | no | Tolerance in percent. Default `0.3` | | account | string | no | The user's account: receiver of every swap and signer of `actions`. Without it the memos carry `` and there are no `actions` | | permission | string | no | Permission for `actions`. Default `active` | | maxHops | number | no | Pools per AMM route, `1` to `3`. Default `3` | | orderbook | boolean | no | `false` keeps the trade on the AMM. Default `true` | **Example** ```shell curl "https://wax.alcor.exchange/api/v3/swapRouter/getRoute?tradeType=exactIn&input=wax-eosio.token&output=tlm-alien.worlds&amount=10&slippage=0.3&account=alcordexfund" ``` ```json { "tradeType": "exactIn", "input": { "id": "wax-eosio.token", "symbol": "WAX", "contract": "eosio.token", "decimals": 8, "amount": "10.00000000" }, "output": { "id": "tlm-alien.worlds", "symbol": "TLM", "contract": "alien.worlds", "decimals": 4, "amount": "39.9242" }, "minReceived": "39.8047", "maxSent": "10.00000000", "priceImpact": "0.3", "routes": [ { "percent": 61, "input": "6.10000000", "output": "24.3483", "hops": [ { "venue": "amm", "pool": 12501, "input": "wax-eosio.token", "output": "usdt-wrap.alcor", "fee": "0.01" }, { "venue": "amm", "pool": 12406, "input": "usdt-wrap.alcor", "output": "tlm-alien.worlds", "fee": "0.3" } ] } ], "transfers": [ { "tokenContract": "eosio.token", "to": "swap.alcor", "quantity": "6.10000000 WAX", "memo": "swapexactin#12501,12406#alcordexfund#24.2754 TLM@alien.worlds#0" } ], "actions": [ { "account": "eosio.token", "name": "transfer", "authorization": [{ "actor": "alcordexfund", "permission": "active" }], "data": { "from": "alcordexfund", "to": "swap.alcor", "quantity": "6.10000000 WAX", "memo": "swapexactin#12501,12406#alcordexfund#24.2754 TLM@alien.worlds#0" } } ] } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | tradeType | string | As requested | | input, output | object | Token metadata and the total `amount` sent or expected | | minReceived | string | Exact input: the least the trade may return | | maxSent | string | Exact output: the most the trade may take | | priceImpact | string | Percent below the venues' spot prices | | routes | array | Paths the input takes: `percent`, `input`, `output` and `hops`. Each hop has `venue` (`amm` or `orderbook`), `pool` or `market`, `input` and `output` token ids, `fee` in percent | | transfers | array | What to send, in order: `tokenContract`, `to`, `quantity`, `memo` | | actions | array | Only with `account`: the transfers as actions, ready to sign | Sign `actions` as they are, in order, in one transaction. An AMM leg is a transfer to `swap.alcor`. An order book leg is a transfer to the DEX contract with the memo ` SYM@contract|min`: a market order that reverts the whole transaction if it pays less than the minimum. Errors are JSON, `{"error": ""}`: HTTP 400 for a bad parameter (`Invalid tradeType`, `Unknown token`, `Invalid amount`, `Invalid slippage`, `Invalid maxHops`, `Invalid orderbook`, `Input and output are the same token`), HTTP 404 for `No route`. # Tokens (/api/tokens) A token is identified by `-` in lower case, e.g. `tlm-alien.worlds`. Prices are refreshed by the indexer and served from cache. ## All tokens [#all-tokens] Every token the exchange knows, with its price and score, sorted by score (highest first). `GET https://wax.alcor.exchange/api/v2/tokens` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | hide_scam | boolean | no | `true` leaves out tokens on the scam lists | **Example** ```shell curl "https://wax.alcor.exchange/api/v2/tokens?hide_scam=true" ``` ```json [ { "contract": "alien.worlds", "decimals": 4, "symbol": "TLM", "id": "tlm-alien.worlds", "usd_price": 0.00123668, "system_price": 0.250077, "score": 93, "is_scam": false, "is_trusted": true, "safe_usd_price": 0.00123668, "safe_system_price": 0.250077, "cmc_id": 9119 } ] ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | id | string | Token id, `-` | | contract | string | Token contract | | symbol | string | Token symbol | | decimals | number | Token precision | | system_price | number | Price in the chain's system token (WAX, EOS, TLOS, XPR) | | usd_price | number | Price in USD | | score | number | Token score, 0 to 100 (see [Token score](#token-score)) | | is_scam | boolean | The token is on the scam lists. Its prices are `0` | | is_trusted | boolean | The token is the system token, a stablecoin, listed as trusted, or scores high enough | | safe_system_price | number | `system_price` for a trusted token, otherwise `0` | | safe_usd_price | number | `usd_price` for a trusted token, otherwise `0`. Use it to value balances | | cmc_id | number | CoinMarketCap id. Present only for tokens CoinMarketCap lists | ## Token [#token] One token by id, with the same fields as [All tokens](#all-tokens). `GET https://wax.alcor.exchange/api/v2/tokens/` **Parameters** | Name | Type | Required | Description | | --- | --- | --- | --- | | token_id | string | yes | Token id, in the path | **Example** ```shell curl https://wax.alcor.exchange/api/v2/tokens/tlm-alien.worlds ``` ```json { "contract": "alien.worlds", "decimals": 4, "symbol": "TLM", "id": "tlm-alien.worlds", "usd_price": 0.00123668, "system_price": 0.250077, "score": 93, "is_scam": false, "is_trusted": true, "safe_usd_price": 0.00123668, "safe_system_price": 0.250077, "cmc_id": 9119 } ``` An unknown id answers HTTP 403 with `Token with this ID is not found`. ## Token score [#token-score] How the token's score is built: its components, the caps applied and the metrics behind them, over a 30-day window. A token without a score answers `{"score": 0}`. `GET https://wax.alcor.exchange/api/v2/tokens//score` **Example** ```shell curl https://wax.alcor.exchange/api/v2/tokens/tlm-alien.worlds/score ``` ```json { "score": 93, "version": "v1", "window": "30d", "components": { "traders": 25, "volume": 20, "liquidity": 14.78, "holders": 10, "activity": 10, "stability": 2.82, "age": 10 }, "capsApplied": [], "metrics": { "uniqueTraders": 809, "volumeUsd": 78906.79, "tvlUsd": 15216.25, "turnover": 5.1857, "holdersCount": 2550784, "tradesCount": 231377, "avgDailyTrades": 7712.5667, "currentPrice": 0.00123848, "rollingHigh30d": 0.00249163, "drawdown30d": 0.497056, "stabilityPoolId": 1256, "ageDays": 2187 }, "updatedAt": "2026-10-15T12:31:16.265Z" } ``` **Response fields** | Name | Type | Description | | --- | --- | --- | | score | number | Total score, 0 to 100 | | version, window | string | Scoring model version and the window it looks at | | components | object | Points per component: traders, volume, liquidity, holders, activity, stability, age | | capsApplied | array | Caps that limited the total, if any | | metrics | object | Raw figures behind the components: USD values, counts, price drawdown, age in days | | updatedAt | string | When the score was computed | The answer also carries a few trend fields, such as `volumeUsd7d`, `trades7d`, `uniqueTraders24h` and `priceChange7dPct`. ## Token logo [#token-logo] The token's logo image. `GET https://wax.alcor.exchange/api/v2/tokens//logo` ```shell curl -L -o tlm.png https://wax.alcor.exchange/api/v2/tokens/tlm-alien.worlds/logo ``` Answers with the image itself or with a redirect to it, so follow redirects (`curl -L`). The logo comes from the on-chain token registry first, then from Alcor's own logo set, then from public token lists. A token without a logo answers HTTP 404. # Trade API (/api/trade-api) The HTTP API only reads data. Orders are placed and cancelled by sending transactions to the DEX contract through any node API, signed by the order owner. The examples use [eosjs](https://github.com/EOSIO/eosjs) and the WAX contract `alcordexmain`; the contract of each chain is listed in [On-chain Data](/api/onchain-data). ```javascript import { Api, JsonRpc } from 'eosjs' import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig' const rpc = new JsonRpc('https://wax.greymass.com', { fetch }) const signatureProvider = new JsSignatureProvider(['']) const api = new Api({ rpc, signatureProvider }) ``` ## Place order [#place-order] Transfer the amount you sell (the bid) to the DEX contract, with the amount you want in return (the ask) in the memo. The contract finds the market and the price from the two tokens and amounts, fills what it can against the opposite side, and leaves the rest as an open order. Memo format: ` @`, e.g. `0.0010 EOS@eosio.token`. ```shell # bob sells 0.5 TKT for 0.001 EOS cleos push action tktoken transfer \ '["bob", "alcordexmain", "0.5000 TKT", "0.0010 EOS@eosio.token"]' -p bob@active ``` ```javascript await api.transact({ actions: [{ account: 'tktoken', // contract of the token you sell name: 'transfer', authorization: [{ actor: 'bob', permission: 'active' }], data: { from: 'bob', to: 'alcordexmain', quantity: '0.5000 TKT', // bid memo: '0.0010 EOS@eosio.token' // ask } }] }, { blocksBehind: 3, expireSeconds: 30 }) ``` Several orders can be placed in one transaction, one transfer action each. Orders cannot be changed. To move an order, cancel it and place a new one. ## Cancel order [#cancel-order] Call `cancelbuy` for a buy order or `cancelsell` for a sell order on the DEX contract. | Parameter | Description | | --- | --- | | executor | Order owner | | market_id | Market id of the order | | order_id | Order id | ```shell # bob cancels sell order 1284277 on market 262 cleos push action alcordexmain cancelsell '["bob", 262, 1284277]' -p bob@active ``` ```javascript await api.transact({ actions: [{ account: 'alcordexmain', name: 'cancelsell', // or 'cancelbuy' authorization: [{ actor: 'bob', permission: 'active' }], data: { executor: 'bob', market_id: 262, order_id: 1284277 } }] }, { blocksBehind: 3, expireSeconds: 30 }) ``` Find order ids in the `buyorder` and `sellorder` tables ([On-chain Data](/api/onchain-data#orders)). # WebSocket (/api/websocket) Live updates are served over [Socket.IO](https://socket.io/) (version 4 client). Connect once, then join rooms with `subscribe` and leave them with `unsubscribe`. Every room takes the chain in its `params`: `wax`, `eos`, `telos` or `proton`. For token prices, pair prices, pools and order books updated every block, over a plain WebSocket with no Socket.IO client, use the [Market stream](/api/market-api#market-stream). ```javascript import { io } from 'socket.io-client' const socket = io('https://wax.alcor.exchange', { transports: ['websocket'] }) socket.emit('subscribe', { room: 'deals', params: { chain: 'wax', market: 26 } }) socket.on('new_deals', deals => console.log(deals)) ``` | Room | Params | Events | | --- | --- | --- | | deals | `chain`, `market` | `new_deals` | | orderbook | `chain`, `market`, `side` | `orderbook_buy`, `orderbook_sell` | | ticker | `chain`, `market`, `resolution` | `tick` | | swap-ticker-v2 | `chain`, `pool`, `resolution` | `swap-tick-v2` | | account | `chain`, `name` | `match`, `account:update-v2` | ## Deals [#deals] New trades of a spot market. ```javascript socket.emit('subscribe', { room: 'deals', params: { chain: 'wax', market: 26 } }) socket.on('new_deals', deals => { /* ... */ }) socket.emit('unsubscribe', { room: 'deals', params: { chain: 'wax', market: 26 } }) ``` On subscribe, `new_deals` delivers the market's last 200 trades. After that, each new trade arrives as a one-element array: ```json [ { "time": 1674820074000, "ask": 3.5771, "bid": 0.99799129, "type": "buymatch", "unit_price": 0.27899985, "trx_id": "d4acaa5ae75bccad12ca82dd2d1d3fa5822cece1307ced10ee0daefaeb6d5009" } ] ``` The fields are those of [Spot trades](/api/account#spot-trades). `time` is unix milliseconds in new trades and an ISO 8601 string in the initial batch, whose trades also carry `_id`. ## Order book [#order-book] Order book levels of one side of a spot market. Subscribe to each side you need. ```javascript socket.emit('subscribe', { room: 'orderbook', params: { chain: 'wax', market: 26, side: 'buy' } }) socket.emit('subscribe', { room: 'orderbook', params: { chain: 'wax', market: 26, side: 'sell' } }) socket.on('orderbook_buy', levels => { /* bids */ }) socket.on('orderbook_sell', levels => { /* asks */ }) // Leaves both sides socket.emit('unsubscribe', { room: 'orderbook', params: { chain: 'wax', market: 26 } }) ``` ```json [ [27899985, 3044158, 8493196253] ] ``` The first message holds the whole side (up to 1000 levels), best price first. Later messages hold only the levels that changed. Each level is `[unit_price, bid, ask]`: | Index | Description | | --- | --- | | 0 | Price as an integer: target per base multiplied by 10^8. Identifies the level | | 1 | Sum of what the level's orders offer, in the smallest units of that token | | 2 | Sum of what they want in return, in the smallest units of that token | A level whose amounts are both `0` has been removed. ## Ticker [#ticker] Live candle of a spot market: every change to the current candle is pushed. ```javascript socket.emit('subscribe', { room: 'ticker', params: { chain: 'wax', market: 26, resolution: '30' } }) socket.on('tick', candle => { /* ... */ }) // Without resolution, leaves every resolution of the market socket.emit('unsubscribe', { room: 'ticker', params: { chain: 'wax', market: 26, resolution: '30' } }) ``` ```json { "open": 0.01175084, "high": 0.01175084, "low": 0.01175084, "close": 0.01175084, "volume": 0.11727339, "time": 1674821301500 } ``` Resolutions are those of [Candles](/api/market-data#candles): `1`, `5`, `15`, `30`, `60`, `240`, `1D`, `1W`, `1M`. `time` is the candle start in unix milliseconds, `volume` is in target. ## Pool ticker [#pool-ticker] Live candle of an AMM pool. The current candle is sent at once on subscribe, then on every change. ```javascript socket.emit('subscribe', { room: 'swap-ticker-v2', params: { chain: 'wax', pool: 1095, resolution: '60' } }) socket.on('swap-tick-v2', tick => { /* ... */ }) socket.emit('unsubscribe', { room: 'swap-ticker-v2', params: { chain: 'wax', pool: 1095, resolution: '60' } }) ``` ```json { "v": 2, "chain": "wax", "poolId": 1095, "resolution": "60", "time": 1792062000000, "bar": { "volumeUSD": 1.47, "sqrtPriceX64": { "open": "12900000000000000", "high": "12931342024590619", "low": "12900000000000000", "close": "12931342024590619" }, "price": { "aPerB": { "open": "0.00489139", "high": "0.00491414", "low": "0.00489139", "close": "0.00491414" }, "bPerA": { "open": "204.4407", "high": "204.4407", "low": "203.494", "close": "203.494" } } }, "pair": { "tokenA": { "id": "wax-eosio.token", "contract": "eosio.token", "symbol": "WAX", "decimals": 8 }, "tokenB": { "id": "usdt-usdt.alcor", "contract": "usdt.alcor", "symbol": "USDT", "decimals": 4 } }, "serverTime": 1792065005120, "source": "chain" } ``` | Name | Description | | --- | --- | | poolId, resolution | Which candle this is. Filter on them if you hold several subscriptions | | time | Candle start, unix milliseconds | | bar.volumeUSD | Candle volume, USD | | bar.price.aPerB | Prices of token A in token B | | bar.price.bPerA | Prices of token B in token A | | bar.sqrtPriceX64 | The same candle as Q64.64 square-root prices | | source | `chain`: pushed at once from the swap action. `db`: the stored candle, authoritative | | serverTime | When the server sent it, unix milliseconds | ## Account [#account] Events of one account. ```javascript socket.emit('subscribe', { room: 'account', params: { chain: 'wax', name: 'alice.wam' } }) socket.on('match', match => { /* one of the account's orders traded */ }) socket.on('account:update-v2', update => { /* something of the account changed */ }) socket.emit('unsubscribe', { room: 'account', params: { chain: 'wax', name: 'alice.wam' } }) ``` **match**: an order of the account traded. ```json { "market_id": 156, "price": 0.01175084, "side": "buy", "match_type": "buymatch", "base_volume": 9.98, "target_volume": 0.11727339, "ask": 0.11727339 } ``` `side` is `buy` or `sell` for the taking order, `base_volume` and `target_volume` are the traded amounts. The event sent to the asker carries `ask`, the one sent to the bidder carries `bid` instead: the amount that account received. **account:update-v2**: the account's balances, orders or positions changed. Use it as a signal to reload them. ```json { "v": 2, "chain": "wax", "account": "alice.wam", "balances": [{ "contract": "eosio.token", "symbol": "WAX" }], "balancesAll": false, "orders": [26], "positions": [], "accountLimits": true, "meta": { "contract": "alcordexmain", "action": "buyreceipt", "trx_id": "…", "block_num": 461162168 } } ``` | Name | Description | | --- | --- | | balances | Token balances that changed, or `null` | | balancesAll | `true` when any balance may have changed: reload all | | orders | Spot market ids where the account's orders changed | | positions | AMM position ids that changed | | accountLimits | `true` when the account's resources may have changed | | meta | The action that caused the update | # Definitions (/definitions-1) **Mainnet** — the live, production network of a blockchain, as opposed to a testnet. **Market order** — an order to buy or sell immediately at the best available price. It is guaranteed to execute, but the execution price is not guaranteed. **Limit order** — an order to buy or sell at a set price or better. It waits in the order book until it is filled or cancelled. **Order book** — the list of open buy (bid) and sell (ask) limit orders for a market, grouped by price. **Liquidity pool** — a pool of two tokens that traders swap against instead of matching with another trader. See [What is a liquidity pool?](/faq/what-is-a-liquidity-pool) **Fee tier** — the fee a pool charges on every swap, paid to its liquidity providers. Alcor pools use 0.01%, 0.05%, 0.3% or 1%. **Price impact** — how much your own trade moves the price of the pair. It is larger in pools and markets with little liquidity. **Slippage** — the difference between the expected price of a trade and the price at which it executes. The slippage tolerance you set on a swap defines the minimum amount you accept to receive; if the price moves beyond it, the swap fails instead of executing. # Examples (/developers-api/amm-swap-contract-api/examples) Pools are in table `pools` of `swap.alcor`, scope `swap.alcor`. Positions are in table `positions`, scope: the pool ID; index position 3 filters by owner. - [Current price of a pool](https://gist.github.com/avral/239e31232eb9a173b77c56dc537ddb6d), e.g. TLM/WAX. - [Token amounts in an account's positions](https://gist.github.com/avral/43a6dacbad1f3db3fe3b0e56b53ba7e7) in a pool. # Formulas (/developers-api/amm-swap-contract-api/formulas) For applications, use the [Alcor SDK](https://github.com/alcorexchange/alcor-v2-sdk). The formulas below are for working with the contract directly. ## Pool price [#pool-price] `sqrtPriceX64` is in the `currSlot` field of the pool row. `precisionA` and `precisionB` are the token precisions. ``` Price of tokenA in tokenB: sqrtPriceX64 ** 2 / 2 ** 128 * 10 ** (precisionA - precisionB) Price of tokenB in tokenA: 2 ** 128 / sqrtPriceX64 ** 2 * 10 ** (precisionB - precisionA) ``` `sqrtPriceX64` is a 128-bit integer. Square it with big integers (e.g. `BigInt`) to avoid losing precision. # Swap contract (/developers-api/amm-swap-contract-api) The Alcor swap contract runs under the same account on every chain: `swap.alcor`. For application development use the [Alcor SDK](https://github.com/alcorexchange/alcor-v2-sdk). To find a route and the expected output, use the [route API](/api/swap). ## Swap [#swap] Transfer the input token to `swap.alcor` with a memo: ``` ##### ``` | Field | Description | | --- | --- | | `type` | `swapexactin` or `swapexactout` | | `pool_ids` | Pool ID, or comma-separated pool IDs of a multi-hop route in swap order, e.g. `0,12` | | `recipient` | Account that receives the output. Cannot be `swap.alcor` | | `output_token` | Extended asset ` @`, see below | | `deadline` | Optional. Unix time in seconds after which the swap fails. `0` means no deadline | | `market` | Optional. Account registered with `regmarket` that takes an extra fee | - **swapexactin** swaps the whole input. `output_token` is the minimum output; the transaction fails if the output is lower. An amount of zero sets no minimum. - **swapexactout** delivers exactly `output_token`. The transferred amount is the maximum input; the unused part is returned to the sender. ``` swapexactin#0#alcordexfund#3.9167 TLM@alien.worlds#0 swapexactin#0#alcordexfund#3.9167 TLM@alien.worlds#0#mymarket ``` The swap fee is the pool fee plus the market fee. Both are in millionths: `3000` = 0.3%. ## Market fee [#market-fee] An application can take its own fee on swaps it routes. Register once with `regmarket`, signed by the market account: | Parameter | Type | Description | | --- | --- | --- | | `marketName` | `name` | Account that receives the fee | | `marketFee` | `uint32` | Fee in millionths, at most `10000` (1%) | Then pass the account as the last memo field. The market fee is paid in the input token to that account. # Contract actions (/developers-api/contract-actions) You trade by transferring tokens to the DEX contract with a memo. The contract account differs per chain (see [Smart Contracts](/developers-api#contract-accounts)). The examples below use WAX (`alcordexmain`). A memo that has no `@` or no space is treated as a plain transfer. ## Limit order [#limit-order] Transfer the amount you sell (the **bid**) and put the amount you want to receive (the **ask**) in the memo. The contract finds the market by the token pair and derives the price from bid and ask. ``` @ ``` ``` 1000.0000 TLM@alien.worlds ``` - The ask must use the token's exact precision and contract. - The part of the order that matches is filled at once. The rest stays in the order book. - Each market has minimum amounts, `min_buy` (base token) and `min_sell` (quote token), in the [markets table](/developers-api/contract-tables#markets). - An account can hold up to 300 open orders by default. - Orders cannot be edited. Cancel and place a new one. ## Market order [#market-order] Set the ask amount to zero. The order fills against the best opposite orders, and the unfilled remainder is refunded. ``` 0.0000 TLM@alien.worlds ``` To fail the transaction unless you receive at least a minimum amount (after fees), put that amount in the memo and add `|min`: ``` 950.0000 TLM@alien.worlds|min ``` ## Cancel order [#cancel-order] Call `cancelbuy` or `cancelsell` on the DEX contract, signed by the order owner. The remaining bid is returned to the owner. | Parameter | Type | Description | | --- | --- | --- | | `executor` | `name` | Order owner | | `market_id` | `uint64` | Market ID | | `order_id` | `uint64` | Order ID in `buyorder` or `sellorder` | ```shell cleos -u https://wax.greymass.com push action alcordexmain cancelsell '["bob", 26, 1284277]' -p bob ``` ## Fees [#fees] Each market has a `fee` in hundredths of a percent (`20` = 0.2%). On every match, both sides receive their amount minus the fee. ## Open a new market [#open-a-new-market] Transfer the market creation fee in the chain's system token (from `eosio.token`) with this memo: ``` new_market|| ``` `` and `` are zero amounts with full precision, symbol and contract: ``` new_market|0.00000000 WAX@eosio.token|0.0000 TLM@alien.worlds ``` The transaction fails if the market already exists or both tokens are the same. The fee goes to the Alcor fee account. See [Market creation](/developers-api/market-creation) for the fee on each chain. # Contract tables (/developers-api/contract-tables) Tables of the order book DEX contract (`alcordexmain` on WAX, `eostokensdex` on EOS and Telos, `alcor` on XPR Network). ## Markets [#markets] Table `markets`, scope: the contract account. ```cpp struct [[eosio::table]] market { uint64_t id; extended_symbol base_token; // token prices are quoted in, e.g. WAX extended_symbol quote_token; // traded token, e.g. TLM asset min_buy; // minimum order amount in base_token asset min_sell; // minimum order amount in quote_token bool frozen = false; uint8_t fee = 0; // hundredths of a percent, 20 = 0.2% 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() ); } // e.g. "TLM/WAX" 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> > markets_index; ``` The `bytokens` index finds a market by its token pair. The key does not depend on token order: ```cpp 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(a, b, c, d); else return checksum256::make_from_word_sequence(c, d, a, b); } ``` A JavaScript version is `make256key` in [alcor-ui/utils/index.js](https://github.com/alcorexchange/alcor-ui/blob/master/utils/index.js). ## Orders [#orders] Tables `buyorder` and `sellorder` have the same structure. Scope: the market ID. ```cpp struct [[eosio::table]] buyorder { uint64_t id; name account; // order owner asset bid; // amount the owner gives asset ask; // amount the owner wants uint128_t unit_price; // price in base_token per quote_token, times 10^8 uint32_t timestamp; // seconds uint64_t primary_key() const { return id; } uint128_t get_price() const { return -unit_price; } // sellorder: unit_price uint64_t get_account() const { return account.value; } }; typedef eosio::multi_index<"buyorder"_n, buyorder, indexed_by<"byprice"_n, const_mem_fun>, indexed_by<"byaccount"_n, const_mem_fun> > buyorders_t; ``` In a buy order `bid` is in the base token and `ask` in the quote token. A sell order is the other way round. The `byprice` index (index position 2, key type `i128`) returns the best orders first: highest price for `buyorder`, lowest for `sellorder`. The `byaccount` index (position 3, `i64`) filters by owner. ```shell cleos -u https://wax.greymass.com get table alcordexmain 26 buyorder --index 2 --key-type i128 -l 10 ``` ## Accounts [#accounts] Table `account`, scope: the contract account. Counts open orders per owner. ```cpp struct [[eosio::table]] account { name account; map buyorders; // market_id -> open buy orders map sellorders; // market_id -> open sell orders uint16_t orders_total = 0; uint16_t orders_limit = 300; }; ``` ## Legacy AMM pairs [#legacy-amm-pairs] The first-generation AMM contract `alcorammswap` (WAX and Telos) keeps pools in table `pairs`, scope `alcorammswap`. Current pools are on [swap.alcor](/developers-api/amm-swap-contract-api). ```cpp struct [[eosio::table]] pairs_struct { uint64_t id; asset supply; // LP token supply extended_asset pool1; extended_asset pool2; int32_t fee; name fee_contract; uint64_t primary_key() const { return id; } checksum256 secondary_key() const { return make256key( 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_index; ``` # Smart Contracts (/developers-api) Markets, orders and pools live on chain. You can trade, cancel orders and read tables with a block explorer, `cleos` or a JavaScript client such as eosjs. For HTTP and WebSocket data, see the [API Reference](/api). The order book contract `book.alcor` runs on Telos, WAX and XPR Network: limit orders with post-only, IOC, FOK and expiry, stop and take-profit triggers, and swaps straight from a wallet with one transfer. See [Order book (book.alcor)](/developers-api/order-book). ## Contract accounts [#contract-accounts] | Chain | Order book DEX | Swap (AMM) | | --- | --- | --- | | WAX | `alcordexmain` | `swap.alcor` | | EOS | `eostokensdex` | `swap.alcor` | | Telos | `eostokensdex` | `swap.alcor` | | XPR Network (Proton) | `alcor` | `swap.alcor` | The first-generation AMM contract `alcorammswap` still holds old liquidity on WAX and Telos. See [Legacy AMM pairs](/developers-api/contract-tables#legacy-amm-pairs). ## Pages [#pages] # Market creation (/developers-api/market-creation) Anyone can open an order book market for two tokens that do not have one yet. This is not a listing request or a verification: the contract creates the market at once, and it is ready for orders. ## In the app [#in-the-app] Open `https://.alcor.exchange/new_market` (for example [wax.alcor.exchange/new_market](https://wax.alcor.exchange/new_market)), or click **Open new market** on the Markets page on desktop. 1. **Quote token (target token)**: the token prices are quoted in. Pick it from your balances. The system token or USDT is recommended. 2. **Base token (listing token)**: the token you list. **Auto select** shows tokens in your wallet. **Manually** takes a token contract and symbol. 3. Check the fee and click **Create market**. The new market shows up on the site within a couple of minutes. ## Fee [#fee] The app charges the fee in the chain's system token: | Chain | Fee | | --- | --- | | WAX | 500.00000000 WAX | | EOS | 10.0000 EOS | | Telos | 100.0000 TLOS | | XPR Network | 2000.0000 XPR | The fee doubles if the target token is not the system token. On WAX, EOS and Telos the transaction also buys 530 bytes of RAM for the DEX contract to store the market. ## With a transaction [#with-a-transaction] The app sends a transfer to the DEX contract with a `new_market|...` memo. See [Open a new market](/developers-api/contract-actions#open-a-new-market) for the format. The app's labels are the reverse of the contract's: the target token becomes `base_token` and the listing token `quote_token` in the [markets table](/developers-api/contract-tables#markets). # Actions (/developers-api/order-book/actions) Examples use Telos and market 2, BNB/USDC (`lot_size` 0.001 BNB, `tick_size` 100). Amounts in actions are minimal units: a price is quote units per lot, a quantity is lots. See [Units](/developers-api/order-book#units). ## Deposit [#deposit] Transfer the token to `book.alcor`. Any memo that does not start with `swap#` is a deposit to the sender. ```shell cleos -u https://mainnet.telos.net push action wrap.alcor transfer \ '["alice", "book.alcor", "100.000000 USDC", ""]' -p alice ``` Transfers from system accounts (`eosio`, `eosio.*`, including Telos EVM withdrawals sent straight to the contract) are not credited to anyone. Tokens that take a fee on transfer are refused. ## Withdraw [#withdraw] | Parameter | Type | Description | | --- | --- | --- | | `owner` | `name` | Account whose available balance pays | | `to` | `name` | Recipient | | `contract` | `name` | Token contract | | `quantity` | `asset` | Amount | | `memo` | `string` | Transfer memo | The contract only sends to an account that already has a row of the token, otherwise `recipient has no balance row`. Put the token's `open` before `withdraw` in the same transaction, signed by the owner: it does nothing when the row exists and creates it, paid by the owner, when it does not. ```shell cleos -u https://mainnet.telos.net push transaction '{"actions":[ {"account":"wrap.alcor","name":"open","authorization":[{"actor":"alice","permission":"active"}], "data":{"owner":"alice","symbol":"6,USDC","ram_payer":"alice"}}, {"account":"book.alcor","name":"withdraw","authorization":[{"actor":"alice","permission":"active"}], "data":{"owner":"alice","to":"alice","contract":"wrap.alcor","quantity":"100.000000 USDC","memo":""}}]}' ``` ## Place order [#place-order] `placeorder(owner, market_id, side, price, qty, flags, expires_at)` | Parameter | Type | Description | | --- | --- | --- | | `owner` | `name` | Order owner | | `market_id` | `uint64` | Market ID | | `side` | `uint8` | `0` buy, `1` sell | | `price` | `uint64` | Quote units per lot, a multiple of `tick_size` | | `qty` | `uint64` | Lots | | `flags` | `uint8` | At most one: `0` none, `1` post-only, `2` IOC, `4` FOK, `8` post-only-skip | | `expires_at` | `uint32` | Block time in seconds after which the order no longer trades; `0` never | Buy 34 lots (0.034 BNB) at 730.0 USDC per BNB, post-only, no expiry. A lot of 0.001 BNB at 730 USDC costs 0.73 USDC, so the price is `730000`: ```shell cleos -u https://mainnet.telos.net push action book.alcor placeorder \ '["alice", 2, 0, 730000, 34, 1, 0]' -p alice ``` The action returns `{order_id, filled, filled_quote, rested, truncated, work}`: the resting order's ID (`0` if nothing rests), lots filled at once and their quote value before fees, lots left in the book, whether the work budget cut the order short, and work units spent. **Flags** - **Post-only** (`1`) fails the transaction if any live order sits at its price, your own included. - **Post-only-skip** (`8`) is a post-only that, where it would trade, places nothing and does not fail: `order_id = 0`, `rested = 0`, no event. A batch of cancels and new quotes in one transaction survives one quote the price ran over. Other errors (funds, tick grid, `min_notional`) still fail the transaction. - **IOC** (`2`) fills what it can and returns the rest. A market sell by amount is an IOC at the worst price you accept. - **FOK** (`4`) fills completely or fails. Only an order that can rest may carry `expires_at`, and it must be in the future. ## Buy by amount [#buy-by-amount] `buyquote(owner, market_id, quote, max_price)` spends up to `quote` minimal quote units, fees included, at prices up to `max_price`. It never rests; whatever is not spent comes back. It returns the same result as `placeorder`. There is no sell by amount: sell by quantity. ## Cancel [#cancel] | Action | Parameters | Who | | --- | --- | --- | | `cancel` | `order_id` | The owner; anyone for an expired order (funds go to its owner) | | `reduceorder` | `order_id`, `qty_rem` | The owner. Lowers the remaining lots and keeps the place in the queue. The new remainder must be smaller and not below `min_notional` | | `cancelall` | `owner`, `market_id`, `limit` | The owner. Cancels up to `limit` (at most 100) orders and triggers in one market and returns how many went. If that equals `limit`, call again | ```shell cleos -u https://mainnet.telos.net push action book.alcor cancelall '["alice", 2, 100]' -p alice ``` ## Triggers [#triggers] A trigger is a limit order with its funds locked at once, waiting for the market's reference price: the median of the last trade prices of the last three blocks that traded. One transaction is one block, so it cannot move the reference alone. Until three blocks have traded there is no reference and triggers do not fire. `placetrigger(owner, market_id, side, op, trigger_price, limit_price, qty, flags)` | Parameter | Description | | --- | --- | | `op` | `0` fires when the reference falls to `trigger_price`, `1` when it rises to it | | `limit_price` | Price of the order it places, and its worst execution price | | `flags` | `0` or `2` (IOC). Stop-market: IOC with a distant `limit_price`. Stop-limit: no IOC, the remainder rests | `placeoco(owner, market_id, side, qty, stop_price, stop_limit, stop_flags, take_price, take_limit, take_flags)` places two triggers on one quantity with one shared lock. When one leg fires or is cancelled, the other goes too. `canceltrig(trigger_id)` cancels a trigger and its OCO leg. Due triggers fire right after a trade, inside the same action, up to 16 at a time; `cranktrig(market_id, limit)`, which anyone may call, fires the rest. A trigger that is already due cannot be placed. Give a stop-market a limit a few percent from its trigger price: with a one-tick limit it sells at any price. ## Read-only actions [#read-only-actions] `getdepth(market_id, side, limit)`, `getorders(owner, market_id, after, limit)` and `gettriggers(owner, market_id, after, limit)` return data without changing state. Call them with `send_read_only_transaction` on an API node with read-only threads. In a normal transaction or `compute_transaction` the return value is capped at 256 bytes on Telos — about 12 depth levels or 4 orders. ## Errors [#errors] | Message | Cause | | --- | --- | | `post-only order would trade` | A post-only order meets a live order at its price | | `recipient has no balance row` | Withdraw or swap output to an account without a row of the token; add `open` first | | `only a resting order can expire` | `expires_at` on an IOC or FOK order | | `order already expired` | `expires_at` not after the current block time | | `swap: received , less than minimum ` | A swap got less than its `min_out` | # Order book (book.alcor) (/developers-api/order-book) `book.alcor` is Alcor's spot order book contract: price-time priority, limit orders with post-only, IOC and FOK, market buys by amount, order expiry, stop and take-profit triggers with OCO, and swaps straight from a wallet with one transfer. The swap router reads it together with the AMM pools, so a swap on Alcor fills against the order book whenever its price is better. ## Networks [#networks] | Network | Contract | Fee account | Indexer API | | --- | --- | --- | --- | | Telos | `book.alcor` | `fees.alcor` | `https://telos.alcor.exchange/api/v2/orderbook` | | WAX | `book.alcor` | `fees.alcor` | `https://wax.alcor.exchange/api/v2/orderbook` | | XPR Network | `book.alcor` | `fees.alcor` | `https://proton.alcor.exchange/api/v2/orderbook` | The contract code is the same on every network. See the [order book API](/api/order-book). ## Internal balances [#internal-balances] Trading runs on balances held by the contract: 1. **Deposit** — transfer a token to `book.alcor` with any memo. The amount is credited to the sender. 2. **Trade** — orders lock what they need from the available balance and trade without token transfers. 3. **Withdraw** — `withdraw` sends tokens from the available balance to any account that has a row of that token. A [swap](/developers-api/order-book/swap) skips the ledger: one transfer in, the output and any change come back in the same action, and nothing stays on the exchange. Each balance has `available` and `locked`. A sell locks its base; a buy locks `qty * price` plus the taker fee and gets back whatever the fill did not need. ## Units [#units] Every market has two fixed numbers: | Field | Meaning | | --- | --- | | `lot_size` | minimal base units in one lot | | `price` | minimal quote units one lot costs | An order of `qty` lots at `price` moves `qty * lot_size` base against `qty * price` quote. All math is in integers; only fees are rounded (down, per fill). `tick_size` is the price step, `min_notional` the smallest quote value of any order or trigger that rests in the book. **Example: WAX/USDT on WAX.** WAX has 8 decimals, USDT 6. `lot_size = 10000000000` is 100 WAX. At 0.00456 USDT per WAX a lot costs 0.456 USDT, so `price = 456000`. `tick_size = 10` makes the price step 0.00001 USDT per lot, or 0.0000001 USDT per WAX. `min_notional = 1000000` is 1 USDT. `lot_size` never changes after listing. `tick_size` and `min_notional` can. ## Fees [#fees] Maker and taker fees are set per market in basis points (`maker_bps`, `taker_bps`). The fee is taken in quote and rounded down on each fill. The rate is fixed in the order when it is placed, so a later fee change never makes a resting order more expensive. The maker rate is never above the taker rate. All markets listed so far trade with 0 / 0. ## Limits [#limits] - **Work budget.** One action does at most 1000 units of work: a fill, or the removal of one of your own orders or an expired order in the way. If the budget runs out while the book still crosses, the rest comes back to you (`truncated = true`) and never rests in the book. - **Minimum size.** A taker remainder below `min_notional` comes back instead of resting. A maker remainder that a partial fill leaves below `min_notional` is cancelled and refunded. - **Self-trade prevention.** Your own order in the way of your taker order is cancelled, not traded. - **Expiry.** An order can carry `expires_at` (block time, seconds). After it the order no longer trades: a taker that reaches it removes it and refunds its owner, and anyone may cancel it. ## Markets [#markets] Markets listed at launch. The live list is the `markets` table or [`GET /markets`](/api/order-book#markets). | Network | ID | Market | Lot | Price step | Min. order | | --- | --- | --- | --- | --- | --- | | Telos | 1 | `USDC@wrap.alcor` / `USDT@wrap.alcor` | 0.01 USDC | 0.0001 USDT | 1 USDT | | Telos | 2 | `BNB@wrap.alcor` / `USDC@wrap.alcor` | 0.001 BNB | 0.1 USDC | 5 USDC | | WAX | 1 | `WAX@eosio.token` / `USDT@wrap.alcor` | 100 WAX | 0.0000001 USDT | 1 USDT | | WAX | 2 | `TLM@alien.worlds` / `USDT@wrap.alcor` | 100 TLM | 0.0000001 USDT | 1 USDT | | WAX | 3 | `WAX@eosio.token` / `USDC@wrap.alcor` | 100 WAX | 0.0000001 USDC | 1 USDC | | XPR | 1 | `XPR@eosio.token` / `XUSDC@xtokens` | 100 XPR | 0.00000001 XUSDC | 1 XUSDC | | XPR | 2 | `XPR@eosio.token` / `USDC@wrap.alcor` | 100 XPR | 0.00000001 USDC | 1 USDC | | XPR | 3 | `XPR@eosio.token` / `USDT@wrap.alcor` | 100 XPR | 0.00000001 USDT | 1 USDT | Price steps are per one base token; a lot's price moves by `tick_size` minimal quote units. ## Pages [#pages] # Market making (/developers-api/order-book/market-making) The Alcor swap router reads `book.alcor` together with the AMM pools. When your quotes beat a pool, swaps fill against them — so liquidity in the book reaches every swap on Alcor, not only traders on the order book page. ## Quote with one transaction [#quote-with-one-transaction] Update a market with one transaction: first `cancel` the orders that moved, then `placeorder` the new ones. Actions run in order, so the funds the cancels release are already available to the new orders. - **Flag 8, post-only-skip.** If the price moves while your transaction is on its way, a quote that would now cross the book is simply not placed, and the rest of the batch goes through. With plain post-only (`1`) one crossing quote reverts the whole transaction — including the cancels, which leaves your old quotes standing exactly when the price has run. - **`expires_at`.** Give every quote an expiry, for example 60 seconds ahead in block time. If your bot stops, its quotes stop trading on their own. Refresh them well before they expire: the router treats an order as expired 10 seconds early. - **Requote threshold.** Leave an order in place while its price is within a few basis points of where you want it. Every update costs CPU, and a new order loses its place in the queue. - **Start and stop with `cancelall`.** It removes up to 100 orders per call; call again while it returns 100. ## Fills [#fills] Subscribe to your account on the [order book API](/api/order-book#websocket): ```json {"op": "subscribe", "channel": "account:alice"} ``` A `trade` event where `owner` is your account is a fill of your order: `id` is the order, `qty` the lots filled, `qty_rem` what is left. The events of your own transactions also come back in the transaction result (`KeySigner.transact` in the [SDK](/developers-api/order-book/sdk)). ## Reading your own state [#reading-your-own-state] A node in `read-mode = head` shows a transaction only once a producer's block includes it. Reading your orders right after sending can return the state from before. Wait until the orders your transaction opened appear and the ones it cancelled disappear — the transaction's `order_open` and `order_cancel` events list them — or until the head is a few blocks past the transaction's block. ## Things to know [#things-to-know] - **Self-trade prevention.** Your own order in the way of your taker order is cancelled, not traded. - **Buy locks include the fee.** A buy locks `ceil(qty * price * (1 + fee_bps / 10000))`; check it against your available quote with `buyReserve`. - **Dust.** A maker remainder below `min_notional` after a partial fill is cancelled and refunded. - **Swaps sell whole lots.** A swap of base sells `floor(amount / lot_size)` lots and returns the rest, so a large lot means larger change for swappers. ## CPU [#cpu] Cancelling and placing about eight orders in one transaction costs roughly 1–1.6 ms of CPU. Re-quoting a market every few seconds adds up to several seconds of CPU a day per market. | Network | How to get CPU | | --- | --- | | Telos | Stake TLOS to the account | | WAX | Stake WAX, or have another account pay: on WAX the first authorizer of the first action pays for the transaction, so a payer's permission linked to a no-op action can go first in every transaction | | XPR Network | `newaccres` gives a new account about 3 s a day. More comes as a 31-day plan from the `resources` contract: transfer XPR to `resources` (memo `account`), then `resources::buyplan(account, plan_index, plan_quantity)`. The plans are in its `plans` table; Plus (1000 XPR) gives about 320 s a day | On XPR, `eosio::stakexpr` is a voting stake and does not add CPU. # SDK (/developers-api/order-book/sdk) `@alcorexchange/orderbook-sdk` is the TypeScript client for `book.alcor`: exact unit conversions, action JSON for any wallet, table and read-only reads, transaction signing for bots, event decoding and a local order book kept current by events. ```bash npm install @alcorexchange/orderbook-sdk @wharfkit/antelope ``` ESM only: Node 20.10+ or a modern bundler. Every 64-bit value is a `bigint`. The published 0.1.0 predates the swap and post-only-skip: `actions.swap`, `quoteSwap` and `OrderFlag.POST_ONLY_SKIP` come with the next release. Until then, build the [swap transfer](/developers-api/order-book/swap) yourself and pass flag `8` as a number. ## Quick start [#quick-start] ```ts import { OrderbookClient, OrderbookActions, KeySigner, Rpc, Side, OrderFlag, priceToUnits, baseToLots } from '@alcorexchange/orderbook-sdk'; const rpc = new Rpc('https://mainnet.telos.net'); const client = new OrderbookClient({ rpc, contract: 'book.alcor' }); const actions = new OrderbookActions('book.alcor'); const m = await client.market(2n); // BNB/USDC: lot size, tick, tokens, fees const order = actions.placeOrder({ owner: 'alice', marketId: m.id, side: Side.BUY, price: priceToUnits(m, '730.0'), qty: baseToLots(m, '0.034'), flags: OrderFlag.POST_ONLY, }); // Wallet users: session.transact({ actions: [order] }). Bots sign with a key: const signer = new KeySigner({ rpc, privateKey: process.env.KEY!, contract: 'book.alcor' }); const { results, events } = await signer.transact([order]); ``` ## Units [#units] Parsing is exact: a value off the token precision, the lot size or the tick grid throws instead of rounding. | Helper | From → to | | --- | --- | | `priceToUnits(m, '730.0')`, `unitsToPrice(m, units)` | price per base token ↔ contract price per lot | | `baseToLots(m, '0.034')`, `lotsToBase(m, lots)` | base amount ↔ lots | | `quoteToUnits(m, '12.5')`, `unitsToQuote(m, units)` | quote amount ↔ minimal units | | `parseUnits`, `formatUnits`, `assetString` | any token amount | ## Actions [#actions] `OrderbookActions` builds action JSON for any wallet (wharfkit Session, Anchor) or a key: - `deposit`, `withdraw` — `withdraw` returns two actions, the recipient's token `open` and the withdrawal; - `placeOrder` with `OrderFlag.POST_ONLY`, `IOC` or `FOK` and an optional `expiresAt` (seconds); - `buyQuote`, `cancel`, `reduceOrder`, `cancelAll`; - `placeTrigger`, `placeOco`, `cancelTrigger`, `crank`. ## Reads [#reads] `OrderbookClient` reads any API node: - `markets()`, `market(id)`, `tokens()`, `config()`; - `book(marketId, side)` (expired orders hidden), `depth(marketId, side, levels)`; - `balances(owner)`, `ordersOf(owner)`, `triggersOf(owner)`; - `triggerQueue(marketId, op)`, `referencePrice(marketId)`; - `readOnly(name, data)` for the read-only actions. ## Local order book [#local-order-book] `BookState` keeps an order book from a snapshot and events, and throws `BookGapError` when an event `seq` is missing: take a new snapshot then. With the [order book API](/api/order-book) the snapshot is `GET /markets/:id/book` and the events come over the WebSocket; `toOrder` and `toEvent` turn their JSON into SDK types. ```ts import { BookState, Side, toEvent, toOrder } from '@alcorexchange/orderbook-sdk'; const api = 'https://telos.alcor.exchange/api/v2/orderbook'; const ws = new WebSocket('wss://telos.alcor.exchange/api/v2/orderbook/ws'); let book: BookState | undefined; ws.onopen = async () => { ws.send(JSON.stringify({ op: 'subscribe', channel: 'market:2' })); // subscribe first, then take the snapshot const snap = await fetch(`${api}/markets/2/book`).then((r) => r.json()); book = new BookState(2n, snap.orders.map(toOrder), BigInt(snap.seq)); }; ws.onmessage = (msg) => { const { events } = JSON.parse(msg.data); for (const e of events ?? []) book?.apply(toEvent(e)); // BookGapError: take the snapshot again if (book) render(book.levels(Side.BUY, 20), book.levels(Side.SELL, 20)); }; ``` Events at or below the snapshot's `seq` are skipped, so subscribing before the snapshot loses nothing. ## Contract math [#contract-math] `buyReserve`, `feeOf`, `affordableLots`, `orderLock`, `isDust`, `referencePrice` and `triggerDue` compute exactly what the contract does, for previews before signing. `KeySigner.transact` returns the events of its own transaction; `decodeEvents` decodes them from state history. # Swap by transfer (/developers-api/order-book/swap) A transfer of the input token to `book.alcor` with this memo trades at once and leaves nothing on the exchange: ``` swap##[#] ``` | Part | Description | | --- | --- | | `market_id` | Decimal market ID | | `min_out` | Minimum output in minimal units of the output token: an integer, no decimal point or symbol | | `recipient` | Who gets the output; the sender by default | This is how the Alcor swap router fills a trade through the order book. ## What happens [#what-happens] - **Base in** sells `floor(quantity / lot_size)` whole lots, IOC, with no price limit. The part below one lot comes back. - **Quote in** buys for the whole amount, fees included, like `buyquote` with no price limit. Whatever cannot buy another lot comes back. - **Output and change** go out in the same action as inline transfers: the output to the recipient (memo `swap`), the unused input to the sender (memo `swap refund`). Zero amounts are not sent. - **Price protection** is `min_out` alone. If the output is below it, the whole transfer fails with `swap: received , less than minimum `. - **Internal balances** do not change and no balance rows are created. If the sender already has a balance, it stays as it was, except where the swap meets the sender's own orders: those are cancelled on the way (self-trade prevention) and their funds return to the sender's available balance. - The output is counted from the fills: for a sell, the quote received minus the taker fee; for a buy, lots filled times `lot_size`. - The work budget is the same 1000 units. If it runs out, the unsold input comes back and `min_out` decides. ## Example [#example] Sell 1111 WAX on WAX market 1 (WAX/USDT, lots of 100 WAX) for at least 5.033293 USDT: ```shell cleos -u https://wax.greymass.com push transaction '{"actions":[ {"account":"wrap.alcor","name":"open","authorization":[{"actor":"alice","permission":"active"}], "data":{"owner":"alice","symbol":"6,USDT","ram_payer":"alice"}}, {"account":"eosio.token","name":"transfer","authorization":[{"actor":"alice","permission":"active"}], "data":{"from":"alice","to":"book.alcor","quantity":"1111.00000000 WAX","memo":"swap#1#5033293"}}]}' ``` The contract sells 11 lots (1100 WAX), sends the USDT to `alice` and returns 11 WAX. ## Recipient's token row [#recipients-token-row] The recipient must exist, must not be `book.alcor`, and must have a row of the output token, or the swap fails with `recipient has no balance row`. Put `::open(recipient, symbol, sender)` before the transfer: it is a no-op when the row exists. ## Choosing min_out [#choosing-min_out] Compute the expected output from a fresh book and take your slippage off it. The SDK does both: `quoteSwap` runs the contract's arithmetic on a copy of the book, `actions.swap` returns the `open` and the transfer. Count the part below one lot: with lots of 100 WAX, 1111 WAX sells as 1100. Anyone who trades before your swap lands can take the difference down to `min_out`, as with an AMM swap. Keep the tolerance tight. ## Other rules [#other-rules] - Pauses: market trading, deposits of the input token, withdrawals of the output token. - A memo that starts with `swap#` but does not parse fails (`swap: invalid memo`, `swap: invalid recipient`); it is never taken as a deposit. - The sender gets the refund as an inline transfer. A contract that sends swaps must not fail on that incoming transfer. - In the event log a swap writes its trades, then a `swap` event (type 12), then any triggers it fired. It writes no deposit or withdrawal. # Tables and events (/developers-api/order-book/tables-and-events) ## Tables [#tables] | Table | Scope | Key | Contents | | --- | --- | --- | --- | | `config` | `book.alcor` | singleton | `fee_account`, global `paused` bits, `ledger_seq` | | `tokens` | `book.alcor` | `id` | `contract`, `sym`, `paused`, `held` (sum of all internal balances of the token) | | `markets` | `book.alcor` | `id` | `base_id`, `quote_id`, `lot_size`, `tick_size`, `min_notional`, `maker_bps`, `taker_bps`, `paused`, `event_seq`, the last three block prices | | `balances` | owner | `token_id` | `available`, `locked` | | `orders` | `(market_id << 1) \| side` | `id` | `owner`, `price`, `qty`, `qty_rem`, `fee_bps`, `created_at`, `expires_at` | | `triggers` | `(market_id << 1) \| op` | `id` | `owner`, `side`, `flags`, `trigger_price`, `limit_price`, `qty`, `fee_bps`, `locked`, `sibling`, `created_at` | `orders` has two secondary indexes: `byprice` (2, `i128`) lists the best order first — the highest bid or the lowest ask, the oldest within a price — and `byowner` (3, `name`). `triggers` has `byfire` (2, `i128`), the next to fire first, and `byowner` (3). An order or trigger ID is `[market_id:16][side or op:1][seq:47]`, so the ID alone names its table scope. ```shell # Best five asks of Telos market 2: scope (2 << 1) | 1 = 5 cleos -u https://mainnet.telos.net get table book.alcor 5 orders --index 2 --key-type i128 --limit 5 # Alice's balances cleos -u https://mainnet.telos.net get table book.alcor alice balances ``` Expired orders stay in `orders` until someone removes them, but they no longer trade. When you read the table directly, drop rows whose `expires_at` is not zero and not after the current block time. ## Events [#events] Every action sends an inline `events` action to the contract itself with a list of events, up to 500 per action. Each market numbers its events with a gapless `seq`. Deposits and withdrawals have `market_id = 0` and their own gapless `seq`. | Type | Event | Fields | | --- | --- | --- | | 1 | `trade` | `id` maker order, `owner` maker, `taker`, `side` taker side, `price`, `qty`, `qty_rem` maker remainder, `maker_fee`, `taker_fee` | | 2 | `order_open` | `id`, `owner`, `side`, `price`, `qty` ordered, `qty_rem` resting, `expires_at`, `fee_bps` | | 3 | `order_cancel` | `id`, `owner`, `side`, `price`, `qty`, `reason` | | 4 | `order_truncated` | `owner`, `side`, `price`, `qty` filled, `qty_rem` returned | | 5 | `trigger_open` | `id`, `owner`, `side`, `flags`, `price` trigger price, `limit_price`, `qty`, `sibling`, `fee_bps`, `locked` | | 6 | `trigger_cancel` | as `trigger_open`, plus `reason` | | 7 | `trigger_fired` | as `trigger_open` | | 8 | `order_reduced` | `id`, `owner`, `side`, `price`, `qty` removed, `qty_rem` left | | 9 | `deposit` | `id` token, `owner`, `qty` amount | | 10 | `withdraw` | `id` token, `owner`, `taker` recipient, `qty` amount | | 11 | `trigger_requeued` | as `trigger_open`; `qty_rem` lots still to fire, `locked` the new lock, bit 128 of `flags` set (armed) | | 12 | `swap` | `owner` sender, `taker` recipient, `side` (`1` sold base, `0` bought base), `qty` input spent, `qty_rem` input returned, `locked` output sent — all in minimal units | `trigger` is non-zero on events caused by that trigger firing. `time` is the block time in seconds. **Cancel reasons:** `0` owner, `1` self-trade prevention, `2` admin, `3` the other OCO leg fired or was cancelled, `4` expired, `5` remainder below `min_notional`. ### Reading events safely [#reading-events-safely] Accept an `events` action only when `act.account == book.alcor`, `receiver == book.alcor` and `creator_action_ordinal != 0`, that is, sent inline by the contract itself. Any contract can deliver an action named `events` by notification; this filter drops such fakes. Check that `seq` has no gaps. The [order book API](/api/order-book) does this for you and serves the events over HTTP and WebSocket. # Public data access (/developers-api/public-alcor-data-access) Alcor stores trade, chart and analytics history in MongoDB. A dump of the database is public at [wax.alcor.exchange/backups](https://wax.alcor.exchange/backups/) as `alcor_prod.dump.zst` (compressed with zstd, about 32 GB). It covers all chains; records carry a `chain` field. The dump is not refreshed on a fixed schedule. Check the file date in the listing. For current data, use the [API Reference](/api). # Does Alcor Exchange Have Fees? (/faq/does-alcor-exchange-have-fees) Fees depend on how you trade. On top of them you pay the network's own resource costs (CPU, NET, RAM), as with any transaction. **Swap** — every pool has a fee tier of 0.01%, 0.05%, 0.3% or 1%, chosen when the pool was created. The fee is charged on each swap through the pool and is earned by the pool's liquidity providers; depending on the pool's protocol fee setting, part of it goes to Alcor. A swap routed through several pools pays the fee of each pool it passes. A website or app that embeds Alcor Swap can add its own fee of up to 1%, see [Referral / Custom Market Fee](/alcor-swap/referral-custom-market-fee). **Spot (order book)** — newly created markets have no trading fee. Some markets have a fee set by Alcor; it goes to the Alcor development fund. **OTC** — each trade is charged 0.25% on both tokens when the amount is large enough; small trades pay no commission. This fee also goes to the Alcor development fund. # FAQ (/faq) # What is a liquidity pool? (/faq/what-is-a-liquidity-pool) A liquidity pool holds two tokens that traders swap against, instead of waiting for a matching buyer or seller in an order book. Liquidity providers deposit both tokens into the pool and earn the pool's fee on every swap that goes through it. Because the pool is always there, a trade can execute at any time. Its price depends on how much liquidity the pool holds: the more liquidity, the less a trade moves the price. Alcor Swap uses **concentrated liquidity**: each provider chooses a price range, and their liquidity is used only while the price stays inside that range. This lets liquidity sit where trading actually happens. See [Alcor Swap](/alcor-swap) for details. # What's the difference between Swap, Spot and OTC? (/faq/whats-the-difference-between-using-swap-market-trade-and-otc) * [**Swap**](/main-page-overview/swap) fills your trade right away at the current price, routed through [liquidity pools](/faq/what-is-a-liquidity-pool) and, by default, order books. * [**Spot**](/main-page-overview/spot) trades on a market's order book. A limit order waits until another user fills it at your price; a market order fills right away against the open orders. * [**OTC**](/main-page-overview/otc) (over-the-counter) is a direct trade with another user at a fixed price set by the order's creator, independent of pool and order book prices. # Introduction (/) ## Use Alcor [#use-alcor] ## Build on Alcor [#build-on-alcor] Nothing in these docs is financial advice. Tokens on Alcor are listed by anyone, so check a token before you trade it. # Exchange rate (/lsw-liquid-staked-wax/exchange-rate) The exchange rate is the amount of LSW one WAX buys: ``` Exchange rate = total LSW in circulation / total WAX staked (including rewards) ``` Both totals are in the `stakemints` table of `liquid.alcor` (`totalLiquidStakedToken` and `totalNativeToken`). - **Staking**: LSW received = WAX deposited × exchange rate. - **Unstaking**: WAX received = LSW returned / exchange rate. The rate started at 1. Every time staking rewards are added, the WAX total grows while the LSW total stays the same, so the rate goes down: each LSW is redeemable for more WAX. Staking and unstaking themselves do not change the rate. The staking page shows the current rate. ## Example [#example] 1. Alice is the first staker. She stakes 100 WAX and receives 100 LSW. ``` Exchange rate = 100 / 100 = 1 ``` 2. Over time, 10 WAX of rewards are added. ``` Exchange rate = 100 / (100 + 10) ≈ 0.909 ``` 3. Alice unstakes her 100 LSW and receives 100 / 0.909 ≈ 110 WAX. # How it works (/lsw-liquid-staked-wax/how-it-works) ## Staking [#staking] 1. You transfer WAX to `liquid.alcor` with the memo `stake` (the staking page does this for you). 2. The contract calculates the LSW amount at the current [exchange rate](/lsw-liquid-staked-wax/exchange-rate), issues that much LSW from `lsw.alcor` and sends it to you in the same transaction. 3. The deposited WAX is staked to CPU of the `liquid.alcor` account. ## Voting and rewards [#voting-and-rewards] - `liquid.alcor` votes through the `top21.oig` proxy, so its stake supports the top 21 WAX guilds. - The rewards this earns (WAX voter pay and other WAX rewards sent to the contract) are added to the pool of staked WAX and staked again right away. LSW supply does not change, so every LSW becomes worth more WAX. - The contract can keep a protocol fee from rewards (`feePct`, sent to `fees.alcor`). It is currently 0%. The contract's `stakemints` table shows the totals: `totalNativeToken` (WAX staked including rewards) and `totalLiquidStakedToken` (LSW in circulation). ## Unstaking [#unstaking] You can get WAX back in two ways: unstake through the contract (takes several days) or sell LSW for WAX on Alcor Swap (instant, at the market price). See [Withdrawal process](/lsw-liquid-staked-wax/withdrawal-process). # LSW: Liquid Staked WAX (/lsw-liquid-staked-wax) LSW is Alcor's liquid staking token for WAX. You stake WAX and receive LSW in return. The staked WAX earns WAX staking rewards, which are added back to the stake, so each LSW is redeemable for a growing amount of WAX. Meanwhile LSW itself is a normal token you can trade, provide as liquidity or use elsewhere. Stake and unstake at `alcor.exchange/v/wax/staking`. LSW exists only on WAX. | | | | --- | --- | | Staking contract | `liquid.alcor` | | LSW token contract | `lsw.alcor` (symbol `LSW`, 8 decimals) | ## Why use LSW [#why-use-lsw] - **Liquidity**: you earn staking rewards and can still sell, swap or use LSW at any time, instead of waiting out WAX's 3-day unstaking period. - **No upkeep**: the rewards are claimed and restaked for you; you do not need to vote or claim yourself. - **Composability**: LSW can be used in Alcor Swap pools and farms, and by other applications that accept it. # Withdrawal process (/lsw-liquid-staked-wax/withdrawal-process) On the **Unstake** tab of `alcor.exchange/v/wax/staking` you choose one of two methods. ## Delayed [#delayed] You get WAX at the [exchange rate](/lsw-liquid-staked-wax/exchange-rate), with no fee. 1. Your LSW is sent to `liquid.alcor` with the memo `withdraw`. The contract burns it and records a withdrawal request for the WAX amount at the current rate. 2. The contract unstakes WAX from CPU in batches. WAX's unstaking period is 3 days, and a new batch starts only after the previous one finishes, so a withdrawal can take up to about 6 days. 3. Once the contract has the WAX, the withdrawal is paid out to your account automatically. Pending requests are listed on the staking page until then. If the payment cannot be sent to your account automatically, it is moved to the contract's `claims` table, and you collect it by calling the `claim` action of `liquid.alcor` with your account name. The WAX amount is fixed when you request the withdrawal and does not earn rewards while it waits. ## Instant [#instant] Your LSW is swapped for WAX on Alcor Swap in one transaction. You get WAX immediately, at the market price of the pools on the route, which can be below the exchange rate. The page shows the expected amount and the price impact before you sign. You can also sell LSW on any other market that lists it. # Bridge (/main-page-overview/bridge) The Bridge page (`/v//bridge`) moves tokens between networks straight from your wallet. It connects: * **Antelope networks:** Telos, WAX, XPR Network and Vaulta. * **Other networks:** Ethereum, BNB Smart Chain, Polygon, Sui and NEAR. To top up your account on the network you are trading on, the [Deposit window](/main-page-overview/deposit-and-withdraw) is usually simpler. It can even take tokens straight from an exchange. ## How the bridge works [#how-the-bridge-works] * **Everything goes through Telos.** Telos is the hub. A transfer between two other networks, for example Ethereum → WAX, passes through Telos. It is still one transfer, and there is nothing to sign on Telos. * **No custodian.** No company or person holds the tokens or approves transfers. Each network checks the other's proof on chain, with a light client, and only then pays out. The **Info** tab explains this under **How it's verified**. * **Never lost.** A transfer that cannot be delivered is sent back to where it came from. A withdrawal that is not claimed in time is refunded to your Telos balance. On Telos, WAX, XPR Network and Vaulta, bridged tokens such as USDT and USDC are issued by the `wrap.alcor` contract. ### Supported tokens [#supported-tokens] The list changes as tokens are added. The **Info** tab always shows the current routes with their limits. As of this writing: | Network | Tokens | |---|---| | Ethereum | ETH, USDC, USDT | | BNB Smart Chain | BNB, USDC, USDT | | Polygon | POL, USDC | | WAX | WAX, USDC, USDT, ETH, BNB, POL | | XPR Network | XPR, USDC, USDT, ETH, BNB, EASY | | Vaulta | A, USDC, USDT | | Sui | SUI, USDC | | NEAR | NEAR, USDC, USDT | Want a token added? Use **Request a token** on the Info tab. ### How long it takes [#how-long-it-takes] These are typical times. The form shows a live estimate in **Arrives in** before you send. | From → to | Time | |---|---| | Ethereum → Telos | about 17 min (Ethereum has to finalize the block) | | BNB Smart Chain or Polygon → Telos | under a minute | | WAX → Telos | about 1 min | | XPR Network → Telos | about 3 min | | Vaulta, Sui or NEAR → Telos | seconds | | Telos → WAX, XPR Network or Vaulta | about 2 min | | Telos → Ethereum, BNB Smart Chain or Polygon | about 1 min, then the delivery or your claim | Between two networks that are not Telos, add the two legs together. For example, Ethereum → WAX takes about 20 minutes. Small deposits from Ethereum arrive faster: up to the amount shown in **Fast deposits up to**, the bridge waits for a few confirmations instead of full finality. ## The page [#the-page] The page has four tabs: * **Bridge**: the transfer form. While a transfer is in flight, it shows its progress. * **History**: your transfers. The badge counts the ones not finished yet. * **Activity**: every transfer on the bridge, on the analytics page. * **Info**: networks, routes and limits, how the bridge is verified, and token requests. ## Making a transfer [#making-a-transfer] 1. **From.** Click the token button and choose the network and token you send. Then enter the amount, or click **MAX** or your balance. 2. **To.** Choose the network you receive on. The arrow between the fields swaps the direction. 3. **Connect wallets.** Use the wallet button next to each field: * **Telos** and the network you are on: the account you signed in with in the header. * **WAX, XPR Network, Vaulta**: Alcor Signer, Anchor, WAX Cloud Wallet (on WAX) or WebAuth (on XPR Network). * **Ethereum, BNB Smart Chain, Polygon**: any browser wallet, such as MetaMask or Rabby, or WalletConnect for a mobile wallet. * **Sui**: Slush or any Sui wallet extension. * **NEAR**: Meteor, HOT, Intear or MyNearWallet. 4. **Recipient.** Tokens go to your connected wallet. To send them somewhere else, click **Send to a different address** (or **account**) and enter it. The form warns you if the account does not exist, or if the address is a contract and not a wallet. 5. **Delivery** (only for Ethereum, BNB Smart Chain and Polygon as the destination). See [Delivery or claim](#delivery-or-claim). 6. **Check the details.** These are **Arrives in**, **On arrival**, the fee and **You receive**. 7. Click **Bridge to <network>** and confirm in your wallet. * A USDT or USDC deposit from Ethereum, BNB Smart Chain or Polygon takes two signatures. The first approves exactly this amount. The second is the deposit. * Gas on the sending network is paid from your wallet in ETH, BNB, POL, SUI or NEAR. Keep a little there. Once sent, the form turns into the transfer's progress. You can close the page; the transfer keeps going. ### Delivery or claim [#delivery-or-claim] A withdrawal to Ethereum, BNB Smart Chain or Polygon is paid out by a transaction on that network. You choose who sends it: * **Deliver it for me** (the default). A courier sends it and pays the gas. Its fee is shown next to the option and taken from the amount. You need no wallet and no ETH, BNB or POL on that network. You can send to any address, an exchange's too. * **I'll claim it myself.** Free, but later you press **Claim on <network>** and pay the gas from your wallet. You have a limited time to claim, shown in the form. After it passes, you can cancel the transfer and get a refund on Telos. Withdrawals to WAX, XPR Network and Vaulta are delivered automatically, with nothing to claim. Withdrawals to Sui and NEAR are claimed from your wallet with one transaction that costs a little SUI or NEAR. ## Tracking a transfer [#tracking-a-transfer] The progress view shows: * the amount and both ends of the transfer; * a progress bar with the time left; * the steps: **Send**, **Confirm**, **Verify**, then **Arrive**, **Deliver** or **Claim**. Each finished step links to its transaction in a block explorer. When a step needs you, it is marked **your turn** and a button appears: * **Claim on <network>**: collect a withdrawal you chose to claim yourself. **Copy link — anyone can claim it** lets someone else pay the gas for you; the tokens still go to your address. * **Deliver on Telos**: a deposit is half an hour late. Anyone can push it through by paying the network fee. * **Cancel transfer**, then **Get refund on Telos**: the claim deadline passed, and this returns the tokens to your Telos balance. The **History** tab lists your transfers, with the tabs **All**, **In progress** and **Done** and a search by token, amount, account or transaction. History is kept by the bridge, not your browser, so it is the same on every device. Each transfer has its own link (`/v//bridge/history/`), and anyone can open it without a wallet. ## If something is wrong [#if-something-is-wrong] * **The button says why it cannot send.** For example: **Enter an amount**, **Not enough balance**, **At least <amount>**, **At most <amount> at once**, or **Connect your <network> wallet**. Next to a limit there is a **use <amount>** link that fixes it. * **No gas.** "Sending from <network> pays gas in <coin>, and this wallet holds none": add a little ETH, BNB, POL, SUI or NEAR to the sending wallet. * **A network can't pay out enough.** A network can only pay out tokens that people brought in from it. If it holds too little, the form shows how much it can pay now. Click **Use <amount>** or choose another network from the list. * **A route is paused or closed.** The button and a note under the form say so, and the Info tab marks the route **Paused for now**. Wait, or choose another network. * **A maintenance banner** (**Update needed**, **Key needed**). A network needs an update from Telos before withdrawals to it go through. Anyone can send the update; it costs only gas. * **Delayed.** A transfer half an hour late shows **Delayed**. Nothing is lost. Use the button on the transfer, or ask in [Telegram](/social-media-contact) with the transfer's link. ## Links to the bridge [#links-to-the-bridge] A link can open the bridge with a transfer already filled in. For example, `/v/wax/bridge/usdc-ethereum-to-wax` opens USDC from Ethereum to WAX. For links with an amount and recipient, and for the widget, see the [Bridge API](/api/bridge). A project that takes deposits from other chains can give each of its users a deposit address of their own: see [Deposit addresses](/api/bridge#deposit-addresses). # Deposit and Withdraw (/main-page-overview/deposit-and-withdraw) The Deposit window brings tokens into your account on the network you are on: Telos, WAX, XPR Network or Vaulta. You can send them from Ethereum, BNB Smart Chain, Polygon, Sui, NEAR, another Antelope network, or an exchange. The Withdraw window sends them back out. Both use the [Alcor bridge](/main-page-overview/bridge) underneath. ## Opening it [#opening-it] * **Deposit** in the header (when you are signed in). A small counter on it shows transfers in progress. * **Deposit** and **Withdraw** next to the trade form. * **Deposit** and **Withdraw** next to each token on [Portfolio](/main-page-overview/portfolio). * **Deposit <token> from <network>** under a form when your balance is too low. The window has three tabs: **Deposit**, **Withdraw** and **History**. ## Deposit [#deposit] 1. **Choose a token.** Search by token or network name, for example `usdt` or `eth`. The icons on each row show where you can send it from. The number on the right is what your connected wallets already hold. 2. **Choose the network** you send from (**From**). Each row shows the expected time. This step is skipped when there is only one way in. 3. Send it in one of the ways below. ### From an exchange or any wallet: deposit address [#from-an-exchange-or-any-wallet-deposit-address] For tokens from Ethereum, BNB Smart Chain or Polygon, the **Deposit address** tab gives you a personal address. You need no wallet connection and no gas, and you can send from an exchange's withdrawal page. The address is yours and does not change. It is the same on all three networks. The window shows the address, a QR code and: * **Network**: the network to send on. * **Minimum**: smaller amounts wait at the address until more arrives. * **Network fee**: paid out of the deposit. * **Arrives in**: counted from when the deposit enters the bridge. * **To**: your account. Send only on the network shown: Ethereum, BNB Smart Chain or Polygon. A deposit sent on Arbitrum, Base, Tron or any other network may be lost. Send only the tokens listed under **Other tokens and networks**. Any other token is not forwarded; it waits at the address until support returns it. The window watches the address. Once your transfer lands, it shows **Last received**, and the deposit appears in **History**. A tiny amount of ETH, BNB or POL below its minimum (at most 0.001 ETH, 0.001 BNB or 1 POL) goes to the courier when a token is forwarded from the address. An amount above a token's limit is forwarded in parts. ### From your wallet [#from-your-wallet] The **Wallet** tab, and every other network (Sui, NEAR, WAX, XPR Network, Vaulta, Telos), sends from a wallet you connect: 1. **Connect** a wallet for that network. Nothing leaves it until you confirm. 2. Enter the amount, or use your full balance. Check **Arrives in** and **You receive**. 3. Click **Deposit <amount> <token>** and confirm in your wallet. USDT and USDC from Ethereum, BNB Smart Chain or Polygon ask for two confirmations: an approval for exactly this amount, then the deposit. The wallet pays the network's gas in ETH, BNB, POL, SUI or NEAR. If it holds none, the window tells you to add a little first. ### The network's own token [#the-networks-own-token] For WAX, TLOS, XPR or A on its own network, choose **Exchange or wallet**. The window shows your account name: send the token to it from an exchange or any wallet, as an ordinary transfer. ### No account yet [#no-account-yet] On Telos, WAX and XPR Network you can create an account with a passkey. You need no seed phrase and nothing to install. The account opens with your first deposit: pick a name, then make the deposit as above. The window shows the account fee taken from it and the smallest deposit that opens an account. On Telos the deposit address works for this too. If someone takes the name before your deposit arrives, nothing is lost: pick another name and the deposit goes on to it. ## Withdraw [#withdraw] 1. **Choose a token.** The tokens you hold come first. 2. **Choose the network** to send to (**To**). 3. **Enter the recipient.** **My wallet** and **Used before** fill it in for you. The window warns if the account does not exist, or if the address is a contract and not a wallet. 4. For Ethereum, BNB Smart Chain and Polygon, choose the delivery: * **Deliver it for me**: the courier pays the gas, and its fee is taken from the amount. Works for any address, an exchange's too. * **I'll claim it myself**: free, but you press **Claim on <network>** later and pay the gas. The window says how long you have. An unclaimed withdrawal can be cancelled and refunded. 5. Enter the amount and click **Withdraw <amount> <token>**. You sign once, on the network you are on. Withdrawals to WAX, XPR Network and Vaulta are delivered automatically. To Sui and NEAR, you connect the receiving wallet and claim with one cheap transaction. ## Progress and History [#progress-and-history] After you send, the window shows the transfer's steps: **Sent from…**, **Confirming…**, **Arriving on…**, **In your balance**. Each step links to its transaction, and there is a countdown. You can close the window; the transfer keeps going. The **History** tab lists your deposits and withdrawals, filtered by **All**, **Deposits** or **Withdrawals**. The ones in progress come first. Click one to open its progress. When a transfer needs you, it shows a button such as **Claim on <network>**, **Cancel transfer** or **Get refund on Telos**. A notification and the counter on **Deposit** in the header tell you when. ## If something is wrong [#if-something-is-wrong] * **"Deposits are closed on the <token> route"** or **"No <token> to pay out on <network> yet"**: the route is paused, or the destination holds too little. Choose another network. * **"The route takes at least…"**: the amount is below the minimum. Click **use <amount>**. * **"The deposit service gave a wrong address. Do not send anything"**: don't send; contact support. * **"A deposit came back… and waits at this address — it is safe"**: contact support to have it forwarded or returned. * **Delivery delayed**: nothing is lost. The transfer shows a button to finish it yourself. Or ask in [Telegram](/social-media-contact) with the transfer from History. For transfers between any two networks, to another person, or with full detail, use the [Bridge page](/main-page-overview/bridge). # App Overview (/main-page-overview) Alcor runs at [alcor.exchange](https://alcor.exchange). Everything can be browsed without a wallet; connecting one enables trading. ## Networks [#networks] Pick a network with the network switcher in the header. Each network has its own set of pages under `/v//`: | Network | URL prefix | |---|---| | WAX | `/v/wax/` | | XPR Network | `/v/xpr/` | | Vaulta (formerly EOS) | `/v/vaulta/` | | Telos | `/v/telos/` | ## Home page [#home-page] The home page (`/`) is a cross-chain swap: pick any token on any network and any token on another, and Alcor plans the route — a swap on one network, a bridge crossing, or a swap, a crossing and a swap at the far end — signed once on the network where it starts. It also lists trending tokens and top markets on every network. ## Pages on each network [#pages-on-each-network] | Page | URL | What it is | |---|---|---| | [Swap](/main-page-overview/swap) | `/v//swap` | Swap two tokens on one network at the best price across pools and order books | | Pool | `/v//swap/positions` | Your concentrated-liquidity positions; create, add to, remove and claim fees | | [Farms](/alcor-farms-unlocking-defi-opportunities) | `/v//swap/farms` | Stake liquidity positions for extra rewards | | [Spot](/main-page-overview/spot) | `/v//spot` | On-chain order book with limit and market orders | | Terminal | `/v//terminal` | Token screener: trending, new tokens, holders, live trades | | [Bridge](/main-page-overview/bridge) | `/v//bridge` | Move tokens between the Antelope networks, Ethereum, BNB Smart Chain, Polygon, Sui and NEAR | | Analytics | `/v//analytics` | TVL, volume and fees, with a page for every pool and token | | [Deposit and Withdraw](/main-page-overview/deposit-and-withdraw) | **Deposit** in the header | Fund your account from another network or an exchange, and send tokens back out | | [Portfolio](/main-page-overview/portfolio) | `/v//portfolio` | Your balances, orders, positions and resources | | [OTC](/main-page-overview/otc) | `/v//otc` | Peer-to-peer trades at a fixed price | | [Stake](/lsw-liquid-staked-wax) | `/v/wax/staking` | WAX liquid staking (WAX only) | ## Connecting a wallet [#connecting-a-wallet] Use **Connect Wallet** (or **Log in**) in the header and choose a wallet supported on the selected network. On networks where Alcor can create accounts, the same dialog offers to create one if you do not have an account yet. # OTC (/main-page-overview/otc) OTC (over-the-counter, `/v//otc`) lets you offer an amount of one token for a fixed amount of another. There is no slippage: whoever fills the order gets exactly the amounts in it. Orders are held by Alcor's OTC contract on the selected network. ## Tabs [#tabs] * **Orders** — all open orders. Filter by the token being sold (**Selling**) and the token wanted (**For**), or search by token or account. * **My Orders** — your own open orders. * **History** — completed trades with maker, buyer, amounts and price. ## Creating an order [#creating-an-order] Click **Create**, enter what **You sell** and what **You receive**, and confirm in your wallet. The tokens you sell are transferred to the OTC contract and stay there until the order is filled or cancelled. ## Filling or cancelling an order [#filling-or-cancelling-an-order] Open an order to see its price and amounts. **Buy** sends the requested tokens and you receive the offered ones in the same transaction. The maker can **Cancel Order** at any time to get the tokens back. Anyone can create an OTC order with any token. Check the token contract before buying; orders that involve a known scam token are marked with a warning. # Portfolio (/main-page-overview/portfolio) Portfolio (`/v//portfolio`) shows the connected account on the selected network. The header shows the total portfolio value, available funds, funds in liquidity pools and the number of active positions. ## Tabs [#tabs] * **Balances** — every token you hold, with its price and value. Search by name or contract, or hide small balances. From a row you can **Transfer** the token, open it in Swap or Spot, or — for assets carried by the Alcor bridge — **Deposit** and **Withdraw** them through the bridge. Click a token to open its analytics page. * **Open Orders** — your open [Spot](/main-page-overview/spot) orders, with **Cancel All**. * **Liquidity Pools** — your liquidity positions and their unclaimed fees. * **Owned Farms** — farms you created as an incentive provider. * **Issued Tokens** — shown only when the account has issued its own tokens. * **Resources** — CPU, NET and RAM usage, staking and unstaking for resources, and pending refunds. On networks whose system contract pays voters (such as WAX), voting rewards can be claimed here. Tokens locked in open orders are not part of your available balance until the order is filled or cancelled. # Spot (/main-page-overview/spot) Spot (`/v//spot`) is Alcor's on-chain order book. Every order is placed, matched and cancelled by the exchange contract on the selected network. A market has its own link, for example `/v/wax/spot/tlm-alien.worlds_wax-eosio.token`. ## The trading page [#the-trading-page] * **Market selector** — the pair name at the top opens a searchable list of markets on the network. Next to it: price, 24h change, volume and market cap. * **Chart** — a TradingView chart of the market. See [tradingview.com](https://www.tradingview.com) for how to use its tools and indicators. * **Order Book / Trades** — open buy (bid) and sell (ask) orders grouped by price with the spread between them, and a feed of recent trades. * **Order form** — choose **Buy** or **Sell**, then the order type. * **Account tables** — **Open Orders** (cancel them here), **Balances** and **Trade History** for the connected account. ## Placing an order [#placing-an-order] * **Limit** — set the price and amount. The order waits in the order book until it is filled or you cancel it. * **Market** — set only the amount; the order fills right away against the best orders in the book. The percentage slider fills the amount from your available balance. If the order book price differs from the Alcor Swap pool price by more than 10%, a market order asks for confirmation first and offers to use [Swap](/main-page-overview/swap) instead. Tokens locked in an open order are not available in your balance until the order is filled or cancelled. # Swap (/main-page-overview/swap) The Swap page (`/v//swap`) exchanges one token for another on the selected network. Alcor finds the best route through its liquidity pools and, by default, also through the order book, so a swap acts like a [market order](/definitions-1): you get the current price, not a price you set. To trade at a price you choose, use [Spot](/main-page-overview/spot). To swap tokens on different networks, use the cross-chain swap on the [home page](https://alcor.exchange). ## Making a swap [#making-a-swap] 1. Choose the token you pay and the token you receive. The arrow between them reverses the pair. 2. Enter an amount in either field; the other is quoted from the current route and refreshes as prices change. 3. Check the details under the form: * **Expected Output** — what you should receive. * **Price Impact** — how much your trade moves the price. It is larger in pairs with little liquidity. * **Min. Received** — the least you accept after slippage. If the price moves beyond it, the swap fails instead of filling worse. * **Multiroute** — the pools and order book markets the swap is split across. 4. Confirm the transaction in your wallet. A pair has its own link, for example `/v/wax/swap/wax-eosio.token_tlm-alien.worlds`. A chart of the selected pair is shown next to the form. ## Transaction settings [#transaction-settings] The gear icon opens: * **Slippage %** — Auto, 0.5%, 1% or a custom value. * **Max Hops** — the most pools a route may pass through (1–3). * **Recalculate On Price Change** — refresh the quote when a pool price changes. * **Split Into Order Book** — let the route use order book markets as well as pools. ## Pool [#pool] The **Pool** tab (`/v//swap/positions`) lists your liquidity positions with their range, value, unclaimed fees and P&L, and has **Farms** and **Activity** tabs. * **Create a position** — select the pair, a fee tier (0.01%, 0.05%, 0.3% or 1%) and a price range, then deposit both tokens. If the pool does not exist yet, you set its starting price. * **Manage a position** — open it to add liquidity, remove part or all of it, claim fees, claim farm rewards, or lock the liquidity (until a date or forever). A position's price range cannot be changed: to move it, remove the position and create a new one. For details see [Alcor Swap](/alcor-swap) and [Providing liquidity](/alcor-swap/providing-liquidity). # Networks Features (/networks-features) Alcor runs the same stack — swap pools, order book, OTC, farms and analytics — on four Antelope networks. The Alcor Bridge connects them with each other and with Ethereum, BNB Smart Chain, Polygon, Sui and NEAR; Telos is the bridge hub. | Network | App | System token | Order book | Swap | OTC | API | |---|---|---|---|---|---|---| | WAX | `/v/wax` | WAX | `alcordexmain` | `swap.alcor` | `alcorotcswap` | `https://wax.alcor.exchange/api/v2` | | XPR Network | `/v/xpr` | XPR | `alcor` | `swap.alcor` | `alcorotc` | `https://proton.alcor.exchange/api/v2` | | Vaulta (formerly EOS) | `/v/vaulta` | A, EOS | `eostokensdex` | `swap.alcor` | `alcorotcswap` | `https://eos.alcor.exchange/api/v2` | | Telos | `/v/telos` | TLOS | `eostokensdex` | `swap.alcor` | `alcorotcswap` | `https://telos.alcor.exchange/api/v2` | On every network, tokens carried by the Alcor bridge (such as USDT and USDC) are issued by the `wrap.alcor` contract. ## Network-specific pages [#network-specific-pages] * [WAX](/networks-features/wax) — USDT on WAX and liquid staking. # USDT on WAX (/networks-features/wax/alcor-usdt) ## USDT@wrap.alcor [#usdtwrapalcor] The standard USDT on WAX is `USDT@wrap.alcor`, brought to WAX by the Alcor bridge. USDT deposited from Ethereum or BNB Smart Chain arrives as the same token whichever chain it came from, and can be withdrawn to any chain the bridge supports. To deposit or withdraw, use the [Alcor Bridge](https://alcor.exchange/v/wax/bridge) at `/v/wax/bridge`. A deposit from an EVM chain takes one transaction in your EVM wallet; the tokens are delivered to your WAX account with nothing to claim. For integration details see the [Bridge API](/api/bridge). ## USDT@usdt.alcor (legacy) [#usdtusdtalcor-legacy] `USDT@usdt.alcor` is the earlier USDT on WAX, bridged from EOS through IBC (`ibc.alcor`). It is now legacy: switch to `USDT@wrap.alcor`. The two swap 1:1 on Alcor in one transaction (order book market 999), and the Swap page offers the replacement when you select the legacy token. # WAX (/networks-features/wax) * [USDT on WAX](/networks-features/wax/alcor-usdt) — the bridged `USDT@wrap.alcor` and the legacy `USDT@usdt.alcor`. * [LSW (Liquid Staked WAX)](/lsw-liquid-staked-wax) — stake WAX for LSW at `/v/wax/staking`. * **Voting rewards** — WAX pays rewards to accounts that vote for block producers; they can be claimed from the Resources tab of the [Portfolio](/main-page-overview/portfolio). # Social Media & Contact (/social-media-contact) * **Telegram** (community and team): [t.me/alcorexchange](https://t.me/alcorexchange) * **Twitter / X**: [twitter.com/alcorexchange](https://twitter.com/alcorexchange) * **Discord**: [discord.gg/Sxum2ETSzq](https://discord.gg/Sxum2ETSzq) * **GitHub**: [github.com/alcorexchange/alcor-ui](https://github.com/alcorexchange/alcor-ui) * **Service status**: [status.alcor.exchange](https://status.alcor.exchange) # Swap Widget (/swap-widget) The swap widget is a compact Alcor swap form you can embed in any web page. Use the link for your network: | Network | Widget URL | |---|---| | WAX | `https://wax.alcor.exchange/swap-widget` | | XPR Network | `https://proton.alcor.exchange/swap-widget` | | Vaulta (EOS) | `https://eos.alcor.exchange/swap-widget` | | Telos | `https://telos.alcor.exchange/swap-widget` | Insert it into your page with an iframe: ```html ``` ## Query parameters [#query-parameters] Token ids use the `symbol-contract` format, for example `wax-eosio.token`. | Parameter | Meaning | Example | |---|---|---| | `input` | Token selected to pay with | `wax-eosio.token` | | `output` | Token selected to receive | `tlm-alien.worlds` | | `only` | Comma-separated list of tokens offered in the token selector | `wax-eosio.token,tlm-alien.worlds` | | `market` | Your registered market account, to earn a fee on swaps made through the widget — see [Referral / Custom Market Fee](/alcor-swap/referral-custom-market-fee) | `mymarket` | For example: ```html ``` A price chart for a pair is available as a separate widget, see [Swap Chart Widget](/swap-widget/swap-chart-widget). # Swap Chart Widget (/swap-widget/swap-chart-widget) The chart widget shows the price chart of a token pair. It lives at `/chart-widget` on the same hosts as the [Swap Widget](/swap-widget), for example `https://wax.alcor.exchange/chart-widget`. Required query parameters, as token ids in `symbol-contract` format: * `input` — the input token * `output` — the output token Example: ```html ``` # Token Analytics Widget (/swap-widget/token-analytics-widget) The token analytics widget is the token page of Alcor Analytics made for an iframe: price chart, liquidity, market cap, volume, score, holders, and the token's pools and spot pairs. It has no site header and no wallet. Trade, Swap, Add Liquidity and every link inside it open Alcor in a new tab, so your page stays where it is. ``` https://alcor.exchange/embed/token// ``` | Network | `` | |---|---| | WAX | `wax` | | XPR Network | `xpr` | | Vaulta (EOS) | `vaulta` | | Telos | `telos` | The token id uses the `symbol-contract` format with the symbol in lowercase, for example `wax-eosio.token` or `tlm-alien.worlds`. It is the same id as in the address of the token's page on Alcor: `alcor.exchange/v/wax/analytics/tokens/tlm-alien.worlds`. ```html ``` Use the `/embed/token/...` address. Alcor's regular pages, `/v//analytics/tokens/...` included, cannot be shown in a frame on another site: the browser will display "alcor.exchange refused to connect". The page is responsive: from about 900px wide the chart has a side column, narrower it stacks. Give it at least 800px of height so the chart and the figures above it fit without scrolling. ## Query parameters [#query-parameters] | Parameter | Meaning | Example | |---|---|---| | `tab` | Table shown first under the chart: `pools`, `pairs` or `holders` | `holders` | For a swap form instead of analytics, see the [Swap Widget](/swap-widget). For a bare price chart of one pair, see the [Swap Chart Widget](/swap-widget/swap-chart-widget). # What is Alcor Exchange? (/what-is-alcor-exchange) Alcor Exchange is a decentralized, self-custodial exchange running since 2020. It started as the order book DEX of WAX and now runs the same stack on four Antelope networks: * **WAX** * **XPR Network** (formerly Proton) * **Vaulta** (formerly EOS) * **Telos** The Alcor Bridge connects these networks with each other and with Ethereum, BNB Smart Chain, Polygon, Sui and NEAR, so USDT, USDC and other bridged assets can move between all of them. ## What you can do on Alcor [#what-you-can-do-on-alcor] * **Cross-chain swap** — swap any token on one network for any token on another in one signature, from the home page at [alcor.exchange](https://alcor.exchange). * **Swap** — best-price swaps on one network, routed through AMM pools and order books together. * **Pools** — provide concentrated liquidity (Uniswap v3 style) in pools with fee tiers of 0.01%, 0.05%, 0.3% and 1%. * **Farms** — stake liquidity positions in incentives to earn extra token rewards. * **Spot** — on-chain order book with limit and market orders. * **Terminal** — token screener with trending and new tokens, holders and live trades. * **[Bridge](/main-page-overview/bridge)** — move tokens between the Antelope networks, Ethereum, BNB Smart Chain, Polygon, Sui and NEAR. * **Portfolio** — balances, open orders, liquidity positions and account resources. * **Analytics** — TVL, volume and fees per network, pool and token. * **Liquid staking** — stake WAX for LSW (WAX only). * **OTC** — peer-to-peer trades at a fixed price. Every product can be browsed without a wallet; connecting a wallet enables trading. See the [App Overview](/main-page-overview) for where each product lives. ## No whitelisting [#no-whitelisting] Anyone can list a token on Alcor by creating a liquidity pool for it — no approval is needed. Projects can add their logo and description through GitHub, see [Adding Token Information](/adding-token-information).