Skip to content

getUsdRate

Returns the current token price in USD.

  • Mint Club tokens: computed via its bonding curve price (in reserve) multiplied by the reserve token USD rate. If reserves are nested Mint Club tokens, the method expands the full path until a DEX-quoted token is reached.
  • Non–Mint Club tokens: priced via 1inch on the current chain. For tokens with very small values (< $0.000001), automatically uses TOKEN → ETH → USD path for better precision instead of direct TOKEN → USDC/USDT path.

Usage

example.ts
import { mintclub } from 'mint.club-v2-sdk'
 
// Mint Club token
const mintToken = await mintclub.network('base').token('GMFR').getUsdRate()
 
// NonMint Club token
const erc20 = await mintclub.network('base').token('0x...erc20').getUsdRate(100)

Return Value

Promise<{
  usdRate: number | null
  reserveToken: null | {
    address: `0x${string}`
    name: string
    symbol: string
    decimals: number
  }
  path: Array<
    | {
        address: `0x${string}`
        method: 'bond'
        reservePerToken: number
        note?: string
        reserveSymbol?: string
        reserveUsdRate?: number
      }
    | {
        address: `0x${string}`
        method: 'oneinch'
        stableSymbol?: string
        note?: string
        reserveSymbol?: string
        rate?: number
      }
  >
}>
  • usdRate: USD price for the requested amount, or null when unavailable
  • reserveToken: the direct reserve token of the Mint Club token (null for non–Mint Club tokens)
  • path: verbose breakdown of how the price was derived
    • bond item: the bonding curve price denominated in the reserve token
    • oneinch item: the DEX quote into a stable coin on the current chain

Examples

Nested Mint Club path (example):

// GNMFER -> GMFR -> MFER -> USDBC
{
  usdRate: 0.0000046,
  reserveToken: { address: '0x...', name: 'gmfer', symbol: 'GMFR', decimals: 18 },
  path: [
    { address: '0x...gnmfer', method: 'bond', reservePerToken: 0.307..., reserveSymbol: 'GMFR' },
    { address: '0x...gmfr', method: 'bond', reservePerToken: 0.0015..., reserveSymbol: 'MFER' },
    { address: '0x...mfer', method: 'oneinch', stableSymbol: 'USDBC', note: 'dex quote to stable', rate: 3.05 }
  ]
}

Parameters

amount (optional)

  • Type: number
  • Default: 1

The amount of the token to be converted to USD. If not provided, defaults to 1.

Errors

  • Throws when 1inch is not supported on the current network.