Skip to content
LogoLogo

Wait for Earn Private Redeem

earn.waitForPrivateRedeem

Waits for a Zone gateway to redeem Earn shares on the parent Tempo chain.

Usage

Pass the correlation fields returned by earn.privateRedeem.prepare.

import {  } from './viem.config'
 
const  = await ..({
  : '0x0000000000000000000000000000000000000000000000000000000000000001',
  : 123456n,
  : '0x0000000000000000000000000000000000000001',
  : '0x0000000000000000000000000000000000000002',
})
{ outputAmount: 99_000_000n, tempoBlockNumber: 123457n, ... }

Use tempoBlockNumber from the result with zone.waitForTempoBlock to confirm that the returned assets were imported by the Zone.

Recipes

Release a Payout After Zone Import

Combine the wait with zone.waitForTempoBlock before notifying a payee that the redeemed funds are spendable in the Zone.

import {  as  } from './viem.config'
import {  as  } from './zones.config'
 
const  = await ..({
  : '0x0000000000000000000000000000000000000000000000000000000000000001',
  : 123456n,
  : '0x0000000000000000000000000000000000000001',
  : '0x0000000000000000000000000000000000000002',
})
{ outputAmount: 99_000_000n, tempoBlockNumber: 123457n, ... }
await ..({ : ., })

Reconcile Swap-Routed Redemptions

Compare vaultAssets with outputAmount when the redemption swaps into another token, so your ledger records both the vault redemption and the swap output.

import {  } from './viem.config'
 
const  = await ..({
  : '0x0000000000000000000000000000000000000000000000000000000000000001',
  : 123456n,
  : '0x0000000000000000000000000000000000000001',
  : '0x0000000000000000000000000000000000000002',
})
 
.({
  : .,
  : .,
  : .,
})
{ outputToken: '0x20c0...0001', swapOutput: 98_920_000n, vaultAssetsRedeemed: 99_400_000n }

Return Type

type ReturnType = {
  actionId: Hex
  outputAmount: bigint
  outputToken: Address
  shares: bigint
  tempoBlockNumber: bigint
  vaultAssets: bigint
  zoneDepositHash: Hex
}

Parameters

actionId

  • Type: Hex

Correlation ID returned by earn.privateRedeem.prepare.

fromBlock

  • Type: bigint

Lower bound for the parent-chain log scan.

gateway

  • Type: Address

Zone gateway address.

pollingInterval (optional)

  • Type: number
  • Default: client.pollingInterval

Polling frequency in milliseconds.

timeout (optional)

  • Type: number
  • Default: 60_000

Maximum time to wait in milliseconds. Set to 0 to disable the timeout.

vault

  • Type: Address

Vault used to filter matching redemption events.