From 50b381bbaf7467f5669866700f75a19a8734ddad Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Sat, 23 Dec 2023 14:12:21 +0530 Subject: [PATCH] fix: lp price isqrt input --- contracts/main/CurveTwocryptoOptimized.vy | 2 +- tests/unitary/pool/test_oracles.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/main/CurveTwocryptoOptimized.vy b/contracts/main/CurveTwocryptoOptimized.vy index 38195ed3..d036988d 100644 --- a/contracts/main/CurveTwocryptoOptimized.vy +++ b/contracts/main/CurveTwocryptoOptimized.vy @@ -1630,7 +1630,7 @@ def lp_price() -> uint256: 0th index @return uint256 LP price. """ - return 2 * self.virtual_price * isqrt(self.internal_price_oracle()) / 10**18 + return 2 * self.virtual_price * isqrt(self.internal_price_oracle() * 10**18) / 10**18 @external diff --git a/tests/unitary/pool/test_oracles.py b/tests/unitary/pool/test_oracles.py index c3808777..96cf2b16 100644 --- a/tests/unitary/pool/test_oracles.py +++ b/tests/unitary/pool/test_oracles.py @@ -219,4 +219,4 @@ def test_lp_price(swap_with_deposit): // 10**18 ) naive_price = tvl * 10**18 // swap_with_deposit.totalSupply() - assert abs(swap_with_deposit.lp_price() / naive_price - 1) < 2e-3 + assert approx(naive_price, swap_with_deposit.lp_price(), 0)