dex.getSellQuote
Gets the quote for selling a specific amount of tokens.
Usage
example.ts
import { parseUnits } from 'viem'
import { client } from './viem.config'
const amountOut = await client.dex.getSellQuote({
amountIn: parseUnits('100', 6),
tokenIn: '0x20c0000000000000000000000000000000000001',
tokenOut: '0x20c0000000000000000000000000000000000002',
})
console.log('Amount received:', amountOut)
Amount received: 99700000nReturn Type
type ReturnType = bigintReturns the amount of tokenOut received for selling the specified amountIn of tokenIn.
Parameters
amountIn
- Type:
bigint
Amount of tokenIn to sell.
tokenIn
- Type:
Address
Address of the token to sell.
tokenOut
- Type:
Address
Address of the token to receive.
account (optional)
- Type:
Account | Address
Account that will be used to send the transaction.
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.