Skip to content

Commit 834ced9

Browse files
✨ feat: add event bus wiring for yield service
- Integrate `LocalBus` for settlement event publishing and consumption by `YieldService` in the application. - Update `TODO.yield.md` to reflect this new feature in the development roadmap.
1 parent 4669622 commit 834ced9

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

TODO.yield.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This roadmap outlines the integration of the Riquid Self-Driving Yield Engine in
2020
- [x] **Auto-Route Service:** Implementation of routing logic upon `SETTLEMENT_CONFIRMED` events.
2121
- [x] **Threshold Logic:** Implement gas-efficiency triggers to prevent micro-transactions.
2222
- [x] **Cron Worker:** Develop a "Self-Driving" background worker for periodic harvesting and reinvestment.
23+
- [x] **Event Bus Wiring:** Settlement events are now published via `LocalBus` and consumed by `YieldService`.
2324

2425
## Phase 5: Account Abstraction & Session Keys (`pkg/crypto` & `pkg/yield`) 🔐
2526
- [/] **ERC-4337 Integration:** Logic to manage funds via non-custodial account abstraction (Skeleton).

apps/settlerd/main.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,18 @@ func main() {
5252
log.Fatalf("Failed to initialize Riquid adapter: %v", err)
5353
}
5454

55-
// 5. Initialize Settlement Engine
56-
engine := service.NewDefaultSettlementEngine(db, mc, riquid)
55+
// 5. Initialize Event Bus
56+
bus := service.NewLocalBus()
5757

58-
// 6. Initialize Yield Service
58+
// 6. Initialize Settlement Engine
59+
engine := service.NewDefaultSettlementEngine(db, mc, riquid, bus)
60+
61+
// 7. Initialize Yield Service
5962
// Threshold: 0.1 BNB (demonstration)
6063
threshold := big.NewInt(100000000000000000)
6164
yieldSvc := service.NewYieldService(engine, riquid, threshold)
6265

63-
// 7. Start Background Worker for Harvesting
66+
// 8. Start Background Workers
6467
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
6568
defer stop()
6669

@@ -73,8 +76,12 @@ func main() {
7376
},
7477
}
7578

79+
// Start Auto-Harvesting
7680
go yieldSvc.StartAutoHarvestWorker(ctx, 1*time.Hour, strategies)
7781

82+
// Listen for new settlements and route 100% to Riquid
83+
go yieldSvc.ListenForSettlements(ctx, bus, strategies[0], 100.0)
84+
7885
log.Println("✅ Settlement daemon is running")
7986

8087
// Keep alive until interrupt

0 commit comments

Comments
 (0)