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.local
and 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.
yarn
- Install dependenciesdoppler run -- yarn dev
- Start development server (requires.env.local
config)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=true
environment 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
:switchNextChain
chainStatus
state managementchainMap
object
- Code formatting: Run
yarn format
before committing (enforced by Prettier in CI) - Tests: Run
yarn test
before 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.