Skip to content

feat: Yield Strategy Interface, Registry, and Deposit Routing#232

Merged
Devsol-01 merged 2 commits intoDevsol-01:mainfrom
OtowoSamuel:feature/three-issues
Feb 25, 2026
Merged

feat: Yield Strategy Interface, Registry, and Deposit Routing#232
Devsol-01 merged 2 commits intoDevsol-01:mainfrom
OtowoSamuel:feature/three-issues

Conversation

@OtowoSamuel
Copy link
Contributor

Closes #225
Closes #224
Closes #222
Closes #223


Summary

Implements the yield strategy subsystem for the Nestera savings protocol. This includes a generic strategy interface for external contracts, a governance-gated strategy registry, and deposit routing logic for LockSave and GroupSave plans.


Changes

interface.rs

  • Defines the YieldStrategy trait with four entry points: strategy_deposit, strategy_withdraw, strategy_harvest, and strategy_balance
  • Uses #[contractclient] to generate YieldStrategyClient for Soroban cross-contract invocation
  • Documents expected behavior and security assumptions for implementing contracts

registry.rs

  • Introduces StrategyInfo struct (address, enabled, risk_level)
  • Implements register_strategy, disable_strategy, get_strategy, get_all_strategies
  • All write operations are restricted to admin or governance via validate_admin_or_governance
  • Strategies stored in persistent storage with TTL extension on every write

routing.rs

  • Implements route_to_strategy following the Checks-Effects-Interactions (CEI) pattern: state is written before the external call, ensuring atomicity if the strategy call reverts
  • Tracks principal_deposited and strategy_shares per plan in a StrategyPosition
  • Supports both Lock and Group position key variants
  • withdraw_from_strategy clears position state before the external call (reentrancy safe)
  • Emits StrategyDeposit and StrategyWithdraw events

errors.rs

  • Adds three new error variants: StrategyNotFound (92), StrategyAlreadyRegistered (93), StrategyDisabled (94)

lib.rs

  • Wires the strategy module and exposes contract-level entry points: register_strategy, disable_strategy, get_strategy, get_all_strategies, route_lock_to_strategy, route_group_to_strategy, get_lock_strategy_position, get_group_strategy_position, withdraw_lock_strategy, withdraw_group_strategy

tests.rs

  • 11 new tests covering: strategy registration, duplicate prevention, disable, unauthorized access, routing validation (invalid amount, unregistered strategy, disabled strategy), and empty position reads

Acceptance Criteria Met

  • Only registered and enabled strategies accept deposits
  • Strategies stored in persistent storage with proper TTL management
  • No reentrancy risk: state is always updated before external calls; Soroban atomicity guarantees rollback on failure
  • All 238 tests pass (11 new + 227 existing)
  • Contract builds successfully

@vercel
Copy link

vercel bot commented Feb 25, 2026

@OtowoSamuel is attempting to deploy a commit to the devsol-01's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Devsol-01 Devsol-01 merged commit 3b017ff into Devsol-01:main Feb 25, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deposit Routing to Strategy Strategy Registry Strategy Registry Strategy Interface Design

2 participants