Assessment reports>Cove>Threat Model>_processInternalTrades

Function: _processInternalTrades(BasketManagerStorage self, InternalTrade[] internalTrades, address[] baskets, uint256[][] basketBalances)

This function handles the processing of internal trades.

Inputs

  • self

    • Control: Controlled by the proposeTokenSwap function.

    • Constraints: None.

    • Impact: The storage reference.

  • internalTrades

    • Control: Controlled by the proposeTokenSwap function.

    • Constraints: None at this level.

    • Impact: The internal trades to be processed.

  • baskets

    • Control: Controlled by the proposeTokenSwap function.

    • Constraints: None at this level.

    • Impact: The baskets that are being rebalanced.

  • basketBalances

    • Control: Controlled by the proposeTokenSwap function.

    • Constraints: None at this level.

    • Impact: The basket's balances.

Branches and code coverage

Intended branches

  • Assume that the trades are most efficiently ordered. This is not enforced in code, and responsibility for this comes from the proposer.

  • Calculate the fee on the sellAmount (if any).

  • Calculate the fee on the buyAmount (if any).

  • Calculate the initial buyAmount based on netSellAmount through the EulerRouter.

  • Update the basket balances based on the trade.

Negative behavior

  • Should not allow the initialBuyAmount to be greater than the balance of the token in the basket.

  • Should not allow having a netBuyAmount less than the minAmount or greater than the maxAmount.

  • Should not allow the sellAmount to be greater than the balance of the token in the basket.

Zellic © 2025Back to top ↑