earn.redeem
Redeems an exact number of vault shares for assets sent to a recipient.
Usage
import { client } from './viem.config'
const result = await client.earn.redeemSync({
shareAmount: 100_000_000n,
slippageBps: 50,
vault: '0x0000000000000000000000000000000000000001',
})
{
// assetAmount: 99_500_000n,
// caller: '0x...',
// receipt: { ... },
// recipient: '0x...',
// shareAmount: 100_000_000n,
// }import { Account, createClient } from 'viem/tempo'
export const client = createClient({
account: Account.fromSecp256k1('0x...'),
})When only slippageBps is provided, the action gets a live
earn.getRedeemQuote and derives the minimum asset output.
The transaction approves the vault shares and redeems them atomically.
Use an Existing Quote
Pass assetAmount with slippageBps when you already have a recent asset quote.
import { client } from './viem.config'
const result = await client.earn.redeemSync({
assetAmount: 99_750_000n,
shareAmount: 100_000_000n,
slippageBps: 50,
vault: '0x0000000000000000000000000000000000000001',
})
{ assetAmount: 99_500_000n, shareAmount: 100_000_000n, ... }import { Account, createClient } from 'viem/tempo'
export const client = createClient({
account: Account.fromSecp256k1('0x...'),
})Asynchronous Usage
earn.redeemSync waits for inclusion and returns the decoded redemption event. Use earn.redeem
to return the transaction hash immediately.
import { client } from './viem.config'
const hash = await client.earn.redeem({
assetAmountMin: 99_000_000n,
shareAmount: 100_000_000n,
vault: '0x0000000000000000000000000000000000000001',
})
0x1234...abcdReturn Value
type ReturnValue = {
/** Assets paid out. */
assetAmount: bigint
/** Redeeming caller. */
caller: Address
/** Transaction receipt. */
receipt: TransactionReceipt
/** Asset recipient. */
recipient: Address
/** Vault shares burned. */
shareAmount: bigint
}The asynchronous action returns the transaction hash instead.
Parameters
assetAmount (optional)
- Type:
bigint
Quoted asset output. Provide it with slippageBps to avoid a live quote.
assetAmountMin (optional)
- Type:
bigint
Minimum assets to accept. It must be greater than zero and cannot be combined with assetAmount or
slippageBps.
recipient (optional)
- Type:
Address - Default:
account.address
Asset recipient.
shareAmount
- Type:
bigint | { decimals?: number | undefined; formatted: string }
Vault shares to redeem. A bigint uses base units; a formatted value uses the share token's
decimals unless decimals is provided.
slippageBps (optional)
- Type:
number
Slippage tolerance below the provided or live quote, in basis points. For example, 50 means 0.5%.
vault
- Type:
Address
Vault address.
account (optional)
- Type:
Account | Address
Account that will be used to send the transaction.
feeToken (optional)
- Type:
Address | bigint
Fee token for the transaction.
Can be an unpaused USD-denominated TIP-20 token address or ID. Use client.fee.validateToken({ token }) to validate a token before submitting a transaction or setting it as a fee preference.
feePayer (optional)
- Type:
Account | true
Fee payer for the transaction.
Can be a Viem Account, or true if a Fee Payer Service will be used.
gas (optional)
- Type:
bigint
Gas limit for the transaction.
maxFeePerGas (optional)
- Type:
bigint
Max fee per gas for the transaction.
maxPriorityFeePerGas (optional)
- Type:
bigint
Max priority fee per gas for the transaction.
nonce (optional)
- Type:
number
Nonce for the transaction.
nonceKey (optional)
- Type:
'expiring' | bigint
Nonce key for the transaction. Use 'expiring' to use expiring nonces (TIP-1009), which enables concurrent transaction submission without nonce ordering.
validBefore (optional)
- Type:
number
Unix timestamp before which the transaction must be included.
validAfter (optional)
- Type:
number
Unix timestamp after which the transaction can be included.
throwOnReceiptRevert (optional)
- Type:
boolean - Default:
true
Whether to throw an error if the transaction receipt indicates a revert. Only applicable to *Sync actions.