Deposit Shares into Earn Vault
earn.depositShares
Deposits venue shares into a vault and mints Earn shares to a recipient.
Usage
import { } from './viem.config'
const = await ..({
: 499_000_000n,
: 30,
: '0x0000000000000000000000000000000000000002',
: 500_000_000n,
: '0x20c0000000000000000000000000000000000001',
})
{// caller: '0x...',// earnShareAmount: 498_750_000n,
// receipt: { ... },
// receivedVenueShareAmount: 500_000_000n,
// recipient: '0x...',
// venueShareAmount: 500_000_000n,
// }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})The action reads the current venue integration, approves it to pull venueShareToken, and deposits
the venue shares in one transaction.
Asynchronous Usage
earn.depositSharesSync waits for inclusion and returns the decoded deposit event. Use
earn.depositShares to return the transaction hash immediately.
import { } from './viem.config'
const = await ..({
: 497_000_000n,
: '0x0000000000000000000000000000000000000002',
: 500_000_000n,
: '0x20c0000000000000000000000000000000000001',
})
0x1234...abcdRecipes
Confirm In-Kind Support Before Migrating
Combine earn.getVault with the deposit to verify the vault's
venue integration accepts venue shares before moving a position.
import { } from './viem.config'
const = '0x0000000000000000000000000000000000000002'
const { } = await ..({ })
if (!.)
throw new ('Vault does not accept venue share deposits.')
const = await ..({
: 497_000_000n,
,
: 500_000_000n,
: '0x20c0000000000000000000000000000000000001',
})
{ earnShareAmount: 498_750_000n, ... }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Quote the Migration Onchain
Use contract.read with the vault's
convertEngineSharesToEarnShares function to derive the Earn share quote from live vault
accounting.
import { } from 'viem/tempo'
import { } from './viem.config'
const = '0x0000000000000000000000000000000000000002'
const = 500_000_000n
const = await ..({
: .,
: ,
: [],
: 'convertEngineSharesToEarnShares',
})
const = await ..({
,
: 30,
,
,
: '0x20c0000000000000000000000000000000000001',
})
{ earnShareAmount: 498_750_000n, ... }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Quote immediately before submission; slippageBps absorbs small value changes between the read and
the deposit.
Return Value
type ReturnValue = {
/** Depositing caller. */
caller: Address
/** Earn shares minted. */
earnShareAmount: bigint
/** Transaction receipt. */
receipt: TransactionReceipt
/** Venue shares measured as received by the integration. */
receivedVenueShareAmount: bigint
/** Earn share recipient. */
recipient: Address
/** Venue shares requested for transfer. */
venueShareAmount: bigint
}The asynchronous action returns the transaction hash instead.
Parameters
earnShareAmount (optional)
- Type:
bigint
Quoted Earn share output. Provide it with slippageBps, or provide earnShareAmountMin instead.
earnShareAmountMin (optional)
- Type:
bigint
Minimum Earn shares to accept. It must be greater than zero and cannot be combined with
earnShareAmount or slippageBps.
recipient (optional)
- Type:
Address - Default:
account.address
Earn share recipient.
slippageBps (optional)
- Type:
number
Slippage tolerance below earnShareAmount, in basis points. For example, 30 means 0.3%.
vault
- Type:
Address
Vault address.
venueShareAmount
- Type:
bigint
Venue shares to deposit, in base units.
venueShareToken
- Type:
Address
Venue share token to deposit.
account (optional)
- Type:
Account | Address
Account that will be used to send the transaction.
feePayer (optional)
- Type:
Account | boolean
Fee payer for the transaction (TIP-1 gas sponsorship).
Pass true to defer the fee token to an external fee payer (e.g. a relay), or a local Account to co-sign the transaction as the fee payer.
feeToken (optional)
- Type:
Address | bigint
Fee token for the transaction.
Can be an unpaused USD-denominated TIP-20 token address or ID.
gas (optional)
- Type:
bigint
Gas limit for the transaction.
keyAuthorization (optional)
- Type:
KeyAuthorization
Signed key authorization to include with the transaction, authorizing an access key to act for the sending account.
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' | 'random' | bigint
Nonce key for the transaction (TIP-1009 2D nonces).
Use 'expiring' to select an expiring nonce, which enables concurrent transaction submission without nonce ordering. Use 'random' to select a random key.
throwOnReceiptRevert (optional)
- Type:
boolean - Default:
true
Whether a Sync action throws when the receipt reports a revert.
validAfter (optional)
- Type:
number
Unix timestamp after which the transaction can be included.
validBefore (optional)
- Type:
number
Unix timestamp before which the transaction must be included.