From ba40f4c0e923ece05d1255bb12ee0bab1869a1d9 Mon Sep 17 00:00:00 2001 From: Wojciech Date: Tue, 9 Apr 2024 11:51:37 +0200 Subject: [PATCH] use U256 in calculateSqrtPrice --- contracts/math/decimal.ral | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/math/decimal.ral b/contracts/math/decimal.ral index 3c43f43..7a8a3a2 100644 --- a/contracts/math/decimal.ral +++ b/contracts/math/decimal.ral @@ -177,8 +177,8 @@ Abstract Contract Decimal(uints: Uints) { if (tickIndex >= 0i) { return rescale(sqrtPrice, FixedPointScale, SqrtPriceScale) } else { - let sqrtPriceInFixedPointScale = uints.bigDiv512(uints.toU512(one(SqrtPriceScale)), sqrtPrice, 1) - return rescale(sqrtPriceInFixedPointScale.lower, FixedPointScale, SqrtPriceScale) + let sqrtPriceInFixedPointScale = FixedPointDenominator * FixedPointDenominator / sqrtPrice + return rescale(sqrtPriceInFixedPointScale, FixedPointScale, SqrtPriceScale) } }