Maia DAO - Ulysses - invitedtea's results

Harnessing the power of Arbitrum, Ulysses Omnichain specializes in Virtualized Liquidity Management.

General Information

Platform: Code4rena

Start Date: 22/09/2023

Pot Size: $100,000 USDC

Total HM: 15

Participants: 175

Period: 14 days

Judge: alcueca

Total Solo HM: 4

Id: 287

League: ETH

Maia DAO

Findings Distribution

Researcher Performance

Rank: 31/175

Findings: 1

Award: $243.33

Analysis:
grade-a

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

243.335 USDC - $243.33

Labels

analysis-advanced
grade-a
sufficient quality report
edited-by-warden
A-19

External Links

Maia DAO - Ulysses audit analysis

Project Description

Ulysses Protocol is a decentralized 'Omnichain Liquidity Protocol' that aims to enhance capital efficiency in the fragmented DeFi liquidity landscape. It allows Liquidity Providers to deploy assets across multiple chains, optimizing revenue and minimizing the downsides of existing market solutions. The protocol also helps DeFi platforms reduce operational costs by centralizing liquidity incentives.

The protocol consists of two primary components: Virtualized and Unified Liquidity Management. The latter leverages Arbitrum's Balancer's Composable Stable Pools. Ulysses introduces a unique token representing stable Liquidity Provider assets from various chains, enhancing composability and versatility. This token can integrate with platforms like Uniswap V3 and Aave.

Ulysses' mechanics includes Ulysses Ports, Virtualized Liquidity, and the use of Layer0 for cross-chain communication.

The key contracts of the protocol for this Audit are:

  • RootPort.sol: The RootPort.sol contract manages omnichain token operations. It functions as the main gateway for cross-chain interactions, facilitating the management and tracking of different tokens across chains.

  • RootBridgeAgentExecutor.sol: The RootBridgeAgentExecutor.sol contract is designed for processing token settlement requests and executing transaction orders originating from branch chains. The execution is "sandboxed", meaning if a transaction fails, all effects on token settlements and interactions with external contracts are reverted.

  • RootBridgeAgent.sol: The RootBridgeAgent.sol contract acts as a gateway for cross-chain token transfers, managing the settlement of tokens, bridging assets in and out, and handling calls to and from branch chains.

  • MulticallRootRouterLibZip.sol: The MulticallRootRouterLibZip.sol contract provides root router functionalities to interface with third-party dApps in the Root Omnichain Environment. It seems to be focused on multicall operations, where multiple function calls can be batched into a single transaction. This contract also appears to support different types of multicalls, including those that don't return outputs, those that return a single output, and those that return multiple outputs. Additionally, there's support for signed versions of these calls.

  • MulticallRootRouter.sol: The MulticallRootRouter.sol contract serves as the root router for interfacing with third-party dApps in the Root Omnichain Environment. This contract focuses on multicall operations, where multiple function calls are batched into a single transaction. It also supports different types of multicalls, both signed and unsigned, and provides functionalities for depositing assets.

  • CoreRootRouter.sol: The CoreRootRouter.sol contract is central to managing the root routing functionalities within the given ecosystem. It seems to be primarily responsible for interfacing with branch chains, bridging agents, and managing strategy tokens and ports. The core functions suggest capabilities to initialize the router, manage branch-bridge relationships, execute response strategies, and handle deposits. It also supports signed versions of these operations. The contract appears to offer mechanisms to synchronize and update branch bridge agents, emphasizing the importance of cross-chain communication and operations in its design.

  • CoreBranchRouter.sol: The CoreBranchRouter.sol contract provides functionalities to manage branch routing within the ecosystem. It appears to act as a mediator, interfacing with global and local tokens and facilitating their operations. The contract is designed to process and execute operations without settlements and to handle the addition of global tokens and bridge agents. Its function signatures suggest it can manage strategy tokens and port strategies, ensuring that tokens are routed and managed efficiently within a branching structure.

  • BranchPort.sol: The BranchPort.sol contract plays a pivotal role in bridging functionalities within the ecosystem. This contract appears to be responsible for facilitating and managing the flow of tokens between branches. It provides mechanisms to initialize the port, manage ownership, replenish reserves, and handle withdrawals. Additionally, it supports bridging multiple tokens in and out and managing bridge agents, strategy tokens, and port strategies. This contract emphasizes the importance of maintaining liquidity and ensuring smooth bridging operations across different chains or branches in the ecosystem.

  • BranchBridgeAgentExecutor.sol: The BranchBridgeAgentExecutor.sol contract is structured as a library and is designed to deploy and execute bridge agent tasks. This library appears to be primarily focused on executing operations either with or without settlements, emphasizing the importance of flexibility and efficiency in handling cross-chain transactions and operations. It provides mechanisms to deploy the executor and execute operations, potentially streamlining the bridge agent tasks and ensuring smooth execution of cross-chain communications.

  • BaseBranchRouter.sol: The BaseBranchRouter.sol contract offers foundational functionalities required for branch routing within the ecosystem. This contract seems to be focused on handling deposits, executing outbound calls, and managing settlements. It provides mechanisms to make calls out to other systems and bridge data across chains. The contract also supports both individual and batch operations, ensuring scalability and flexibility in handling various operations. Its structure suggests it is likely a foundational layer, potentially extended by other contracts to achieve specific branch routing functionalities.

  • ArbitrumBranchPort.sol: The ArbitrumBranchPort.sol contract appears to be a specialized variant of the branch port, tailored for the Arbitrum chain. This contract focuses on facilitating the deposit and withdrawal of tokens within the Arbitrum environment, acting as a bridge between the local chain and external systems. It provides mechanisms to deposit tokens into the port, withdraw from the port, and handle bridging operations both in and out. Given its naming convention and core functionalities, it likely plays a key role in managing liquidity and ensuring smooth token operations within the Arbitrum branch of the ecosystem.

  • ArbitrumBranchBridgeAgent.sol: The ArbitrumBranchBridgeAgent.sol contract is structured as a library and is designed to deploy and execute bridge agent tasks specifically for the Arbitrum chain. This library focuses on depositing and withdrawing tokens from the port, emphasizing its role in the token flow between the Arbitrum chain and other systems. The library also provides mechanisms for retrying settlements and performing calls, indicating its role in ensuring transactional reliability and efficient communication within the Arbitrum environment.

  • ArbitrumBranchBridgeAgent.sol: The ArbitrumBranchBridgeAgent.sol contract is structured as a library and is designed to deploy and execute bridge agent tasks specifically for the Arbitrum chain. This library focuses on depositing and withdrawing tokens from the port, emphasizing its role in the token flow between the Arbitrum chain and other systems. The library also provides mechanisms for retrying settlements and performing calls, indicating its role in ensuring transactional reliability and efficient communication within the Arbitrum environment.

Approach

During the analysis, we focused on thoroughly understanding the codebase and providing recommendations to improve its functionality.

We divided the audit into 6 parts. The examined strategy were:

1. Ports 2. Virtual Liqudity 3. Bridge Agents 4. Routers 5. Virtual Accont 6. Arbitrum Part

Smart Contract Auditing Plan

1. Ports (e.g., BranchPort.sol, ArbitrumBranchPort.sol)

Objective: Ensure the secure and efficient handling of token deposits, withdrawals, and bridging operations.

  • Key Points:
    • Review token deposit and withdrawal mechanisms.
    • Examine bridging operations and ensure data consistency and integrity.
    • Check for reentrancy vulnerabilities.
    • Verify proper event emission for key operations.

2. Virtual Liquidity

Objective: Assess mechanisms that handle and manage virtual liquidity to ensure accuracy and prevent fraudulent activities.

  • Key Points:
    • Review token minting, burning, and distribution mechanisms.
    • Examine any logic related to liquidity pools and swapping.
    • Ensure proper access control for liquidity management functions.
    • Validate calculations for liquidity provision and withdrawal.

3. Bridge Agents (e.g., BranchBridgeAgent.sol, ArbitrumBranchBridgeAgent.sol)

Objective: Validate the secure and efficient facilitation of cross-chain communications and operations.

  • Key Points:
    • Review bridging logic for consistency and security.
    • Examine settlement mechanisms.
    • Check for potential front-running vulnerabilities.
    • Ensure that bridging fees, if any, are correctly calculated and applied.
    • Validate proper event emission during bridging activities.

4. Routers (e.g., CoreRootRouter.sol, CoreBranchRouter.sol, ArbitrumCoreBranchRouter.sol)

Objective: Examine routing logic to ensure secure and efficient token and data routing across systems.

  • Key Points:
    • Validate token routing logic for different branches.
    • Check access control for router management functions.
    • Review mechanisms for adding, removing, or updating routes.
    • Ensure that routing fees, if any, are correctly calculated and applied.

5. Virtual Account

Objective: Inspect virtual account mechanisms to ensure data privacy, security, and correct functionality.

  • Key Points:
    • Review account creation, management, and deletion processes.
    • Validate logic related to virtual account balances and transactions.
    • Check for potential vulnerabilities related to account impersonation.
    • Ensure proper event emission for account-related activities.

6. Arbitrum Part (e.g., ArbitrumBranchPort.sol, ArbitrumBranchBridgeAgent.sol, ArbitrumCoreBranchRouter.sol)

Objective: Specifically validate contracts designed for the Arbitrum environment, ensuring compatibility and efficiency.

  • Key Points:
    • Review any Arbitrum-specific optimizations or modifications.
    • Check the integration with the Arbitrum chain and its unique features.
    • Examine any cross-chain communication mechanisms specific to Arbitrum.
    • Validate the compatibility of token standards (e.g., ERC-20) within the Arbitrum context.

General Audit Practices:

  • Gas Optimization: Ensure that the contracts are optimized for gas usage.
  • Reentrancy Checks: Verify that functions are safe from reentrancy attacks.
  • Overflow & Underflow: Check for potential integer overflow or underflow vulnerabilities.
  • Access Control: Ensure only authorized entities can access specific functions.
  • Code Clarity: Ensure the code is well-commented, structured, and easy to understand.
  • Test Coverage: Confirm that all functions have associated tests and that edge cases are considered.

Architecture Description and Diagram

Architecture of the key contracts:

The ecosystem appears to be designed around the concept of bridging tokens and data across multiple chains, with a particular focus on the Arbitrum chain:

Ports (e.g., BranchPort.sol, ArbitrumBranchPort.sol):

Serve as entry and exit points for tokens in the ecosystem. Responsible for token deposits, withdrawals, and bridging operations.

Virtual Liquidity:

Handles the creation and management of virtualized liquidity within the system. Supports operations like minting, burning, and swapping. Bridge Agents (e.g., BranchBridgeAgent.sol, ArbitrumBranchBridgeAgent.sol):

Facilitate the cross-chain bridging of tokens and data. Handle settlements, perform external calls, and manage cross-chain communications. Routers (e.g., CoreRootRouter.sol, CoreBranchRouter.sol, ArbitrumCoreBranchRouter.sol):

Direct the flow of tokens and data across the ecosystem. Interface with different chains or branches and manage routing paths.

Virtual Account:

Provides mechanisms for creating and managing virtual accounts. Handles account-related operations, balances, and transactions. Arbitrum Part (e.g., ArbitrumBranchPort.sol, ArbitrumBranchBridgeAgent.sol, ArbitrumCoreBranchRouter.sol):

Specialized components designed specifically for the Arbitrum chain. Handle Arbitrum-specific operations, optimizations, and integrations.

Codebase Quality

Overall, we consider the quality of the provided codebase to be commendable. The code demonstrates a sophisticated design, especially in the realms of cross-chain operations and token management. We've observed the careful implementation of branch routing in contracts such as CoreRootRouter.sol and CoreBranchRouter.sol, alongside the bridging functionalities evident in BranchBridgeAgent.sol and ArbitrumBranchBridgeAgent.sol. The ecosystem places a strong emphasis on liquidity management, as seen in the various port contracts like BranchPort.sol and ArbitrumBranchPort.sol. Moreover, the dedicated components for the Arbitrum chain highlight a targeted approach to integrate with specific Layer 2 solutions. Drawing parallels to other established projects, the architecture embodies best practices seen in prominent DeFi projects. Details of each component are elaborated upon in the sections above.

Codebase Quality CategoriesComments
Unit TestingThe codebase demonstrates a comprehensive testing approach. It's commendable to see the use of advanced testing frameworks, ensuring robustness and security.
Code CommentsOverall, the code is well-commented, providing insights into the functionalities. However, specific contracts, especially those related to bridging and routing, could benefit from more detailed comments. Enhancing comments, especially in the more complex contracts such as CoreRootRouter.sol and BranchBridgeAgent.sol, would improve clarity and facilitate better understanding for developers. Additional details in these sections would streamline development and integration efforts for future contributors.
DocumentationComprehensive documentation detailing the intricacies of the cross-chain operations, bridging, and token management would be beneficial. A deep dive into the ecosystem, starting from the foundational contracts like BaseBranchRouter.sol to the specialized Arbitrum components, would greatly aid developers, users, and auditors aiming to engage with this protocol.
OrganizationThe codebase showcases a mature organizational structure. There's a clear demarcation between different functionalities, ranging from ports to routers and bridge agents. The distinct categorization of contracts, complemented by their interfaces, ensures clarity and facilitates efficient development.

Systemic & Centralization Risks

The analysis of the provided smart contracts reveals multiple systemic and centralization risks in the protocol. These risks include liquidity management in BranchPort.sol, bridging functionalities in BranchBridgeAgent.sol, dependency on external systems via routers, and centralization concerns arising from ownership mechanisms in certain contracts. Further examination of the documentation is essential to determine the intent behind certain designs. Moreover, the potential absence of rigorous testing, such as fuzzing, could introduce vulnerabilities.

  1. Liquidity Management in BranchPort.sol:

    • If the BranchPort.sol contract handles a considerable portion of the ecosystem's assets, it presents a risk, especially if mismanagement or significant losses occur. Distributing responsibilities across different contracts or mechanisms can help in risk mitigation.
  2. Bridging Functionality Risks:

    • The BranchBridgeAgent.sol and its counterparts play a critical role in cross-chain operations. If there are inefficiencies or vulnerabilities in the bridging logic, users might face challenges or losses during bridging operations, affecting trust in the protocol.
  3. Dependency on External Systems via Routers:

    • The protocol's reliance on routers like CoreRootRouter.sol and CoreBranchRouter.sol indicates a dependency on external systems for data routing. Any issues with these external systems or chains can cascade and disrupt the protocol's operations.
  4. Centralization Risks:

    • The contracts exhibit ownership patterns, emphasizing the role of an "owner" or similar privileged entity. In a truly decentralized ecosystem, governance should ideally be distributed, involving the community in key decisions rather than a singular role. The following contracts exhibit ownership or management patterns:
      • BranchPort.sol
      • CoreRootRouter.sol
      • CoreBranchRouter.sol
      • BaseBranchRouter.sol
      • BranchBridgeAgentExecutor.sol

    These contracts and their management mechanisms introduce centralization risks. If manipulated by a nefarious actor, they could compromise the protocol's integrity or act against the community's best interests.

  5. Cross-chain Token Risks:

    • When dealing with cross-chain operations, especially in contracts like ArbitrumBranchPort.sol, there's a risk associated with unfamiliar or malicious tokens. These tokens can:
      • Cause Fund Loss: If not handled correctly, they might exploit vulnerabilities, leading to stolen funds or protocol disruptions.
      • Manipulate Prices: These tokens can disrupt liquidity or bridging operations, affecting asset prices or system stability.
  6. The potential absence of extensive testing methods, such as fuzzing or invariant testing, might expose the protocol to unforeseen vulnerabilities and threats.

**Properly managing these risks and implementing best practices in security and decentralization will contribute to the sustainability and long-term success of this project **.

Recommendations

  1. Enhance Bridging Functionality:

    • Explore the feasibility of integrating multiple bridging protocols. Consider diversifying beyond the current implementations, like BranchBridgeAgent.sol, to integrate functionalities from other renowned bridges. This would provide a layered security approach, reducing dependency on a single bridging mechanism and enhancing overall system resilience.
  2. Refined Documentation:

    • Augment the documentation, especially for pivotal contracts such as CoreRootRouter.sol and CoreBranchRouter.sol. Ensure comments and explanations within the codebase are both clear and comprehensive. This will facilitate developers in understanding, maintaining, and evolving the codebase seamlessly.
  3. Decentralized Governance:

    • Work towards a more decentralized governance structure. The presence of ownership patterns in certain contracts suggests centralization. Transitioning towards a community-centric governance system can not only empower users but also bolster the protocol's adaptability and security in the long run.
  4. Optimized Liquidity Flow:

    • Reinforce liquidity operations in key contracts like BranchPort.sol and ArbitrumBranchPort.sol. Efficient management of liquidity is paramount, especially in a system emphasizing cross-chain operations, ensuring consistent and reliable token transfers.
  5. Function Redundancy:

    • Certain contracts, notably CoreRootRouter.sol and CoreBranchRouter.sol, exhibit patterns of recurring function names or structures. Reducing such redundancies can prevent potential confusion and misinterpretations during development and auditing processes.
  6. Simplify Inheritance and Nested Calls:

    • The codebase, especially in router and bridge agent contracts, displays intricate inheritance patterns and nested function calls. Simplifying these structures can vastly improve readability, making it easier to audit and identify potential issues.
  7. Introduce Safety Mechanisms:

    • Given the critical operations related to bridging and routing, it would be prudent to incorporate safety measures, like a circuit breaker or pausing mechanism, in essential contracts such as BranchBridgeAgent.sol. Such mechanisms provide a safety net during unforeseen vulnerabilities, enabling swift interventions and resolutions.

Gas Optimization

The provided codebase demonstrates commendable efficiency concerning gas optimizations. Many widely accepted gas optimization practices are evident throughout the contracts. While some minor gas optimizations have been flagged in automated findings, they don't overshadow the primary focus on code clarity and maintainability. Hence, further gas optimizations may not be prioritized over these aspects.

Conclusion

Overall, the architecture of the provided smart contracts reflects a sophisticated and thoughtful design. It's evident that the development team has put in substantial effort into crafting a robust codebase. However, the highlighted systemic and centralization risks should be addressed promptly. To foster better collaboration and understanding, enhancing documentation and in-code comments is essential. The team is strongly encouraged to continue their emphasis on security, investing in mitigation reviews, periodic audits, and establishing bug bounty programs. These measures will significantly contribute to upholding the protocol's security and trustworthiness.

Time Spent

The audit was conducted over a span of 5 days, distributed as follows:

  • 1st Day: Delved into understanding the protocol's intricacies and overall design.
  • 2nd Day: Primarily focused on critical contracts such as BranchPort.sol, CoreRootRouter.sol, CoreBranchRouter.sol, BaseBranchRouter.sol, and BranchBridgeAgentExecutor.sol.
  • 3rd Day: Dived deeper into the remaining smart contracts, emphasizing their interactions and dependencies.
  • 4th Day: Concluded the quality assurance process and detailed analysis of the codebase.
  • 5th Day: Compiled the observations, emphasizing high and medium-risk findings, and drafted the report.

Time spent: 40 hours

Time spent:

40 hours

#0 - c4-pre-sort

2023-10-15T14:23:15Z

0xA5DF marked the issue as sufficient quality report

#1 - alcueca

2023-10-20T09:49:17Z

Well written and extensive report. Some minor flaws like stating some risks acknowledged in the README or possibly copying some bits from previous analyses that don't match the codebase (Unit Testing). Overall, great quality.

#2 - c4-judge

2023-10-20T09:49:21Z

alcueca marked the issue as grade-a

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter