-
Notifications
You must be signed in to change notification settings - Fork 8
xiaoming90 - Incorrect number of shares minted as fee #624
Comments
|
Disagree. This is an valid issue.
|
It is unfair to use two different formulas for user addresses and fee addresses. Since share is choosed as the fee, sink must be treated as a user address. Why let users use formula with losses? |
If the same formula is used, it is not the users who are on the losing end. Instead, it is the protocol team who are on the losing end. Assume that a user and protocol team are entitled to 20 WETH shares.
Speaking of the old formula, an important difference is that when minting the users' shares, the total assets and supply increase because the user deposited 20 WETH. Thus, the value of the share remain constant before and after minting the shares. However, when minting the protocol's share, only the total supply increases. The following shows the user received 20 WETH worth of shares after the minting.
The following shows that the protocol did not receive 20 WETH worth of shares after the minting.
|
Agree it. Thanks for your explanation. |
xiaoming90
high
Incorrect number of shares minted as fee
Summary
An incorrect number of shares was minted as fees during fee collection, resulting in a loss of fee.
Vulnerability Detail
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVault.sol#L818
Assume that the following states:
profit
is 100 WETHfees
will be 20 WETH.totalSupply
is 100 shares andtotalAssets()
is 1000 WETHLet the number of shares to be minted be$shares2mint$ . The current implementation uses the following formula (simplified) to determine $shares2mint$ .
In this case, two (2) shares will be minted to the
sink
address as the fee is taken.However, the above formula used in the codebase is incorrect. The total cost/value of the newly-minted shares does not correspond to the fee taken. Immediately after the mint, the value of the two (2) shares is worth only 19.60 WETH, which does not correspond to the 20 WETH fee that the
sink
address is entitled to.Impact
Loss of fee. Fee collection is an integral part of the protocol; thus the loss of fee is considered a High issue.
Code Snippet
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVault.sol#L818
Tool used
Manual Review
Recommendation
The correct formula to compute the number of shares minted as fee should be as follows:
The above formula is the same as the one LIDO used (https://docs.lido.fi/guides/steth-integration-guide/#fees)
The following is the proof to show that
2.0408163265306122448979591836735
shares are worth 20 WETH after the mint.The text was updated successfully, but these errors were encountered: