HydraDX-node icon indicating copy to clipboard operation
HydraDX-node copied to clipboard

[Audit_RV]Observation: Withdraw liquidity at significant price drop could resulting majority of shares goes to the pool

Open yanliu18 opened this issue 2 years ago • 0 comments

It is not necessary an issue or a vulnerability, but an observation of the current design.

Description

https://github.com/galacticcouncil/HydraDX-node/blob/16cdbcf25ef2f1dac5c3569d8cd44cc028ec4076/pallets/omnipool/src/lib.rs#L751

The state change of the remove_liquidity() operation calculates a delta_b variable as follows:

 let delta_b = if current_price < position_price {
        let sum = current_price.checked_add(&position_price)?;
        let sub = position_price.checked_sub(&current_price)?;

This delta_b is the amount of shares given to pool from the LP at the time of price drop. The more the current asset price is less than the invested price, the more shares of the LP's position will be taken out to the pool.

yanliu18 avatar Sep 07 '22 04:09 yanliu18