Files
smom-dbis-138/docs/treasury/EXECUTOR_BOT_INTEGRATION.md
2026-03-02 12:14:09 -08:00

48 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Executor Bot Integration
Bot triggers harvest, rebalance, export. Must not set token addresses, receiver, selector, or caps.
## Entrypoints (StrategyExecutor138)
| Function | When to call | Notes |
| -------- | ------------ | ----- |
| `harvestFees()` | Per strategy schedule | Stub: reverts `NotImplemented` until LP contracts are wired. |
| `rebalanceLp()` | Per strategy schedule | Stub: reverts `NotImplemented` until LP contracts are wired. |
| `exportToMainnet(weth9Token, weth9Amount, deadline)` | When CCIP is live and policy/caps allow | Direct export. Requires `exportsEnabled == true` on CcipBridgeAdapter138. |
| `recordExportIntent(token, amount)` | When CCIP is **not** live | Records a single pending intent (overwrites previous). Call only when `exportsEnabled == false`. |
| `processPendingIntent(deadline)` | After CCIP is enabled and a pending intent exists | Executes the recorded intent (same path as `exportToMainnet`) and clears the slot. |
## ExportPolicy (StrategyExecutor138)
- **Read:** `exportPolicy()` returns (mode, minExportUsd, maxPerTxUsd, maxDailyUsd, rateLimitPerHour, cooldownBlocks, exportAsset, destinationSelector, destinationReceiver).
- **Set:** Admin calls `setExportPolicy(ExportPolicy)` (e.g. after deploy or when changing mode).
- **Modes:** `Daily` (sweep on schedule), `Threshold` (export when balance ≥ minExportUsd), `Hybrid`.
- Caps are enforced by TreasuryVault; the policys `minExportUsd` is for bot logic (when to trigger in Threshold/Hybrid mode).
## Intent queue (CCIP not live)
- While `exportsEnabled == false`, call `recordExportIntent(allowedWeth9Token, amount)` (KEEPER).
- When CCIP is enabled, call `processPendingIntent(deadline)` (KEEPER) to execute the pending intent once.
- Only one pending intent is stored; recording again overwrites it.
## Startup
1. Run: `node scripts/treasury/verify-weth9-fingerprint.js`
2. Optionally set `ExportPolicy` on StrategyExecutor138 (admin) and `expectedWeth9Source` on ReceiverExecutorMainnet (admin) for operator reference.
## Implementation status (complete)
| Item | Status |
| ---- | ------ |
| ExportPolicy struct + setter (StrategyExecutor138) | Done |
| Intent queue: recordExportIntent / processPendingIntent | Done |
| harvestFees() / rebalanceLp() entrypoints (stubs) | Done |
| Receiver expected WETH9 source (setExpectedWeth9Source / getExpectedWeth9Source) | Done |
| Tests: TreasuryVault, CcipBridgeAdapter138, StrategyExecutor138, ReceiverExecutorMainnet | 21 tests |
## Refs
- [EXECUTOR_ALLOWLIST_MATRIX.md](EXECUTOR_ALLOWLIST_MATRIX.md)
- [CCIP_LIVE_CHECKLIST.md](CCIP_LIVE_CHECKLIST.md)
- [EXPORT_STATE_MACHINE.md](EXPORT_STATE_MACHINE.md)