-
Notifications
You must be signed in to change notification settings - Fork 31
Adding changes needed for the SetTokenTransferFee Update #1836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sowgandhi11
wants to merge
14
commits into
main
Choose a base branch
from
fix/set-token-transfer-fee-fq2.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+362
−80
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
175a2d5
Adding changes needed for the SetTokenTransferFee Update
sowgandhi11 8a389a5
Add changes for set_toke_transfer_fee.go
sowgandhi11 12a2959
Update fqRef retrieval in 2.0
sowgandhi11 ed58808
Fix filter for 1.6 fees.go
sowgandhi11 a98020e
Fix filter for 2.0 fees.go
sowgandhi11 116969f
Update sequence description
sowgandhi11 168baae
fixes in set_token_transfer_fee.go
sowgandhi11 1f6e7d1
Add GetFeeContractRef(...) to Solana 1.6 adapter
sowgandhi11 68b3b3b
Merge branch 'main' into fix/set-token-transfer-fee-fq2.0
sowgandhi11 81356d0
Fix FeeUSDCents params in 2.0
sowgandhi11 3289612
Add lookup version for 1.6
sowgandhi11 ab058dd
Add map from version -> adapter / input for batching sequences to exe…
sowgandhi11 b325c16
Add FindAndFormatRef for filtering in fees.go for all versions
sowgandhi11 5478e38
Add FindAndFormatRef for filtering in fees.go for all versions
sowgandhi11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import ( | |
| evmseq "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/sequences" | ||
| "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_3/fee_quoter" | ||
| "github.com/smartcontractkit/chainlink-ccip/deployment/fees" | ||
| datastore_utils "github.com/smartcontractkit/chainlink-ccip/deployment/utils/datastore" | ||
| "github.com/smartcontractkit/chainlink-ccip/deployment/utils/sequences" | ||
| cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" | ||
| "github.com/smartcontractkit/chainlink-deployments-framework/datastore" | ||
|
|
@@ -29,13 +30,31 @@ func NewFeesAdapter(evmAdapter *evmseq.EVMAdapter) *FeesAdapter { | |
| } | ||
| } | ||
|
|
||
| func (a *FeesAdapter) getFeeQuoterAddress(ds datastore.DataStore, src uint64) (common.Address, error) { | ||
| func (a *FeesAdapter) GetFeeContractRef(e cldf.Environment, src uint64, dst uint64) (datastore.AddressRef, error) { | ||
| ds := e.DataStore | ||
| fqAddr, err := a.evm.GetFQAddress(ds, src) | ||
| if err != nil { | ||
| return common.Address{}, fmt.Errorf("failed to get FeeQuoter address for chain selector %d: %w", src, err) | ||
| return datastore.AddressRef{}, fmt.Errorf("failed to get FeeQuoter address for chain selector %d: %w", src, err) | ||
| } | ||
|
|
||
| return common.BytesToAddress(fqAddr), nil | ||
| filter := datastore.AddressRef{ | ||
| Type: datastore.ContractType(fqops.ContractType), | ||
| Address: common.BytesToAddress(fqAddr).Hex(), | ||
| ChainSelector: src, | ||
| } | ||
| feecontractref, err := datastore_utils.FindAndFormatRef( | ||
| ds, | ||
| filter, | ||
| src, | ||
| datastore_utils.FullRef, | ||
| ) | ||
|
|
||
| if err != nil { | ||
| return datastore.AddressRef{}, fmt.Errorf("failed to find FeeQuoter address ref for chain selector %d: %w", src, err) | ||
|
|
||
| } | ||
|
|
||
| return feecontractref, nil | ||
| } | ||
|
|
||
| func (a *FeesAdapter) GetDefaultTokenTransferFeeConfig(src uint64, dst uint64) fees.TokenTransferFeeArgs { | ||
|
|
@@ -48,11 +67,12 @@ func (a *FeesAdapter) GetOnchainTokenTransferFeeConfig(e cldf.Environment, src u | |
| return fees.TokenTransferFeeArgs{}, fmt.Errorf("chain with selector %d not defined", src) | ||
| } | ||
|
|
||
| fqAddr, err := a.getFeeQuoterAddress(e.DataStore, src) | ||
| fqRef, err := a.GetFeeContractRef(e, src, dst) | ||
| if err != nil { | ||
| return fees.TokenTransferFeeArgs{}, fmt.Errorf("failed to get FeeQuoter address for chain selector %d: %w", src, err) | ||
| } | ||
|
|
||
| fqAddr := common.HexToAddress(fqRef.Address) | ||
| fq, err := fee_quoter.NewFeeQuoter(fqAddr, chain.Client) | ||
| if err != nil { | ||
| return fees.TokenTransferFeeArgs{}, fmt.Errorf("failed to instantiate FeeQuoter contract at address %s on chain selector %d: %w", fqAddr.Hex(), src, err) | ||
|
|
@@ -89,62 +109,65 @@ func (a *FeesAdapter) SetTokenTransferFee(e cldf.Environment) *operations.Sequen | |
| var result sequences.OnChainOutput | ||
| src := input.Selector | ||
|
|
||
| fqAddr, err := a.getFeeQuoterAddress(e.DataStore, src) | ||
| fqRef, err := a.GetFeeContractRef(e, src, 0) // dst is not needed to get the fee quoter address in 1.6 | ||
| if err != nil { | ||
| return sequences.OnChainOutput{}, fmt.Errorf("failed to get FeeQuoter address for chain selector %d: %w", src, err) | ||
| } | ||
|
|
||
| updatesByChain := fqops.ApplyTokenTransferFeeConfigUpdatesArgs{} | ||
| for dst, dstCfg := range input.Settings { | ||
| var tokensToUseDefaultFeeConfigs []fqops.TokenTransferFeeConfigRemoveArgs | ||
| var tokenTransferFeeConfigs []fqops.TokenTransferFeeConfigSingleTokenArgs | ||
| for rawTokenAddress, feeCfg := range dstCfg { | ||
| if !common.IsHexAddress(rawTokenAddress) { | ||
| return sequences.OnChainOutput{}, fmt.Errorf("invalid token address for src %d and dst %d: %s", src, dst, rawTokenAddress) | ||
| fqAddr := common.HexToAddress(fqRef.Address) | ||
|
|
||
| updatesByChain := fqops.ApplyTokenTransferFeeConfigUpdatesArgs{} | ||
| for dst, dstCfg := range input.Settings { | ||
|
|
||
|
Comment on lines
+120
to
+121
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small nit: is it possible to revert the formatting changes on this so the diff is smaller? For context, sometimes when debugging we need to look at past PRs to see where the issue got introduced and having a smaller diff always helps! |
||
| var tokensToUseDefaultFeeConfigs []fqops.TokenTransferFeeConfigRemoveArgs | ||
| var tokenTransferFeeConfigs []fqops.TokenTransferFeeConfigSingleTokenArgs | ||
| for rawTokenAddress, feeCfg := range dstCfg { | ||
| if !common.IsHexAddress(rawTokenAddress) { | ||
| return sequences.OnChainOutput{}, fmt.Errorf("invalid token address for src %d and dst %d: %s", src, dst, rawTokenAddress) | ||
| } | ||
|
|
||
| token := common.HexToAddress(rawTokenAddress) | ||
| if feeCfg == nil { | ||
| tokensToUseDefaultFeeConfigs = append( | ||
| tokensToUseDefaultFeeConfigs, | ||
| fqops.TokenTransferFeeConfigRemoveArgs{ | ||
| DestChainSelector: dst, | ||
| Token: token, | ||
| }, | ||
| ) | ||
| } else { | ||
| tokenTransferFeeConfigs = append( | ||
| tokenTransferFeeConfigs, | ||
| fqops.TokenTransferFeeConfigSingleTokenArgs{ | ||
| Token: token, | ||
| TokenTransferFeeConfig: fqops.TokenTransferFeeConfig{ | ||
| DestBytesOverhead: feeCfg.DestBytesOverhead, | ||
| DestGasOverhead: feeCfg.DestGasOverhead, | ||
| MinFeeUSDCents: feeCfg.MinFeeUSDCents, | ||
| MaxFeeUSDCents: feeCfg.MaxFeeUSDCents, | ||
| IsEnabled: feeCfg.IsEnabled, | ||
| DeciBps: feeCfg.DeciBps, | ||
| }, | ||
| }, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| token := common.HexToAddress(rawTokenAddress) | ||
| if feeCfg == nil { | ||
| tokensToUseDefaultFeeConfigs = append( | ||
| tokensToUseDefaultFeeConfigs, | ||
| fqops.TokenTransferFeeConfigRemoveArgs{ | ||
| DestChainSelector: dst, | ||
| Token: token, | ||
| }, | ||
| ) | ||
| } else { | ||
| tokenTransferFeeConfigs = append( | ||
| tokenTransferFeeConfigs, | ||
| fqops.TokenTransferFeeConfigSingleTokenArgs{ | ||
| Token: token, | ||
| TokenTransferFeeConfig: fqops.TokenTransferFeeConfig{ | ||
| DestBytesOverhead: feeCfg.DestBytesOverhead, | ||
| DestGasOverhead: feeCfg.DestGasOverhead, | ||
| MinFeeUSDCents: feeCfg.MinFeeUSDCents, | ||
| MaxFeeUSDCents: feeCfg.MaxFeeUSDCents, | ||
| IsEnabled: feeCfg.IsEnabled, | ||
| DeciBps: feeCfg.DeciBps, | ||
| }, | ||
| }, | ||
| ) | ||
| if len(tokensToUseDefaultFeeConfigs) > 0 { | ||
| updatesByChain.TokensToUseDefaultFeeConfigs = append(updatesByChain.TokensToUseDefaultFeeConfigs, tokensToUseDefaultFeeConfigs...) | ||
| } | ||
| } | ||
|
|
||
| if len(tokensToUseDefaultFeeConfigs) > 0 { | ||
| updatesByChain.TokensToUseDefaultFeeConfigs = append(updatesByChain.TokensToUseDefaultFeeConfigs, tokensToUseDefaultFeeConfigs...) | ||
| if len(tokenTransferFeeConfigs) > 0 { | ||
| updatesByChain.TokenTransferFeeConfigArgs = append(updatesByChain.TokenTransferFeeConfigArgs, fqops.TokenTransferFeeConfigArgs{ | ||
| TokenTransferFeeConfigs: tokenTransferFeeConfigs, | ||
| DestChainSelector: dst, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| if len(tokenTransferFeeConfigs) > 0 { | ||
| updatesByChain.TokenTransferFeeConfigArgs = append(updatesByChain.TokenTransferFeeConfigArgs, fqops.TokenTransferFeeConfigArgs{ | ||
| TokenTransferFeeConfigs: tokenTransferFeeConfigs, | ||
| DestChainSelector: dst, | ||
| }) | ||
| if len(updatesByChain.TokensToUseDefaultFeeConfigs) == 0 && len(updatesByChain.TokenTransferFeeConfigArgs) == 0 { | ||
| return result, nil | ||
| } | ||
| } | ||
|
|
||
| if len(updatesByChain.TokensToUseDefaultFeeConfigs) == 0 && len(updatesByChain.TokenTransferFeeConfigArgs) == 0 { | ||
| return result, nil | ||
| } | ||
|
|
||
| result, err = sequences.RunAndMergeSequence(b, chains, | ||
| evmseq.FeeQuoterApplyTokenTransferFeeConfigUpdatesSequence, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.