# 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)

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`:
```
###