Skip to content

Automated Rebalancer#2835

Open
shahthepro wants to merge 4 commits intomasterfrom
shah/auto-rebalancer
Open

Automated Rebalancer#2835
shahthepro wants to merge 4 commits intomasterfrom
shah/auto-rebalancer

Conversation

@shahthepro
Copy link
Collaborator

@shahthepro shahthepro commented Mar 10, 2026

Code Changes

  • Add a new Safe Module RebalancerModule with methods to process deposits, withdrawals or both (in withdrawals -> deposits order). It will be replacing the existing AutoWithdrawalModule
  • Add a script for Rebalancer's core logic, Check readme file for the core logic
  • Add a hardhat tasks planRebalance that prints the optimal allocations and recommended actions
  • Add a Defender script that uses the Rebalancer to find recommended actions and execute it using the Module
  • Adds unit tests for the Module and the Rebalancer logic

Executing Hardhat task

$ npx hardhat planRebalance --network mainnet

=== OUSD Rebalancer Status ===

Total vault value    : 7,574,123.35 OUSD
  (excl. Curve AMO)  : 4,302,431.61 USDC
  Curve AMO balance  : 3,271,692.73 USDC
Withdrawal shortfall : 0.00 USDC

--- Allocations ---

Strategy                              Current       Target (optimal)              Delta      APY
------------------------------------------------------------------------------------------------
Ethereum Morpho *                1,935,732.45 (45.0%)           1,289,829.48 (30.0%)        -645,902.97    3.48%
Base Morpho                      2,327,877.52 (54.1%)           3,009,602.13 (70.0%)        +681,724.61    6.54%
Vault (idle)                        38,821.64 (0.9%)               3,000.00 (0.1%)         -35,821.64        —
------------------------------------------------------------------------------------------------
Total                            4,302,431.61
  * = default strategy

--- Actions for Optimal Allocation ---

  WITHDRAW $      645,902.97  from  Ethereum Morpho
  DEPOSIT  $      681,724.61  to    Base Morpho

--- Recommended Actions ---

  WITHDRAW $      645,902.97  from  Ethereum Morpho
  DEPOSIT  $      681,724.61  to    Base Morpho

Pending Things

  • Monitoring: Discord Notifications (Will do in a separate PR)

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.41%. Comparing base (817fb11) to head (923944d).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ontracts/contracts/automation/RebalancerModule.sol 83.33% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2835       +/-   ##
===========================================
+ Coverage   39.88%   54.41%   +14.53%     
===========================================
  Files         111      111               
  Lines        4771     4798       +27     
  Branches     1311     1316        +5     
===========================================
+ Hits         1903     2611      +708     
+ Misses       2865     2183      -682     
- Partials        3        4        +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shahthepro shahthepro changed the title [WIP] Automated Rebalancer Automated Rebalancer Mar 12, 2026
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.

1 participant