Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

carrot - IchiLP token pricing mechanism vulnerable to price manipulation #160

Closed
github-actions bot opened this issue Mar 1, 2023 · 0 comments
Closed
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@github-actions
Copy link

github-actions bot commented Mar 1, 2023

carrot

high

IchiLP token pricing mechanism vulnerable to price manipulation

Summary

The IchiLP tokens are priced as r0px0 + r1px1, where r0,r1 are the reserves, and px0,px1 are the oracle prices. This pricing formula has been the cause of multiple price manipulation exploits, like Warp Finance

Vulnerability Detail

The IchiLpOracle contract prices the LP tokens in the manner shown
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/oracle/IchiLpOracle.sol#L27-L38

The Ichi LP tokens are priced according to the formula
$$value = r0 * px0 + r1 * px1$$
where $r0,r1$ are the token reserves, and $px0,px1$ are the oracle prices. AMMs also follow the invariant formula $r0 * r1 = K$, which is also true for UniswapV3 when we consider the real reserves. This implies that $r0$ can be written as $K/r1$ and thus the pricing formula becomes
$$value = K * px0 / r1 + r1 * px1$$
which is a formula dependent solely on r1 (assuming oracle prices cannot be manipulated), and thus the composition of the uniV3 pool, which can be changed within a transaction with a flashloan.
Plotting out the value over $r1$, we get a curve like shown.
image
If the composition of the pool is close to this inflection point, the attacker can change the value of the LP tokens at a very low cost, leading to bad debt in the protocol.

Impact

Oracle contract susceptible to manipulation

Code Snippet

https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/oracle/IchiLpOracle.sol#L27-L38

Tool used

Manual Review

Recommendation

Use the LP token pricing formula established by alphaventure dao, which uses LP invariants. Can be seen discussed here and here

Duplicate of #20

@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue labels Mar 1, 2023
@github-actions github-actions bot closed this as completed Mar 1, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Mar 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant