From 852287291c32935b89776ca933b94260115b8725 Mon Sep 17 00:00:00 2001 From: Patricio Tourne Passarino Date: Mon, 26 Jan 2026 15:45:36 -0500 Subject: [PATCH 1/4] test: didn't have regression --- devenv/onchain.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/devenv/onchain.go b/devenv/onchain.go index b12d7f1f4..4484d3c90 100644 --- a/devenv/onchain.go +++ b/devenv/onchain.go @@ -9,6 +9,7 @@ import ( "github.com/smartcontractkit/chainlink-deployments-framework/operations" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/simple_node_set" + "github.com/smartcontractkit/chainlink-ton/deployment/ccip/config" "github.com/smartcontractkit/chainlink-ton/deployment/ccip/operation" "github.com/smartcontractkit/chainlink-ton/deployment/pkg/dep" "github.com/smartcontractkit/chainlink-ton/deployment/pkg/ops/ton" @@ -40,12 +41,26 @@ func (m *CCIP16TON) PostDeployContractsForSelector(ctx context.Context, env *dep // Calculate TON token price: 2 USD with 9 decimals = 2e27 var TONBaseAmountTokenPrice = big.NewInt(int64(TONtoUSD * (TokenPriceBaseAmount / TONtoNanoTON))) - tonTokenPrice := big.NewInt(0).Mul(TONBaseAmountTokenPrice, USDDecimals) + oldTonTokenPrice := big.NewInt(0).Mul(TONBaseAmountTokenPrice, USDDecimals) // Calculate LINK token price: 20 USD with 9 decimals = 20e27 // LINK has 9 decimals on TON, same as TON - linkTokenPrice := big.NewInt(0).Mul(big.NewInt(20), big.NewInt(1e18)) - linkTokenPrice = big.NewInt(0).Mul(linkTokenPrice, big.NewInt(1e9)) // Scale from 1e18 to 1e27 + oldLinkTokenPrice := big.NewInt(0).Mul(big.NewInt(20), big.NewInt(1e18)) + oldLinkTokenPrice = big.NewInt(0).Mul(oldLinkTokenPrice, big.NewInt(1e9)) // Scale from 1e18 to 1e27 + + tonTokenPrice, err := config.CCIPTokenPrice("2", 9) + if err != nil { + return fmt.Errorf("failed to calculate TON token price: %w", err) + } + linkTokenPrice, err := config.CCIPTokenPrice("20", 18) + if err != nil { + return fmt.Errorf("failed to calculate LINK token price: %w", err) + } + + if tonTokenPrice.Cmp(oldTonTokenPrice) != 0 || linkTokenPrice.Cmp(oldLinkTokenPrice) != 0 { + env.Logger.Errorf("Token price calculations should match, but got:\nTON token price: expected %s, got %s\nLINK token price: expected %s, got %s\n", oldTonTokenPrice.String(), tonTokenPrice.String(), oldLinkTokenPrice.String(), linkTokenPrice.String()) + return nil + } updateConfig := operation.UpdateFeeQuoterPricesInput{ TokenPrices: map[string]*big.Int{ From 0bd5f0a81e507ef3302accf722e3179fc49a81d8 Mon Sep 17 00:00:00 2001 From: Patricio Tourne Passarino Date: Mon, 26 Jan 2026 16:21:02 -0500 Subject: [PATCH 2/4] fix: decimal count --- devenv/onchain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devenv/onchain.go b/devenv/onchain.go index 4484d3c90..d7c646aeb 100644 --- a/devenv/onchain.go +++ b/devenv/onchain.go @@ -52,7 +52,7 @@ func (m *CCIP16TON) PostDeployContractsForSelector(ctx context.Context, env *dep if err != nil { return fmt.Errorf("failed to calculate TON token price: %w", err) } - linkTokenPrice, err := config.CCIPTokenPrice("20", 18) + linkTokenPrice, err := config.CCIPTokenPrice("20", 9) if err != nil { return fmt.Errorf("failed to calculate LINK token price: %w", err) } From 8344037ea833bac533350b44a8f9e422d0568b71 Mon Sep 17 00:00:00 2001 From: Patricio Tourne Passarino Date: Tue, 27 Jan 2026 11:54:01 -0500 Subject: [PATCH 3/4] fix: error str --- devenv/onchain.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/devenv/onchain.go b/devenv/onchain.go index d7c646aeb..6d538bc6a 100644 --- a/devenv/onchain.go +++ b/devenv/onchain.go @@ -58,8 +58,9 @@ func (m *CCIP16TON) PostDeployContractsForSelector(ctx context.Context, env *dep } if tonTokenPrice.Cmp(oldTonTokenPrice) != 0 || linkTokenPrice.Cmp(oldLinkTokenPrice) != 0 { - env.Logger.Errorf("Token price calculations should match, but got:\nTON token price: expected %s, got %s\nLINK token price: expected %s, got %s\n", oldTonTokenPrice.String(), tonTokenPrice.String(), oldLinkTokenPrice.String(), linkTokenPrice.String()) - return nil + errorStr := fmt.Errorf("Token price calculations should match, but got:\nTON token price: expected %s, got %s\nLINK token price: expected %s, got %s\n", oldTonTokenPrice.String(), tonTokenPrice.String(), oldLinkTokenPrice.String(), linkTokenPrice.String()) + env.Logger.Errorf(errorStr.Error()) + return errorStr } updateConfig := operation.UpdateFeeQuoterPricesInput{ From 5d945f2db9ea8edc902768ce7971738e618828ee Mon Sep 17 00:00:00 2001 From: Patricio Tourne Passarino Date: Wed, 28 Jan 2026 21:33:10 -0300 Subject: [PATCH 4/4] fix: rm redundant code --- devenv/onchain.go | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/devenv/onchain.go b/devenv/onchain.go index 6d538bc6a..0f6d8c65e 100644 --- a/devenv/onchain.go +++ b/devenv/onchain.go @@ -28,41 +28,18 @@ func (m *CCIP16TON) PostDeployContractsForSelector(ctx context.Context, env *dep return fmt.Errorf("failed to load CCIP state: %w", err) } - // Token price constants - const TONtoUSD = 2 // Example value (test/dev only) - const TONtoNanoTON = 1e9 // TON has 9 decimals - const TokenPriceBaseAmount = 1e18 // Base amount for TokenPrices - var USDDecimals = big.NewInt(1e18) // USD precision - - // Token prices are normalized to account for token decimals. - // The formula is: (USD price in 1e18) * (1e18 / 10^tokenDecimals) - // For TON/LINK with 9 decimals: price * 1e18 * (1e18 / 1e9) = price * 1e27 - // See: deployment/ccip/config/tokenPrice.go:CCIPTokenPrice - // Calculate TON token price: 2 USD with 9 decimals = 2e27 - var TONBaseAmountTokenPrice = big.NewInt(int64(TONtoUSD * (TokenPriceBaseAmount / TONtoNanoTON))) - oldTonTokenPrice := big.NewInt(0).Mul(TONBaseAmountTokenPrice, USDDecimals) - - // Calculate LINK token price: 20 USD with 9 decimals = 20e27 - // LINK has 9 decimals on TON, same as TON - oldLinkTokenPrice := big.NewInt(0).Mul(big.NewInt(20), big.NewInt(1e18)) - oldLinkTokenPrice = big.NewInt(0).Mul(oldLinkTokenPrice, big.NewInt(1e9)) // Scale from 1e18 to 1e27 - tonTokenPrice, err := config.CCIPTokenPrice("2", 9) if err != nil { return fmt.Errorf("failed to calculate TON token price: %w", err) } + // Calculate LINK token price: 20 USD with 9 decimals = 20e27 + // LINK has 9 decimals on TON, same as TON linkTokenPrice, err := config.CCIPTokenPrice("20", 9) if err != nil { return fmt.Errorf("failed to calculate LINK token price: %w", err) } - if tonTokenPrice.Cmp(oldTonTokenPrice) != 0 || linkTokenPrice.Cmp(oldLinkTokenPrice) != 0 { - errorStr := fmt.Errorf("Token price calculations should match, but got:\nTON token price: expected %s, got %s\nLINK token price: expected %s, got %s\n", oldTonTokenPrice.String(), tonTokenPrice.String(), oldLinkTokenPrice.String(), linkTokenPrice.String()) - env.Logger.Errorf(errorStr.Error()) - return errorStr - } - updateConfig := operation.UpdateFeeQuoterPricesInput{ TokenPrices: map[string]*big.Int{ tvm.TonTokenAddr.String(): tonTokenPrice,