Shell Protocol - moneyversed's results

A set of EVM-based smart contracts on Arbitrum One. In a nutshell it is DeFi made simple.

General Information

Platform: Code4rena

Start Date: 21/08/2023

Pot Size: $36,500 USDC

Total HM: 1

Participants: 43

Period: 7 days

Judge: Dravee

Id: 277

League: ETH

Shell Protocol

Findings Distribution

Researcher Performance

Rank: 26/43

Findings: 1

Award: $31.37

Analysis:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Labels

analysis-advanced
grade-b
sufficient quality report
A-10

Awards

31.3724 USDC - $31.37

External Links

The EvolvingProteus.sol contract is a meticulous representation of a dynamic protocol system that adapts and evolves its parameters based on time dependencies. It encapsulates various functionalities ranging from token swapping to liquidity management, all while being governed by an ever-changing configuration. To understand the intricacies and the logic behind this contract, here's a systematic breakdown:


1. Analysis of Codebase

  • Profound Dependency Management:
    • ABDKMath64x64.sol: An esoteric math library that guarantees 128-bit precision, enhancing the reliability of calculations.
    • @openzeppelin/contracts/utils/math/Math.sol: A time-tested library from OpenZeppelin, renowned for its impeccable basic mathematical operations.
    • ILiquidityPoolImplementation.sol: A pivotal interface that delineates the foundational functionalities of the contract.
  • Struct and Library Ensemble:
    • Config struct: A sophisticated representation of evolving configuration, capturing the transition from initial to culmination states.
    • LibConfig: A helper library ingeniously designed to manage operations on the Config struct, signifying the temporal evolution of parameters.
  • State and Constants Alchemy:
    • Constants: Strategically placed to define boundaries, enhancing the robustness of operations.
    • config: A transparent state variable of type Config, ensuring external agents can gauge the current system configuration.
  • Error Dynamics:
    • The protocol harnesses custom errors, a brilliant move, amplifying the descriptiveness of revert messages - a gift for developers and troubleshooters.
  • Constructor Craft:
    • Initialization is pivotal. The constructor not only sets initial parameters but also integrates checks ensuring price bounds harmony.
  • Swap Mechanics:
    • Functions like swapGivenInputAmount and swapGivenOutputAmount masterfully manage token exchanges, accounting for fees and maintaining equilibrium with balance constraints.
  • Liquidity Mastery:
    • The contract intelligently manages liquidity through its deposit (depositGivenInputAmount & depositGivenOutputAmount) and withdrawal (withdrawGivenOutputAmount & withdrawGivenInputAmount) functions, catering to various scenarios.

2. Architectural Refinements

  • Modularity Magic: Given the contract's complex temporal nature, fragmenting it into specialized contracts or libraries could accentuate readability, adaptability, and upgradability.
  • Eventful Milestones: A recommendation to intersperse the contract with events that mark significant time-dependent transitions, enabling easier external tracking.
  • Mathematical Precision: The ABDK library, though impeccable in precision, might be a gas guzzler. Re-evaluating precision needs and potentially adopting lighter alternatives can be considered.

3. Centralization Perils

  • Library Trust: Third-party dependencies, while efficient, can be Achilles' heels. Ensuring their trustworthiness through audits is indispensable.
  • Adaptability Dilemma: The contract's rigidity in upgradability is both its strength and weakness, guaranteeing immutability but compromising on adaptability.

4. Time Spent:

  • Code Dive: 1st day spent immersing in the code to unravel its nuances.
  • Risks & Evaluation: 2nd and 3rd day were dedicated to understand potential pitfalls, alongside with a single separate reported finding.
  • Recommendations Forge: approx. 1 up to 2 days invested in crafting suggestions for enhancement pertaining to the noticed vulnerable sructs.

5. Key Directives

  • Guard Against Zero: Address the lurking danger of the division by zero within the t function. A sentinel ensuring t_final surpasses t_init is crucial.
  • Mathematical Scrutiny: The complexity of calculations necessitates rigorous testing against anomalies like rounding discrepancies, potential overflows, and front-running ploys.
  • Library Due Diligence: Thoroughly vet the third-party libraries, especially esoteric ones like ABDK.
  • Vigilant Monitoring: Deploy monitoring mechanisms to oversee the temporal evolution, ensuring anomalies are flagged.

Epilogue:

The EvolvingProteus.sol contract is a magnum opus of time-dependent parameter evolution. Its structural integrity is commendable, but the lurking division by zero vulnerability necessitates urgent rectification. The intricate nature of its operations demands particular attention on the protocol side and rigorous testing prior to any deployment. Moreover, a critical evaluation of the mathematical libraries in use, especially from a gas efficiency standpoint, is highly recommended.

Time spent:

82 hours

#0 - c4-pre-sort

2023-08-31T05:28:31Z

0xRobocop marked the issue as sufficient quality report

#1 - c4-judge

2023-09-11T20:38:20Z

JustDravee marked the issue as grade-a

#2 - c4-judge

2023-09-11T22:22:07Z

JustDravee marked the issue as grade-b

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