Skip to content

feat(contracts): treasury epoch limits, min shares, rebalance order, loss CB#670

Open
success-OG wants to merge 2 commits into
Junirezz:mainfrom
success-OG:feat/development
Open

feat(contracts): treasury epoch limits, min shares, rebalance order, loss CB#670
success-OG wants to merge 2 commits into
Junirezz:mainfrom
success-OG:feat/development

Conversation

@success-OG
Copy link
Copy Markdown

closes #642
closes #644
closes #645
closes #646

Summary

Adds four on-chain safety controls to the YieldVault Soroban contract:

  1. Treasury withdrawal rate limiter (epoch windows) — Configurable epoch length and per-epoch cap; withdraw_treasury enforces budget, rolls windows by ledger time, and emits trswdcap / trswdep / trswd events.
  2. Minimum share supply guardset_min_share_supply blocks withdrawals that would leave 0 < total_shares < min (dust lockup prevention).
  3. Deterministic strategy rebalance orderingrebalance_strategies sorts targets by strategy address, divests in reverse order, then invests in ascending order to avoid nondeterministic drift.
  4. Circuit-breaker thresholds for abnormal loss — Baseline + threshold (bps); eval_cb_loss trips on excessive drawdown, blocks sensitive ops via CircuitBreakerTripped, with admin set_cb_loss_baseline / reset_cb_loss.

Tasks closed

Task Implementation
Treasury epoch rate limit set_treasury_withdraw_epoch_cap, set_trs_wd_epoch_len, withdraw_treasury, TreasuryWithdrawEpochWindow
Min share supply set_min_share_supply, check in do_withdraw
Deterministic rebalance rebalance_strategies + sort_strategy_targets
Loss circuit breaker set_cb_loss_thresh, set_cb_loss_baseline, eval_cb_loss, is_cb_loss_tripped, reset_cb_loss

Test plan

  • cargo build in contracts/vault
  • Configure treasury epoch cap/duration; verify cap rejection and window reset across epochs
  • Set min_share_supply; confirm partial withdraw that leaves dust reverts with MinShareSupplyViolated
  • Call rebalance_strategies with two strategies; confirm execution order is address-sorted
  • Set baseline + threshold; drop total_assets; confirm CircuitBreakerTripped blocks deposit/withdraw

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@success-OG Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant