Simulate Swap
Simulates a swap operation and returns the amount to be received for the swap.
query Simulate_swap($assetIn: String!, $amountIn: String!, $assetOut: String!, $minAmountOut: String!, $swaps: [String!]) {
router {
simulate_swap(asset_in: $assetIn, amount_in: $amountIn, asset_out: $assetOut, min_amount_out: $minAmountOut, swaps: $swaps) {
amount_out
asset_out
}
}
}
Example
curl --request POST \
--header 'content-type: application/json' \
--url 'https://testnet.api.euclidprotocol.com/graphql' \
--data '{"query":"query Simulate_swap($assetIn: String!, $amountIn: String!, $assetOut: String!, $minAmountOut: String!, $swaps: [String!]) {\n router {\n simulate_swap(asset_in: $assetIn, amount_in: $amountIn, asset_out: $assetOut, min_amount_out: $minAmountOut, swaps: $swaps) {\n amount_out\n asset_out\n }\n }\n}","variables":{"assetIn":"euclid","amountIn":"1000","assetOut":"nibi","minAmountOut":"1","swaps":["euclid","nibi"]}}'
Arguments
- assetIn (String!): The identifier of the input asset.
- amountIn (String!): The amount of the input asset to swap.
- assetOut (String!): The identifier of the output asset.
- minAmountOut (String!): The minimum amount of the output asset expected from the swap.
- swaps ([String!]): The list of swaps to execute.
Return Fields
Field | Type | Description |
---|---|---|
amount_out | String | The amount of the output asset received from the swap. |
asset_out | String | The identifier of the output asset. |