Skip to content

dex.getSellQuote

Gets the quote for selling a specific amount of tokens.

Usage

ts
import { 
Actions
} from 'wagmi/tempo'
import {
parseUnits
} from 'viem'
import {
config
} from './config'
const
amountOut
= await
Actions
.
dex
.
getSellQuote
(
config
, {
amountIn
:
parseUnits
('100', 6),
tokenIn
: '0x20c0000000000000000000000000000000000001',
tokenOut
: '0x20c0000000000000000000000000000000000002',
})
console
.
log
('Amount received:',
amountOut
)
Amount received: 99700000n
ts
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 = bigint

Returns 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.

Viem

Released under the MIT License.