code-423n4 / 2021-07-spartan-findings

0 stars 0 forks source link

Inconsistent slip adjustment calculation with the Thorchain model #237

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

shw

Vulnerability details

Impact

The getSlipAdustment implementation of Utils is inconsistent with the Thorchain liquidity model. The slip adjustment in Utils is calculated as (1 - ABS((B t - b T)/((2 b + B) (t + T)))). However, the slip adjustment in the Thorchain model is defined as (1 - ABS((B t - b T)/((b + B) (t + T)))), without the constant 2. The inconsistency could cause users to get different number of LP tokens when adding liquidity.

Proof of Concept

Referenced code: Utils.sol#L97 Utils.sol#L101

Recommended Mitigation Steps

Remove the constant 2 at line 101. By the way, there is a typo in the function name, which should be getSlipAdjustment instead.

SamusElderg commented 3 years ago

Duplicate of #62

ghoul-sol commented 3 years ago

duplicate of #62 hence non-critical