Open hats-bug-reporter[bot] opened 1 week ago
Hello,
We classified this issue as Invalid because the view functions of this contract are only meant to be used as references of how to add liquidity to Curve Pools, users are responsible for the way they decide to add liquidity. As you can see, they aren't called in our contracts and thus cannot result in theft of funds.
Thanks
Github username: -- Twitter username: -- Submission hash (on-chain): 0xca94a59f2331a33b1c9e2e115706c9c153fcfd5c8699627c2004197d1905bd26 Severity: high
Description: Description\ In the
CurveLiqArbitrage.sol
contract, thefindBestProportion
function is designed to identify the optimal liquidity addition ratio. However, the function’sepsilon
parameter lacks adequate boundary checks, potentially leading to: 1.Impacting overall protocol liquidity 2.Increase slippageAttack Scenario\ All liquidity addition operations using the
findBestProportion
function could impact the protocol's liquidity efficiency and increase user gas costs. If liquidity providers use suboptimal ratios, they will receive fewer LP tokens, potentially causing the pool's balance to deviate from the ideal state, which could increase slippage and affect other users' trading costs. The optimal proportion should be close to0.8e18
; deviating from this ratio reduces liquidity efficiency, and cumulative effects can cause a sustained decline in pool efficiency.Although the single-instance impact is small (around 0.01%), the impact could be amplified under the following conditions: large liquidity deposits, high-frequency operations, or during market volatility. Therefore, while the single-instance impact is minor, the functionality’s effectiveness could be compromised over time, reducing liquidity provision efficiency, affecting pool balance, increasing transaction costs, and thereby impacting overall protocol liquidity efficiency.
Attachments
src/router/util/CurveLiqArbitrage.sol:findBestProportion#L66-L70
Parameter Control Issue
epsilon
is a public parameter and can be set arbitrarily.1e2
and`1e3,
1e3and
1e4`.Impact
epsilon
is set too low, thewhile
loop will iterate excessively.calc_token_amount
function.Verification Test cases indicate that the optimal ratio provides about a 0.01% advantage:
test/Router/CurveLiqArbitrageTest.t.sol:testCDFindBestProportionFuzz#L2978-L3037
epsilon
Parameter: Instead, implement an internal calculation to dynamically compute precision based on pool state and trade volume. Introduce an adaptive mechanism to increase precision when needed, with a maximum iteration limit as a safeguard.epsilon
: Consider caching the optimal ratio and providing fallback options under extreme market conditions.