Get Quote
getQuote
Fetches a quote for swapping tokens based on the provided quoteRequest
and an options
argument.
getQuote(
quoteRequest: QuoteRequest,
options?: RequestOptions
): Promise<QuoteResponse>
The quoteRequest
object describes the swap for which a quote is returned.
Param | Description | Data type |
---|---|---|
srcChain | Source chain for the swap | ChainId |
destChain | Destination chain for the swap | ChainId |
srcAsset | Asset to be swapped from the source chain | string |
destAsset | Asset to be received on the destination chain | string |
amount | Amount of the source token to be swapped | string |
Example
import { Chains, Assets } from "@chainflip-io/chainflip-sdk/swap";
const quoteRequest = {
srcChain: Chains.Ethereum,
destChain: Chains.Bitcoin,
srcAsset: Assets.ETH,
destAsset: Assets.BTC,
amount: (1.5e18).toString(), // 1.5 ETH
};
console.log(await swapSDK.getQuote(quoteRequest));
Sample Response
{
"srcChain": "Ethereum",
"destChain": "Bitcoin",
"srcAsset": "ETH",
"destAsset": "BTC",
"amount": "1500000000000000000", // 1.5 ETH
"quote": {
"intermediateAmount": "2000000000", // 2000 USDC
"egressAmount": "10000000", // 0.1 BTC
"includedFees": [
{ "type": "network", "asset": "USDC", "amount": "2000000" },
{ "type": "liquidity", "asset": "ETH", "amount": "15000000000000000" },
{ "type": "liquidity", "asset": "USDC", "amount": "2000000" }
]
}
}
The intermediate amount is the value of the first swap leg.
In this case, BTC > ETH requires both BTC/USDC and USDC/ETH pools (or legs).
Learn more about Chainflip's $USDC Denominated Pools.