Get multiple swap quotes based on desired receive amount
Retrieves multiple swap quotes from available LPs based on the amount of destination tokens you want to receive. This endpoint queries active LP orders and calculates how much of the source token you need to send to receive the specified amount of destination tokens. Returns an array of quotes, each containing the required source amount (amountFrom) and optionally the LP address. This is useful when you know exactly how much you want to receive and need to compare different LP rates. The quotes are typically sorted by the best rate (lowest amountFrom for the same amountTo).
Query Parameters
The source token contract address. This is the L2 contract address (C1 contract) for the token you want to send in the swap.
The destination token contract address. This is the L2 contract address (C2 contract) for the token you want to receive in the swap.
The amount of destination tokens you want to receive. This is specified in the smallest unit of the destination token (e.g., satoshis for BTC, wei for ETH). The endpoint will calculate how much of the source token you need to send to receive this amount.
Backend URL. Default is https://api-cloud.coinweb.io/wallet. This URL is used to query available LPs orders and calculate swap quotes.
uriOptional filter to get quotes only from a specific LP. If provided, only quotes from this LP will be returned. The LP is identified by their address (hex string without 0x prefix).
The type of the source token blockchain. Used to determine the blockchain type for the source token (e.g., "btc", "eth", "usdc"). If not provided, the system may attempt to infer it from the contract address.
"eth" | "btc" | "ltc" | "doge" | "bnb" | "pol" | "trx" | "usdt_trx" | "usdt_bnb" | "usdc_bnb" | "usd1_bnb" | "wbtc_bnb" | "usdt_eth" | "wbtc_eth" | "usdc_eth" | "usd1_eth" | "usdt_pol"The type of the destination token blockchain. Used to determine the blockchain type for the destination token (e.g., "btc", "eth", "usdc"). If not provided, the system may attempt to infer it from the contract address.
"eth" | "btc" | "ltc" | "doge" | "bnb" | "pol" | "trx" | "usdt_trx" | "usdt_bnb" | "usdc_bnb" | "usd1_bnb" | "wbtc_bnb" | "usdt_eth" | "wbtc_eth" | "usdc_eth" | "usd1_eth" | "usdt_pol"Whether to include additional data in the response. If true, the response will include additional data for the swap.
falseResponse Body
curl -X GET "https://cwap-api-dev.coinhq.store/pactswap_cm/getSwapQuotesByAmountTo?from=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&to=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&amountTo=0&backendUrl=https%3A%2F%2Fapi-cloud.coinweb.io%2Fwallet&lp=020a89e0698443aaf4ecd613317d2fdf90ef73b99244182fc7bb3c6b85f375b876&fromType=eth&toType=eth&withAdditionalData=false"[
{
"amountFrom": 1000000000000000000,
"lp": "020a89e0698443aaf4ecd613317d2fdf90ef73b99244182fc7bb3c6b85f375b876",
"usdAmounts": {
"from": 100,
"to": 100
},
"additionalData": {
"allC2Orders": [
"string"
],
"c1Order": "string",
"c2Order": "string"
}
}
]Was this documentation helpful? Any suggestions?
Last updated on