From 2b110f40251698c3a8a1b57aaa9de160e07d8f8c Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 22 Mar 2024 18:43:04 +0100 Subject: [PATCH 1/4] perf: removed unnecessary array --- contracts/main/CurveTwocryptoOptimized.vy | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/contracts/main/CurveTwocryptoOptimized.vy b/contracts/main/CurveTwocryptoOptimized.vy index 4c409b59..b8464d08 100644 --- a/contracts/main/CurveTwocryptoOptimized.vy +++ b/contracts/main/CurveTwocryptoOptimized.vy @@ -1250,13 +1250,11 @@ def _fee(xp: uint256[N_COINS]) -> uint256: @internal @pure def get_xcp(D: uint256, price_scale: uint256) -> uint256: - - x: uint256[N_COINS] = [ - unsafe_div(D, N_COINS), - D * PRECISION / (price_scale * N_COINS) - ] - - return isqrt(x[0] * x[1]) # <------------------- Geometric Mean. + return isqrt( + unsafe_div(D, N_COINS) * # <------------- xp[0] + D * PRECISION / (price_scale * N_COINS) # xp[1] + ) + @view From e4b6786b293e5c8b8b2c2ba8ebeb1452b8cae67c Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 22 Mar 2024 18:47:49 +0100 Subject: [PATCH 2/4] chore: fix linting --- contracts/main/CurveTwocryptoOptimized.vy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/main/CurveTwocryptoOptimized.vy b/contracts/main/CurveTwocryptoOptimized.vy index b8464d08..b9ca2e5f 100644 --- a/contracts/main/CurveTwocryptoOptimized.vy +++ b/contracts/main/CurveTwocryptoOptimized.vy @@ -1254,7 +1254,7 @@ def get_xcp(D: uint256, price_scale: uint256) -> uint256: unsafe_div(D, N_COINS) * # <------------- xp[0] D * PRECISION / (price_scale * N_COINS) # xp[1] ) - + @view From 9b17a68b0dd65c10f2f5ee3201daf59c30176b88 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 26 Mar 2024 10:22:14 +0100 Subject: [PATCH 3/4] docs: added mistakenly removed comment --- contracts/main/CurveTwocryptoOptimized.vy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/main/CurveTwocryptoOptimized.vy b/contracts/main/CurveTwocryptoOptimized.vy index b9ca2e5f..c4089642 100644 --- a/contracts/main/CurveTwocryptoOptimized.vy +++ b/contracts/main/CurveTwocryptoOptimized.vy @@ -1253,7 +1253,7 @@ def get_xcp(D: uint256, price_scale: uint256) -> uint256: return isqrt( unsafe_div(D, N_COINS) * # <------------- xp[0] D * PRECISION / (price_scale * N_COINS) # xp[1] - ) + ) # <------------------------------- Geometric mean From 58476a8bc342f0a5f47389ce63fc386e17995771 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 26 Mar 2024 10:22:49 +0100 Subject: [PATCH 4/4] chore: bump boa version --- requirements.txt | 2 +- tests/unitary/math/test_newton_D.py | 1 - tests/unitary/math/test_newton_D_ref.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index a2b9e663..931c4383 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,5 +23,5 @@ pandas matplotlib # vyper and dev framework: -git+https://github.com/vyperlang/titanoboa@87593bb5c4d02bb8eaf4cc93e0e940ebf9a37900 +git+https://github.com/vyperlang/titanoboa@8c2f673c10439d13b976d1f1667462810379f010 vyper>=0.3.10 diff --git a/tests/unitary/math/test_newton_D.py b/tests/unitary/math/test_newton_D.py index d1cfe5b7..efdc0d88 100644 --- a/tests/unitary/math/test_newton_D.py +++ b/tests/unitary/math/test_newton_D.py @@ -4,7 +4,6 @@ from decimal import Decimal import pytest -from boa.vyper.contract import BoaError from hypothesis import given, settings from hypothesis import strategies as st diff --git a/tests/unitary/math/test_newton_D_ref.py b/tests/unitary/math/test_newton_D_ref.py index 6852c39d..aa49b7b2 100644 --- a/tests/unitary/math/test_newton_D_ref.py +++ b/tests/unitary/math/test_newton_D_ref.py @@ -3,7 +3,7 @@ from decimal import Decimal import pytest -from boa.vyper.contract import BoaError +from boa import BoaError from hypothesis import given, settings from hypothesis import strategies as st