@exodus/token-delegation
v1.0.0
Published
Token delegation feature for managing delegated token addresses per wallet account
Maintainers
Keywords
Readme
@exodus/token-delegation
Token delegation feature for managing delegated token addresses per wallet account. Handles storing and managing token delegation relationships with transaction signing and broadcasting.
Design Note
This module does not fetch delegations from the blockchain. Delegations must be provided externally via setDelegations(). This is intentional: resolving delegations on-chain typically requires expensive reverse lookups (e.g., scanning all accounts to find those with a matching delegate), which is prohibitively slow via RPC.
The module is chain-agnostic. Any asset implementing approveDelegation and revokeDelegation can be used.
Install
yarn add @exodus/token-delegationUsage
This feature is designed to be used together with @exodus/headless. See using the sdk.
import tokenDelegation from '@exodus/token-delegation'
exodus.use(tokenDelegation())API Side
See using the sdk for more details on how features plug into the SDK.
tokenDelegate
Manages delegation data storage.
// Set delegations from external source (replaces existing)
await exodus.tokenDelegate.setDelegations({
solana: [
{ delegatedAddress: 'delegate-addr-1', assetName: 'usdcoin_solana' },
{ delegatedAddress: 'delegate-addr-2', assetName: 'tetherusd_solana' },
],
})
// Get all stored delegations as a map keyed by base asset
const delegations = await exodus.tokenDelegate.getDelegations()
// { solana: [{ delegatedAddress: '...', assetName: 'usdcoin_solana' }] }tokenDelegator
Handles on-chain delegation transactions (sign + broadcast).
// Approve delegation (signs and broadcasts tx)
const { txId } = await exodus.tokenDelegator.approveDelegation({
assetName: 'usdcoin_solana',
delegateAddress: 'delegate-address',
amount: '1000000',
})
// Revoke delegation (signs and broadcasts tx)
const { txId } = await exodus.tokenDelegator.revokeDelegation({
assetName: 'usdcoin_solana',
})Events
The feature emits tokenDelegation/updated when setDelegations is called.
