Constructor
| Parameter | Type | Required | Description |
|---|---|---|---|
evmClients | Record<number | string, PublicClient> | For transaction methods | Chain ID to viem PublicClient map |
wallet | WalletClient | For transaction methods | Any viem-compatible WalletClient — used only to read the sender address. The SDK never signs. |
apiKey | string | No | Partner API key from the Developer Portal |
attributionMode | AttributionMode | No | Defaults to AttributionMode.PUBLIC |
builderCode | string | No | Builder identifier for attribution — must be requested from Gauntlet, not self-serve. NOT the same as API key. Without it, transactions are unattributed. |
Discover Vaults
Transaction Functions
Import from@gauntlet-xyz/sdk/evm. These communicate on-chain via your RPC URLs. Require wallet in the client config — the SDK reads the account address from wallet.account.
getDepositTx
ThevaultId string resolves to a VaultDeployment from the manifest. This is how the SDK knows which token to approve (supplyToken[0].address), which contract to call (vaultAddress or provisionerAddress), and whether the vault supports sync or async deposits.
| Parameter | Type | Required | Description |
|---|---|---|---|
vaultId | string | Yes | Vault identifier — resolves token, contract, and deposit mode from the manifest |
amount | bigint | Yes | Amount in token base units |
chainId | number | For multi-chain vaults | Defaults to Base |
assetSymbol | string | No | Required for multi-asset vaults to select the asset token |
depositMode | string | No | Override deposit mode: 'async' (queued) or 'sync' (instant). When omitted, uses the vault’s native mode — async for Aera, sync for Morpho. Vaults with depositMode: 'both' default to async. |
receiver | Address | No | Defaults to wallet.account. Aera vaults require receiver to equal the signer — providing a different address throws an error. |
slippageBps | number | No | Slippage tolerance in basis points (e.g. 100 = 1%). Defaults to 100. Must be an integer between 0 and 10000. |
getWithdrawTx
| Parameter | Type | Required | Description |
|---|---|---|---|
vaultId | string | Yes | Vault identifier |
shares | amount | entireAmount | — | Yes (one of) | Exact shares, exact asset amount, or full position |
chainId | number | For multi-chain vaults | Defaults to Base |
assetSymbol | string | No | Required for multi-asset vaults to select the withdraw token |
depositMode | string | No | Override withdraw mode: 'async' (queued) or 'sync' (instant). When omitted, uses the vault’s native mode — async for Aera, sync for Morpho. Vaults with depositMode: 'both' default to async. |
receiver | Address | No | Defaults to wallet.account. Aera vaults require receiver to equal the signer — providing a different address throws an error. |
slippageBps | number | No | Slippage tolerance in basis points (e.g. 100 = 1%). Defaults to 100. Must be an integer between 0 and 10000. |
User Vault Balance
Balance lifecycle
An async deposit or withdrawal passes through a pending state while the vault solver queues and processes the operation:pendingDeposit— funds are locked in the provisioner contract. They are not yet earning yield. Once the solver settles the request, they move tobalanceand begin earning.pendingWithdraw— vault shares have been redeemed but the underlying assets have not yet been transferred. They are no longer earning yield. Once the solver settles the request, they arrive as ERC-20 tokens in the receiver wallet.
| Path | Where the balance lands | Notes |
|---|---|---|
| Async deposit | pendingDeposit for ~2–12 hours (usually ~2), then moves to balance | Not earning during pending; best execution price once settled |
| Sync deposit | Directly into balance | Slightly worse price; no waiting |
| Sync withdraw | Removed from balance immediately; claimable as ERC-20 in the receiver wallet | Slightly worse price; no waiting |
| Async withdraw | Moves from balance to pendingWithdraw for ~2–12 hours (usually ~2), then claimable as ERC-20 in the receiver wallet | No longer earning during pending; best execution price once settled |
getUserCurrentBalance
| Parameter | Type | Required | Description |
|---|---|---|---|
vaultId | string | Yes | Must resolve to an Aera multi-depositor vault — throws UnsupportedProtocolError otherwise |
address | Address | Yes | Account to query |
chainId | number | No | When omitted, returns one entry per chain the vault is deployed on. When provided, returns only that chain — throws ChainMismatchError if not deployed there. |
Promise<UserCurrentBalance[]> — one entry per chain the vault is deployed on:
0n — this is not an error.
Result Shape
BothgetDepositTx and getWithdrawTx return Promise<PreparedTx[]>.
approve step, when present, always comes first.
Each step exposes two submission paths with different trade-offs:
Path 1 — step.payload + sendTransaction
Use for: backend scripts, embedded wallets (Privy, Dynamic), server-side signing, EVM pre-simulation (eth_call on the exact bytes to be broadcast).
Attribution is pre-concatenated into payload.data — it cannot be lost regardless of wallet or provider.
Path 2 — step.tx + writeContract
Use for: browser wallets via wagmi (MetaMask, Coinbase Wallet, WalletConnect), or when you need wagmi simulation hooks.
Pass step.tx.attribution as dataSuffix — wagmi appends it to the ABI-encoded calldata before sending. If dataSuffix is omitted or the EIP-1193 provider strips it, the transaction succeeds but volume is not attributed.
Attribution
How ERC-8021 builder codes work, why
dataSuffix matters, and how to verify attribution is tracked.Types
VaultInfo
VaultDeployment
The objectvaultId resolves to. Carries all metadata the SDK needs to construct deposit and withdraw transactions — you never supply these directly.
TokenInfo
VaultFilter
AttributionMode
Errors
All errors extendGauntletSDKError, which extends Error.
| Error | Description |
|---|---|
VaultNotFoundError | Vault ID doesn’t exist or isn’t deployed on the requested chain. Has .vaultId and optional .chainId properties. |
UnsupportedAssetError | Token not accepted by this vault. Has .asset and .vaultId properties. |
ChainMismatchError | Chain parameter doesn’t match vault deployment. Has .expected and .received properties. |
UnsupportedDepositModeError | Requested sync/async mode not supported by this vault. Has .vaultId, .requested, and .available properties. |
RpcNotConfiguredError | No evmClients entry provided for the required chain ID. Has .chainId property. |
AccountRequiredError | No wallet provided in client config. |
UnsupportedProtocolError | Vault protocol is not supported by this method (e.g. getUserCurrentBalance only supports Aera multi-depositor). Has .protocol property. |
InvalidWithdrawParamsError | getWithdrawTx called without exactly one of shares, amount, or entireAmount. |
InvalidSlippageBPSError | slippageBps is not an integer in the range 0–10000. Has .slippage property. |
UnimplementedFeatureError | Feature exists in the API but is not yet implemented (e.g. AttributionMode.ENCODED). Has .feature property. |
UnsupportedFeatureError | Feature is not supported at all (distinct from unimplemented). Has .feature property. |
UnitConversionError | Failed to convert token units for a vault — fee calculator unavailable on-chain. Has .vaultAddress property. |
Go Deeper
Examples
End-to-end code for deposits, withdrawals, and error handling.
API Reference
Use the raw API directly if you need more control than the SDK provides.