@circle-fin/usdckit - v0.21.0
    Preparing search index...

    Function getSwapExactInQuote

    • Gets a quote for swapping an exact amount of one token for another token

      Parameters

      Returns Promise<GetSwapExactInQuoteReturnType>

      An object containing the amount of output token and the gas estimate for the operation.

      Calculating a quote for a swap of 1 USDC to WETH on Ethereum Sepolia

      const quote = await client.getSwapExactInQuote({
      tokenIn: ETH_SEPOLIA.contracts.USDC,
      tokenInAmount: '1',
      tokenOut: '0xfff9976782d46cc05630d1f6ebab18b2324d6b14',
      chain: ETH_SEPOLIA,
      })

      Use quote to swap

      const quote = await client.getSwapExactInQuote({
      tokenIn: ETH_SEPOLIA.contracts.USDC,
      tokenInAmount: '1',
      tokenOut: '0xfff9976782d46cc05630d1f6ebab18b2324d6b14',
      chain: ETH_SEPOLIA,
      })

      await client.swap({ ...quote, account })