AlcorDocs

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>
FieldDescription
typeswapexactin or swapexactout
pool_idsPool ID, or comma-separated pool IDs of a multi-hop route in swap order, e.g. 0,12
recipientAccount that receives the output. Cannot be swap.alcor
output_tokenExtended asset <amount> <SYMBOL>@<contract>, see below
deadlineOptional. Unix time in seconds after which the swap fails. 0 means no deadline
marketOptional. 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

An application can take its own fee on swaps it routes. Register once with regmarket, signed by the market account:

ParameterTypeDescription
marketNamenameAccount that receives the fee
marketFeeuint32Fee 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.

On this page