Mimo August 2022 contest - hyh's results

Bridging the chasm between the DeFi world and the world of regulated financial institutions.

General Information

Platform: Code4rena

Start Date: 02/08/2022

Pot Size: $50,000 USDC

Total HM: 12

Participants: 69

Period: 5 days

Judge: gzeon

Total Solo HM: 5

Id: 150

League: ETH

Mimo DeFi

Findings Distribution

Researcher Performance

Rank: 47/69

Findings: 1

Award: $88.17

🌟 Selected for report: 0

🚀 Solo Findings: 0

1. README rebalance parameter equation should come with rebalanceValue instead of rebalanceAmount

Formula in the code is correct (with mcrB = vaultBMcr + mcrBuffer):

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/automated/MIMOAutoRebalance.sol#L13-L19

/**
  Rebalance value is calculated by the formula below :

        targetRatio * (vaultDebt + fixedFee) - collateralValue
      ----------------------------------------------------------
          targetRatio / mcrB - 1 - targetRatio * variableFee 
 */

While one in README incorrectly states that the fraction equals rebalanceAmount, while it is `rebalanceValue = rebalanceAmount * collateralBPARPrice':

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/docs/README.md#L173-L177


    rebalanceAmount =
     (targetRatio * (vaultADebt + fixedFee) - vaultACollateralValue) / 
     (targetRatio / (vaultBMcr + mcrBuffer) - targetRatio * varFee - 1);

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/docs/README.md#L173-L177


-   rebalanceAmount =
+   rebalanceValue =
     (targetRatio * (vaultADebt + fixedFee) - vaultACollateralValue) / 
     (targetRatio / (vaultBMcr + mcrBuffer) - targetRatio * varFee - 1);

2. MIMOManagedRebalance's _preRebalanceChecks description omits rebalanceAmount argument

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/managed/MIMOManagedRebalance.sol#L135-L147

  /**
    @notice Helper function performing pre rebalance operation sanity checks
    @dev Checks that vault is managed, that rebalance was called by manager, and maximum daily operation was not reached 
    @param managedVault ManagedVault struct of the vault to rebalance
    @param rbData RebalanceData struct of the vault to rebalance
    @param vaultsData Cached VaultsDataProvider interface for gas saving
   */
  function _preRebalanceChecks(
    ManagedVault memory managedVault,
    IMIMORebalance.RebalanceData calldata rbData,
    IVaultsDataProvider vaultsData,
    uint256 rebalanceAmount
  ) internal view {

Consider adding @param rebalanceAmount to the description

3. Obscure/incorrect managed vault description

Managed Vault Config description talks about automation:

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/docs/README.md#L106

The default state for our V2 SuperVault starts with `isManaged` set to `false` - which corresponds to a state of the vault not being open to automated. To open the vault up for automation, `isManaged` will need to be set to `true`.

Consider clarifying, for example:

The default state for our V2 SuperVault starts with `isManaged` set to `false` - which corresponds to a state of the vault not being open to external management. To open the vault up for management, `isManaged` will need to be set to `true`.

4. _isVaultVariationAllowed miss arguments description

MIMOAutoAction's _isVaultVariationAllowed():

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/automated/MIMOAutoAction.sol#L88-L96

  /**
    @notice Helper function determining if a vault value variation is within vault's management parameters
    @return True if value change is below allowedVariation and false if it is above
   */
  function _isVaultVariationAllowed(
    AutomatedVault memory autoVault,
    uint256 rebalanceValue,
    uint256 swapResultValue
  ) internal pure returns (bool) {

MIMOManagedAction's _isVaultVariationAllowed():

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/managed/MIMOManagedAction.sol#L111-L119

  /**
    @notice Helper function determining if a vault value variation is within vault's management parameters
    @return True if value change is below allowedVariation and false if it is above
   */
  function _isVaultVariationAllowed(
    ManagedVault memory managedVault,
    uint256 rebalanceValue,
    uint256 swapResultValue
  ) internal pure returns (bool) {

Consider adding arguments description to both functions.

There are several instances of other omitted argument descriptions, but there it is only one argument, which is straightforward. Here it is 3 arguments and proper description will be useful

5. Typos in descriptions

asset argument description to be rebalanced in both contracts:

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/automated/MIMOAutoRebalance.sol#L84

    @param assets Address array with one element corresponding to the address of the reblanced asset

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/managed/MIMOManagedRebalance.sol#L85

    @param assets Address array with one element corresponding to the address of the reblanced asset

setManagement() description, to be manager:

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/managed/MIMOManagedAction.sol#L29

    @dev Can only be called by vault owner and can only appoint whitelisting managers as manger

_getAmounts() description, to be of the vault:

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/automated/MIMOAutoRebalance.sol#L159

    @param vaultState VaultState struct og the vault to rebalance

README, to be Rebalance parameter Equation:

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/docs/README.md#L156

## Rebalance paramater Equation Calculation

6. IMIMOAutoAction and IMIMOManagedAction events aren't indexed

Filtering on unindexed events is disabled, which makes it harder to programmatically use and analyse the system.

Proof of Concept

MIMOAutoAction's event:

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/automated/interfaces/IMIMOAutoAction.sol#L25

  event AutomationSet(uint256 vaultId, AutomatedVault autoVault);

MIMOManagedAction's events:

https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/actions/managed/interfaces/IMIMOManagedAction.sol#L22-L23

  event ManagerSet(address manager, bool isManager);
  event ManagementSet(uint256 vaultId, ManagedVault managedVault);

Consider adding indexes to vaultId and manager address to improve events usability

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