From bbc2686de9dd1f72ced3f5a3a5ac93842de5af1a Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Tue, 5 Nov 2024 22:20:27 +0100 Subject: [PATCH] chore(wallet)_: send type package simplification - path processor constants moved to wallet constants - FetchPrices and FindToken functions moved from send type package to router package --- services/wallet/api.go | 2 +- services/wallet/common/const.go | 21 +- services/wallet/common/helpers.go | 8 + .../wallet/requests/router_input_params.go | 14 +- .../router_send_transactions_params.go | 24 +- services/wallet/routeexecution/manager.go | 8 +- .../wallet/router/pathprocessor/common.go | 6 +- .../wallet/router/pathprocessor/constants.go | 28 - .../wallet/router/pathprocessor/errors.go | 21 +- .../router/pathprocessor/errors_test.go | 26 +- .../wallet/router/pathprocessor/processor.go | 10 +- .../pathprocessor/processor_bridge_celar.go | 8 +- .../pathprocessor/processor_bridge_hop.go | 8 +- .../pathprocessor/processor_ens_public_key.go | 4 +- .../pathprocessor/processor_ens_register.go | 4 +- .../pathprocessor/processor_ens_release.go | 4 +- .../router/pathprocessor/processor_erc1155.go | 4 +- .../router/pathprocessor/processor_erc721.go | 4 +- .../pathprocessor/processor_stickers_buy.go | 4 +- .../pathprocessor/processor_swap_paraswap.go | 4 +- .../processor_swap_paraswap_test.go | 8 +- .../router/pathprocessor/processor_test.go | 93 +-- .../pathprocessor/processor_transfer.go | 4 +- services/wallet/router/router.go | 20 +- services/wallet/router/router_helper.go | 54 ++ services/wallet/router/router_test_data.go | 657 +++++++++--------- services/wallet/router/sendtype/send_type.go | 82 +-- services/wallet/transfer/errors.go | 1 - services/wallet/transfer/helpers.go | 3 +- .../wallet/transfer/transaction_manager.go | 14 - .../transaction_manager_multitransaction.go | 3 +- .../transfer/transaction_manager_route.go | 23 +- 32 files changed, 590 insertions(+), 584 deletions(-) diff --git a/services/wallet/api.go b/services/wallet/api.go index 434f2d4c5..6e7abfb07 100644 --- a/services/wallet/api.go +++ b/services/wallet/api.go @@ -759,7 +759,7 @@ func (api *API) BuildTransactionsFromRoute(ctx context.Context, buildInputParams // - call `SendRouterTransactionsWithSignatures` with the signatures of signed hashes from the previous step // // TODO: remove this struct once mobile switches to the new approach -func (api *API) ProceedWithTransactionsSignatures(ctx context.Context, signatures map[string]transfer.SignatureDetails) (*transfer.MultiTransactionCommandResult, error) { +func (api *API) ProceedWithTransactionsSignatures(ctx context.Context, signatures map[string]requests.SignatureDetails) (*transfer.MultiTransactionCommandResult, error) { logutils.ZapLogger().Debug("[WalletAPI:: ProceedWithTransactionsSignatures] sign with signatures and send multi transaction") return api.s.transactionManager.ProceedWithTransactionsSignatures(ctx, signatures) } diff --git a/services/wallet/common/const.go b/services/wallet/common/const.go index d9c4703a5..57adb2724 100644 --- a/services/wallet/common/const.go +++ b/services/wallet/common/const.go @@ -13,7 +13,26 @@ type MultiTransactionIDType int64 const ( NoMultiTransactionID = MultiTransactionIDType(0) HexAddressLength = 42 - StatusDomain = "stateofus.eth" + + StatusDomain = "stateofus.eth" + EthDomain = "eth" + + EthSymbol = "ETH" + SntSymbol = "SNT" + SttSymbol = "STT" + UsdcSymbol = "USDC" + HopSymbol = "HOP" + + ProcessorTransferName = "Transfer" + ProcessorBridgeHopName = "Hop" + ProcessorBridgeCelerName = "CBridge" + ProcessorSwapParaswapName = "Paraswap" + ProcessorERC721Name = "ERC721Transfer" + ProcessorERC1155Name = "ERC1155Transfer" + ProcessorENSRegisterName = "ENSRegister" + ProcessorENSReleaseName = "ENSRelease" + ProcessorENSPublicKeyName = "ENSPublicKey" + ProcessorStickersBuyName = "StickersBuy" ) type ChainID uint64 diff --git a/services/wallet/common/helpers.go b/services/wallet/common/helpers.go index c770d337d..d275abdca 100644 --- a/services/wallet/common/helpers.go +++ b/services/wallet/common/helpers.go @@ -12,6 +12,14 @@ import ( "github.com/status-im/status-go/contracts/ierc20" ) +func IsProcessorBridge(name string) bool { + return name == ProcessorBridgeHopName || name == ProcessorBridgeCelerName +} + +func IsProcessorSwap(name string) bool { + return name == ProcessorSwapParaswapName +} + func PackApprovalInputData(amountIn *big.Int, approvalContractAddress *common.Address) ([]byte, error) { if approvalContractAddress == nil || *approvalContractAddress == ZeroAddress() { return []byte{}, nil diff --git a/services/wallet/requests/router_input_params.go b/services/wallet/requests/router_input_params.go index b6bd28b56..f0ab9adf7 100644 --- a/services/wallet/requests/router_input_params.go +++ b/services/wallet/requests/router_input_params.go @@ -8,7 +8,6 @@ import ( "github.com/status-im/status-go/errors" walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/router/fees" - "github.com/status-im/status-go/services/wallet/router/pathprocessor" "github.com/status-im/status-go/services/wallet/router/sendtype" "github.com/status-im/status-go/services/wallet/token" ) @@ -65,8 +64,8 @@ type RouteInputParams struct { type RouterTestParams struct { TokenFrom *token.Token TokenPrices map[string]float64 - EstimationMap map[string]pathprocessor.Estimation // [processor-name, estimation] - BonderFeeMap map[string]*big.Int // [token-symbol, bonder-fee] + EstimationMap map[string]Estimation // [processor-name, estimation] + BonderFeeMap map[string]*big.Int // [token-symbol, bonder-fee] SuggestedFees *fees.SuggestedFees BaseFee *big.Int BalanceMap map[string]*big.Int // [token-symbol, balance] @@ -74,17 +73,22 @@ type RouterTestParams struct { ApprovalL1Fee uint64 } +type Estimation struct { + Value uint64 + Err error +} + func (i *RouteInputParams) Validate() error { if i.SendType == sendtype.ENSRegister { if i.Username == "" || i.PublicKey == "" { return ErrENSRegisterRequiresUsernameAndPubKey } if i.TestnetMode { - if i.TokenID != pathprocessor.SttSymbol { + if i.TokenID != walletCommon.SttSymbol { return ErrENSRegisterTestnetSTTOnly } } else { - if i.TokenID != pathprocessor.SntSymbol { + if i.TokenID != walletCommon.SntSymbol { return ErrENSRegisterMainnetSNTOnly } } diff --git a/services/wallet/requests/router_send_transactions_params.go b/services/wallet/requests/router_send_transactions_params.go index bc0de61c0..a2c040cb1 100644 --- a/services/wallet/requests/router_send_transactions_params.go +++ b/services/wallet/requests/router_send_transactions_params.go @@ -1,8 +1,26 @@ package requests -import "github.com/status-im/status-go/services/wallet/transfer" +import "github.com/status-im/status-go/errors" + +var ( + ErrInvalidSignatureDetails = &errors.ErrorResponse{Code: errors.ErrorCode("WT-004"), Details: "invalid signature details"} +) type RouterSendTransactionsParams struct { - Uuid string `json:"uuid"` - Signatures map[string]transfer.SignatureDetails `json:"signatures"` + Uuid string `json:"uuid"` + Signatures map[string]SignatureDetails `json:"signatures"` +} + +type SignatureDetails struct { + R string `json:"r"` + S string `json:"s"` + V string `json:"v"` +} + +func (sd *SignatureDetails) Validate() error { + if len(sd.R) != 64 || len(sd.S) != 64 || len(sd.V) != 2 { + return ErrInvalidSignatureDetails + } + + return nil } diff --git a/services/wallet/routeexecution/manager.go b/services/wallet/routeexecution/manager.go index 6241bec5d..105117712 100644 --- a/services/wallet/routeexecution/manager.go +++ b/services/wallet/routeexecution/manager.go @@ -15,10 +15,10 @@ import ( status_common "github.com/status-im/status-go/common" statusErrors "github.com/status-im/status-go/errors" + walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/responses" "github.com/status-im/status-go/services/wallet/router" - "github.com/status-im/status-go/services/wallet/router/pathprocessor" "github.com/status-im/status-go/services/wallet/router/sendtype" "github.com/status-im/status-go/services/wallet/transfer" "github.com/status-im/status-go/signal" @@ -117,9 +117,9 @@ func (m *Manager) SendRouterTransactionsWithSignatures(ctx context.Context, send clearLocalData := true if routeInputParams.SendType == sendtype.Swap { // in case of swap don't clear local data if an approval is placed, but swap tx is not sent yet - if m.transactionManager.ApprovalRequiredForPath(pathprocessor.ProcessorSwapParaswapName) && - m.transactionManager.ApprovalPlacedForPath(pathprocessor.ProcessorSwapParaswapName) && - !m.transactionManager.TxPlacedForPath(pathprocessor.ProcessorSwapParaswapName) { + if m.transactionManager.ApprovalRequiredForPath(walletCommon.ProcessorSwapParaswapName) && + m.transactionManager.ApprovalPlacedForPath(walletCommon.ProcessorSwapParaswapName) && + !m.transactionManager.TxPlacedForPath(walletCommon.ProcessorSwapParaswapName) { clearLocalData = false } } diff --git a/services/wallet/router/pathprocessor/common.go b/services/wallet/router/pathprocessor/common.go index e1d7f213f..718cd503a 100644 --- a/services/wallet/router/pathprocessor/common.go +++ b/services/wallet/router/pathprocessor/common.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/status-im/status-go/account" "github.com/status-im/status-go/eth-node/types" + walletCommon "github.com/status-im/status-go/services/wallet/common" ) func getSigner(chainID uint64, from types.Address, verifiedAccount *account.SelectedExtKey) bind.SignerFn { @@ -32,8 +33,9 @@ func makeKey(fromChain, toChain uint64, fromTokenSymbol, toTokenSymbol string, a } func getNameFromEnsUsername(ensUsername string) string { - if strings.HasSuffix(ensUsername, StatusDomain) { - return ensUsername[:len(ensUsername)-len(StatusDomain)] + suffix := "." + walletCommon.StatusDomain + if strings.HasSuffix(ensUsername, suffix) { + return ensUsername[:len(ensUsername)-len(suffix)] } return ensUsername } diff --git a/services/wallet/router/pathprocessor/constants.go b/services/wallet/router/pathprocessor/constants.go index eea7a4d0d..c1ce112c0 100644 --- a/services/wallet/router/pathprocessor/constants.go +++ b/services/wallet/router/pathprocessor/constants.go @@ -3,32 +3,4 @@ package pathprocessor const ( IncreaseEstimatedGasFactor = 1.2 SevenDaysInSeconds = 60 * 60 * 24 * 7 - - StatusDomain = ".stateofus.eth" - EthDomain = ".eth" - - EthSymbol = "ETH" - SntSymbol = "SNT" - SttSymbol = "STT" - UsdcSymbol = "USDC" - HopSymbol = "HOP" - - ProcessorTransferName = "Transfer" - ProcessorBridgeHopName = "Hop" - ProcessorBridgeCelerName = "CBridge" - ProcessorSwapParaswapName = "Paraswap" - ProcessorERC721Name = "ERC721Transfer" - ProcessorERC1155Name = "ERC1155Transfer" - ProcessorENSRegisterName = "ENSRegister" - ProcessorENSReleaseName = "ENSRelease" - ProcessorENSPublicKeyName = "ENSPublicKey" - ProcessorStickersBuyName = "StickersBuy" ) - -func IsProcessorBridge(name string) bool { - return name == ProcessorBridgeHopName || name == ProcessorBridgeCelerName -} - -func IsProcessorSwap(name string) bool { - return name == ProcessorSwapParaswapName -} diff --git a/services/wallet/router/pathprocessor/errors.go b/services/wallet/router/pathprocessor/errors.go index 8de34d92f..0a76834e7 100644 --- a/services/wallet/router/pathprocessor/errors.go +++ b/services/wallet/router/pathprocessor/errors.go @@ -4,6 +4,7 @@ import ( "context" "github.com/status-im/status-go/errors" + walletCommon "github.com/status-im/status-go/services/wallet/common" ) // Abbreviartion `WPP` for the error code stands for `Wallet Path Processor` @@ -69,25 +70,25 @@ func createErrorResponse(processorName string, err error) error { var customErrResp *errors.ErrorResponse switch processorName { - case ProcessorTransferName: + case walletCommon.ProcessorTransferName: customErrResp = ErrTransferCustomError - case ProcessorERC721Name: + case walletCommon.ProcessorERC721Name: customErrResp = ErrERC721TransferCustomError - case ProcessorERC1155Name: + case walletCommon.ProcessorERC1155Name: customErrResp = ErrERC1155TransferCustomError - case ProcessorBridgeHopName: + case walletCommon.ProcessorBridgeHopName: customErrResp = ErrBridgeHopCustomError - case ProcessorBridgeCelerName: + case walletCommon.ProcessorBridgeCelerName: customErrResp = ErrBridgeCellerCustomError - case ProcessorSwapParaswapName: + case walletCommon.ProcessorSwapParaswapName: customErrResp = ErrSwapParaswapCustomError - case ProcessorENSRegisterName: + case walletCommon.ProcessorENSRegisterName: customErrResp = ErrENSRegisterCustomError - case ProcessorENSReleaseName: + case walletCommon.ProcessorENSReleaseName: customErrResp = ErrENSReleaseCustomError - case ProcessorENSPublicKeyName: + case walletCommon.ProcessorENSPublicKeyName: customErrResp = ErrENSPublicKeyCustomError - case ProcessorStickersBuyName: + case walletCommon.ProcessorStickersBuyName: customErrResp = ErrStickersBuyCustomError default: return genericErrResp diff --git a/services/wallet/router/pathprocessor/errors_test.go b/services/wallet/router/pathprocessor/errors_test.go index 550d25127..364cd0967 100644 --- a/services/wallet/router/pathprocessor/errors_test.go +++ b/services/wallet/router/pathprocessor/errors_test.go @@ -7,6 +7,8 @@ import ( s_errors "github.com/status-im/status-go/errors" + walletCommon "github.com/status-im/status-go/services/wallet/common" + "github.com/stretchr/testify/require" ) @@ -15,17 +17,17 @@ func TestPlainError(t *testing.T) { err := errors.New(errString) processorNames := []string{ - ProcessorTransferName, - ProcessorTransferName, - ProcessorBridgeHopName, - ProcessorBridgeCelerName, - ProcessorSwapParaswapName, - ProcessorERC721Name, - ProcessorERC1155Name, - ProcessorENSRegisterName, - ProcessorENSReleaseName, - ProcessorENSPublicKeyName, - ProcessorStickersBuyName, + walletCommon.ProcessorTransferName, + walletCommon.ProcessorTransferName, + walletCommon.ProcessorBridgeHopName, + walletCommon.ProcessorBridgeCelerName, + walletCommon.ProcessorSwapParaswapName, + walletCommon.ProcessorERC721Name, + walletCommon.ProcessorERC1155Name, + walletCommon.ProcessorENSRegisterName, + walletCommon.ProcessorENSReleaseName, + walletCommon.ProcessorENSPublicKeyName, + walletCommon.ProcessorStickersBuyName, } for _, processorName := range processorNames { @@ -62,7 +64,7 @@ func TestNonGenericErrorResponse(t *testing.T) { Details: "Not Generic Error Response", } err := s_errors.CreateErrorResponseFromError(errResp) - ppErrResp := createErrorResponse(ProcessorTransferName, err) + ppErrResp := createErrorResponse(walletCommon.ProcessorTransferName, err) castPPErrResp := ppErrResp.(*s_errors.ErrorResponse) require.Equal(t, errResp.Code, castPPErrResp.Code) diff --git a/services/wallet/router/pathprocessor/processor.go b/services/wallet/router/pathprocessor/processor.go index 439b0091b..4f188019f 100644 --- a/services/wallet/router/pathprocessor/processor.go +++ b/services/wallet/router/pathprocessor/processor.go @@ -11,6 +11,7 @@ import ( "github.com/status-im/status-go/account" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/params" + "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/token" "github.com/status-im/status-go/transactions" ) @@ -61,13 +62,8 @@ type ProcessorInputParams struct { // for testing purposes TestsMode bool - TestEstimationMap map[string]Estimation // [bridge-name, estimation] - TestBonderFeeMap map[string]*big.Int // [token-symbol, bonder-fee] + TestEstimationMap map[string]requests.Estimation // [bridge-name, estimation] + TestBonderFeeMap map[string]*big.Int // [token-symbol, bonder-fee] TestApprovalGasEstimation uint64 TestApprovalL1Fee uint64 } - -type Estimation struct { - Value uint64 - Err error -} diff --git a/services/wallet/router/pathprocessor/processor_bridge_celar.go b/services/wallet/router/pathprocessor/processor_bridge_celar.go index a4941a8aa..df835e5d0 100644 --- a/services/wallet/router/pathprocessor/processor_bridge_celar.go +++ b/services/wallet/router/pathprocessor/processor_bridge_celar.go @@ -64,11 +64,11 @@ func NewCelerBridgeProcessor(rpcClient *rpc.Client, transactor transactions.Tran } func createBridgeCellerErrorResponse(err error) error { - return createErrorResponse(ProcessorBridgeCelerName, err) + return createErrorResponse(walletCommon.ProcessorBridgeCelerName, err) } func (s *CelerBridgeProcessor) Name() string { - return ProcessorBridgeCelerName + return walletCommon.ProcessorBridgeCelerName } func (s *CelerBridgeProcessor) estimateAmt(from, to *params.Network, amountIn *big.Int, symbol string) (*cbridge.EstimateAmtResponse, error) { @@ -147,11 +147,11 @@ func (s *CelerBridgeProcessor) AvailableFor(params ProcessorInputParams) (bool, var fromAvailable *cbridge.Chain var toAvailable *cbridge.Chain for _, chain := range transferConfig.Chains { - if uint64(chain.GetId()) == params.FromChain.ChainID && chain.GasTokenSymbol == EthSymbol { + if uint64(chain.GetId()) == params.FromChain.ChainID && chain.GasTokenSymbol == walletCommon.EthSymbol { fromAvailable = chain } - if uint64(chain.GetId()) == params.ToChain.ChainID && chain.GasTokenSymbol == EthSymbol { + if uint64(chain.GetId()) == params.ToChain.ChainID && chain.GasTokenSymbol == walletCommon.EthSymbol { toAvailable = chain } } diff --git a/services/wallet/router/pathprocessor/processor_bridge_hop.go b/services/wallet/router/pathprocessor/processor_bridge_hop.go index 5a276374e..328261cc4 100644 --- a/services/wallet/router/pathprocessor/processor_bridge_hop.go +++ b/services/wallet/router/pathprocessor/processor_bridge_hop.go @@ -126,11 +126,11 @@ func NewHopBridgeProcessor(rpcClient rpc.ClientInterface, transactor transaction } func createBridgeHopErrorResponse(err error) error { - return createErrorResponse(ProcessorBridgeHopName, err) + return createErrorResponse(walletCommon.ProcessorBridgeHopName, err) } func (h *HopBridgeProcessor) Name() string { - return ProcessorBridgeHopName + return walletCommon.ProcessorBridgeHopName } func (h *HopBridgeProcessor) Clear() { @@ -164,7 +164,7 @@ func (c *HopBridgeProcessor) getAppropriateABI(contractType string, chainID uint if token.IsNative() { return abi.JSON(strings.NewReader(hopL1EthBridge.HopL1EthBridgeABI)) } - if token.Symbol == HopSymbol { + if token.Symbol == walletCommon.HopSymbol { return abi.JSON(strings.NewReader(hopL1HopBridge.HopL1HopBridgeABI)) } return abi.JSON(strings.NewReader(hopL1Erc20Bridge.HopL1Erc20BridgeABI)) @@ -575,7 +575,7 @@ func (h *HopBridgeProcessor) sendL1BridgeTx(contractAddress common.Address, ethC walletCommon.ZeroBigIntValue()) } - if token.Symbol == HopSymbol { + if token.Symbol == walletCommon.HopSymbol { contractInstance, err := hopL1HopBridge.NewHopL1HopBridge( contractAddress, ethClient, diff --git a/services/wallet/router/pathprocessor/processor_ens_public_key.go b/services/wallet/router/pathprocessor/processor_ens_public_key.go index 709f8ec6d..4017cde91 100644 --- a/services/wallet/router/pathprocessor/processor_ens_public_key.go +++ b/services/wallet/router/pathprocessor/processor_ens_public_key.go @@ -36,11 +36,11 @@ func NewENSPublicKeyProcessor(rpcClient *rpc.Client, transactor transactions.Tra } func createENSPublicKeyErrorResponse(err error) error { - return createErrorResponse(ProcessorENSPublicKeyName, err) + return createErrorResponse(walletCommon.ProcessorENSPublicKeyName, err) } func (s *ENSPublicKeyProcessor) Name() string { - return ProcessorENSPublicKeyName + return walletCommon.ProcessorENSPublicKeyName } func (s *ENSPublicKeyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { diff --git a/services/wallet/router/pathprocessor/processor_ens_register.go b/services/wallet/router/pathprocessor/processor_ens_register.go index 9544e734e..5df64a17c 100644 --- a/services/wallet/router/pathprocessor/processor_ens_register.go +++ b/services/wallet/router/pathprocessor/processor_ens_register.go @@ -38,11 +38,11 @@ func NewENSRegisterProcessor(rpcClient *rpc.Client, transactor transactions.Tran } func createENSRegisterProcessorErrorResponse(err error) error { - return createErrorResponse(ProcessorENSRegisterName, err) + return createErrorResponse(walletCommon.ProcessorENSRegisterName, err) } func (s *ENSRegisterProcessor) Name() string { - return ProcessorENSRegisterName + return walletCommon.ProcessorENSRegisterName } func (s *ENSRegisterProcessor) GetPriceForRegisteringEnsName(chainID uint64) (*big.Int, error) { diff --git a/services/wallet/router/pathprocessor/processor_ens_release.go b/services/wallet/router/pathprocessor/processor_ens_release.go index 16edd3ea0..51731459d 100644 --- a/services/wallet/router/pathprocessor/processor_ens_release.go +++ b/services/wallet/router/pathprocessor/processor_ens_release.go @@ -36,11 +36,11 @@ func NewENSReleaseProcessor(rpcClient *rpc.Client, transactor transactions.Trans } func createENSReleaseErrorResponse(err error) error { - return createErrorResponse(ProcessorENSReleaseName, err) + return createErrorResponse(walletCommon.ProcessorENSReleaseName, err) } func (s *ENSReleaseProcessor) Name() string { - return ProcessorENSReleaseName + return walletCommon.ProcessorENSReleaseName } func (s *ENSReleaseProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { diff --git a/services/wallet/router/pathprocessor/processor_erc1155.go b/services/wallet/router/pathprocessor/processor_erc1155.go index 68531c93f..91014d7cd 100644 --- a/services/wallet/router/pathprocessor/processor_erc1155.go +++ b/services/wallet/router/pathprocessor/processor_erc1155.go @@ -36,11 +36,11 @@ func NewERC1155Processor(rpcClient *rpc.Client, transactor transactions.Transact } func createERC1155ErrorResponse(err error) error { - return createErrorResponse(ProcessorERC1155Name, err) + return createErrorResponse(walletCommon.ProcessorERC1155Name, err) } func (s *ERC1155Processor) Name() string { - return ProcessorERC1155Name + return walletCommon.ProcessorERC1155Name } func (s *ERC1155Processor) AvailableFor(params ProcessorInputParams) (bool, error) { diff --git a/services/wallet/router/pathprocessor/processor_erc721.go b/services/wallet/router/pathprocessor/processor_erc721.go index ff46911c3..eb9585963 100644 --- a/services/wallet/router/pathprocessor/processor_erc721.go +++ b/services/wallet/router/pathprocessor/processor_erc721.go @@ -43,11 +43,11 @@ func NewERC721Processor(rpcClient *rpc.Client, transactor transactions.Transacto } func createERC721ErrorResponse(err error) error { - return createErrorResponse(ProcessorERC721Name, err) + return createErrorResponse(walletCommon.ProcessorERC721Name, err) } func (s *ERC721Processor) Name() string { - return ProcessorERC721Name + return walletCommon.ProcessorERC721Name } func (s *ERC721Processor) AvailableFor(params ProcessorInputParams) (bool, error) { diff --git a/services/wallet/router/pathprocessor/processor_stickers_buy.go b/services/wallet/router/pathprocessor/processor_stickers_buy.go index 40c717ded..1b1d93ad5 100644 --- a/services/wallet/router/pathprocessor/processor_stickers_buy.go +++ b/services/wallet/router/pathprocessor/processor_stickers_buy.go @@ -35,11 +35,11 @@ func NewStickersBuyProcessor(rpcClient *rpc.Client, transactor transactions.Tran } func createStickersBuyErrorResponse(err error) error { - return createErrorResponse(ProcessorStickersBuyName, err) + return createErrorResponse(walletCommon.ProcessorStickersBuyName, err) } func (s *StickersBuyProcessor) Name() string { - return ProcessorStickersBuyName + return walletCommon.ProcessorStickersBuyName } func (s *StickersBuyProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { diff --git a/services/wallet/router/pathprocessor/processor_swap_paraswap.go b/services/wallet/router/pathprocessor/processor_swap_paraswap.go index 07c440327..b0f6234d4 100644 --- a/services/wallet/router/pathprocessor/processor_swap_paraswap.go +++ b/services/wallet/router/pathprocessor/processor_swap_paraswap.go @@ -76,11 +76,11 @@ func createSwapParaswapErrorResponse(err error) error { case "ESTIMATED_LOSS_GREATER_THAN_MAX_IMPACT": return ErrPriceImpactTooHigh } - return createErrorResponse(ProcessorSwapParaswapName, err) + return createErrorResponse(walletCommon.ProcessorSwapParaswapName, err) } func (s *SwapParaswapProcessor) Name() string { - return ProcessorSwapParaswapName + return walletCommon.ProcessorSwapParaswapName } func (s *SwapParaswapProcessor) Clear() { diff --git a/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go b/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go index 56f38bcff..ae4593e00 100644 --- a/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go +++ b/services/wallet/router/pathprocessor/processor_swap_paraswap_test.go @@ -36,10 +36,10 @@ func TestParaswapWithPartnerFee(t *testing.T) { processor := NewSwapParaswapProcessor(nil, nil, nil) fromToken := token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, } toToken := token.Token{ - Symbol: UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, } chainIDs := []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet, walletCommon.OptimismMainnet, walletCommon.UnknownChainID} @@ -107,10 +107,10 @@ func TestParaswapErrors(t *testing.T) { processor.paraswapClient = client fromToken := token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, } toToken := token.Token{ - Symbol: UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, } chainID := walletCommon.EthereumMainnet diff --git a/services/wallet/router/pathprocessor/processor_test.go b/services/wallet/router/pathprocessor/processor_test.go index dd8131487..596ca6dd6 100644 --- a/services/wallet/router/pathprocessor/processor_test.go +++ b/services/wallet/router/pathprocessor/processor_test.go @@ -6,6 +6,7 @@ import ( "github.com/status-im/status-go/params" walletCommon "github.com/status-im/status-go/services/wallet/common" + "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/token" "github.com/stretchr/testify/assert" @@ -43,10 +44,10 @@ var optimism = params.Network{ RelatedChainID: walletCommon.OptimismMainnet, } -var testEstimationMap = map[string]Estimation{ - ProcessorTransferName: {uint64(1000), nil}, - ProcessorBridgeHopName: {uint64(5000), nil}, - ProcessorSwapParaswapName: {uint64(2000), nil}, +var testEstimationMap = map[string]requests.Estimation{ + walletCommon.ProcessorTransferName: {Value: uint64(1000)}, + walletCommon.ProcessorBridgeHopName: {Value: uint64(5000)}, + walletCommon.ProcessorSwapParaswapName: {Value: uint64(2000)}, } type expectedResult struct { @@ -67,15 +68,15 @@ func TestPathProcessors(t *testing.T) { TestsMode: true, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: ErrNoChainSet, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrNoChainSet, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrNoChainSet, }, @@ -90,15 +91,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: ErrNoTokenSet, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrNoTokenSet, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrToAndFromTokensMustBeSet, }, @@ -111,20 +112,20 @@ func TestPathProcessors(t *testing.T) { FromChain: &mainnet, ToChain: &mainnet, FromToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: true, expectedError: nil, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrFromAndToChainsMustBeDifferent, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrToAndFromTokensMustBeSet, }, @@ -137,23 +138,23 @@ func TestPathProcessors(t *testing.T) { FromChain: &mainnet, ToChain: &mainnet, FromToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, ToToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToTokensMustBeDifferent, }, @@ -166,23 +167,23 @@ func TestPathProcessors(t *testing.T) { FromChain: &mainnet, ToChain: &mainnet, FromToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, ToToken: &token.Token{ - Symbol: UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, }, TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: true, expectedError: nil, }, @@ -197,15 +198,15 @@ func TestPathProcessors(t *testing.T) { TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: ErrNoTokenSet, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrNoTokenSet, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -218,20 +219,20 @@ func TestPathProcessors(t *testing.T) { FromChain: &mainnet, ToChain: &optimism, FromToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: nil, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: true, expectedError: nil, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -244,23 +245,23 @@ func TestPathProcessors(t *testing.T) { FromChain: &mainnet, ToChain: &optimism, FromToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, ToToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -273,23 +274,23 @@ func TestPathProcessors(t *testing.T) { FromChain: &mainnet, ToChain: &optimism, FromToken: &token.Token{ - Symbol: EthSymbol, + Symbol: walletCommon.EthSymbol, }, ToToken: &token.Token{ - Symbol: UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, }, TestEstimationMap: testEstimationMap, }, expected: map[string]expectedResult{ - ProcessorTransferName: { + walletCommon.ProcessorTransferName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorBridgeHopName: { + walletCommon.ProcessorBridgeHopName: { expected: false, expectedError: ErrToTokenShouldNotBeSet, }, - ProcessorSwapParaswapName: { + walletCommon.ProcessorSwapParaswapName: { expected: false, expectedError: ErrFromAndToChainsMustBeSame, }, @@ -302,11 +303,11 @@ func TestPathProcessors(t *testing.T) { t.Run(fmt.Sprintf("%s[%s]", processorName, tt.name), func(t *testing.T) { var processor PathProcessor - if processorName == ProcessorTransferName { + if processorName == walletCommon.ProcessorTransferName { processor = NewTransferProcessor(nil, nil) - } else if processorName == ProcessorBridgeHopName { + } else if processorName == walletCommon.ProcessorBridgeHopName { processor = NewHopBridgeProcessor(nil, nil, nil, nil) - } else if processorName == ProcessorSwapParaswapName { + } else if processorName == walletCommon.ProcessorSwapParaswapName { processor = NewSwapParaswapProcessor(nil, nil, nil) } @@ -325,8 +326,8 @@ func TestPathProcessors(t *testing.T) { assert.Greater(t, estimatedGas, uint64(0)) input := tt.input - input.TestEstimationMap = map[string]Estimation{ - "randomName": {10000, nil}, + input.TestEstimationMap = map[string]requests.Estimation{ + "randomName": {Value: 10000}, } estimatedGas, err = processor.EstimateGas(input) assert.Error(t, err) diff --git a/services/wallet/router/pathprocessor/processor_transfer.go b/services/wallet/router/pathprocessor/processor_transfer.go index 7e1e3faa6..07521fcf4 100644 --- a/services/wallet/router/pathprocessor/processor_transfer.go +++ b/services/wallet/router/pathprocessor/processor_transfer.go @@ -27,11 +27,11 @@ func NewTransferProcessor(rpcClient *rpc.Client, transactor transactions.Transac } func createTransferErrorResponse(err error) error { - return createErrorResponse(ProcessorTransferName, err) + return createErrorResponse(walletCommon.ProcessorTransferName, err) } func (s *TransferProcessor) Name() string { - return ProcessorTransferName + return walletCommon.ProcessorTransferName } func (s *TransferProcessor) AvailableFor(params ProcessorInputParams) (bool, error) { diff --git a/services/wallet/router/router.go b/services/wallet/router/router.go index f8c2800b6..85a44343e 100644 --- a/services/wallet/router/router.go +++ b/services/wallet/router/router.go @@ -356,7 +356,7 @@ func (r *Router) prepareBalanceMapForTokenOnChains(ctx context.Context, input *r for _, chain := range selectedFromChains { // check token existence - token := input.SendType.FindToken(r.tokenManager, r.collectiblesService, input.AddrFrom, chain, input.TokenID) + token := findToken(input.SendType, r.tokenManager, r.collectiblesService, input.AddrFrom, chain, input.TokenID) if token == nil { chainError(chain.ChainID, input.TokenID, ErrTokenNotFound) continue @@ -629,14 +629,14 @@ func (r *Router) resolveCandidates(ctx context.Context, input *requests.RouteInp if testsMode { token = input.TestParams.TokenFrom } else { - token = input.SendType.FindToken(r.tokenManager, r.collectiblesService, input.AddrFrom, network, input.TokenID) + token = findToken(input.SendType, r.tokenManager, r.collectiblesService, input.AddrFrom, network, input.TokenID) } if token == nil { continue } if input.SendType == sendtype.Swap { - toToken = input.SendType.FindToken(r.tokenManager, r.collectiblesService, common.Address{}, network, input.ToTokenID) + toToken = findToken(input.SendType, r.tokenManager, r.collectiblesService, common.Address{}, network, input.ToTokenID) } var fetchedFees *fees.SuggestedFees @@ -668,12 +668,12 @@ func (r *Router) resolveCandidates(ctx context.Context, input *requests.RouteInp // 6. ... // // With the current routing algorithm atm we're not able to generate all possible routes. - if !input.SendType.CanUseProcessor(pProcessor) { + if !input.SendType.CanUseProcessor(pProcessor.Name()) { continue } // if we're doing a single chain operation, we can skip bridge processors - if walletCommon.IsSingleChainOperation(selectedFromChains, selectedToChains) && pathprocessor.IsProcessorBridge(pProcessor.Name()) { + if walletCommon.IsSingleChainOperation(selectedFromChains, selectedToChains) && walletCommon.IsProcessorBridge(pProcessor.Name()) { continue } @@ -840,7 +840,7 @@ func (r *Router) checkBalancesForTheBestRoute(ctx context.Context, bestRoute rou } } - if path.ProcessorName == pathprocessor.ProcessorBridgeHopName { + if path.ProcessorName == walletCommon.ProcessorBridgeHopName { if path.TxBonderFees.ToInt().Cmp(path.AmountOut.ToInt()) > 0 { return hasPositiveBalance, ErrLowAmountInForHopBridge } @@ -861,12 +861,12 @@ func (r *Router) checkBalancesForTheBestRoute(ctx context.Context, bestRoute rou } } - ethKey := makeBalanceKey(path.FromChain.ChainID, pathprocessor.EthSymbol) + ethKey := makeBalanceKey(path.FromChain.ChainID, walletCommon.EthSymbol) if nativeBalance, ok := balanceMapCopy[ethKey]; ok { if nativeBalance.Cmp(path.RequiredNativeBalance) == -1 { err := &errors.ErrorResponse{ Code: ErrNotEnoughNativeBalance.Code, - Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, pathprocessor.EthSymbol, path.FromChain.ChainID), + Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, walletCommon.EthSymbol, path.FromChain.ChainID), } return hasPositiveBalance, err } @@ -884,14 +884,14 @@ func (r *Router) resolveRoutes(ctx context.Context, input *requests.RouteInputPa if input.TestsMode { prices = input.TestParams.TokenPrices } else { - prices, err = input.SendType.FetchPrices(r.marketManager, []string{input.TokenID, input.ToTokenID}) + prices, err = fetchPrices(input.SendType, r.marketManager, []string{input.TokenID, input.ToTokenID}) if err != nil { return nil, errors.CreateErrorResponseFromError(err) } } tokenPrice := prices[input.TokenID] - nativeTokenPrice := prices[pathprocessor.EthSymbol] + nativeTokenPrice := prices[walletCommon.EthSymbol] var allRoutes []routes.Route suggestedRoutes, allRoutes = newSuggestedRoutes(input, candidates, prices) diff --git a/services/wallet/router/router_helper.go b/services/wallet/router/router_helper.go index 2468602de..7a6c68bb3 100644 --- a/services/wallet/router/router_helper.go +++ b/services/wallet/router/router_helper.go @@ -4,6 +4,8 @@ import ( "context" "errors" "math/big" + "slices" + "strings" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -13,7 +15,9 @@ import ( gaspriceoracle "github.com/status-im/status-go/contracts/gas-price-oracle" "github.com/status-im/status-go/params" "github.com/status-im/status-go/services/wallet/bigint" + "github.com/status-im/status-go/services/wallet/collectibles" walletCommon "github.com/status-im/status-go/services/wallet/common" + "github.com/status-im/status-go/services/wallet/market" "github.com/status-im/status-go/services/wallet/router/fees" "github.com/status-im/status-go/services/wallet/router/pathprocessor" routs "github.com/status-im/status-go/services/wallet/router/routes" @@ -236,3 +240,53 @@ func (r *Router) cacluateFees(ctx context.Context, path *routs.Path, fetchedFees return nil } + +func findToken(sendType sendtype.SendType, tokenManager *token.Manager, collectibles *collectibles.Service, account common.Address, network *params.Network, tokenID string) *token.Token { + if !sendType.IsCollectiblesTransfer() { + return tokenManager.FindToken(network, tokenID) + } + + parts := strings.Split(tokenID, ":") + contractAddress := common.HexToAddress(parts[0]) + collectibleTokenID, success := new(big.Int).SetString(parts[1], 10) + if !success { + return nil + } + uniqueID, err := collectibles.GetOwnedCollectible(walletCommon.ChainID(network.ChainID), account, contractAddress, collectibleTokenID) + if err != nil || uniqueID == nil { + return nil + } + + return &token.Token{ + Address: contractAddress, + Symbol: collectibleTokenID.String(), + Decimals: 0, + ChainID: network.ChainID, + } +} + +func fetchPrices(sendType sendtype.SendType, marketManager *market.Manager, tokenIDs []string) (map[string]float64, error) { + nonUniqueSymbols := append(tokenIDs, "ETH") + // remove duplicate enteries + slices.Sort(nonUniqueSymbols) + symbols := slices.Compact(nonUniqueSymbols) + if sendType.IsCollectiblesTransfer() { + symbols = []string{"ETH"} + } + + pricesMap, err := marketManager.GetOrFetchPrices(symbols, []string{"USD"}, market.MaxAgeInSecondsForFresh) + + if err != nil { + return nil, err + } + prices := make(map[string]float64, 0) + for symbol, pricePerCurrency := range pricesMap { + prices[symbol] = pricePerCurrency["USD"].Price + } + if sendType.IsCollectiblesTransfer() { + for _, tokenID := range tokenIDs { + prices[tokenID] = 0 + } + } + return prices, nil +} diff --git a/services/wallet/router/router_test_data.go b/services/wallet/router/router_test_data.go index da2d7f1df..61899bb24 100644 --- a/services/wallet/router/router_test_data.go +++ b/services/wallet/router/router_test_data.go @@ -14,7 +14,6 @@ import ( walletCommon "github.com/status-im/status-go/services/wallet/common" "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/router/fees" - "github.com/status-im/status-go/services/wallet/router/pathprocessor" "github.com/status-im/status-go/services/wallet/router/routes" "github.com/status-im/status-go/services/wallet/router/sendtype" "github.com/status-im/status-go/services/wallet/token" @@ -51,19 +50,19 @@ const ( ) var ( - testEstimationMap = map[string]pathprocessor.Estimation{ - pathprocessor.ProcessorTransferName: {Value: uint64(1000), Err: nil}, - pathprocessor.ProcessorBridgeHopName: {Value: uint64(5000), Err: nil}, + testEstimationMap = map[string]requests.Estimation{ + walletCommon.ProcessorTransferName: {Value: uint64(1000), Err: nil}, + walletCommon.ProcessorBridgeHopName: {Value: uint64(5000), Err: nil}, } testBBonderFeeMap = map[string]*big.Int{ - pathprocessor.EthSymbol: big.NewInt(testBonderFeeETH), - pathprocessor.UsdcSymbol: big.NewInt(testBonderFeeUSDC), + walletCommon.EthSymbol: big.NewInt(testBonderFeeETH), + walletCommon.UsdcSymbol: big.NewInt(testBonderFeeUSDC), } testTokenPrices = map[string]float64{ - pathprocessor.EthSymbol: 2000, - pathprocessor.UsdcSymbol: 1, + walletCommon.EthSymbol: 2000, + walletCommon.UsdcSymbol: 1, } testSuggestedFees = &fees.SuggestedFees{ @@ -79,12 +78,12 @@ var ( } testBalanceMapPerChain = map[string]*big.Int{ - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount2ETHInWei), - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount2ETHInWei), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount2ETHInWei), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount2ETHInWei), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(testAmount2ETHInWei), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount2ETHInWei), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC), } ) @@ -174,7 +173,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -182,14 +181,14 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, SuggestedFees: testSuggestedFees, BalanceMap: testBalanceMapPerChain, - EstimationMap: map[string]pathprocessor.Estimation{ - pathprocessor.ProcessorTransferName: { + EstimationMap: map[string]requests.Estimation{ + walletCommon.ProcessorTransferName: { Value: uint64(0), Err: fmt.Errorf("failed with 50000000 gas: insufficient funds for gas * price + value: address %s have 68251537427723 want 100000000000000", common.HexToAddress("0x1")), }, @@ -214,13 +213,13 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(0)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -234,19 +233,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -262,13 +261,13 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -282,55 +281,55 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -346,14 +345,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -368,19 +367,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -396,14 +395,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -418,37 +417,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -464,14 +463,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -487,19 +486,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -515,14 +514,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -537,37 +536,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: false, @@ -583,7 +582,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, @@ -591,7 +590,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -606,7 +605,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -622,7 +621,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -630,7 +629,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -645,7 +644,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -661,7 +660,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, @@ -669,7 +668,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -684,7 +683,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -700,7 +699,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet}, @@ -708,7 +707,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -723,25 +722,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -757,7 +756,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -765,7 +764,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -780,7 +779,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: false, @@ -796,7 +795,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -804,7 +803,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -830,7 +829,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.EthereumMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), }, @@ -839,7 +838,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -854,63 +853,63 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei - testBonderFeeETH)), @@ -927,7 +926,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.EthereumMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), @@ -938,7 +937,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -953,21 +952,21 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei - testAmount0Point2ETHInWei - testAmount0Point3ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), //(*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), //(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), //(*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), @@ -984,7 +983,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.EthereumMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), @@ -994,7 +993,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -1009,63 +1008,63 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), @@ -1082,7 +1081,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.EthereumMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), @@ -1093,7 +1092,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -1108,63 +1107,63 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei - testBonderFeeETH)), @@ -1181,7 +1180,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.EthereumMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point2ETHInWei)), walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), @@ -1192,7 +1191,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -1217,7 +1216,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point3ETHInWei)), walletCommon.ArbitrumMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point8ETHInWei)), @@ -1227,7 +1226,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -1252,13 +1251,13 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1273,55 +1272,55 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1337,14 +1336,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1359,19 +1358,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1387,14 +1386,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1409,37 +1408,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1455,14 +1454,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1477,19 +1476,19 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1505,14 +1504,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1527,37 +1526,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -1573,7 +1572,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, @@ -1581,7 +1580,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1596,7 +1595,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -1612,7 +1611,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -1620,7 +1619,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1635,7 +1634,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1651,7 +1650,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, @@ -1659,7 +1658,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1674,7 +1673,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, @@ -1690,7 +1689,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet}, @@ -1698,7 +1697,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1713,25 +1712,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1747,7 +1746,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -1755,7 +1754,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1770,7 +1769,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -1786,7 +1785,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -1794,7 +1793,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1819,13 +1818,13 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(2.5 * testAmount100USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -1840,168 +1839,168 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(2.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &mainnet, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(0.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(2.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(0.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &arbitrum, ToChain: &arbitrum, AmountOut: (*hexutil.Big)(big.NewInt(2.5 * testAmount100USDC)), ApprovalRequired: false, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(0.5*testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(testAmount100USDC - testBonderFeeUSDC)), ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, AmountOut: (*hexutil.Big)(big.NewInt(2.5*testAmount100USDC - testBonderFeeUSDC)), @@ -2018,13 +2017,13 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2039,37 +2038,37 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2085,14 +2084,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2107,13 +2106,13 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2129,14 +2128,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2151,25 +2150,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2185,14 +2184,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2207,13 +2206,13 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2229,14 +2228,14 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2251,25 +2250,25 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &optimism, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2285,7 +2284,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, @@ -2293,7 +2292,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2318,7 +2317,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -2326,7 +2325,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2341,7 +2340,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2357,7 +2356,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, @@ -2365,7 +2364,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2390,7 +2389,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet}, @@ -2398,7 +2397,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2413,13 +2412,13 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &arbitrum, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2435,7 +2434,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -2443,7 +2442,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2458,7 +2457,7 @@ func getNormalTestParamsList() []normalTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2474,7 +2473,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -2482,7 +2481,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2507,7 +2506,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount3ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, @@ -2515,7 +2514,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, TokenPrices: testTokenPrices, @@ -2529,11 +2528,11 @@ func getNormalTestParamsList() []normalTestParams { }, expectedError: &errors.ErrorResponse{ Code: ErrNotEnoughNativeBalance.Code, - Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, pathprocessor.EthSymbol, walletCommon.EthereumMainnet), + Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, walletCommon.EthSymbol, walletCommon.EthereumMainnet), }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: false, @@ -2549,7 +2548,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(5 * testAmount100USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, @@ -2557,7 +2556,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2571,11 +2570,11 @@ func getNormalTestParamsList() []normalTestParams { }, expectedError: &errors.ErrorResponse{ Code: ErrNotEnoughTokenBalance.Code, - Details: fmt.Sprintf(ErrNotEnoughTokenBalance.Details, pathprocessor.UsdcSymbol, walletCommon.EthereumMainnet), + Details: fmt.Sprintf(ErrNotEnoughTokenBalance.Details, walletCommon.UsdcSymbol, walletCommon.EthereumMainnet), }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, @@ -2591,7 +2590,7 @@ func getNormalTestParamsList() []normalTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(0.01 * testAmount1USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.OptimismMainnet}, DisabledToChainIDs: []uint64{walletCommon.OptimismMainnet, walletCommon.ArbitrumMainnet}, @@ -2599,7 +2598,7 @@ func getNormalTestParamsList() []normalTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, @@ -2615,7 +2614,7 @@ func getNormalTestParamsList() []normalTestParams { expectedError: ErrLowAmountInForHopBridge, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &mainnet, ApprovalRequired: true, @@ -2644,7 +2643,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount100USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, @@ -2652,13 +2651,13 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, SuggestedFees: testSuggestedFees, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.UsdcSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.UsdcSymbol): big.NewInt(0), }, EstimationMap: testEstimationMap, BonderFeeMap: testBBonderFeeMap, @@ -2677,7 +2676,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount100USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, @@ -2685,14 +2684,14 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, SuggestedFees: testSuggestedFees, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(0), }, EstimationMap: testEstimationMap, BonderFeeMap: testBBonderFeeMap, @@ -2702,11 +2701,11 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedError: &errors.ErrorResponse{ Code: ErrNotEnoughNativeBalance.Code, - Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, pathprocessor.EthSymbol, walletCommon.OptimismMainnet), + Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, walletCommon.EthSymbol, walletCommon.OptimismMainnet), }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, @@ -2724,25 +2723,25 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount100USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, SuggestedFees: testSuggestedFees, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.UsdcSymbol): big.NewInt(0), - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.EthSymbol): big.NewInt(0), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.UsdcSymbol): big.NewInt(0), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(0), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.UsdcSymbol): big.NewInt(0), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.UsdcSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.EthSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.UsdcSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.UsdcSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(0), }, EstimationMap: testEstimationMap, BonderFeeMap: testBBonderFeeMap, @@ -2761,25 +2760,25 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount100USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, SuggestedFees: testSuggestedFees, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(0), - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.EthSymbol): big.NewInt(0), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.EthSymbol): big.NewInt(0), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(0), }, EstimationMap: testEstimationMap, BonderFeeMap: testBBonderFeeMap, @@ -2789,17 +2788,17 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedError: &errors.ErrorResponse{ Code: ErrNotEnoughNativeBalance.Code, - Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, pathprocessor.EthSymbol, walletCommon.ArbitrumMainnet), + Details: fmt.Sprintf(ErrNotEnoughNativeBalance.Details, walletCommon.EthSymbol, walletCommon.ArbitrumMainnet), }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, @@ -2807,7 +2806,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { RequiredNativeBalance: big.NewInt((testBaseFee + testPriorityFeeLow) * testApprovalGasEstimation), }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2823,21 +2822,21 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { AddrFrom: common.HexToAddress("0x1"), AddrTo: common.HexToAddress("0x2"), AmountIn: (*hexutil.Big)(big.NewInt(testAmount100USDC)), - TokenID: pathprocessor.UsdcSymbol, + TokenID: walletCommon.UsdcSymbol, DisabledToChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.UsdcSymbol, + Symbol: walletCommon.UsdcSymbol, Decimals: 6, }, TokenPrices: testTokenPrices, SuggestedFees: testSuggestedFees, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.UsdcSymbol): big.NewInt(testAmount100USDC + testAmount100USDC), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), }, EstimationMap: testEstimationMap, BonderFeeMap: testBBonderFeeMap, @@ -2847,13 +2846,13 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedCandidates: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &mainnet, ToChain: &optimism, ApprovalRequired: true, }, { - ProcessorName: pathprocessor.ProcessorTransferName, + ProcessorName: walletCommon.ProcessorTransferName, FromChain: &optimism, ToChain: &optimism, ApprovalRequired: false, @@ -2861,7 +2860,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { RequiredNativeBalance: big.NewInt((testBaseFee + testPriorityFeeLow) * testApprovalGasEstimation), }, { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2869,7 +2868,7 @@ func getNoBalanceTestParamsList() []noBalanceTestParams { }, expectedBest: routes.Route{ { - ProcessorName: pathprocessor.ProcessorBridgeHopName, + ProcessorName: walletCommon.ProcessorBridgeHopName, FromChain: &arbitrum, ToChain: &optimism, ApprovalRequired: true, @@ -2894,14 +2893,14 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{}, @@ -2923,7 +2922,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet}, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), @@ -2933,7 +2932,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{}, @@ -2955,7 +2954,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount2ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet}, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), @@ -2965,7 +2964,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{}, @@ -2993,7 +2992,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount2ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, DisabledFromChainIDs: []uint64{walletCommon.EthereumMainnet}, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), @@ -3004,7 +3003,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{}, @@ -3032,7 +3031,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount2ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), walletCommon.ArbitrumMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), @@ -3042,7 +3041,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{}, @@ -3070,7 +3069,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount5ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), walletCommon.ArbitrumMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), @@ -3080,7 +3079,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{}, @@ -3114,19 +3113,19 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount3ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), }, }, }, @@ -3170,7 +3169,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount3ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei)), }, @@ -3179,13 +3178,13 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount2ETHInWei), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount3ETHInWei), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount2ETHInWei), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount3ETHInWei), }, }, }, @@ -3225,7 +3224,7 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount3ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, FromLockedAmount: map[uint64]*hexutil.Big{ walletCommon.OptimismMainnet: (*hexutil.Big)(big.NewInt(testAmount0Point5ETHInWei)), walletCommon.EthereumMainnet: (*hexutil.Big)(big.NewInt(testAmount1ETHInWei)), @@ -3235,13 +3234,13 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount2ETHInWei), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount3ETHInWei), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount2ETHInWei), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount3ETHInWei), }, }, }, @@ -3273,19 +3272,19 @@ func getAmountOptionsTestParamsList() []amountOptionsTestParams { Uuid: uuid.NewString(), SendType: sendtype.Transfer, AmountIn: (*hexutil.Big)(big.NewInt(testAmount5ETHInWei)), - TokenID: pathprocessor.EthSymbol, + TokenID: walletCommon.EthSymbol, TestsMode: true, TestParams: &requests.RouterTestParams{ TokenFrom: &token.Token{ ChainID: 1, - Symbol: pathprocessor.EthSymbol, + Symbol: walletCommon.EthSymbol, Decimals: 18, }, BalanceMap: map[string]*big.Int{ - makeBalanceKey(walletCommon.EthereumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), - makeBalanceKey(walletCommon.OptimismMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), - makeBalanceKey(walletCommon.ArbitrumMainnet, pathprocessor.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.EthereumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.OptimismMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), + makeBalanceKey(walletCommon.ArbitrumMainnet, walletCommon.EthSymbol): big.NewInt(testAmount1ETHInWei), }, }, }, diff --git a/services/wallet/router/sendtype/send_type.go b/services/wallet/router/sendtype/send_type.go index 9a159bf82..161284da2 100644 --- a/services/wallet/router/sendtype/send_type.go +++ b/services/wallet/router/sendtype/send_type.go @@ -2,16 +2,9 @@ package sendtype import ( "math/big" - "slices" - "strings" - "github.com/ethereum/go-ethereum/common" "github.com/status-im/status-go/params" - "github.com/status-im/status-go/services/wallet/collectibles" walletCommon "github.com/status-im/status-go/services/wallet/common" - "github.com/status-im/status-go/services/wallet/market" - "github.com/status-im/status-go/services/wallet/router/pathprocessor" - "github.com/status-im/status-go/services/wallet/token" ) type SendType int @@ -40,79 +33,28 @@ func (s SendType) IsStickersTransfer() bool { return s == StickersBuy } -func (s SendType) FetchPrices(marketManager *market.Manager, tokenIDs []string) (map[string]float64, error) { - nonUniqueSymbols := append(tokenIDs, "ETH") - // remove duplicate enteries - slices.Sort(nonUniqueSymbols) - symbols := slices.Compact(nonUniqueSymbols) - if s.IsCollectiblesTransfer() { - symbols = []string{"ETH"} - } - - pricesMap, err := marketManager.GetOrFetchPrices(symbols, []string{"USD"}, market.MaxAgeInSecondsForFresh) - - if err != nil { - return nil, err - } - prices := make(map[string]float64, 0) - for symbol, pricePerCurrency := range pricesMap { - prices[symbol] = pricePerCurrency["USD"].Price - } - if s.IsCollectiblesTransfer() { - for _, tokenID := range tokenIDs { - prices[tokenID] = 0 - } - } - return prices, nil -} - -func (s SendType) FindToken(tokenManager *token.Manager, collectibles *collectibles.Service, account common.Address, network *params.Network, tokenID string) *token.Token { - if !s.IsCollectiblesTransfer() { - return tokenManager.FindToken(network, tokenID) - } - - parts := strings.Split(tokenID, ":") - contractAddress := common.HexToAddress(parts[0]) - collectibleTokenID, success := new(big.Int).SetString(parts[1], 10) - if !success { - return nil - } - uniqueID, err := collectibles.GetOwnedCollectible(walletCommon.ChainID(network.ChainID), account, contractAddress, collectibleTokenID) - if err != nil || uniqueID == nil { - return nil - } - - return &token.Token{ - Address: contractAddress, - Symbol: collectibleTokenID.String(), - Decimals: 0, - ChainID: network.ChainID, - } -} - // canUseProcessor is used to check if certain SendType can be used with a given path processor -func (s SendType) CanUseProcessor(p pathprocessor.PathProcessor) bool { - pathProcessorName := p.Name() +func (s SendType) CanUseProcessor(pathProcessorName string) bool { switch s { case Transfer: - return pathProcessorName == pathprocessor.ProcessorTransferName || - pathprocessor.IsProcessorBridge(pathProcessorName) + return pathProcessorName == walletCommon.ProcessorTransferName || + walletCommon.IsProcessorBridge(pathProcessorName) case Bridge: - return pathprocessor.IsProcessorBridge(pathProcessorName) + return walletCommon.IsProcessorBridge(pathProcessorName) case Swap: - return pathprocessor.IsProcessorSwap(pathProcessorName) + return walletCommon.IsProcessorSwap(pathProcessorName) case ERC721Transfer: - return pathProcessorName == pathprocessor.ProcessorERC721Name + return pathProcessorName == walletCommon.ProcessorERC721Name case ERC1155Transfer: - return pathProcessorName == pathprocessor.ProcessorERC1155Name + return pathProcessorName == walletCommon.ProcessorERC1155Name case ENSRegister: - return pathProcessorName == pathprocessor.ProcessorENSRegisterName + return pathProcessorName == walletCommon.ProcessorENSRegisterName case ENSRelease: - return pathProcessorName == pathprocessor.ProcessorENSReleaseName + return pathProcessorName == walletCommon.ProcessorENSReleaseName case ENSSetPubKey: - return pathProcessorName == pathprocessor.ProcessorENSPublicKeyName + return pathProcessorName == walletCommon.ProcessorENSPublicKeyName case StickersBuy: - return pathProcessorName == pathprocessor.ProcessorStickersBuyName + return pathProcessorName == walletCommon.ProcessorStickersBuyName default: return true } @@ -121,7 +63,7 @@ func (s SendType) CanUseProcessor(p pathprocessor.PathProcessor) bool { func (s SendType) ProcessZeroAmountInProcessor(amountIn *big.Int, amountOut *big.Int, processorName string) bool { if amountIn.Cmp(walletCommon.ZeroBigIntValue()) == 0 { if s == Transfer { - if processorName != pathprocessor.ProcessorTransferName { + if processorName != walletCommon.ProcessorTransferName { return false } } else if s == Swap { diff --git a/services/wallet/transfer/errors.go b/services/wallet/transfer/errors.go index 383f47fde..7f3450e04 100644 --- a/services/wallet/transfer/errors.go +++ b/services/wallet/transfer/errors.go @@ -9,5 +9,4 @@ var ( ErrNoRoute = &errors.ErrorResponse{Code: errors.ErrorCode("WT-001"), Details: "no generated route"} ErrNoTrsansactionsBeingBuilt = &errors.ErrorResponse{Code: errors.ErrorCode("WT-002"), Details: "no transactions being built"} ErrMissingSignatureForTx = &errors.ErrorResponse{Code: errors.ErrorCode("WT-003"), Details: "missing signature for transaction %s"} - ErrInvalidSignatureDetails = &errors.ErrorResponse{Code: errors.ErrorCode("WT-004"), Details: "invalid signature details"} ) diff --git a/services/wallet/transfer/helpers.go b/services/wallet/transfer/helpers.go index 9b6ff8ac1..96c2c7d5e 100644 --- a/services/wallet/transfer/helpers.go +++ b/services/wallet/transfer/helpers.go @@ -17,6 +17,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/logutils" wallet_common "github.com/status-im/status-go/services/wallet/common" + "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/router/pathprocessor" ) @@ -72,7 +73,7 @@ func rowsToMultiTransactions(rows *sql.Rows) ([]*MultiTransaction, error) { return multiTransactions, nil } -func addSignaturesToTransactions(transactions map[common.Hash]*TransactionDescription, signatures map[string]SignatureDetails) error { +func addSignaturesToTransactions(transactions map[common.Hash]*TransactionDescription, signatures map[string]requests.SignatureDetails) error { if len(transactions) == 0 { return errors.New("no transactions to proceed with") } diff --git a/services/wallet/transfer/transaction_manager.go b/services/wallet/transfer/transaction_manager.go index 716d7b257..cb54bfb3f 100644 --- a/services/wallet/transfer/transaction_manager.go +++ b/services/wallet/transfer/transaction_manager.go @@ -21,20 +21,6 @@ import ( "github.com/status-im/status-go/transactions" ) -type SignatureDetails struct { - R string `json:"r"` - S string `json:"s"` - V string `json:"v"` -} - -func (sd *SignatureDetails) Validate() error { - if len(sd.R) != 64 || len(sd.S) != 64 || len(sd.V) != 2 { - return ErrInvalidSignatureDetails - } - - return nil -} - // TODO: remove this struct once mobile switches to the new approach type TransactionDescription struct { chainID uint64 diff --git a/services/wallet/transfer/transaction_manager_multitransaction.go b/services/wallet/transfer/transaction_manager_multitransaction.go index ce9468a65..35b3ac900 100644 --- a/services/wallet/transfer/transaction_manager_multitransaction.go +++ b/services/wallet/transfer/transaction_manager_multitransaction.go @@ -14,6 +14,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/logutils" wallet_common "github.com/status-im/status-go/services/wallet/common" + "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/router/pathprocessor" "github.com/status-im/status-go/services/wallet/walletevent" "github.com/status-im/status-go/signal" @@ -102,7 +103,7 @@ func (tm *TransactionManager) SendTransactions(ctx context.Context, multiTransac }, nil } -func (tm *TransactionManager) ProceedWithTransactionsSignatures(ctx context.Context, signatures map[string]SignatureDetails) (*MultiTransactionCommandResult, error) { +func (tm *TransactionManager) ProceedWithTransactionsSignatures(ctx context.Context, signatures map[string]requests.SignatureDetails) (*MultiTransactionCommandResult, error) { if err := addSignaturesToTransactions(tm.transactionsForKeycardSigning, signatures); err != nil { return nil, err } diff --git a/services/wallet/transfer/transaction_manager_route.go b/services/wallet/transfer/transaction_manager_route.go index 321a5a5ad..c2f88d80b 100644 --- a/services/wallet/transfer/transaction_manager_route.go +++ b/services/wallet/transfer/transaction_manager_route.go @@ -13,6 +13,7 @@ import ( "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" walletCommon "github.com/status-im/status-go/services/wallet/common" + "github.com/status-im/status-go/services/wallet/requests" "github.com/status-im/status-go/services/wallet/responses" "github.com/status-im/status-go/services/wallet/router/pathprocessor" "github.com/status-im/status-go/services/wallet/router/routes" @@ -178,13 +179,13 @@ func buildTxForPath(transactor transactions.TransactorIface, path *routes.Path, if !path.FromToken.IsNative() { sendArgs.Value = (*hexutil.Big)(big.NewInt(0)) - if path.ProcessorName == pathprocessor.ProcessorTransferName || - path.ProcessorName == pathprocessor.ProcessorStickersBuyName || - path.ProcessorName == pathprocessor.ProcessorENSRegisterName || - path.ProcessorName == pathprocessor.ProcessorENSReleaseName || - path.ProcessorName == pathprocessor.ProcessorENSPublicKeyName || - path.ProcessorName == pathprocessor.ProcessorERC721Name || - path.ProcessorName == pathprocessor.ProcessorERC1155Name { + if path.ProcessorName == walletCommon.ProcessorTransferName || + path.ProcessorName == walletCommon.ProcessorStickersBuyName || + path.ProcessorName == walletCommon.ProcessorENSRegisterName || + path.ProcessorName == walletCommon.ProcessorENSReleaseName || + path.ProcessorName == walletCommon.ProcessorENSPublicKeyName || + path.ProcessorName == walletCommon.ProcessorERC721Name || + path.ProcessorName == walletCommon.ProcessorERC1155Name { // TODO: update functions from `TransactorIface` to use `ToContractAddress` (as an address of the contract a transaction should be sent to) // and `To` (as the destination address, recipient) of `SendTxArgs` struct appropriately toContractAddr := types.Address(path.FromToken.Address) @@ -248,7 +249,7 @@ func (tm *TransactionManager) BuildTransactionsFromRoute(route routes.Route, pat response.Hashes = append(response.Hashes, txDetails.ApprovalTxData.HashToSign) // if approval is needed for swap, we cannot build the swap tx before the approval tx is mined - if path.ProcessorName == pathprocessor.ProcessorSwapParaswapName { + if path.ProcessorName == walletCommon.ProcessorSwapParaswapName { continue } } @@ -264,7 +265,7 @@ func (tm *TransactionManager) BuildTransactionsFromRoute(route routes.Route, pat return response, nil } -func getSignatureForTxHash(txHash string, signatures map[string]SignatureDetails) ([]byte, error) { +func getSignatureForTxHash(txHash string, signatures map[string]requests.SignatureDetails) ([]byte, error) { sigDetails, ok := signatures[txHash] if !ok { err := &errors.ErrorResponse{ @@ -306,7 +307,7 @@ func validateAndAddSignature(txData *TransactionData, signatures map[string]Sign return nil } -func (tm *TransactionManager) ValidateAndAddSignaturesToRouterTransactions(signatures map[string]SignatureDetails) error { +func (tm *TransactionManager) ValidateAndAddSignaturesToRouterTransactions(signatures map[string]requests.SignatureDetails) error { if len(tm.routerTransactions) == 0 { return ErrNoTrsansactionsBeingBuilt } @@ -365,7 +366,7 @@ func (tm *TransactionManager) SendRouterTransactions(ctx context.Context, multiT transactions = append(transactions, response) // if approval is needed for swap, then we need to wait for the approval tx to be mined before sending the swap tx - if desc.RouterPath.ProcessorName == pathprocessor.ProcessorSwapParaswapName { + if desc.RouterPath.ProcessorName == walletCommon.ProcessorSwapParaswapName { continue } }