No slippage protection for adding liquidity in stableswap pool for add_liquidity() #152
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-93
🤖_15_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2024-02-hydradx/blob/603187123a20e0cb8a7ea85c6a6d718429caad8d/HydraDX-node/pallets/stableswap/src/lib.rs#L475-L479
Vulnerability details
Impact
In stableswap pool,
add_liquidity()
lacks slippage protection, and users might lose shares due to trading activities or price manipulation.Proof of Concept
In stableswap pool, slippage protection is not consistently implemented. Notably all other trading and liquidity management functions such as (
sell()
,buy()
,add_liquidity_shares()
,remove_liquidity_one_asset()
,etc) have slippage protection, except foradd_liquidity()
.add_liquidity()
takes an array of asset amount to add liquidity but allows for any calculated share amount (share_amount
) to pass.(https://github.com/code-423n4/2024-02-hydradx/blob/603187123a20e0cb8a7ea85c6a6d718429caad8d/HydraDX-node/pallets/stableswap/src/lib.rs#L475-L479)
As seen above, any non_zero/non_dust
share_amount
will be accepted. The user is unprotected from slippage when adding liquidity.Tools Used
Manual
Recommended Mitigation Steps
Add slippage protection in
add_liquidity()
, similar to other trading and liquidity management methods.Assessed type
Other
The text was updated successfully, but these errors were encountered: