Skip to content

dex.useBuyQuote ​

Gets the quote for buying a specific amount of tokens.

Usage ​

ts
import { Hooks } from 'wagmi/tempo'
import { parseUnits } from 'viem'

const { data: quote } = Hooks.dex.useBuyQuote({
  amountOut: parseUnits('100', 6),
  tokenIn: '0x20c0000000000000000000000000000000000001',
  tokenOut: '0x20c0000000000000000000000000000000000002',
})

console.log('Amount needed:', quote)
// @log: Amount needed: 100300000n
ts
import { createConfig, http } from 'wagmi'
import { tempo } from 'wagmi/chains'
import { tempoWallet } from 'wagmi/tempo'

export const config = createConfig({
  connectors: [tempoWallet()],
  chains: [tempo],
  multiInjectedProviderDiscovery: false,
  transports: {
    [tempo.id]: http(),
  },
})

Return Type ​

See TanStack Query query docs for more info hook return types.

data ​

See Wagmi Action dex.getBuyQuote Return Type

Parameters ​

See Wagmi Action dex.getBuyQuote Parameters

query ​

See the TanStack Query query docs for more info hook parameters.

Action ​

Released under the MIT License.