From c2a8f095da1c24d519257af921e43459df8d93c4 Mon Sep 17 00:00:00 2001 From: Michael Egorov Date: Mon, 16 Dec 2024 00:30:12 +0100 Subject: [PATCH] Twocrypto -> replace linear with square in the xcp_profit vs virtual_price check --- contracts/main/CurveTwocryptoOptimized.vy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/main/CurveTwocryptoOptimized.vy b/contracts/main/CurveTwocryptoOptimized.vy index 4c409b59..6d20b14a 100644 --- a/contracts/main/CurveTwocryptoOptimized.vy +++ b/contracts/main/CurveTwocryptoOptimized.vy @@ -991,7 +991,7 @@ def tweak_price( self.xcp_profit = xcp_profit # ------------ Rebalance liquidity if there's enough profits to adjust it: - if virtual_price * 2 - 10**18 > xcp_profit + 2 * rebalancing_params[0]: + if virtual_price ** 2 > xcp_profit * (10**18 + 2 * rebalancing_params[0]): # allowed_extra_profit --------^ # ------------------- Get adjustment step ---------------------------- @@ -1052,7 +1052,7 @@ def tweak_price( # ---------------------------- Proceed if we've got enough profit. if ( old_virtual_price > 10**18 and - 2 * old_virtual_price - 10**18 > xcp_profit + old_virtual_price ** 2 > xcp_profit * 10**18 ): self.D = D