Skip to content

Commit 656121a

Browse files
add ton tokenprice default value (#663)
* add ton tokenprice default value * update
1 parent 5def0f0 commit 656121a

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

deployment/ccip/1_6_0/sequences/connect_chains.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
99
"github.com/xssnick/tonutils-go/tlb"
1010

11+
"github.com/smartcontractkit/chainlink-ton/deployment/state"
12+
1113
cldfChain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
1214
cldf_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations"
1315

@@ -79,6 +81,15 @@ func (a *TonLaneAdapter) GetDefaultGasPrice() *big.Int {
7981
return big.NewInt(2.12e9)
8082
}
8183

84+
func (a *TonLaneAdapter) GetDefaultTokenPrices() map[datastore.ContractType]*big.Int {
85+
defaultLinkPrice := new(big.Int).Mul(big.NewInt(20), big.NewInt(1e18))
86+
defaultTONPrice := new(big.Int).Mul(new(big.Int).Mul(big.NewInt(2), big.NewInt(1e18)), big.NewInt(1e9)) // 2e18 * 1e9 = 2e27, 2 is approx USD price of TON
87+
return map[datastore.ContractType]*big.Int{
88+
state.LinkToken: defaultLinkPrice,
89+
state.TONNative: defaultTONPrice,
90+
}
91+
}
92+
8293
func (a *TonLaneAdapter) ConfigureLaneLegAsSource() *cldf_ops.Sequence[lanes.UpdateLanesInput, sequences.OnChainOutput, cldfChain.BlockChains] {
8394
return ConfigureLaneLegAsSource
8495
}

deployment/ccip/cs_deploy_ton_chain.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ func (cs DeployCCIPContracts) Apply(env cldf.Environment, cfg DeployCCIPContract
7878
})
7979
}
8080

81+
// TODO: deploy TON native token
82+
if s.TONNativeAddress.IsAddrNone() {
83+
s.TONNativeAddress = *tvm.TonTokenAddr // using dummy TON address until we deploy real one
84+
_ = dataStore.Addresses().Upsert(ds.AddressRef{
85+
Address: tvm.TonTokenAddr.String(),
86+
ChainSelector: selector,
87+
Labels: ds.LabelSet{},
88+
Type: state.TONNative,
89+
Version: &state.Version1_6_0,
90+
})
91+
}
92+
8193
states[selector] = s
8294

8395
dp, err := dep.NewDependencyProvider(

deployment/ccip/sequence/deploy_ccip.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ func deployCCIPSequence(b operations.Bundle, dp *dep.DependencyProvider, in Depl
132132
})
133133
}
134134

135+
tonNativeTokenAddress := stateCCIP.TONNativeAddress
136+
if tonNativeTokenAddress.IsAddrNone() {
137+
tonNativeTokenAddress = *tvm.TonTokenAddr
138+
addresses = append(addresses, datastore.AddressRef{
139+
Address: tonNativeTokenAddress.String(),
140+
ChainSelector: in.ChainSelector,
141+
Labels: datastore.LabelSet{},
142+
Type: state.TONNative,
143+
Version: &state.Version1_6_0,
144+
})
145+
}
146+
135147
feeQuoterAddress := stateCCIP.FeeQuoter
136148
if feeQuoterAddress.IsAddrNone() {
137149
feeQuoterStorage := feequoter.Storage{

deployment/state/state.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var (
2626
MCMSVersion = *semver.MustParse("0.0.4")
2727
// Core contracts
2828
LinkToken ds.ContractType = "LinkToken"
29+
TONNative ds.ContractType = "TONNative"
2930
Router ds.ContractType = "Router"
3031
OnRamp ds.ContractType = "OnRamp"
3132
OffRamp ds.ContractType = "OffRamp"
@@ -44,6 +45,7 @@ var (
4445
// on a chain. If a binding is nil, it means there is no such contract on the chain.
4546
type CCIPChainState struct {
4647
LinkTokenAddress address.Address
48+
TONNativeAddress address.Address
4749
OffRamp address.Address
4850
Router address.Address
4951
OnRamp address.Address
@@ -192,6 +194,8 @@ func loadCCIPChainState(addresses []ds.AddressRef) (CCIPChainState, error) {
192194
switch contractType {
193195
case LinkToken:
194196
state.LinkTokenAddress = *contractAddress
197+
case TONNative:
198+
state.TONNativeAddress = *contractAddress
195199
case TonReceiver:
196200
state.ReceiverAddress = *contractAddress
197201
case OffRamp:

devenv/onchain.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/smartcontractkit/chainlink-ton/deployment/pkg/dep"
1414
"github.com/smartcontractkit/chainlink-ton/deployment/pkg/ops/ton"
1515
"github.com/smartcontractkit/chainlink-ton/deployment/state"
16-
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
1716
)
1817

1918
func (m *CCIP16TON) PreDeployContractsForSelector(ctx context.Context, env *deployment.Environment, cls []*simple_node_set.Input, selector uint64, ccipHomeSelector uint64, crAddr string) error {
@@ -49,7 +48,7 @@ func (m *CCIP16TON) PostDeployContractsForSelector(ctx context.Context, env *dep
4948

5049
updateConfig := operation.UpdateFeeQuoterPricesInput{
5150
TokenPrices: map[string]*big.Int{
52-
tvm.TonTokenAddr.String(): tonTokenPrice,
51+
stateCCIP.TONNativeAddress.String(): tonTokenPrice,
5352
stateCCIP.LinkTokenAddress.String(): linkTokenPrice,
5453
},
5554
}

0 commit comments

Comments
 (0)