Swap contract
Swapping through the swap.alcor concentrated liquidity contract.
The Alcor swap contract runs under the same account on every chain: swap.alcor. For application development use the Alcor SDK. To find a route and the expected output, use the route API.
Swap
Transfer the input token to swap.alcor with a memo:
<type>#<pool_ids>#<recipient>#<output_token>#<deadline>#<market>| 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 <amount> <SYMBOL>@<contract>, 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_tokenis 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#mymarketThe swap fee is the pool fee plus the market fee. Both are in millionths: 3000 = 0.3%.
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.