The _mytSharesDeposited variable is a critical accounting metric in the AlchemistV3 contract, designed to track the total amount of myt (yield-bearing tokens) held by the contract. This value is the sole input for the _getTotalUnderlyingValue() function, which calculates the protocol's Total Value Locked (TVL).
Several functions that transfer myt tokens out of the contract fail to decrement _mytSharesDeposited, leading to a persistent discrepancy between the accounted TVL and the actual on-chain balance. The primary functions affected are:
_forceRepay(): When repaying earmarked debt during a liquidation, this function transfers creditToYield to the transmuter and protocolFeeTotal to the protocol fee receiver. However, it does not decrease _mytSharesDeposited to reflect these outflows. _doLiquidation(): This function transfers amountLiquidated to the transmuter and feeInYield to the liquidator, but _mytSharesDeposited is not updated. _resolveRepaymentFee(): When a repayment fee is paid to a liquidator, the fee amount is transferred out, but again, _mytSharesDeposited is not decremented.
This contrasts with other functions like withdraw(), burn(), and repay(), which correctly update the metric, creating an accounting inconsistency that is triggered specifically during liquidations and forced repayments.
The primary and most severe impact is the under-enforcement of liquidations, leading to an increased risk of bad debt for the protocol.
The liquidation mechanism relies on the global system health, represented by alchemistCurrentCollateralization, which is derived directly from the inflated TVL. The calculateLiquidation function has a critical branch: if the system is globally undercollateralized (alchemistCurrentCollateralization < alchemistMinimumCollateralization), it enforces a full liquidation of the unhealthy position to protect the protocol.
References
Add any relevant links to documentation or code
Proof of Concept
Proof of Concept
add the following test to src/test/AlchemistV3.t.sol