Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions devenv/onchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -27,25 +28,17 @@ 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)))
tonTokenPrice := big.NewInt(0).Mul(TONBaseAmountTokenPrice, USDDecimals)

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 := big.NewInt(0).Mul(big.NewInt(20), big.NewInt(1e18))
linkTokenPrice = big.NewInt(0).Mul(linkTokenPrice, big.NewInt(1e9)) // Scale from 1e18 to 1e27
linkTokenPrice, err := config.CCIPTokenPrice("20", 9)
if err != nil {
return fmt.Errorf("failed to calculate LINK token price: %w", err)
}

updateConfig := operation.UpdateFeeQuoterPricesInput{
TokenPrices: map[string]*big.Int{
Expand Down
Loading