Skip to main content

Simulate Swap

Simulates a swap operation and returns the amount to be received for the swap.

query Query($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://api.euclidprotocol.com/graphql' \
--data '{"query":"query Query($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":"osmo","amountIn":"10","assetOut":"atom","minAmountOut":"1","swaps":["osmo","usdt","usdc","atom"]}}'

Open in Playground

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

FieldTypeDescription
amount_outStringThe amount of the output asset received from the swap.
asset_outStringThe identifier of the output asset.