preSwap

To initiate a swap, start with a preliminary swap assessment to understand the potential outcome. Afterward, you can set the amount limit based on the swap result and the slippage tolerance.

Preswap by simulation transaction

Signature

computeSwapResultV2(options: ComputeSwapResultOptionsV2): Promise<Transaction>

Params

interface ComputeSwapResultOptionsV2 {
  pools: Array<{
    // Pool object ID
    pool: string;
    // swap from coinA to coinB
    a2b: boolean;
    amountSpecified: string | number 
  }>;
  // Operator's wallet address
  address: string;
  amountSpecifiedIsInput: boolean;
  tickStep?: number;
}
  • pools : Multiple pools can be passed for prediction, which is particularly useful when there are multiple fee pools with the same token.

  • address : Transaction sender

  • a2b : Swap Direction: A value of true indicates a swap from CoinA to CoinB

  • amountSpecifiedIsInput : true means fixed the amount of input, false means fixed the amount of output

  • tickStep: Represented this pre swap can move up to how many tickSpacing

Examples

Response

Last updated