Fetching a quote
Let's fetch a quote for executing a chain abstracted batch of transactions
Importing libraries
import axios from 'axios';Defining types
enum QuoteType {
AMOUNT_IN = 'AMOUNT_IN',
AMOUNT_OUT = 'AMOUNT_OUT'
}
type Transaction = {
to: string; // destination contract/address (0x-prefixed)
data: string; // calldata (0x-prefixed)
value: string; // value in wei (as string)
};
type GetQuoteParams = {
// Solution inputs
walletAddress: string; // registered EVM address or Solana Address
chainId: number; // chain ID
amount: string; // smallest units, e.g. "200000" for 0.2 USDC
type: QuoteType; // borrow mode (AMOUNT_IN or AMOUNT_OUT)
settlementToken?: string | null; // 'SOL' for SOL settlement, USDC by default
spendingTokenAddress?: string | null; // USDC by default, specify address of token on the chain corresponding to the given chainId
// New: explicit call bundle the solver should execute
transactions?: Transaction[]; // [{ to, data, value }, ...]
};
type QuoteResponse = type Quote = {
chainId: number;
tokenAddress: string;
// Amount the user pays from source chains
settlementAmount: string;
// Expected amount of tokens the user will have on the target chain after borrowing
expectedAmountOut: string;
// Map of chain IDs to amounts to be settled from the corresponding chain
settlementPlan: Record<string, string>;
};Setting up request headers
Calling the quote API
Last updated