Skip to content
LogoLogo

Get Earn Withdraw Quote

earn.getWithdrawQuote

Gets the Earn shares required for an exact asset output, including fees.

Usage

import {  } from './viem.config'
 
const  = await ..({
  : 100_000_000n,
  : '0x0000000000000000000000000000000000000001',
})
100_500_000n

Recipes

Check Shares Cover an Invoice Payment

Quote the shares an exact invoice amount requires, verify the position covers them with earn.getPosition, then execute with earn.withdrawExactSync bound to the quote.

import {  } from './viem.config'
 
const  = '0x0000000000000000000000000000000000000001'
const  = 250_000_000n
 
const [, ] = await .([
  ..({ : ,  }),
  ..({  }),
])
 
if ( > .)
  throw new ('Position does not cover the invoice.')
 
const  = await ..({
  : ,
  : '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  ,
  : 25,
  ,
})

Return Value

bigint

The required Earn share input in base units, rounded up.

Parameters

assetAmount

  • Type: bigint

Exact number of assets to receive, in base units.

vault

  • Type: Address

Vault address.

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.