dex.getBuyQuote
Gets the quote for buying a specific amount of tokens.
Usage
import { } from 'viem'
import { } from './viem.config'
const = await .dex.getBuyQuote({
: ('100', 6),
: '0x20c0000000000000000000000000000000000001',
: '0x20c0000000000000000000000000000000000002',
})
.('Amount needed:', )
Amount needed: 100300000nReturn Type
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.
blockNumber (optional)
- Type:
bigint
Block number to read the state from.
blockOverrides (optional)
- Type:
BlockOverrides
Block overrides to apply to the state.
blockTag (optional)
- Type:
BlockTag
Block tag to read the state from.
stateOverride (optional)
- Type:
StateOverride
State override to apply.