Skip to content

Dev - #73

Merged
matteoettam09 merged 8 commits into
mainfrom
dev
Oct 5, 2025
Merged

Dev#73
matteoettam09 merged 8 commits into
mainfrom
dev

Conversation

@matteoettam09

@matteoettam09 matteoettam09 commented Oct 2, 2025

Copy link
Copy Markdown
Member

Summary by Sourcery

Update orchestrator and vault contracts to enhance access control, unify deposit/redeem logic, and enrich event data, while adjusting tests and configuration to support the new workflows and whitelisting features.

New Features:

  • Allow both contract owner and Chainlink Automation Registry to trigger performUpkeep in orchestrators
  • Add whitelistedVaultOwners management in OrionConfig for vault factory access control
  • Expose epoch token list and total assets for deposit in InternalStatesOrchestrator
  • Extend deposit and redeem events to include vault address and epoch

Enhancements:

  • Refactor LiquidityOrchestrator to consolidate deposit and redeem handling into a single processing function
  • Introduce onlyAuthorizedTrigger modifier replacing onlyAutomationRegistry for broader access control
  • Optimize OrionVault fulfillDeposit and fulfillRedeem functions with early return checks and epoch-scoped event emissions
  • Add vaultsTotalAssetsForFulfillDeposit mapping and cleanup in InternalStatesOrchestrator

Documentation:

  • Add additional social and tooling badges to README

Tests:

  • Adjust Vault exchange rate tests to use impersonated liquidity orchestrator
  • Extend Orchestrators tests to cover authorized (owner and registry) and unauthorized callers

Chores:

  • Regenerate contract artifacts after interface and implementation changes

Summary by CodeRabbit

  • New Features

    • Vault owner whitelisting with add/check endpoints.
    • New read endpoints to fetch epoch tokens and per-vault deposit totals.
    • Buffer management APIs: target buffer ratio, deposit/withdraw liquidity.
  • Changes

    • Deposit events now include vault/user/epoch; new Redeem event; Withdraw removed.
    • Simplified execution calls for buy/sell (fewer parameters).
    • Orchestration phase renamed to FulfillDepositAndRedeem; fulfillment flow updated.
  • Access Control

    • performUpkeep allowed for owner and automation registry; vault fulfill ops restricted to Liquidity Orchestrator.
  • Documentation / Chores

    • README badges refreshed; tooling ignores updated (.gitignore / prettier / eslint).
  • Tests

    • Tests updated to cover new buffer APIs, authorization, and orchestrator usage.

@sourcery-ai

sourcery-ai Bot commented Oct 2, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR overhauls orchestrator and vault interactions by integrating a dedicated liquidity orchestrator in tests and contracts, strengthening authorization via onlyAuthorizedTrigger, unifying deposit and redeem processing in the LiquidityOrchestrator, extending the InternalStatesOrchestrator to track and expose deposit assets and epoch tokens, refining OrionVault’s fulfill logic and event emissions with epoch context, introducing vault owner whitelisting in configuration and enforcing it in factories, and updating interfaces and README badges to reflect these enhancements.

Class diagram for updated OrionVault fulfill logic and event emissions

classDiagram
  class OrionVault {
    +fulfillDeposit(uint256 depositTotalAssets)
    +fulfillRedeem(uint256 redeemTotalAssets)
    +event Deposit(address vault, address user, uint256 epoch, uint256 depositAmount, uint256 sharesMinted)
    +event Redeem(address vault, address user, uint256 epoch, uint256 redeemAmount, uint256 sharesBurned)
  }
Loading

File-Level Changes

Change Details Files
Updated test suites to include liquidity orchestrator and broaden impersonation
  • Added liquidityOrchestratorAddress to loadFixture calls in vault exchange rate tests
  • Swapped internalStatesOrchestrator.fulfillDeposit calls to use liquor orchestrator impersonation
  • Expanded Orchestrators.test to cover owner, automation registry, and unauthorized performUpkeep scenarios
test/OrionVaultExchangeRate.test.ts
test/Orchestrators.test.ts
Enhanced orchestrator authorization and renamed the fulfill phase/action
  • Introduced onlyAuthorizedTrigger modifier in both orchestrators to allow owner or registry
  • Renamed FulfillRedeem phase and ACTION_PROCESS_FULFILL_REDEEM to FulfillDepositAndRedeem variants
  • Updated performUpkeep signatures to use onlyAuthorizedTrigger
contracts/orchestrators/LiquidityOrchestrator.sol
contracts/orchestrators/InternalStatesOrchestrator.sol
Refactored LiquidityOrchestrator to process deposits and redeems via a helper
  • Implemented _processVaultDepositAndRedeem to handle pendingDeposit and pendingRedeem
  • Replaced inline loops with calls to getVaultTotalAssetsForFulfillDeposit and getVaultTotalAssetsForFulfillRedeem
  • Simplified epoch phase transitions for deposit+redeem
contracts/orchestrators/LiquidityOrchestrator.sol
Tracked deposit assets in InternalStatesOrchestrator and added view utilities
  • Added vaultsTotalAssetsForFulfillDeposit mapping and recorded it during state updates
  • Deleted epoch data cleanup for deposit tracking
  • Exposed getVaultTotalAssetsForFulfillDeposit and getEpochTokens view methods with Idle checks
contracts/orchestrators/InternalStatesOrchestrator.sol
contracts/interfaces/IInternalStateOrchestrator.sol
Updated OrionVault fulfill logic, event signatures, and permissions
  • Restricted fulfillDeposit and fulfillRedeem to onlyLiquidityOrchestrator and added early returns on empty queues
  • Fetched current epoch from orchestrator and emitted contextual Deposit and Redeem events including vault and epoch
  • Removed legacy Withdraw event and replaced with Redeem
contracts/vaults/OrionVault.sol
contracts/interfaces/IOrionVault.sol
Added vault owner whitelisting in config and enforced in factories
  • Introduced whitelistedVaultOwners set and add/isWhitelistedVaultOwner in OrionConfig
  • Updated EncryptedVaultFactory and TransparentVaultFactory to require vaultOwner whitelist
  • Extended IOrionConfig with whitelist methods
contracts/OrionConfig.sol
contracts/factories/EncryptedVaultFactory.sol
contracts/factories/TransparentVaultFactory.sol
contracts/interfaces/IOrionConfig.sol
Updated README with new social and tooling badges
  • Added Sourcery, LinkedIn, X and Telegram badges
  • Reordered and updated existing CI and coverage badges
README.md

Possibly linked issues

  • #Issue 1: The PR prevents multiple deposit processing by refactoring OrionVault's fulfillment logic and updates orchestrator access control.
  • #chore: stress test orchestrator: PR refactors orchestrator deposit/redeem logic, updates access control, and enhances event data, directly contributing to gas optimization and cost measurement.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 2, 2025

Copy link
Copy Markdown

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds vault-owner whitelisting and enforces it in factories; removes slippage parameters and related error; extends orchestrator APIs, phases, and access gating (onlyAuthorizedTrigger); shifts fulfillDeposit/fulfillRedeem authorization to LiquidityOrchestrator; standardizes Deposit/Redeem events; updates tests and many compiled artifacts.

Changes

Cohort / File(s) Summary
Docs
README.md
Badge block restructured: Discord badge line removed, added Sourcery/LinkedIn/X/Telegram/Discord social badges and adjusted layout.
Config: vault-owner whitelist
contracts/OrionConfig.sol, contracts/interfaces/IOrionConfig.sol, artifacts/.../OrionConfig.sol/OrionConfig.json, artifacts/.../IOrionConfig.sol/IOrionConfig.json
Added whitelistedVaultOwners storage and APIs: addWhitelistedVaultOwner(address) and isWhitelistedVaultOwner(address); constructor seeds initial owner; artifacts/ABI updated.
Factories: enforce whitelist
contracts/factories/EncryptedVaultFactory.sol, contracts/factories/TransparentVaultFactory.sol
Replaced zero-address check with config.isWhitelistedVaultOwner(vaultOwner) and now revert UnauthorizedAccess when not whitelisted.
Execution adapters & mocks / interface
contracts/execution/OrionAssetERC4626ExecutionAdapter.sol, contracts/mocks/MockExecutionAdapter.sol, contracts/interfaces/IExecutionAdapter.sol, artifacts/.../OrionAssetERC4626ExecutionAdapter.json, artifacts/.../MockExecutionAdapter.json, artifacts/.../IExecutionAdapter.json
Removed maxUnderlyingAmount/minUnderlyingAmount params from buy/sell signatures across interface, adapter, and mock; adapter logic updated to remove per-call slippage checks; artifacts updated.
Errors library
contracts/libraries/ErrorsLib.sol, artifacts/.../ErrorsLib.sol/ErrorsLib.json
Removed public error SlippageExceeded() and updated artifacts.
InternalStatesOrchestrator: state & API
contracts/orchestrators/InternalStatesOrchestrator.sol, contracts/interfaces/IInternalStateOrchestrator.sol, artifacts/.../IInternalStateOrchestrator.json
Added epoch state tracking vaultsTotalAssetsForFulfillDeposit, getters getEpochTokens() and getVaultTotalAssetsForFulfillDeposit(address), added idle-state guards, replaced onlyAutomationRegistry with onlyAuthorizedTrigger usage in relevant call sites.
LiquidityOrchestrator: phases & buffer mgmt
contracts/orchestrators/LiquidityOrchestrator.sol, contracts/interfaces/ILiquidityOrchestrator.sol, artifacts/.../LiquidityOrchestrator.json, artifacts/.../ILiquidityOrchestrator.json
Replaced onlyAutomationRegistry with onlyAuthorizedTrigger; renamed FulfillRedeem → FulfillDepositAndRedeem; added _processVaultDepositAndRedeem; removed slippage-bound API, added setTargetBufferRatio, depositLiquidity, withdrawLiquidity; ABI/bytecode updated.
Vaults: access and events
contracts/vaults/OrionVault.sol, contracts/interfaces/IOrionVault.sol, artifacts/.../OrionVault.sol/OrionVault.json
fulfillDeposit/fulfillRedeem now callable by LiquidityOrchestrator; early exits when no pending ops; events changed to include vault and epoch and renamed fields to depositAmount/sharesMinted and redeemAmount/sharesBurned; Withdraw removed; ABIs updated.
Transparent / Encrypted vault interfaces (events)
artifacts/.../IOrionTransparentVault.sol/IOrionTransparentVault.json, artifacts/.../IOrionEncryptedVault.sol/IOrionEncryptedVault.json
Event schema changes: added vault indexed param, renamed amountepoch, split amounts into depositAmount/sharesMinted, removed Withdraw, added Redeem.
Orchestrator tests & fixtures
test/Orchestrators.test.ts, test/OrionVaultExchangeRate.test.ts
Replaced setSlippageBound with setTargetBufferRatio in tests; expanded performUpkeep authorization tests (owner and automation registry allowed); added liquidityOrchestratorAddress to fixtures; updated fulfill calls to use LiquidityOrchestrator.
Artifacts: bytecode-only updates
artifacts/.../OrionAssetERC4626PriceAdapter.sol/OrionAssetERC4626PriceAdapter.json, artifacts/.../PriceAdapterRegistry.sol/PriceAdapterRegistry.json, other updated artifacts
Bytecode/deployedBytecode updated for multiple artifacts to reflect compilations; ABI mostly unchanged in some artifacts.
Tooling ignores
.gitignore, .prettierignore, eslint.config.mjs
Added orion-strategies to .gitignore and .prettierignore and ESLint global ignores.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Owner as Owner
  participant AR as AutomationRegistry
  participant LO as LiquidityOrchestrator
  participant ISO as InternalStatesOrchestrator
  participant V as OrionVault

  rect rgba(220,235,255,0.35)
  note over Owner,AR: Authorized triggers (owner or automation registry)
  Owner->>LO: performUpkeep()
  AR-->>LO: performUpkeep()
  LO->>LO: onlyAuthorizedTrigger check
  end

  LO->>ISO: getEpochTokens()
  ISO-->>LO: tokens[]
  loop per vault
    LO->>ISO: getVaultTotalAssetsForFulfillDeposit(vault)
    ISO-->>LO: depositTotalAssets
    alt pending deposit
      LO->>V: fulfillDeposit(depositTotalAssets)
      V-->>LO: ok
      V-->>V: emit Deposit(vault,user,epoch,depositAmount,sharesMinted)
    end
    alt pending redeem
      LO->>V: fulfillRedeem(redeemTotalAssets)
      V-->>LO: ok
      V-->>V: emit Redeem(vault,user,epoch,redeemAmount,sharesBurned)
    end
  end
  LO-->>Owner: upkeep complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Dev #72 — touches InternalStatesOrchestrator and related getters/tests; likely code-level overlap.
  • fix: fulfillRedeem, unit tests #71 — aligns with making vault fulfill functions callable by LiquidityOrchestrator (access-control changes).
  • Develop #68 — related orchestrator refactors affecting performUpkeep and orchestrator callbacks.

Poem

I nibble bytes where epochs hop in line,
Whitelisted burrows now tidy and fine.
Orchestrators drum a two-phase delight,
Deposits and redeems hop into sight.
A rabbit applauds—code polished and spry. 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “Dev” is overly generic and does not convey any information about the changes introduced in this pull request, making it impossible for reviewers to understand the main purpose without diving into the details. It fails to highlight key updates such as new whitelisting functionality, access control modifiers, event enhancements, and test adjustments. As a result, it does not meet the criteria for a clear, concise, and informative title. Please update the pull request title to a concise sentence that summarizes the principal change, for example “Add vault owner whitelisting and onlyAuthorizedTrigger modifier to orchestrators” or similar, so reviewers can immediately grasp the PR’s intent.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `contracts/orchestrators/LiquidityOrchestrator.sol:456-105` </location>
<code_context>
+    /// @param vault The vault address
+    /// @param totalAssetsForDeposit The total assets for deposit operations
+    /// @param totalAssetsForRedeem The total assets for redeem operations
+    function _processVaultDepositAndRedeem(
+        address vault,
+        uint256 totalAssetsForDeposit,
+        uint256 totalAssetsForRedeem
+    ) internal {
+        IOrionVault vaultContract = IOrionVault(vault);
+
+        // Check if vault has pending deposits and redemptions
+        uint256 pendingDeposit = vaultContract.pendingDeposit();
+        uint256 pendingRedeem = vaultContract.pendingRedeem();
+
+        if (pendingDeposit > 0) {
+            // Only deposits exist
+            vaultContract.fulfillDeposit(totalAssetsForDeposit);
+        } else if (pendingRedeem > 0) {
+            // Only redemptions exist
+            vaultContract.fulfillRedeem(totalAssetsForRedeem);
         }
+        // If neither exists, do nothing
     }
</code_context>

<issue_to_address>
**question:** Vault deposit and redeem logic only processes one or the other per call.

If both pendingDeposit and pendingRedeem are nonzero, only the deposit is processed. Should both be handled in the same call? If not intentional, consider updating the logic to process both sequentially.
</issue_to_address>

### Comment 2
<location> `contracts/vaults/OrionVault.sol:570-574` </location>
<code_context>
         }

         _pendingDeposit = 0;
+        uint16 currentEpoch = internalStatesOrchestrator.epochCounter();

         // Process all requests
</code_context>

<issue_to_address>
**suggestion:** Epoch counter is used for event emission, but may not be consistent if called mid-epoch.

If these functions are called before the epoch is updated, emitted events may show the previous epoch, potentially confusing event consumers.

```suggestion
        _pendingDeposit = 0;

        // Fetch the latest epoch value right before event emission to ensure consistency
        uint16 currentEpoch = internalStatesOrchestrator.epochCounter();

        // Process all requests
        for (uint32 i = 0; i < length; ++i) {
            uint256 shares = convertToSharesWithPITTotalAssets(amount, depositTotalAssets, Math.Rounding.Floor);
            _mint(user, shares);

            // Fetch epoch again in case it changes during processing (if relevant)
            uint16 epochForEvent = internalStatesOrchestrator.epochCounter();
            emit Deposit(address(this), user, epochForEvent, amount, shares);
        }
```
</issue_to_address>

### Comment 3
<location> `contracts/OrionConfig.sol:54` </location>
<code_context>
     // Vault-specific configuration
     using EnumerableSet for EnumerableSet.AddressSet;
     EnumerableSet.AddressSet private whitelistedAssets;
+    EnumerableSet.AddressSet private whitelistedVaultOwners;

     /// @notice Mapping of token address to its decimals
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Whitelisted vault owners are tracked, but not removed on asset removal.

Ensure whitelistedVaultOwners is updated when a vault owner is removed or an asset is de-whitelisted to avoid stale data.

Suggested implementation:

```
    EnumerableSet.AddressSet private whitelistedAssets;
    EnumerableSet.AddressSet private whitelistedVaultOwners;

```

```
        // slither-disable-next-line unused-return
        whitelistedAssets.add(underlyingAsset_);

        // slither-disable-next-line unused-return
        whitelistedVaultOwners.add(initialOwner);
    }

    /// @notice Remove an asset from the whitelist and its associated vault owner
    function removeWhitelistedAsset(address asset, address vaultOwner) external onlyOwner {
        // slither-disable-next-line unused-return
        whitelistedAssets.remove(asset);

        // Remove the vault owner from the whitelist if present
        if (whitelistedVaultOwners.contains(vaultOwner)) {
            // slither-disable-next-line unused-return
            whitelistedVaultOwners.remove(vaultOwner);
        }
    }

    /// @notice Remove a vault owner from the whitelist
    function removeWhitelistedVaultOwner(address vaultOwner) external onlyOwner {
        // slither-disable-next-line unused-return
        whitelistedVaultOwners.remove(vaultOwner);
    }

```

You may need to:
1. Update any places in your codebase that remove assets or vault owners to use these new functions.
2. Ensure that you have access to the vault owner address when removing an asset, or maintain a mapping from asset to owner if needed.
3. Add events for removals if your contract emits events for such changes.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread contracts/orchestrators/LiquidityOrchestrator.sol
Comment thread contracts/vaults/OrionVault.sol
Comment thread contracts/OrionConfig.sol
@codecov

codecov Bot commented Oct 2, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.83117% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
contracts/orchestrators/LiquidityOrchestrator.sol 68.88% 14 Missing ⚠️
...racts/orchestrators/InternalStatesOrchestrator.sol 66.66% 5 Missing ⚠️
contracts/OrionConfig.sol 50.00% 3 Missing ⚠️
contracts/vaults/OrionVault.sol 77.77% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
artifacts/contracts/interfaces/IOrionTransparentVault.sol/IOrionTransparentVault.json (1)

108-140: Add missing Deposit event emission in OrionTransparentVault.sol
The TransparentVault implementation doesn’t emit the updated Deposit(vault, user, epoch, depositAmount, sharesMinted) event. In contracts/vaults/OrionTransparentVault.sol, emit

Deposit(address(this), user, currentEpoch, amount, shares)

(or renamed parameters) at the end of its deposit function.

artifacts/contracts/interfaces/IOrionEncryptedVault.sol/IOrionEncryptedVault.json (1)

108-241: Emit Deposit and Redeem events in OrionEncryptedVault implementation.

The interface defines Deposit and Redeem events, but contracts/vaults/OrionEncryptedVault.sol does not emit them. Add emit Deposit(…) in your deposit logic and emit Redeem(…) in your redemption logic.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3821ff and fcb632e.

📒 Files selected for processing (24)
  • README.md (1 hunks)
  • artifacts/contracts/OrionConfig.sol/OrionConfig.json (3 hunks)
  • artifacts/contracts/execution/OrionAssetERC4626ExecutionAdapter.sol/OrionAssetERC4626ExecutionAdapter.json (1 hunks)
  • artifacts/contracts/interfaces/IInternalStateOrchestrator.sol/IInternalStateOrchestrator.json (2 hunks)
  • artifacts/contracts/interfaces/IOrionConfig.sol/IOrionConfig.json (2 hunks)
  • artifacts/contracts/interfaces/IOrionEncryptedVault.sol/IOrionEncryptedVault.json (3 hunks)
  • artifacts/contracts/interfaces/IOrionTransparentVault.sol/IOrionTransparentVault.json (3 hunks)
  • artifacts/contracts/interfaces/IOrionVault.sol/IOrionVault.json (3 hunks)
  • artifacts/contracts/orchestrators/LiquidityOrchestrator.sol/LiquidityOrchestrator.json (1 hunks)
  • artifacts/contracts/price/OrionAssetERC4626PriceAdapter.sol/OrionAssetERC4626PriceAdapter.json (1 hunks)
  • artifacts/contracts/price/PriceAdapterRegistry.sol/PriceAdapterRegistry.json (1 hunks)
  • artifacts/contracts/vaults/OrionVault.sol/OrionVault.json (3 hunks)
  • contracts/OrionConfig.sol (3 hunks)
  • contracts/factories/EncryptedVaultFactory.sol (1 hunks)
  • contracts/factories/TransparentVaultFactory.sol (1 hunks)
  • contracts/interfaces/IInternalStateOrchestrator.sol (1 hunks)
  • contracts/interfaces/ILiquidityOrchestrator.sol (1 hunks)
  • contracts/interfaces/IOrionConfig.sol (1 hunks)
  • contracts/interfaces/IOrionVault.sol (1 hunks)
  • contracts/orchestrators/InternalStatesOrchestrator.sol (10 hunks)
  • contracts/orchestrators/LiquidityOrchestrator.sol (8 hunks)
  • contracts/vaults/OrionVault.sol (5 hunks)
  • test/Orchestrators.test.ts (2 hunks)
  • test/OrionVaultExchangeRate.test.ts (17 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
contracts/OrionConfig.sol (1)
test/OrionConfigVault.test.ts (4)
  • owner (37-156)
  • it (169-243)
  • it (245-265)
  • it (615-637)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Sourcery review
  • GitHub Check: Build, Lint and Test
🔇 Additional comments (24)
artifacts/contracts/execution/OrionAssetERC4626ExecutionAdapter.sol/OrionAssetERC4626ExecutionAdapter.json (1)

175-176: Bytecode refresh looks consistent.

No issues spotted with the regenerated bytecode/deployedBytecode; update aligns with the broader contract changes.

contracts/interfaces/IOrionConfig.sol (2)

96-99: LGTM!

The function signature and documentation are clear and consistent with the existing whitelist pattern for assets.


101-104: LGTM!

The function signature and documentation are clear and follow the established whitelist query pattern.

artifacts/contracts/interfaces/IOrionConfig.sol/IOrionConfig.json (2)

47-59: LGTM!

The ABI entry correctly represents the addWhitelistedVaultOwner function from the interface.


188-206: LGTM!

The ABI entry correctly represents the isWhitelistedVaultOwner view function from the interface.

artifacts/contracts/price/OrionAssetERC4626PriceAdapter.sol/OrionAssetERC4626PriceAdapter.json (1)

91-92: Bytecode-only artifact update.

The bytecode has been updated without ABI changes, likely due to recompilation. No review required for bytecode-only changes.

artifacts/contracts/orchestrators/LiquidityOrchestrator.sol/LiquidityOrchestrator.json (1)

654-655: Bytecode-only artifact update.

The bytecode has been updated without ABI changes, likely due to recompilation. No review required for bytecode-only changes.

artifacts/contracts/interfaces/IOrionTransparentVault.sol/IOrionTransparentVault.json (1)

205-241: Redeem event emission and Withdraw removal verified
Redeem is emitted in contracts/vaults/OrionVault.sol:615 with the correct parameters; no remaining Withdraw emissions found.

contracts/factories/EncryptedVaultFactory.sol (1)

45-45: Whitelist initialization and unauthorized access tests confirmed

  • OrionConfig constructor auto-whitelists initialOwner.
  • UnauthorizedAccess revert cases are covered in existing tests.
  • Confirm or add tests for successful vault creation by whitelisted owners (e.g., calling addWhitelistedVaultOwner in setup).
contracts/interfaces/ILiquidityOrchestrator.sol (1)

16-16: Enum variant rename verified: All LiquidityUpkeepPhase.FulfillRedeem references have been replaced with LiquidityUpkeepPhase.FulfillDepositAndRedeem in contracts and tests; no remaining old enum usage.

contracts/factories/TransparentVaultFactory.sol (1)

45-45: LGTM! Whitelist-based access control is enforced.

The change replaces the zero-address check with whitelist validation, aligning with the new vault-owner whitelisting model introduced in OrionConfig. The error type UnauthorizedAccess is semantically appropriate for this access control scenario.

artifacts/contracts/interfaces/IOrionVault.sol/IOrionVault.json (2)

108-141: LGTM! Enhanced Deposit event structure.

The updated Deposit event now includes vault, user, epoch, depositAmount, and sharesMinted fields with appropriate indexing. This standardization improves deposit fulfillment tracking and enables efficient event filtering.


205-241: LGTM! New Redeem event standardizes redemption tracking.

The new Redeem event provides symmetry with the updated Deposit event, including vault, user, epoch, redeemAmount, and sharesBurned fields with appropriate indexing. This standardization improves redemption tracking and event filtering.

artifacts/contracts/interfaces/IInternalStateOrchestrator.sol/IInternalStateOrchestrator.json (2)

92-104: LGTM! New getter enhances epoch token observability.

The getEpochTokens() function exposes the list of tokens for the current epoch, improving transparency and enabling external systems to query epoch-specific token information.


162-180: LGTM! New getter enhances per-vault deposit tracking.

The getVaultTotalAssetsForFulfillDeposit(address vault) function exposes per-vault deposit fulfillment assets, improving transparency and enabling external systems to query vault-specific deposit information.

artifacts/contracts/OrionConfig.sol/OrionConfig.json (2)

200-212: LGTM! New function enables vault owner whitelisting.

The addWhitelistedVaultOwner(address vaultOwner) function allows the contract owner to add vault owners to the whitelist, implementing the new access control model introduced in this PR.


354-372: LGTM! New function supports vault owner whitelist checks.

The isWhitelistedVaultOwner(address vaultOwner) function enables external contracts (e.g., vault factories) to verify vault owner whitelist membership, supporting the new access control model.

contracts/interfaces/IOrionVault.sol (1)

49-74: LGTM! Standardized event signatures improve tracking.

The updated Deposit event and new Redeem event include vault, user, epoch, and amount/shares fields with appropriate indexing. These standardized signatures improve deposit/redemption tracking and enable efficient event filtering across the vault lifecycle.

contracts/OrionConfig.sol (3)

54-54: LGTM! New storage tracks whitelisted vault owners.

The whitelistedVaultOwners EnumerableSet follows the same pattern as whitelistedAssets, providing efficient membership checks and iteration capabilities for the new vault-owner whitelisting feature.


89-90: LGTM! Initial owner seeded in whitelist.

The constructor adds the initial owner to the whitelistedVaultOwners set, ensuring the owner can create vaults immediately after deployment without requiring an additional transaction to whitelist themselves.


192-201: LGTM! New functions implement vault owner whitelisting.

The addWhitelistedVaultOwner function (owner-only) and isWhitelistedVaultOwner function (public view) implement the new vault-owner whitelisting feature. The AlreadyRegistered check prevents duplicate entries, and the access control is appropriate.

contracts/interfaces/IInternalStateOrchestrator.sol (1)

105-113: LGTM! New functions expand orchestrator state exposure.

The getVaultTotalAssetsForFulfillDeposit(address vault) and getEpochTokens() functions enhance observability by exposing per-vault deposit assets and epoch tokens. Note the dev comment indicating getEpochTokens() blocks if the orchestrator is not idle—ensure callers handle this appropriately.

test/Orchestrators.test.ts (2)

739-774: LGTM! Comprehensive access control testing for performUpkeep.

The new tests validate that both the owner and automation registry can call performUpkeep on the internal states orchestrator, while unauthorized addresses are correctly blocked with the NotAuthorized error. This aligns with the new onlyAuthorizedTrigger pattern introduced in this PR.


788-817: LGTM! Liquidity orchestrator access control tests.

The new tests validate that both the owner and automation registry can call performUpkeep on the liquidity orchestrator when upkeep is needed, while unauthorized addresses are correctly blocked with the NotAuthorized error. The conditional guards based on upkeepNeeded prevent false negatives and improve test reliability.

Comment thread contracts/orchestrators/LiquidityOrchestrator.sol Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
contracts/orchestrators/LiquidityOrchestrator.sol (1)

493-499: Critical: if/else if prevents concurrent deposit and redeem processing.

The if/else if structure on lines 493-499 means when a vault has both pendingDeposit > 0 AND pendingRedeem > 0, only the deposit is fulfilled. The redeem remains pending until the next epoch. This creates several problems:

  1. User experience: Redeemers wait an extra epoch unnecessarily
  2. Share price distortion: The deposit mint increases totalSupply before redemptions are processed, slightly diluting existing shares
  3. Inconsistent state: The vault tracks both pending amounts but only processes one

Based on past review comments, this issue was already flagged. Apply this fix to process both operations in the same cycle, executing redemptions before deposits to maintain accurate pricing:

-        if (pendingDeposit > 0) {
-            // Only deposits exist
-            vaultContract.fulfillDeposit(totalAssetsForDeposit);
-        } else if (pendingRedeem > 0) {
-            // Only redemptions exist
+        if (pendingRedeem > 0) {
             vaultContract.fulfillRedeem(totalAssetsForRedeem);
         }
+
+        if (pendingDeposit > 0) {
+            vaultContract.fulfillDeposit(totalAssetsForDeposit);
+        }
🧹 Nitpick comments (2)
contracts/orchestrators/InternalStatesOrchestrator.sol (1)

495-499: FHEVM mulDiv optimization tracked as technical debt.

The TODO comment appropriately flags the need for a proper FHEVM mulDiv implementation with type upcasting. This optimization should be tracked and prioritized based on gas profiling results.

Do you want me to open a new issue to track this FHEVM optimization work?

contracts/orchestrators/LiquidityOrchestrator.sol (1)

436-444: Verify the 2x approval buffer is sufficient.

Line 441 approves estimatedUnderlyingAmount * 2 for the buy operation, providing a generous buffer for price movement. This assumes prices won't move more than 100% during execution.

Consider whether this 2x buffer is appropriate for your use case. If assets are highly volatile or if there's significant time between estimation and execution, this might be insufficient. You may want to:

  1. Make the multiplier configurable via a parameter
  2. Add explicit bounds checking after the buy to ensure the actual amount doesn't exceed reasonable limits
  3. Document the rationale for the 2x buffer

Do you want me to propose a more flexible approach?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fcb632e and 9902382.

📒 Files selected for processing (23)
  • .gitignore (1 hunks)
  • .prettierignore (1 hunks)
  • artifacts/contracts/OrionConfig.sol/OrionConfig.json (3 hunks)
  • artifacts/contracts/execution/OrionAssetERC4626ExecutionAdapter.sol/OrionAssetERC4626ExecutionAdapter.json (1 hunks)
  • artifacts/contracts/interfaces/IExecutionAdapter.sol/IExecutionAdapter.json (0 hunks)
  • artifacts/contracts/interfaces/IInternalStateOrchestrator.sol/IInternalStateOrchestrator.json (3 hunks)
  • artifacts/contracts/interfaces/ILiquidityOrchestrator.sol/ILiquidityOrchestrator.json (3 hunks)
  • artifacts/contracts/libraries/ErrorsLib.sol/ErrorsLib.json (1 hunks)
  • artifacts/contracts/mocks/MockExecutionAdapter.sol/MockExecutionAdapter.json (1 hunks)
  • artifacts/contracts/orchestrators/LiquidityOrchestrator.sol/LiquidityOrchestrator.json (4 hunks)
  • artifacts/contracts/price/OrionAssetERC4626PriceAdapter.sol/OrionAssetERC4626PriceAdapter.json (1 hunks)
  • artifacts/contracts/price/PriceAdapterRegistry.sol/PriceAdapterRegistry.json (1 hunks)
  • contracts/OrionConfig.sol (3 hunks)
  • contracts/execution/OrionAssetERC4626ExecutionAdapter.sol (2 hunks)
  • contracts/interfaces/IExecutionAdapter.sol (1 hunks)
  • contracts/interfaces/IInternalStateOrchestrator.sol (2 hunks)
  • contracts/interfaces/ILiquidityOrchestrator.sol (3 hunks)
  • contracts/libraries/ErrorsLib.sol (0 hunks)
  • contracts/mocks/MockExecutionAdapter.sol (1 hunks)
  • contracts/orchestrators/InternalStatesOrchestrator.sol (11 hunks)
  • contracts/orchestrators/LiquidityOrchestrator.sol (10 hunks)
  • eslint.config.mjs (1 hunks)
  • test/Orchestrators.test.ts (4 hunks)
💤 Files with no reviewable changes (2)
  • contracts/libraries/ErrorsLib.sol
  • artifacts/contracts/interfaces/IExecutionAdapter.sol/IExecutionAdapter.json
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (2)
  • artifacts/contracts/price/OrionAssetERC4626PriceAdapter.sol/OrionAssetERC4626PriceAdapter.json
  • artifacts/contracts/price/PriceAdapterRegistry.sol/PriceAdapterRegistry.json
🧰 Additional context used
🧬 Code graph analysis (2)
contracts/orchestrators/InternalStatesOrchestrator.sol (1)
test/OrionVaultExchangeRate.test.ts (3)
  • it (126-184)
  • it (386-431)
  • loadFixture (241-286)
contracts/execution/OrionAssetERC4626ExecutionAdapter.sol (1)
test/OrionConfigVault.test.ts (3)
  • it (537-554)
  • it (651-676)
  • it (428-471)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, Lint and Test
  • GitHub Check: Sourcery review
🔇 Additional comments (46)
.prettierignore (1)

14-14: LGTM!

The addition of orion-strategies to the Prettier ignore list is correct and consistent with the file's existing format.

eslint.config.mjs (1)

35-35: LGTM!

The addition of "**/orion-strategies" to the ESLint global ignores is correct and follows the established pattern for directory exclusions.

artifacts/contracts/OrionConfig.sol/OrionConfig.json (1)

200-212: LGTM: Artifact correctly reflects contract changes.

The ABI additions for addWhitelistedVaultOwner and isWhitelistedVaultOwner, along with the updated bytecode, accurately represent the new whitelist functionality in the Solidity source. As these are auto-generated artifacts, the primary review focuses on the source contract.

Also applies to: 354-372, 618-619

contracts/OrionConfig.sol (3)

54-54: LGTM: Storage for vault owner whitelist.

The addition of whitelistedVaultOwners using EnumerableSet is consistent with the existing whitelistedAssets pattern and provides efficient set operations for access control.


88-89: LGTM: Initial owner whitelisted in constructor.

Adding the initialOwner to the whitelist is appropriate, as they should have permission to create vaults from the start. The zero address validation is already handled by OpenZeppelin's Ownable constructor.


197-200: LGTM: Whitelist membership check.

The view function correctly checks if an address is in the whitelistedVaultOwners set.

contracts/interfaces/ILiquidityOrchestrator.sol (3)

16-16: Enum member renamed to reflect broader scope.

The rename from FulfillRedeem to FulfillDepositAndRedeem accurately reflects the expanded scope where both deposit and redeem operations are now processed together in this phase, aligning with the per-vault fulfillment flow introduced across the PR.


40-42: Buffer-ratio-based liquidity management replaces slippage bounds.

The function rename from setSlippageBound to setTargetBufferRatio reflects a strategic shift in liquidity management. This change is consistent with the removal of SlippageExceeded error handling and introduction of explicit buffer management through depositLiquidity/withdrawLiquidity functions.


77-86: Explicit buffer management functions added.

The new depositLiquidity and withdrawLiquidity functions provide explicit, owner-controlled buffer management. The safety checks mentioned for withdrawLiquidity are appropriate to prevent predatory withdrawals that could disrupt protocol operations.

contracts/orchestrators/InternalStatesOrchestrator.sol (9)

100-101: Per-vault deposit fulfillment tracking added.

The vaultsTotalAssetsForFulfillDeposit mapping appropriately tracks vault state for deposit fulfillment, complementing the existing redeem tracking and supporting the new per-vault processing flow.


153-159: Dual authorization for upkeep triggers.

The new onlyAuthorizedTrigger modifier allows both the owner and the Chainlink Automation Registry to trigger performUpkeep, replacing the previous registry-only restriction. This improves operational flexibility by enabling manual intervention when needed.

Verify that dual authorization is intentional and consider documenting any additional security considerations for owner-triggered upkeep in production scenarios.


236-238: Maximum volume fee tightened from 1% to 0.5%.

The protocol fee cap reduction from 1% to 0.5% is a more conservative limit that may improve protocol competitiveness. Ensure this tightened constraint aligns with economic modeling and won't disrupt existing deployments expecting the previous 1% maximum.


283-283: performUpkeep authorization updated.

The modifier change to onlyAuthorizedTrigger applies the dual authorization (owner and registry) to performUpkeep, consistent with the new access control pattern.


332-332: Epoch state cleanup includes new deposit fulfillment tracking.

Properly clears vaultsTotalAssetsForFulfillDeposit at epoch start, preventing stale data carryover and maintaining consistent state management.


432-432: Deposit fulfillment state captured at correct point in preprocessing.

Both transparent (Line 432) and encrypted (Line 610) vault preprocessing correctly set vaultsTotalAssetsForFulfillDeposit after subtracting pending redeems but before adding pending deposits, capturing the appropriate totalAssets for deposit fulfillment calculations.

Also applies to: 610-610


823-823: Idle-state guards added to public getters.

The SystemNotIdle reverts added to getOrders (Line 823), getEpochTokens (Line 915), and getPriceOf (Line 921) prevent reading inconsistent state during epoch processing. This is a breaking change for callers.

Verify that external integrations and off-chain systems can handle or avoid calling these functions during non-idle phases. Consider whether a view function that returns both the phase and the data might be useful for callers who need to check availability.

Also applies to: 915-915, 921-921


913-917: Epoch tokens list exposed via public getter.

The new getEpochTokens() function appropriately exposes the current epoch's token list with an idle-state guard to prevent reading inconsistent data.


947-952: Consider idle-state guard for deposit fulfillment getter.

The new getVaultTotalAssetsForFulfillDeposit function exposes per-vault deposit fulfillment state but lacks an idle-state guard, unlike other similar getters.

Verify whether this getter should also have a SystemNotIdle guard like getEpochTokens and getOrders, or if reading this value during processing is intentionally allowed. The similar getter getVaultTotalAssetsForFulfillRedeem (Line 943) also lacks a guard, but consistency across the API would be clearer with explicit design intent documented.

artifacts/contracts/libraries/ErrorsLib.sol/ErrorsLib.json (1)

115-116: Artifact updated consistently with error removal.

The bytecode hashes reflect the removal of the SlippageExceeded error, consistent with the broader shift away from slippage-based constraints across the codebase.

artifacts/contracts/orchestrators/LiquidityOrchestrator.sol/LiquidityOrchestrator.json (5)

48-52: InsufficientAmount error added to support buffer validation.

The InsufficientAmount error addition supports validation logic in the new liquidity management functions.


326-338: depositLiquidity function added to ABI.

Correctly reflects the new buffer deposit functionality in the public interface.


540-540: Buffer ratio setter replaces slippage bound setter.

The rename from setSlippageBound to setTargetBufferRatio is correctly reflected in the ABI, consistent with the strategic shift in liquidity management.

Also applies to: 544-544


658-670: withdrawLiquidity function added to ABI.

Correctly reflects the new buffer withdrawal functionality in the public interface.


672-673: Bytecode updated with new functionality.

The artifact bytecode reflects all the ABI changes including new liquidity management functions and renamed setters.

artifacts/contracts/interfaces/ILiquidityOrchestrator.sol/ILiquidityOrchestrator.json (1)

56-68: Interface artifact consistent with source changes.

The ABI correctly reflects the interface changes: depositLiquidity and withdrawLiquidity additions, and the setSlippageBoundsetTargetBufferRatio rename.

Also applies to: 135-135, 139-139, 227-239

contracts/mocks/MockExecutionAdapter.sol (1)

13-15: Mock adapter signatures simplified.

The removal of maxUnderlyingAmount and minUnderlyingAmount parameters from buy and sell aligns the mock with the simplified IExecutionAdapter interface and the broader removal of slippage-based constraints.

Also applies to: 18-20

artifacts/contracts/execution/OrionAssetERC4626ExecutionAdapter.sol/OrionAssetERC4626ExecutionAdapter.json (1)

160-161: Execution adapter artifact updated consistently.

The bytecode reflects the removal of slippage parameters from buy and sell functions, consistent with the interface simplification across the codebase.

artifacts/contracts/interfaces/IInternalStateOrchestrator.sol/IInternalStateOrchestrator.json (1)

6-18: New state exposure functions added to interface.

The three new getters (bufferAmount, getEpochTokens, and getVaultTotalAssetsForFulfillDeposit) appropriately expose internal orchestrator state to support the new per-vault fulfillment and buffer management flows.

Also applies to: 105-117, 175-193

contracts/interfaces/IExecutionAdapter.sol (1)

18-24: LGTM! Simplified interface aligns with centralized slippage handling.

The removal of slippage parameters (minUnderlyingAmount, maxUnderlyingAmount) from the adapter interface is a valid architectural choice that centralizes slippage protection at the orchestrator level. This simplification makes the adapter interface cleaner and easier to implement.

contracts/interfaces/IInternalStateOrchestrator.sol (2)

57-59: LGTM! Buffer amount exposure supports external monitoring.

The new bufferAmount() getter enables external visibility into the protocol's liquidity buffer state.


108-117: LGTM! Per-vault asset queries support new fulfillment flow.

The addition of getVaultTotalAssetsForFulfillDeposit and getEpochTokens properly extends the interface to support the refactored deposit and redeem fulfillment logic. The dev note on Line 116 appropriately warns about the blocking behavior when the orchestrator is not idle.

artifacts/contracts/mocks/MockExecutionAdapter.sol/MockExecutionAdapter.json (1)

60-61: Artifact update aligns with interface changes.

The bytecode and ABI updates correctly reflect the simplified buy and sell signatures from the interface changes.

contracts/execution/OrionAssetERC4626ExecutionAdapter.sol (2)

50-66: LGTM! Sell logic correctly simplified.

The removal of minUnderlyingAmount shifts slippage protection to the orchestrator level. The vault asset validation via try-catch (lines 54-58) is a good security practice. The zero-amount check (line 59) prevents wasteful transactions.


69-100: LGTM! Buy logic correctly simplified with proper cleanup.

The implementation correctly:

  • Validates the vault asset (lines 73-77)
  • Prevents zero-amount buys (line 78)
  • Uses previewMint to calculate costs (line 82)
  • Cleans up approvals after execution (line 95)
  • Transfers shares to caller (line 98)
test/Orchestrators.test.ts (4)

168-184: LGTM! Target buffer ratio validation is thorough.

The test properly validates:

  • Zero ratio is rejected (line 172)
  • Ratio > 500 (5%) is rejected (line 177)
  • Valid ratios (1 and 400) are accepted (lines 183-184)

738-773: LGTM! Authorization model properly tested.

The three tests comprehensively verify that:

  1. Owner can call performUpkeep (lines 738-747)
  2. Automation registry can call performUpkeep (lines 749-759)
  3. Unauthorized addresses are rejected with NotAuthorized error (lines 761-773)

787-816: LGTM! Liquidity orchestrator authorization properly tested.

The tests correctly handle the conditional nature of liquidity orchestrator upkeep (checking liquidityUpkeepNeeded before attempting calls) and verify the authorization model.


818-824: LGTM! Edge case coverage for buffer ratio.

The test verifies typical buffer ratio (100 = 1%) works correctly.

contracts/orchestrators/LiquidityOrchestrator.sol (8)

104-110: LGTM! Authorization expansion enables manual triggering.

The new onlyAuthorizedTrigger modifier properly allows both the contract owner and the Chainlink Automation Registry to call performUpkeep, enabling manual intervention when needed. This is a sensible operational improvement.


163-169: LGTM! Target buffer ratio validation is appropriate.

The validation correctly:

  • Rejects zero ratio (line 164)
  • Enforces maximum of 5% (500 basis points, line 166)
  • Requires system to be idle (line 167)

172-201: LGTM! Liquidity management functions are well-implemented.

Both depositLiquidity and withdrawLiquidity properly:

  • Validate non-zero amounts
  • Check system is idle
  • Update the internal states orchestrator buffer
  • Handle token transfers with error checking

The withdrawal function includes an appropriate safety check (line 193) to prevent negative buffer amounts.


72-73: LGTM! Constant renaming reflects unified fulfillment flow.

The rename from ACTION_PROCESS_FULFILL_REDEEM to ACTION_PROCESS_FULFILL_DEPOSIT_AND_REDEEM accurately describes the combined processing of both deposits and redemptions in a single phase.


287-293: LGTM! Phase transition logic updated correctly.

The phase name change from FulfillRedeem to FulfillDepositAndRedeem (line 287) aligns with the unified fulfillment approach.


298-298: LGTM! Authorization enforced at entry point.

The performUpkeep function correctly uses the new onlyAuthorizedTrigger modifier to enforce access control.


423-423: LGTM! Adapter call simplified.

The sell call now passes only (asset, sharesAmount), consistent with the simplified interface.


449-476: LGTM! Unified fulfillment processing is well-structured.

The _processFulfillDepositAndRedeem function correctly:

  • Validates the current phase (line 451)
  • Transitions to Idle (line 455)
  • Processes both transparent and encrypted vaults (lines 457-475)
  • Retrieves per-vault totals before processing

Comment thread contracts/OrionConfig.sol
Comment thread contracts/OrionConfig.sol

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
contracts/orchestrators/LiquidityOrchestrator.sol (1)

494-501: Process redemptions before deposits to preserve correct share pricing.

The current implementation processes deposits (lines 494-496) before redemptions (lines 499-501). This order can inflate the vault's totalSupply before redemptions are calculated, causing redeemers to receive fewer underlying assets than they should. Previous reviews explicitly flagged this issue.

Apply this diff to fix the order:

-    // Process deposits if pending
-    if (pendingDeposit > 0) {
-        vaultContract.fulfillDeposit(totalAssetsForDeposit);
-    }
-
     // Process redemptions if pending
     if (pendingRedeem > 0) {
         vaultContract.fulfillRedeem(totalAssetsForRedeem);
     }
+
+    // Process deposits if pending
+    if (pendingDeposit > 0) {
+        vaultContract.fulfillDeposit(totalAssetsForDeposit);
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9902382 and b608294.

📒 Files selected for processing (1)
  • contracts/orchestrators/LiquidityOrchestrator.sol (10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Sourcery review
  • GitHub Check: Build, Lint and Test
🔇 Additional comments (6)
contracts/orchestrators/LiquidityOrchestrator.sol (6)

104-110: LGTM! Flexible access control for upkeep triggering.

The new modifier appropriately allows both the contract owner and Chainlink Automation Registry to trigger upkeep operations, providing operational flexibility while maintaining access control.


287-290: LGTM! Phase check updated correctly.

The condition correctly checks for the renamed FulfillDepositAndRedeem phase and encodes the appropriate action constant.


298-298: LGTM! Access control updated for flexible triggering.

The modifier change correctly implements the new access control model, allowing both owner and Chainlink Automation Registry to perform upkeep.


309-310: LGTM! Action handler updated correctly.

The handler correctly processes the renamed action and delegates to the new fulfillment function.


392-392: LGTM! Phase transition updated correctly.

The phase transition correctly moves to FulfillDepositAndRedeem after the buying leg completes.


163-169: No action required: targetBufferRatio is used in InternalStatesOrchestrator.sol (line 662) for buffer calculations.

Likely an incorrect or invalid review comment.

Comment thread contracts/orchestrators/LiquidityOrchestrator.sol
Comment thread contracts/orchestrators/LiquidityOrchestrator.sol
Comment thread contracts/orchestrators/LiquidityOrchestrator.sol
@matteoettam09
matteoettam09 merged commit 7ef01b3 into main Oct 5, 2025
4 of 5 checks passed
@matteoettam09
matteoettam09 deleted the dev branch October 5, 2025 19:55
@coderabbitai coderabbitai Bot mentioned this pull request Dec 20, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 29, 2025
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Jan 12, 2026
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Feb 4, 2026
This was referenced Feb 5, 2026
Merged
This was referenced Apr 23, 2026
Merged
Merged
Merged
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