Assessment reports>Magma Finance>Discussion>Protocol accounting

Protocol accounting

In the withdraw_managed function within voter_escrow.move, there appears to be an accounting concern around how balances are reduced. The function deducts both the principal amount (weight) and earned rewards (reward_from_locked) from a managed lock's balance in a single calculation: new_locked_managed.amount - (weight + reward_from_locked). This double deduction could potentially be problematic since the rewards were never included in the initial principal balance.

However, Magma Finance notes this is not an issue due to how rewards are handled in the implementation. The rewards only originate from the increase_amount_for_internal function (L582 in voting_escrow.move), where for permanent locks, any increased amount is simultaneously added to both the permanent locked balance and treated as managed lock rewards. This design pattern ensures the withdrawal calculation remains accurate despite appearing to double-count the deduction.

Zellic © 2025Back to top ↑