Zap Pilot is a general-purpose intent-based DeFi execution engine that provides a universal interface for DeFi operations across multiple protocols and chains. The platform enables users to manage various vault strategies including Stablecoin Vault, Index500 (S&P500-like index fund), BTC vault, ETH vault, with support for customizable vaults.
- Copy environment configuration:
cp .env.sample .env.localand update values as needed - Install dependencies:
yarn - Start development server:
doppler run -- yarn dev
Open http://localhost:3000 to view the application.
You can start editing by modifying pages/index.tsx - the page auto-updates as you edit.
The application supports URL parameters to control the initial wallet connection mode, allowing users to specify whether they want to use Account Abstraction (AA) or Externally Owned Account (EOA) mode.
| Parameter | Values | Description |
|---|---|---|
mode |
aa | eoa |
Sets wallet mode (Account Abstraction or EOA) |
walletMode |
aa | eoa |
Alternative parameter name for wallet mode |
# Account Abstraction mode (gasless transactions)
https://localhost:3000/?mode=aa
https://localhost:3000/?walletMode=aa
# Externally Owned Account mode (traditional wallet)
https://localhost:3000/?mode=eoa
https://localhost:3000/?walletMode=eoa
# Default behavior (AA mode) - no parameter needed
https://localhost:3000/- One-time initialization: URL sets the initial wallet mode, but users can still toggle afterward
- Case insensitive:
aa,AA,Aaall work the same way - Fallback support: Invalid or missing parameters default to AA mode
- Backward compatible: Existing URLs without parameters continue to work
- Deep linking: Perfect for bookmarks, testing, and integration links
-
Development & Testing
# Test EOA mode specifically http://localhost:3000/?mode=eoa # Test AA mode with gasless transactions http://localhost:3000/?mode=aa
-
User Bookmarks
- Users can bookmark their preferred wallet mode
- Returning users get their preferred experience immediately
-
Integration Links
# Partner integrations can specify wallet mode https://yourapp.com/vault/btc?mode=eoa
-
Documentation & Tutorials
# Tutorial links can demonstrate specific wallet modes https://docs.yourapp.com/guide?mode=aa
The URL parameter is processed in WalletModeContext.jsx using Next.js router:
- Parameters are checked only on initial page load
- User toggle functionality remains fully intact
- Router state management ensures proper hydration
yarn- Install dependenciesdoppler run -- yarn dev- Start development server (requires.env.localconfig)yarn build- Build for productionyarn lint- Run ESLint with auto-fixyarn format- Format code with Prettier and Blackyarn test- Run Vitest tests (140s timeout)yarn test-ui- Start Vitest UI at http://localhost:51204/__vitest__/yarn coverage- Run test coverage report
The application is built around a modular protocol architecture:
- BaseProtocol (
classes/BaseProtocol.js) - Abstract base class for all DeFi protocol integrations - BaseVault (
classes/Vaults/BaseVault.js) - Portfolio orchestrator managing multiple protocols with weighted allocations - Protocol Classes - Concrete implementations for specific protocols (Aave, Convex, Moonwell, Camelot, etc.)
All protocols support standard operations:
zapIn- Deposit funds into protocolzapOut- Withdraw funds from protocolstake/unstake- Manage staking positionstransfer- Move assets between accountsclaimAndSwap- Harvest rewards and convert
Vaults combine multiple protocols with weighted allocations across categories and chains:
- Strategy Definition:
{category: {chain: [{interface: protocol, weight: number}]}} - Weight Mapping: Category-level allocations that must sum to 1.0
- Auto-normalization: Weights within categories are automatically normalized
- Tests are located in
__tests__/directory - Protocol-specific tests in
__tests__/intent/subdirectory - Running tests:
yarn test - UI interface:
yarn test-ui→ http://localhost:51204/__vitest__/ - Coverage reports:
yarn coverage
- Create test vaults containing only your protocol for isolated testing
- Copy existing test patterns from
__tests__/intent/when adding new protocol tests - Comment out
loading={zapInIsLoading}in ZapInTab.jsx for faster testing - Use
TEST=trueenvironment variable for test-specific behavior
-
Research Phase
- Interact with the protocol using your wallet
- Capture transaction details from block explorer (example txn)
- Extract: function name, parameters, contract address, ABI
- Save ABI files to
lib/contracts/directory
-
Implementation
- Inherit from BaseProtocol.js
- Implement required methods:
customDeposit,customWithdrawAndClaim,_stake,_unstake,pendingRewards - Set protocol metadata:
protocolName,protocolVersion, contract addresses - Handle both "single" token and "LP" token modes
-
Integration
- Add protocol to existing vault (like EthVault) or create new vault
- Update vault strategy in ./utils/thirdwebSmartWallet.ts
- Add vault to landing page
-
Testing
- Create isolated test vault with only your protocol
- Copy and modify test cases from tests/intent/
- Test frontend integration
-
Backend Integration
- Update transaction parser in rebalance backend:
_find_refund_data_by_txn_hash()
- Update transaction parser in rebalance backend:
Reference: ThirdWeb Supported Chains
- Verify bridge support for the new chain
- Update chain mappings in
utils/general.js(CHAIN_ID_TO_CHAIN, etc.) - Configure gas sponsorship settings in ThirdWeb
- Update UI components for chain selection
- Modify chain-specific functions in
indexOverviews.jsx:switchNextChainchainStatusstate managementchainMapobject
- Code formatting: Run
yarn formatbefore committing (enforced by Prettier in CI) - Tests: Run
yarn testbefore committing
- Staging (branch
main): https://all-weather-protocol-staging.on.fleek.co/ - Production (branch
prod): https://all-weather-protocol.on.fleek.co/
For updating chain/protocol/token images, refer to public/README.md.
Images are stored in WebP format in:
public/chainPicturesWebp/- Chain logospublic/projectPictures/- Protocol logos
- Comment out other protocols in vaults during development to speed up testing
- Comment out transaction calls (
depositTxn,stakeTxn) in protocol classes for UI testing - Use isolated test vaults for protocol development
- Environment setup requires Doppler for environment variable management
For detailed architecture information, see CLAUDE.md.