Dopex - hunter_w3b'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: 98/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
A-04

Awards

90.0998 USDC - $90.10

External Links

[A-01] Any comments for the judge to contextualize your findings

My primary objective is to enhance the gas efficiency and cost-effectiveness of the protocol. Throughout my analysis, I have diligently pursued opportunities to optimize gas and have prepared a comprehensive report comprising 26 detailed gas optimization with forge test and refactoring recommendations tailored to the specific needs of the protocol.

The optimizations I have identified aim to improve gas efficiency, reduce storage reads, and overall make the smart contracts more cost-effective to deploy and interact with on the blockchain

[A-02] Approach taken in evaluating the codebase

Accordingly, I analyzed and audited the subject in the following steps;

  1. Core Protocol Contracts Overview:

    • UniV2LiquidityAmo.sol:

      Description: This contract encompasses all functions for the Uniswap V2 AMO (Automated Market Maker Optimization). Dependencies: It appears to depend on the OpenZeppelin library and Uniswap V2 libraries.

    • UniV3LiquidityAmo.sol:

      Description: This contract encompasses all functions for the Uniswap V3 AMO, which is likely related to optimizing Uniswap V3 liquidity. Dependencies: Similar to the previous contract, it depends on the OpenZeppelin library and Uniswap V3 libraries.

    • RdpxV2Core.sol:

      Description: This is the core contract of rDPX V2, but the exact functionality isn't detailed here. It might be the central contract for a specific DeFi protocol. Dependencies: It depends on the OpenZeppelin library.

    • RdpxV2Bond.sol:

      Description: This contract seems to be an ERC721 contract for minting NFT (Non-Fungible Token) bonds via the core contract RdpxV2Core.sol. Dependencies: It depends on the OpenZeppelin library.

    • RdpxDecayingBonds.sol:

      Description: This contract is responsible for minting rDPX decaying bonds, which might be a financial instrument or token with time-based decay properties. Dependencies: It depends on the OpenZeppelin library.

    • DpxEthToken.sol:

      Description: This is an ERC20 contract for the dpxETH token. ERC20 tokens are fungible tokens commonly used in Ethereum-based applications. Dependencies: It depends on the OpenZeppelin library.

    • PerpetualAtlanticVault.sol:

      Description: This contract appears to be related to the Perpetual Atlantic Vault and is implemented as an ERC721 contract, suggesting it handles non-fungible tokens. Dependencies: It depends on the OpenZeppelin library.

    • PerpetualAtlanticVaultLP.sol:

      Description: This contract is associated with the Perpetual Atlantic Vault LP (ERC4626). ERC4626 is not a standard Ethereum token, so this may be a custom token type used in the project. It also mentions "solmate," which could be an additional library or dependency. Dependencies: It depends on the OpenZeppelin library and possibly "solmate."

    • ReLPContract.sol:

      Description: This contract appears to be related to the reLP process on the Uniswap V2 AMO. It might involve actions like removing liquidity from Uniswap V2 pools. Dependencies: It is not explicitly mentioned, but it might depend on the OpenZeppelin library and potentially other contracts from the project.

  2. Documentation Review:

    • Glossary

      The documentation begins with a glossary of important terms and acronyms used throughout the document. Some of the key terms include:

      1. Backing Reserve: A reserve of tokens that back the amount of dpxETH in supply. It consists of two components: rDPX Backing Reserve and ETH Backing Reserve.
      2. Treasury Reserve: Tokens held by the treasury for decaying bonds and discounts provided during the bonding process. Core Contract: The contract responsible for managing the PSM (Peg Stability Module), backing reserve, and bonding processes.
      3. AMO: Algorithmic Market Operations Controller.
      4. APP: Atlantic Perpetual Put Option.
    • Introduction to rDPX V2

      rDPX V2 introduces a synthetic coin called dpxETH, which is pegged to ETH. This coin is used to earn boosted yields on ETH and serves as collateral for future Dopex Options Products.

    • Bonding Mechanism

      The bonding process is explained in detail, and it consists of three ways for users to bond: regular bonding, delegate bonding, and bonding via rDPX Decaying Bonds. Each method involves different steps and requirements.

      1. Regular Bonding: Users deposit rDPX and ETH to mint a bond, which eventually yields receipt tokens. The process involves various calculations and allocations to reserves.

      2. Delegate Bonding: Users pool their ETH, set fees, and allow rDPX holders to bond using their pooled ETH.

      3. Bonding via rDPX Decaying Bond: Users use decaying bonds with rDPX to mint bonds and receive receipt tokens.

    • Atlantic Perpetual PUTS Options

      This section explains the perpetual options pool for rDPX options used in the bonding process. Funding for these options is calculated based on BlackScholes and comes from the CRV (Curve) rewards.

    • Receipt Token

      Receipt tokens represent dpxETH/ETH LP tokens on Curve and are staked in Curve gauges with boosted rewards. They earn rewards and incentives, including DPX and decaying bonds. Redemption of receipt tokens is explained in detail.

    • AMO (Algorithmic Market Operations)

      AMOs are explained with four key properties: Recollateralize, Decollateralize, Market Operations, and FXS1559. In the context of rDPX V2, AMOs handle market operations, specifically Uniswap V2 and Uniswap V3 AMOs.

    • Peg Stability Module (PSM)

      The PSM is described as part of the Core Contract and is responsible for maintaining the peg of dpxETH to ETH. It includes functions for upperDepeg, lowerDepeg, and settling.

    • System Parameters

      System parameters are governance-controlled and include veDPX Bonding Fee, Reward Distribution Percentages, Discount Factor, rDPX V2 Bond Maturity, and Redemption Fee. These parameters affect the stability and operation of the system.

    • Launch Details

      This section outlines the launch process, including deploying contracts, bonding by Treasury funds and partners, and the public announcement of rDPX V2.

    • Contracts Architecture

      The documentation concludes with an overview of the various contracts that make up the rDPX V2 system, including rDPX V2 Core, Receipt Token-related contracts, Atlantic Perpetual Pool contracts, and various oracles.

  3. Graphical Analysis: Solidity-metrics is a popular tool used to analyze and visualize Solidity code. It provides various metrics and visualizations to gain insights into the codebase's complexity and maintainability. solidity-metrics

  4. Utilizing Static Analysis Tools: In this phase of the analysis, Slither has already been executed as part of the static analysis process.

  5. Test Coverage Evaluation: During this phase, I play with the tests, initially encountering challenges when attempting to run them first. However, after resolving the issues, I found the well-written tests to be quite interesting.

  6. Manuel Code Review In this phase, I initially conducted a line-by-line analysis, following that, I engaged in a comparison mode, Despite the complexity of this codebase, I didn't come across any noteworthy insights during the first two modes. Consequently, I shifted my focus to the Blackboxing mode.

    • Line by Line Analysis: Pay close attention to the contract's intended functionality and compare it with its actual behavior on a line-by-line basis.

    • Comparison Mode: Compare the implementation of each function with established standards or existing implementations, focusing on the function names to identify any deviations.

    • Blackboxing Mode: Particularly useful for complex codebases. Grasp the protocol's expected behavior through tests, and experiment with them to better understand and navigate the intricacies of the code.

[A-03] Architecture recommendations

The following architecture improvements and feedback could be considered:

  1. Delegate Bonding Incentives:

    Consider implementing incentives for users who participate in delegate bonding. Encourage rDPX holders to provide ETH to the bonding pool by rewarding them with additional tokens or benefits.

  2. Decaying Bond Mechanics:

    Clearly define the mechanics of decaying bonds, including how they are minted, the duration of their maturity, and the specific use cases for these bonds. Ensure that decaying bonds align with the overall goals of the protocol.

    • Minting Conditions:

      Clearly define the conditions under which users receive decaying bonds. These conditions can include: Providing liquidity to certain pools. Participating in specific protocol events. Being active participants in governance.

    • Maturity Duration:

      Determine the exact duration of maturity for decaying bonds. This period should be long enough to incentivize users to remain engaged with the protocol but not overly restrictive.

    • Use Cases:

      Enumerate specific use cases for decaying bonds, ensuring they align with the protocol's goals. Examples of use cases include: Compensation for losses incurred in options trading. Incentivizing long-term participation in the protocol. Rewarding users for contributing to protocol development.

    • Decay Rate Algorithm:

      Develop a transparent decay rate algorithm that governs how the bond's value decreases over time. This algorithm should be publicly auditable and subject to governance control.

    • Redemption Process:

      Outline a straightforward redemption process for users to exchange their decaying bonds for receipt tokens or other rewards. Ensure that this process is user-friendly and well-documented.

    • Minting Limits:

      Set limits on the number of decaying bonds that can be minted over specific periods to prevent excessive issuance.

  3. Incentives for Receipt Token Stakers:

    While it's mentioned that receipt tokens staked with Dopex earn additional incentives in the form of DPX and decaying bonds, providing more details on the specifics of these incentives would be valuable. Explain how DPX rewards are calculated and when decaying bonds are rewarded to users.

  4. Redemption Fee Structure:

    The document mentions a variable redemption fee, but it doesn't specify how this fee is calculated or what factors influence its variability. Providing clarity on the fee structure, its components, and how it's determined would be beneficial for users who wish to redeem their receipt tokens.

  5. AMO Functionality Separation:

    It's mentioned that Decollateralize and Recollateralize functions are separated into the Treasury singleton PSM, and FXS1559 defines how much FXS can be burned with profits above the target CR. To enhance understanding, provide a brief description of how these functions work within the Treasury singleton and Core Contract. A step-by-step breakdown can help users grasp the processes involved.

[A-04] Codebase analysis

  1. UniV2LiquidityAmo.sol: This contract seems to serve as an intermediary for handling liquidity operations involving RDPX, WETH, and LP tokens in Uniswap V2. It provides administrative controls for setting addresses and managing slippage tolerance, as well as functions for liquidity management and token swapping.

    Lack of Comments: The code could benefit from more inline comments and function-level explanations to make it easier for developers to understand its logic and purpose.

    SafeMath: There is no need for SafeMath library,because Solidity 0.8.0 introduced a new overflow and underflow protection mechanism for arithmetic operations on integer types.

    Admin-Only Functions: Ensure that only trusted individuals or contracts are assigned admin roles

    Magic Numbers: There are some magic numbers in the contract, such as slippageTolerance values. It's a good practice to replace these with named constants to improve code readability and maintainability.

    Overview of the UniV2LiquidityAmo.sol

    • Inheritance and Imports:

      It inherits from the AccessControl contract provided by OpenZeppelin, which is commonly used for role-based access control. It imports various Solidity contracts, including SafeMath, SafeERC20, and several interfaces from the Dopex project.

    • State Variables:

      The contract includes several state variables, including Addresses, which is a struct containing addresses of various contracts and tokens. Constants like DEFAULT_PRECISION and slippageTolerance are defined. lpTokenBalance tracks the LP token balance in the contract.

    • Constructor:

      The constructor initializes the contract and sets the deployer as the default admin role.

    • Admin Functions:

      The contract includes several functions that can only be called by an admin with the default admin role. These functions allow the admin to configure the contract's settings, such as setting addresses, slippage tolerance, approving contracts to spend tokens, and performing emergency withdrawals.

    • AMO Functions:

      The contract includes functions for adding and removing liquidity from Uniswap V2 pools (addLiquidity and removeLiquidity) and swapping tokens (swap). These functions interact with the Uniswap V2 router.

    • Events:

      The contract emits several events to log various actions, including adding/removing liquidity, swapping tokens, transferring assets, and emergency withdrawals.

  2. UniV3LiquidityAmo.sol: This contract is a UniV3 Liquidity AMO (Automated Market Maker Operator) that interacts with Uniswap V3 pools to manage liquidity positions.

    Below are some observations and potential improvements:

    Consistency in Naming: Ensure consistent naming conventions for variables and functions. For example, some variables use _ as a prefix, while others don't. Consistency improves code readability.

    Recovery Functions: The contract includes functions to recover ERC20 tokens and ERC721 tokens. Ensure that these functions are only callable by authorized addresses and that they do not pose security risks.

    Overview of the UniV2LiquidityAmo.sol

    1. UniV3LiquidityAMO focuses on Uniswap V3 liquidity management.

    2. It uses similar libraries and design patterns as the UniV2 counterpart.

    3. The contract interacts with Uniswap V3 pools using the univ3_positions and univ3_router interfaces.

    4. It maintains a list of liquidity positions in positions_array and a mapping in positions_mapping.

    5. The addLiquidity and removeLiquidity functions allow the contract to manage liquidity positions in Uniswap V3 pools.

    6. The swap function is used to perform token swaps within Uniswap V3 pools.

    7. Like the UniV2 version, it has an emergency token withdrawal function (recoverERC20) and an emergency NFT withdrawal function (recoverERC721).

  3. RdpxV2Core.sol: This contract is critical component of a Dopex protocol, related to managing liquidity, options, and bonds for the rDPX token. It provides extensive admin capabilities for managing its parameters and interacting with external contracts.

    Admin Functions:

    The contract provides several admin functions, including pausing and unpausing the contract, emergency token withdrawals, and settings for parameters like rdpxBurnPercentage, rdpxFeePercentage, isReLPActive, putOptionsRequired, bondMaturity, bondDiscountFactor, and slippageTolerance. Admins can also add or remove assets from the reserve, set contract addresses, and manage contract whitelists.

    1. The contract makes use of various imported libraries from OpenZeppelin, such as SafeERC20 and EnumerableSet, for safe token operations and managing enumerable sets.

    2. There are mappings for tracking bonds, owned options, and whether funding has been paid for a specific epoch.

    3. The contract seems to be designed to work with multiple tokens and assets, including WETH, rDPX, and others. It also includes functionality related to options and bonding.

    4. The contract contains precision constants and ratios, which are used in calculations throughout the contract.

    5. There is support for managing delegates, and various events are emitted for contract state changes.

    6. This contract implements roles using OpenZeppelin's AccessControl, allowing certain addresses to access admin functions.

    7. Certain functions require the contract to be unpaused (_whenPaused) to ensure safe operation.

    8. There's also an oracle component to this contract (setPricingOracleAddresses) for fetching token prices.

    9. The contract seems to interact with external contracts, such as AMMs (Automated Market Makers), bonding contracts (RdpxV2Bond), and others through the addresses provided in the setAddresses function.

    Overview of functions

    • pause(): Pauses the vault for emergency cases. Only the owner can call this function.

    • unpause(): Unpauses the vault. Only the owner can call this function.

    • emergencyWithdraw(address[] calldata tokens): Transfers all funds to msg.sender for a list of ERC20 tokens. Only the owner can call this function when the contract is paused.

    • setRdpxBurnPercentage(uint256 _rdpxBurnPercentage): Sets the rdpx burn percentage.

    • setRdpxFeePercentage(uint256 _rdpxFeePercentage): Sets the rdpx fee percentage.

    • setIsreLP(bool _isReLPActive): Sets whether reLP is active.

    • setPutOptionsRequired(bool _putOptionsRequired): Sets whether put options are required or not.

    • setBondMaturity(uint256 _bondMaturity): Update the bond maturity.

    • addAssetTotokenReserves(address _asset, string memory _assetSymbol): Adds an asset to the reserves tokens.

    • removeAssetFromtokenReserves(string memory _assetSymbol): Removes an asset from the reserves tokens.

    • setAddresses(): Update various contract addresses like AMM router, curve pool, and more.

    • setPricingOracleAddresses(): Update pricing oracle addresses.

    • addAMOAddress(address _addr): Adds an AMO contract address to an array.

    • removeAMOAddress(uint256 _index): Removes an AMO contract address from the array.

    • approveContractToSpend(address _token, address _spender, uint256 _amount): Approves a contract to spend a certain amount of tokens.

    • addToContractWhitelist(address _addr): Adds a contract to the contract whitelist.

    • removeFromContractWhitelist(address _addr): Removes a contract from the contract whitelist. function.

    • setBondDiscount(uint256 _bondDiscountFactor): Set the rDPX LP bond discount factor.

    • setSlippageTolerance(uint256 _slippageTolerance): Set the slippage tolerance.

  4. RdpxV2Bond.sol: This contract allows for the creation of rDPX V2 Bonds that can be minted by entities with the MINTER_ROLE. The contract owner (admin) has the authority to pause and unpause token transfers, and the contract supports enumeration of tokens. Additionally, tokens can be burned by their owners due to the inheritance of ERC721Burnable. Access control is enforced using the AccessControl contract.

    • mint(address to) Function:The mint function allows an entity with the MINTER_ROLE to create and mint new tokens. It increments the _tokenIdCounter to generate a new unique token ID. Then, it mints the new token and assigns it to the specified address (to). The function returns the newly created token's ID.

    • _beforeTokenTransfer(...) Function: This internal function is used as a hook to perform actions before transferring tokens. It checks whether the contract is paused using _whenNotPaused(), which is a function likely defined in the Pausable contract. It calls the corresponding _beforeTokenTransfer functions from both ERC721 and ERC721Enumerable.

  5. RdpxDecayingBonds.sol: The contract designed for managing and minting decaying rDPX bonds. These bonds are represented as ERC721 tokens.

    Access Control: It defines two roles: MINTER_ROLE for minting bonds and RDPXV2CORE_ROLE for Rdpx v2 core operations.

    Pausing: The contract can be paused and unpaused by the contract owner (with DEFAULT_ADMIN_ROLE) to control its functionality during emergency situations.

    Overall Functionality: Users with the MINTER_ROLE can mint decaying rDPX bonds for a specified address, recording bond details in the bonds mapping. The decreaseAmount function allows the Rdpx v2 core to adjust the bond amount as it decays over time.Bond ownership can be queried using getBondsOwned.

  6. PerpetualAtlanticVault.sol: This contract is for managing perpetual options on an underlying asset represented by the underlyingSymbol. The options are called "Perpetual Atlantic rDPX PUT options", These options are represented as ERC721 tokens with associated functionality for purchasing and settling them. The contract has functions for managing funding payments, pausing the contract in emergencies, and other administrative tasks.

    Treasury Functions:

    The contract includes functions related to treasury management, such as purchasing and settling options, as well as paying funding.

    1. purchase(): Allows the RDPXV2CORE_ROLE to purchase options. It calculates premiums, transfers collateral, and mints option tokens.

    2. settle(): Allows the RDPXV2CORE_ROLE to settle options, transferring collateral and rDPX tokens.

    3. payFunding(): Allows the RDPXV2CORE_ROLE to pay funding based on active options.

  7. ReLPContract.sol: The main purpose of this contract is to manage liquidity for a pair of tokens (token A and token B) on an automated market maker (AMM) exchange, similar to Uniswap. It allows users with the appropriate roles to adjust parameters, set addresses, and execute liquidity provision and management operations.

    The reLP function is the core of this contract and performs the following steps:

    1. Calculates the amount of token A to remove from the liquidity pool.
    2. Transfers LP tokens from an Automated Market Operator (AMO) contract to this contract.
    3. Removes liquidity from the AMM to obtain token B.
    4. Swaps token B for token A.
    5. Adds liquidity back to the AMM.
    6. Transfers LP tokens back to the AMO contract.
    7. Transfers the remaining token A to another contract (rdpxV2Core) and syncs the contract.
    8. The contract also manages various parameters related to slippage tolerance and precisio

[A-05] Centralization risks

Precision Control: The contract uses precision constants and parameters (DEFAULT_PRECISION, liquiditySlippageTolerance, and slippageTolerance) that are defined within the contract. Any change in these values requires admin control, potentially centralizing control over how precision and slippage are handled.

  1. UniV2LiquidityAMO contract:

    • Admin Control: The contract has an admin role (DEFAULT_ADMIN_ROLE) that can modify critical parameters, approve spending for tokens, and perform emergency withdrawals. If the admin account is compromised or acts maliciously, it can make unauthorized changes.
    • Slippage Tolerance Control: The contract allows the admin to set the slippage tolerance. This parameter controls the acceptable deviation from expected prices in swaps. If set incorrectly or maliciously, it can impact the contract's performance and the fairness of swaps.
    • Token Approval Control: The admin can approve contracts to spend a certain amount of tokens. This control should be used with caution, as it allows the admin to grant spending permissions to any contract. Misuse can lead to unauthorized token transfers.
    • Emergency Withdrawal: The admin can trigger an emergency withdrawal of all funds (tokens) from the contract. While this can be a safety feature, it also centralizes control over fund management and could be misused.
  2. UniV3LiquidityAMO contract:

    • Admin Control: The contract has an admin role (DEFAULT_ADMIN_ROLE) that can execute various functions, including approving token transfers, adding/removing liquidity from Uniswap v3 pools, and recovering ERC20/ERC721 tokens. If the admin role is controlled by a single entity or a small group of entities, it can introduce centralization risks. Malicious actions or mistakes by the admin could have a significant impact on the contract's behavior and user funds.

    • Custodian Role: Depending on the roles and permissions of the custodian, centralization risks may arise if the custodian has significant control over the contract's actions or if there is a lack of transparency in how the custodian is selected and managed.

  3. RdpxV2Core.sol

    • Approval of Token Spending: The contract allows the administrator to approve other contracts to spend tokens. This control could be abused if not properly managed.

    • Fees and Discounts: The contract sets parameters for fees and discounts. If these parameters can be easily changed by a central authority, it may centralize control over the system.

    • Emergency Pausing: The contract uses the _whenNotPaused() modifier to prevent certain functions from being executed when the contract is paused. The ability to pause and unpause the contract is controlled by an administrator, which can be a centralization risk.

  4. RdpxV2Bond.sol

    • Minter Role: The contract has a MINTER_ROLE that allows certain addresses to mint new tokens. The assignment of this role is controlled by the contract deployer (msg.sender in the constructor). This centralization of minting privileges can be risky if the criteria for becoming a minter are not transparent or subject to community governance.
  5. RdpxDecayingBonds.sol

    • Emergency Withdrawal: The emergency withdrawal functionality is centralized and can be used by the contract owner.
  6. PerpetualAtlanticVault.sol

    • Contract Whitelist Management: The contract owner can add or remove contracts to/from the whitelist, which can impact interactions with external contracts.The ability to manage the contract whitelist is centralized, and improper management could result in disruptions or favoritism in interactions with other contracts.

    • Setter Functions: Several setter functions, such as setAddresses, updateFundingDuration, and setLpAllowance, can be called only by the owner (DEFAULT_ADMIN_ROLE). These setter functions grant centralized control over critical contract parameters.

    • Funding Calculations: The calculateFunding function calculates funding based on options held and funding rates. This calculation could be affected by centralized factors like the choice of oracle and external conditions. The accuracy and fairness of funding calculations could be compromised if the oracle or external data sources are controlled by a single entity or are not transparent.

  7. ReLPContract.sol

    • Token Transfer: The contract transfers tokens (e.g., LP tokens, rdpx tokens) between addresses controlled by the contract. Any centralized control over these addresses or the contract itself can pose a centralization risk. For example, if the amo address or rdpxV2Core address is controlled by a single entity, they can influence the contract's behavior significantly.

    • Implicit Dependencies: The contract assumes that certain addresses (e.g., tokenA, tokenB, pair, rdpxV2Core, etc.) are correctly set by the admin. If these addresses are controlled by a single entity or become compromised, it can impact the contract's functionality.

[A-06] Systemic risks

Treasury Reserve Risks: The system relies on the Treasury Reserve to cover discounts and emissions to veDPX holders during the bonding process. If the Treasury Reserve is inadequately managed or depleted, it may not be able to fulfill its obligations, affecting system stability.

Liquidity and ReLP Process: The reLP process, which involves removing liquidity and swapping assets, is subject to market conditions. If the market for rDPX is illiquid or experiences sudden price fluctuations, the process could lead to slippage and impact the value of the system's assets.

Maturity Period and Redemption Risks: The variable maturity period for bonds introduces uncertainty for users. If users are unable to redeem their bonds when needed, it could lead to dissatisfaction and potential losses.

Redemption Fee Uncertainty: The variable redemption fee adds uncertainty for users seeking to redeem receipt tokens. Depending on the fee structure and current backing ratios, users may face unpredictable costs when redeeming, potentially affecting user satisfaction and trust in the system.

Incentive Overlaps: Receipt tokens also earn additional incentives in the form of DPX and decaying bonds. These multiple incentives may introduce complexities and potential conflicts of interest among token holders, affecting the ecosystem's stability.

Market Liquidity Risks: Liquidity issues in the dpxETH/ETH LP pool on the curve can impact the redemption process. Illiquidity can result in slippage when selling LP tokens, potentially leading to reduced redemption values.

Market Operations Reliance: The AMOs play a crucial role in adding/removing liquidity from Uniswap V2 and Uniswap V3 pools. Dependency on these operations exposes the ecosystem to potential liquidity risks, particularly if market conditions change rapidly, impacting the AMOs' ability to maintain equilibrium.

  1. UniV2LiquidityAmo.sol

    • Slippage Tolerance: The contract allows the admin to set a slippage tolerance for swaps. If this parameter is not set appropriately, it could lead to losses or inefficient use of funds during swaps, affecting the overall performance of the system.

    • Sync Function: The sync function is used to sync asset reserves with contract balances. If not called or managed properly, it could lead to inaccuracies in the contract's understanding of its token balances, affecting trading decisions.

    • Token Price Oracle: The contract uses an external price oracle (IRdpxEthOracle) to fetch the LP token's price. If the oracle becomes unreliable or manipulated, it could lead to incorrect pricing information, affecting trading decisions and user funds.

    • Calculations and Precision: The contract performs mathematical calculations with specific precision (e.g., 1e8). Any rounding errors or precision issues in these calculations could lead to unexpected behavior and financial losses.

  2. UniV3LiquidityAmo.sol

    • Token Transfers: The contract performs token transfers. Errors in token transfer functions can lead to the loss of assets, and in some cases, tokens can get stuck in the contract if transfer conditions are not met.
  3. PerpetualAtlanticVault.sol

    • Funding Management: The code implements a funding mechanism with an adjustable funding duration. Funding management can be complex, and any errors in calculating or distributing funding can have significant financial implications. Extensive testing and auditing are essential.

    • Rounding Precision:The code includes a function to round values to a specific precision. Ensure that this precision is chosen appropriately for the use case and that rounding errors are minimized.

Time spent:

17 hours

#0 - c4-pre-sort

2023-09-15T15:54:56Z

bytes032 marked the issue as sufficient quality report

#1 - c4-judge

2023-10-20T09:55:25Z

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