earn.getPosition
Gets an account's asset and vault share balances, allowances, and current share value.
Usage
import { client } from './viem.config'
const position = await client.earn.getPosition({
vault: '0x0000000000000000000000000000000000000001',
})
{
// assetAllowance: 0n,
// assetBalance: 250_000_000n,
// assetToken: '0x20c0...0001',
// shareAllowance: 0n,
// shareBalance: 99_500_000n,
// shareToken: '0x20c0...0002',
// value: 100_000_000n,
// }import { Account, createClient } from 'viem/tempo'
export const client = createClient({
account: Account.fromSecp256k1('0x...'),
})Read Another Account
Pass account to inspect a position other than the client account.
import { client } from './viem.config'
const position = await client.earn.getPosition({
account: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
vault: '0x0000000000000000000000000000000000000001',
})
{
// assetAllowance: 0n,
// assetBalance: 250_000_000n,
// assetToken: '0x20c0...0001',
// shareAllowance: 0n,
// shareBalance: 99_500_000n,
// shareToken: '0x20c0...0002',
// value: 100_000_000n,
// }import { Account, createClient } from 'viem/tempo'
export const client = createClient({
account: Account.fromSecp256k1('0x...'),
})Return Value
type ReturnValue = {
/** Assets the vault may spend from the account. */
assetAllowance: bigint
/** Asset balance held by the account. */
assetBalance: bigint
/** Token accepted by the vault. */
assetToken: Address
/** Vault shares the vault may spend from the account. */
shareAllowance: bigint
/** Vault share balance held by the account. */
shareBalance: bigint
/** Token representing vault shares. */
shareToken: Address
/** Current asset value of the vault share balance, including fees. */
value: bigint
}Parameters
account (optional)
- Type:
Account | Address - Default:
client.account
Account whose position is returned.
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.