dex.getBuyQuote
Gets the quote for buying a specific amount of tokens.
Usage
ts
import { Actions } from 'wagmi/tempo'
import { parseUnits } from 'viem'
import { config } from './config'
const amountIn = await Actions.dex.getBuyQuote(config, {
amountOut: parseUnits('100', 6),
tokenIn: '0x20c0000000000000000000000000000000000001',
tokenOut: '0x20c0000000000000000000000000000000000002',
})
console.log('Amount needed:', amountIn)
Amount needed: 100300000nts
import { createConfig, http } from 'wagmi'
import { tempoTestnet } from 'wagmi/chains'
import { KeyManager, webAuthn } from 'wagmi/tempo'
export const config = createConfig({
connectors: [
webAuthn({
keyManager: KeyManager.localStorage(),
}),
],
chains: [tempoTestnet],
multiInjectedProviderDiscovery: false,
transports: {
[tempoTestnet.id]: http(),
},
})Return Type
ts
type ReturnType = bigintReturns the amount of tokenIn needed to buy the specified amountOut of tokenOut.
Parameters
amountOut
- Type:
bigint
Amount of tokenOut to buy.
tokenIn
- Type:
Address
Address of the token to spend.
tokenOut
- Type:
Address
Address of the token to buy.