Skip to content

Commit

Permalink
fix(fluid-dex) : Update logic calculating max reserves
Browse files Browse the repository at this point in the history
  • Loading branch information
sunspirit99 authored Nov 18, 2024
1 parent 211912b commit bd73786
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/liquidity-source/fluid/dex-t1/pool_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,16 @@ func getMaxReserves(
}

maxRealReserves := new(big.Int).Add(realColReserves, realDebtReserves)
if decimals > DexAmountsDecimals {
maxRealReserves.Mul(maxRealReserves, bignumber.TenPowInt(int8(decimals)-DexAmountsDecimals))
} else if decimals < DexAmountsDecimals {
maxRealReserves.Div(maxRealReserves, bignumber.TenPowInt(DexAmountsDecimals-int8(decimals)))
}

var maxReserve = maxLimitReserves
if maxRealReserves.Cmp(maxLimitReserves) < 0 {
maxReserve = maxRealReserves
}

if decimals > DexAmountsDecimals {
maxReserve.Mul(maxReserve, bignumber.TenPowInt(int8(decimals)-DexAmountsDecimals))
} else if decimals < DexAmountsDecimals {
maxReserve.Div(maxReserve, bignumber.TenPowInt(DexAmountsDecimals-int8(decimals)))
}

return maxReserve
}

0 comments on commit bd73786

Please sign in to comment.