Skip to content
LogoLogo

Wait for Earn Private Deposit

earn.waitForPrivateDeposit

Waits for a Zone gateway to deposit assets into an Earn vault on the parent Tempo chain.

Usage

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

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

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

Recipes

Credit a Balance After Zone Import

Combine the wait with zone.waitForTempoBlock before treating the returned shares as spendable inside the Zone.

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

Handle Settlement Timeouts in a Worker

Catch WaitForPrivateDepositTimeoutError to keep a settlement worker alive; the wait only scans logs, so retrying with the same fields is safe.

import {  } from 'viem/tempo'
import {  } from './viem.config'
 
try {
  await ..({
    : '0x0000000000000000000000000000000000000000000000000000000000000001',
    : 123456n,
    : '0x0000000000000000000000000000000000000001',
    : 300_000,
    : '0x0000000000000000000000000000000000000002',
  })
} catch () {
  if (!( instanceof )) throw 
  // Settlement can still complete later; retry with the same fields.
}

Return Type

type ReturnType = {
  actionId: Hex
  inputAmount: bigint
  inputToken: Address
  shares: bigint
  tempoBlockNumber: bigint
  vaultAssets: bigint
  zoneDepositHash: Hex
}

Parameters

actionId

  • Type: Hex

Correlation ID returned by earn.privateDeposit.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 deposit events.