Overview
This example covers:- Fetching available strategies
- Getting strategy details
- Requesting a quote
- Generating transaction bytecode
- Executing transactions
- Verifying the deposit
Prerequisites
- Node.js 18+
- Pods API key
- Ethereum wallet with USDC balance
- Basic understanding of async/await
Installation
- ethers.js
- viem
Environment Variables
Create a.env file:
Step-by-Step Walkthrough
1. Initialize API Client
2. Fetch Available Strategies
3. Get Strategy Details
4. Generate Bytecode
Same-Chain Swap + Deposit
If you hold a different token (e.g., WETH) and want to deposit into a USDC strategy, pass thefromTokenAddress parameter. The API will return swap transaction(s) followed by the deposit bytecode:
When
fromTokenAddress is provided, include fromChainId or chainIdIn. For same-chain swap + deposit, use the strategy chain. The amount parameter refers to the amount of that token to swap, not the strategy’s underlying asset.Cross-Chain Deposit
If the funds start on a different chain, passfromChainId or chainIdIn plus fromTokenAddress. Store result.id; it is used for asynchronous tracking.
5. Execute Transactions (atomic batch)
EOA (recommended): use EIP-7702executeBatch or run
strategy-deposit-eip7702.js /
eip7702-batch.js.
Smart account: add output=userOperation and submit via your bundler —
Smart Account Deposit.
6. Verify Deposit
7. Track Cross-Chain Deposit Status (Cross-Chain Only)
If you made a cross-chain deposit, the bridge and the destination-chain deposit happen in separate transactions and complete asynchronously. Use theid returned in the bytecode response to poll /actions/:id until the status reaches a terminal state.
8. Track Cross-Chain Deposit Status (Cross-Chain Only)
If you made a cross-chain deposit (you passedfromChainId in Step 5), the bridge and the destination-chain deposit happen in separate transactions and complete asynchronously. Use the id returned in the bytecode response to poll /actions/:id until the action reaches a terminal state.
Same-chain deposits do not require polling — the deposit completes inline with the user’s signed transaction. You can still call
GET /actions/:id with the returned id for record-keeping.Error Handling
The example includes comprehensive error handling:Running the Example
Expected Output
Next Steps
EIP-7702 Batch Deposit
Atomic EOA execution (recommended)
Executing Bytecode
Output types and wallet decision tree
Strategy Withdrawal
Withdraw from strategies, including cross-chain withdrawals
Cross-Chain Swap
Execute cross-chain token swaps
Check Positions
Track wallet positions
API Reference
View complete API documentation