Dopex - rjs's results

A rebate system for option writers in the Dopex Protocol.

General Information

Platform: Code4rena

Start Date: 21/08/2023

Pot Size: $125,000 USDC

Total HM: 26

Participants: 189

Period: 16 days

Judge: GalloDaSballo

Total Solo HM: 3

Id: 278

League: ETH

Dopex

Findings Distribution

Researcher Performance

Rank: 100/189

Findings: 1

Award: $90.10

Analysis:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Labels

analysis-advanced
grade-b
sufficient quality report
edited-by-warden
A-10

Awards

90.0998 USDC - $90.10

External Links

1. Summary

1.1. Approach Taken

Preparation

Execution

  • Reviewed the core contracts in principal, and identified Areas of Concern
  • Initial code review
  • Drafted reports
  • Deep code review
  • Wrote & submitted reports

Effort 21 hours total

1.2. Mechanism Review

rDPX V2 is a complex new system involving changes to the existing rDPX token which forms part of the Dopex ecosystem. It introduces dpxETH, which is pegged to ETH in a 1:1 ratio. dpxETH will be designated as a staple collateral token for future Dopex options products. The dpxETH:ETH peg is maintained via an interplay between bonding mechanisms, backing reserves controlled via AMOs, and a peg stability module. There are dependencies on Curve Finance, Uniswap V2 and Uniswap V3 for performing some of these functions.

ComponentNotes
Peg Stability Module (PSM)Ensures dpxETH to ETH peg on the Curve pool
Regular Bonding MechanismDeposit rDPX + ETH to mint a bond -> send rDPX/ETH to backing reserves/Curve -> burn/send rDPX as rewards -> mint ERC721 bond token
Delegate BondingUsers with rDPX-only or ETH-only deposit into pool and then can use pool to perform regular bonding
Bonding via rDPX Decaying BondSimilar to regular bonding mechanism, but there is a maturity + redemption process involved
Atlantic Perpetual PUTS OptionsA perpetual options pool for rDPX options which the Core Contract uses for the bonding process with 1 week epoch
Receipt TokenRepresents dpxETH/ETH LP tokens on the curve, and are staked in Curve gauges for rewards then distributed to receipt token stakers and the Core Contract
Receipt RedemptionRedeemed at current ratio of the rDPX/ETH backing reserve, less redemption fee
AMOInspired by Frax's AMO but tailored for rDPX V2; modifications should be carefully reviewed

1.3. Areas of Concern

ComponentConcern
Peg Stability ModuleIs it possible to depeg dpxETH:ETH, e.g. under extreme market conditions or aggressive market manipulation?
Regular Bonding MechanismIs the bonding mechanism susceptible to economic attacks due to its reliance on market prices e.g. flash loan attacks or oracle manipulations
Regular Bonding MechanismIs liquidity a concern any where in this process, or is it fully controlled by the Dopex contracts?
Delegate BondingAre there any sequences of interactions in the delegated bonding process that result in unexpected outcomes for rDPX and ETH holders participating in the pool?
Bonding via rDPX Decaying BondDo the calculations here always hold through all market and reserve conditions? Can the redemption process be brought forward or exploited?
Atlantic Perpetual PUTS OptionsAre there surprises on the epoch boundaries? Is it possible to deny service to users by blocking collateral availability?
Receipt TokenCan the current ratio of the Backing Reserve in rDPX/ETH provide an exploit path to unexpected behavior elsewhere?
AMODoes separating out the Decollateralize and Recollateralize into the Treasury single PSM violate any assumptions in the Frax AMO ecosystem?
DependenciesCan unlikely failure in two components produce an unexpected interaction?

2. Codebase Quality Analysis

2.1. Codebase Review

Each source unit was assessed with respect to modularity, access control mechanism, centralization risks, validation completeness and documentation quality:

Source UnitModularityAccess ControlCentralizationValidationDocumentation
UniV2LiquidityAmo.sol🟢 Good🟢 Role-based🟡 Admin-only functions🟢 Excellent🟢 Good
UniV3LiquidityAmo.sol🟢 Good🟢 Role-based🟡 Admin-only functions🟢 Excellent🟢 Good
RdpxV2Core.sol🟢 Excellent🟢 Role-based🟡 Admin-only functions🟢 Excellent🟢 Good
RdpxV2Bond.sol🟢 Excellent🟢 Role-based🟢 Standard🟢 Standard🟢 Standard
RdpxDecayingBonds.sol🟢 Excellent🟢 Role-based🟢 Standard🟢 Standard🟢 Standard
DpxEthToken.sol🟢 Excellent🟢 Role-based🟢 Standard🟢 Standard⚪ N/A
PerpetualAtlanticVault.sol🟢 Excellent🟢 Role-based🟡 Admin-only functions🟢 Excellent🟡 Basic
PerpetualAtlanticVaultLP.sol🟢 Excellent🟢 Creator-only🟢 None🟡 Basic🟡 Basic
ReLPContract.sol🟢 Excellent🟢 Role-based🟡 Admin-only functions🟢 Excellent🟡 Basic

2.2. Maturity Level

  • "Admin-only functions" represents a centralization risk; ideally, a more granular set of roles would be implemented
  • "Basic" validation refers to code where not all parameters or scenarios were validated; details in the QA report
  • "Basic" documentation refers to code lacking a clear description of code purpose, assumptions, etc.
  • Overall, the codebase demonstrated high maturity.

2.3. Recommendations

  • Validation and documentation should be expanded in the areas highlighted yellow above
  • Where possible, centralization risks should be reduced by splitting dedicated roles out of the single "admin" role

3. Architecture Recommendations & Risks

3.1. Consider reducing Peg Stability Module (PSM) dependencies

The PSM is entirely controlled by the Core Contract managers; if these are compromised or act maliciously, they could disrupt the peg. There could also be scenarios where the Curve pool may not have enough liquidity to correct the peg effectively.

3.2. Consider improvements to reduces parameters in the bonding mechanism

Multiple parameters (e.g. discount factor) are set by governance. If governance is compromised or acts inefficiently, it can affect the stability of the bonding process. It is worth considering if improvements are possible to allow parameters to dynamically reflect economic conditions rather than being configured through governance.

3.3. Consider making it possible for funding to be calculated without the APP contract admin

"The APP contract admin needs to calculate the funding needs to be called for every strike before the epoch ends".

Ideally any critical processes ought to be executable directly or indirectly by the impacted users in the ordinary course of operations, to reduce centralization risks.

3.4. Consider more granular roles for System Parameters

System parameters are set by governance and therefore pose a centralization risk. Consider splitting system parameters by role if possible.

3.5. Document system intention through more worked examples

It is possible to create a forge script that runs multiple scenarios and assumptions through the protocol and outputs graph points, when can then be rendered graphically. This would greatly improve the documentation and communicate system intention more clearly.

Time spent:

21 hours

#0 - c4-pre-sort

2023-09-15T15:56:59Z

bytes032 marked the issue as sufficient quality report

#1 - c4-judge

2023-10-20T10:02:09Z

GalloDaSballo 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