3.6 KiB
3.6 KiB
Deployment Guide
Prerequisites
- Node.js 18+
- pnpm 8+
- Foundry (for contract deployment)
- RPC endpoints for target chains
- Private key or hardware wallet
Step 1: Environment Setup
- Clone the repository:
git clone <repo-url>
cd strategic
- Install dependencies:
pnpm install
- Copy environment template:
cp .env.example .env
- Configure
.env:
# RPC Endpoints
RPC_MAINNET=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
RPC_ARBITRUM=https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY
RPC_OPTIMISM=https://opt-mainnet.g.alchemy.com/v2/YOUR_KEY
RPC_BASE=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
# Private Key (use hardware wallet in production)
PRIVATE_KEY=0x...
# Executor Address (set after deployment)
EXECUTOR_ADDR=
# Optional: 1inch API Key
ONEINCH_API_KEY=
# Optional: Flashbots
FLASHBOTS_RELAY=https://relay.flashbots.net
Step 2: Build
pnpm build
Step 3: Deploy Executor Contract
Testnet Deployment
- Set up Foundry:
forge install
- Deploy to testnet:
forge script script/Deploy.s.sol \
--rpc-url $RPC_SEPOLIA \
--broadcast \
--verify
- Update
.envwith deployed address:
EXECUTOR_ADDR=0x...
Mainnet Deployment
-
Verify addresses in
scripts/Deploy.s.solmatch your target chain -
Deploy with multi-sig:
forge script script/Deploy.s.sol \
--rpc-url $RPC_MAINNET \
--broadcast \
--verify \
--sender <MULTISIG_ADDRESS>
-
Transfer ownership to multi-sig after deployment
-
Configure allow-list via multi-sig:
executor.setAllowedTargets([...protocols], true);
executor.setAllowedPool(aavePool, true);
Step 4: Verify Deployment
- Check contract on block explorer
- Verify ownership
- Verify allow-list configuration
- Test with small transaction
Step 5: Test Strategy
- Create test strategy:
{
"name": "Test",
"chain": "mainnet",
"executor": "0x...",
"steps": [
{
"id": "test",
"action": {
"type": "aaveV3.supply",
"asset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"amount": "1000000"
}
}
]
}
- Simulate first:
strategic run test.json --simulate --fork $RPC_MAINNET
- Dry run:
strategic run test.json --dry
- Execute with small amount:
strategic run test.json
Step 6: Production Configuration
Multi-Sig Setup
- Create multi-sig wallet (Gnosis Safe recommended)
- Transfer executor ownership to multi-sig
- Configure signers (minimum 3-of-5)
- Set up emergency pause procedures
Monitoring
- Set up transaction monitoring
- Configure alerts (see PRODUCTION_RECOMMENDATIONS.md)
- Set up health dashboard
- Configure logging
Security
- Review access controls
- Test emergency pause
- Verify allow-list
- Set up incident response plan
Troubleshooting
Deployment Fails
- Check RPC endpoint
- Verify gas prices
- Check contract size limits
- Verify addresses are correct
Execution Fails
- Check executor address in strategy
- Verify allow-list includes target protocols
- Check gas limits
- Verify strategy JSON is valid
High Gas Usage
- Optimize batch size
- Review strategy complexity
- Consider splitting into multiple transactions
Post-Deployment
- Monitor for 24-48 hours
- Review all transactions
- Gradually increase limits
- Expand allow-list as needed
- Document learnings
Rollback Plan
If issues occur:
- Pause executor immediately
- Review recent transactions
- Revoke problematic addresses
- Fix issues
- Resume with caution