This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
xiaoming90 - Incorrect pricing for CurveV2 LP Token #621
Labels
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
xiaoming90
high
Incorrect pricing for CurveV2 LP Token
Summary
The price of the CurveV2 LP Tokens is incorrect as the incorrect quote currency is being used when computing the value, resulting in a loss of assets due to the overvaluing or undervaluing of the assets.
Vulnerability Detail
Using the Curve rETH/frxETH pool (0xe7c6e0a739021cdba7aac21b4b728779eef974d9) to illustrate the issue:
The price of the LP token of Curve rETH/frxETH pool can be obtained via the following
lp_price
function:https://etherscan.io/address/0xe7c6e0a739021cdba7aac21b4b728779eef974d9#code#L1308
Thus, the formula to obtain the price of the LP token is as follows:
Information about the$internalPriceOracle$ can be obtained from the
pool.price_oracle()
function or from the Curve's Pool page (https://curve.fi/#/ethereum/pools/factory-crypto-218/swap). Refer to the Price Data's Price Oracle section.https://etherscan.io/address/0xe7c6e0a739021cdba7aac21b4b728779eef974d9#code#L1341
The$internalPriceOracle$ is the price of
coins[1]
(frxETH) withcoins[0]
(rETH) as the quote currency, which means how many rETH (quote) are needed to purchase one frxETH (base).During pool registration, the
poolInfo.tokenToPrice
is always set to the second coin (coins[1]
) as per Line 131 below. In this example,poolInfo.tokenToPrice
will be set to frxETH token address (coins[1]
).https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/oracles/providers/CurveV2CryptoEthOracle.sol#L107
Note that$internalPriceOracle$ in the above formula.
assetPrice
variable below is equivalent toWhen fetching the price of the LP token, Line 166 computes the price of frxETH with ETH as the quote currency ($frxETH/ETH$ ) via the
getPriceInEth
function, and assigns to theassetPrice
variable.However, the$internalPriceOracle$ or $frxETH/rETH$ instead of $frxETH/ETH$ . Thus, the price of the LP token computed will be incorrect.
assetPrice
should behttps://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/oracles/providers/CurveV2CryptoEthOracle.sol#L151
Impact
The protocol relies on the oracle to provide accurate pricing for many critical operations, such as determining the debt values of DV, calculators/stats used during the rebalancing process, NAV/shares of the LMPVault, and determining how much assets the users should receive during withdrawal.
Incorrect pricing of LP tokens would result in many implications that lead to a loss of assets, such as users withdrawing more or fewer assets than expected due to over/undervalued vaults or strategy allowing an unprofitable rebalance to be executed.
Code Snippet
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/oracles/providers/CurveV2CryptoEthOracle.sol#L151
Tool used
Manual Review
Recommendation
Update the$internalPriceOracle$ or
getPriceInEth
function to ensure that theassetPrice
return the price ofcoins[1]
withcoins[0]
as the quote currency.The text was updated successfully, but these errors were encountered: