🛠
Frontend Integration
How to use AshSwap's Aggregator API and smart contract
AshSwap doesn't charge any fees for our Aggregator module, so we really appreciate it if you can add something like "Powered by AshSwap" when integrating this service into your UI.
Host:
Mainnet:
https://aggregator.ashswap.io
Devnet:
https://aggregator-devnet.ashswap.io
Endpoint:
/tokens
Method:
GET
Endpoint:
/pools
Method:
GET
Endpoint:
/aggregate
Method:
GET
Arguments:
Field | Description |
---|---|
from | Input token ID |
to | Output token ID |
amount | Amount of input token with decimals |
E.g. A request to swap from 100 WEGLD (decimals = 18) to ASH. /aggregate?from=WEGLD-bd4d79&to=ASH-a642d1&amount=100000000000000000000
Field | Description |
---|---|
tokenIn | Input token ID |
tokenOut | Output token ID |
swapAmount | Input amount (no decimals) |
returnAmount | Output amount (no decimals) |
returnAmountWithoutSwapFees | Ouput amount without swap fees |
marketSp | Market spot price before swap |
effectivePrice | Market spot price for current swap |
priceImpact | Price impact |
tokenAddresses | Array of token IDs |
swaps | An array of SwapStep . This value will be used to compute the arguments for the aggregator contract. |
routes | An array of Route . This value will be used to display on the UI. |
SwapStep:
Field | Description |
---|---|
poolId | Pool ID |
assetInIndex | Pool index of input token |
assetOutIndex | Pool index of output token |
assetIn | Input token ID |
assetOut | Output token ID |
amount | Input token amount with decimals. If amount = 0 means all amount from the previous step will be used to swap in this step |
returnAmount | Return amount with decimals |
functionName | Function name to call |
arguments | Function arguments |
Route:
Field | Description |
---|---|
tokenIn | Input token ID |
tokenInAmount | Input token amount with decimals |
tokenOut | Output token ID |
tokenOutAmount | Output token amount with decimals |
hops | An array of Hop |
Hop:
Field | Description |
---|---|
poolId | Pool ID |
pool | Pool Information |
tokenIn | Input token ID |
tokenInAmount | Input token amount without decimals |
tokenOut | Output token ID |
tokenOutAmount | Output token amount without decimals |
The contract combines and execute all the steps in a single transaction.
Contract Addresses:
Mainnet:
erd1qqqqqqqqqqqqqpgqglgkaxm73j7mhw5u940fsmmncnayxj884fvs54lnr6
Devnet:
erd1qqqqqqqqqqqqqpgqqtaru570tfcq4fwer9nlnzl6n4afp4yzh2uswv2vkh
Function name:
aggregate
Payments: List of tokens used as inputs. AshSwap UI supports 1 input token at the moment.
Arguments:
Field | Description |
---|---|
steps | A list of AggregatorStep |
limits | A list of tokens involved in the steps. For non-output tokens, set the value to 0. Note: Each element in the limits list must be unique. The limits argument must contain all the tokens involved in the steps. This allows clients to have control over the execution of their tokens in the contract. |
AggregatorStep
Field | Description |
---|---|
token_in | Input token ID |
token_out | Output token ID |
amount_in | Input token amount. If amount_in = 0, the contract will use all amount of token_in from the previous step (recommended). |
pool_address | Pool address |
function_name | Pool's swap function name |
arguments | Pool's swap function arguments |
Last modified 3mo ago