205 lines
3.6 KiB
Markdown
205 lines
3.6 KiB
Markdown
# 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
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone <repo-url>
|
|
cd strategic
|
|
```
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pnpm install
|
|
```
|
|
|
|
3. Copy environment template:
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
|
|
4. Configure `.env`:
|
|
```bash
|
|
# 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
|
|
|
|
```bash
|
|
pnpm build
|
|
```
|
|
|
|
## Step 3: Deploy Executor Contract
|
|
|
|
### Testnet Deployment
|
|
|
|
1. Set up Foundry:
|
|
```bash
|
|
forge install
|
|
```
|
|
|
|
2. Deploy to testnet:
|
|
```bash
|
|
forge script script/Deploy.s.sol \
|
|
--rpc-url $RPC_SEPOLIA \
|
|
--broadcast \
|
|
--verify
|
|
```
|
|
|
|
3. Update `.env` with deployed address:
|
|
```bash
|
|
EXECUTOR_ADDR=0x...
|
|
```
|
|
|
|
### Mainnet Deployment
|
|
|
|
1. **Verify addresses** in `scripts/Deploy.s.sol` match your target chain
|
|
|
|
2. Deploy with multi-sig:
|
|
```bash
|
|
forge script script/Deploy.s.sol \
|
|
--rpc-url $RPC_MAINNET \
|
|
--broadcast \
|
|
--verify \
|
|
--sender <MULTISIG_ADDRESS>
|
|
```
|
|
|
|
3. **Transfer ownership** to multi-sig after deployment
|
|
|
|
4. **Configure allow-list** via multi-sig:
|
|
```solidity
|
|
executor.setAllowedTargets([...protocols], true);
|
|
executor.setAllowedPool(aavePool, true);
|
|
```
|
|
|
|
## Step 4: Verify Deployment
|
|
|
|
1. Check contract on block explorer
|
|
2. Verify ownership
|
|
3. Verify allow-list configuration
|
|
4. Test with small transaction
|
|
|
|
## Step 5: Test Strategy
|
|
|
|
1. Create test strategy:
|
|
```json
|
|
{
|
|
"name": "Test",
|
|
"chain": "mainnet",
|
|
"executor": "0x...",
|
|
"steps": [
|
|
{
|
|
"id": "test",
|
|
"action": {
|
|
"type": "aaveV3.supply",
|
|
"asset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
"amount": "1000000"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
2. Simulate first:
|
|
```bash
|
|
strategic run test.json --simulate --fork $RPC_MAINNET
|
|
```
|
|
|
|
3. Dry run:
|
|
```bash
|
|
strategic run test.json --dry
|
|
```
|
|
|
|
4. Execute with small amount:
|
|
```bash
|
|
strategic run test.json
|
|
```
|
|
|
|
## Step 6: Production Configuration
|
|
|
|
### Multi-Sig Setup
|
|
|
|
1. Create multi-sig wallet (Gnosis Safe recommended)
|
|
2. Transfer executor ownership to multi-sig
|
|
3. Configure signers (minimum 3-of-5)
|
|
4. Set up emergency pause procedures
|
|
|
|
### Monitoring
|
|
|
|
1. Set up transaction monitoring
|
|
2. Configure alerts (see PRODUCTION_RECOMMENDATIONS.md)
|
|
3. Set up health dashboard
|
|
4. Configure logging
|
|
|
|
### Security
|
|
|
|
1. Review access controls
|
|
2. Test emergency pause
|
|
3. Verify allow-list
|
|
4. 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
|
|
|
|
1. Monitor for 24-48 hours
|
|
2. Review all transactions
|
|
3. Gradually increase limits
|
|
4. Expand allow-list as needed
|
|
5. Document learnings
|
|
|
|
## Rollback Plan
|
|
|
|
If issues occur:
|
|
|
|
1. Pause executor immediately
|
|
2. Review recent transactions
|
|
3. Revoke problematic addresses
|
|
4. Fix issues
|
|
5. Resume with caution
|
|
|