From 4fc9361f128be4ab030142f7bd94ee4facd1567e Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Thu, 7 Nov 2024 14:16:00 +0100 Subject: [PATCH] fix(wallet)_: broken swap and bridge for erc20 tokens fixed --- services/wallet/router/pathprocessor/processor_bridge_hop.go | 2 +- .../wallet/router/pathprocessor/processor_swap_paraswap.go | 4 ++-- services/wallet/transfer/transaction_manager_route.go | 1 + transactions/types.go | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/services/wallet/router/pathprocessor/processor_bridge_hop.go b/services/wallet/router/pathprocessor/processor_bridge_hop.go index 760ff92e2..5a276374e 100644 --- a/services/wallet/router/pathprocessor/processor_bridge_hop.go +++ b/services/wallet/router/pathprocessor/processor_bridge_hop.go @@ -386,7 +386,7 @@ func (h *HopBridgeProcessor) sendOrBuildV2(sendArgs *transactions.SendTxArgs, si return tx, createBridgeHopErrorResponse(err) } - bonderKey := makeKey(sendArgs.FromChainID, sendArgs.ToChainID, "", "", (*big.Int)(sendArgs.Value)) + bonderKey := makeKey(sendArgs.FromChainID, sendArgs.ToChainID, "", "", (*big.Int)(sendArgs.ValueIn)) bonderFeeIns, ok := h.bonderFee.Load(bonderKey) if !ok { return nil, ErrNoBonderFeeFound diff --git a/services/wallet/router/pathprocessor/processor_swap_paraswap.go b/services/wallet/router/pathprocessor/processor_swap_paraswap.go index c52627eb0..07c440327 100644 --- a/services/wallet/router/pathprocessor/processor_swap_paraswap.go +++ b/services/wallet/router/pathprocessor/processor_swap_paraswap.go @@ -212,7 +212,7 @@ func (s *SwapParaswapProcessor) GetContractAddress(params ProcessorInputParams) func (s *SwapParaswapProcessor) prepareTransaction(sendArgs *MultipathProcessorTxArgs) error { slippageBP := uint(sendArgs.SwapTx.SlippagePercentage * 100) // convert to basis points - key := makeKey(sendArgs.SwapTx.ChainID, sendArgs.SwapTx.ChainIDTo, sendArgs.SwapTx.TokenIDFrom, sendArgs.SwapTx.TokenIDTo, sendArgs.SwapTx.Value.ToInt()) + key := makeKey(sendArgs.SwapTx.ChainID, sendArgs.SwapTx.ChainIDTo, sendArgs.SwapTx.TokenIDFrom, sendArgs.SwapTx.TokenIDTo, sendArgs.SwapTx.ValueIn.ToInt()) priceRouteIns, ok := s.priceRoute.Load(key) if !ok { return ErrPriceRouteNotFound @@ -258,7 +258,7 @@ func (s *SwapParaswapProcessor) prepareTransaction(sendArgs *MultipathProcessorT func (s *SwapParaswapProcessor) prepareTransactionV2(sendArgs *transactions.SendTxArgs) error { slippageBP := uint(sendArgs.SlippagePercentage * 100) // convert to basis points - key := makeKey(sendArgs.FromChainID, sendArgs.ToChainID, sendArgs.FromTokenID, sendArgs.ToTokenID, sendArgs.Value.ToInt()) + key := makeKey(sendArgs.FromChainID, sendArgs.ToChainID, sendArgs.FromTokenID, sendArgs.ToTokenID, sendArgs.ValueIn.ToInt()) priceRouteIns, ok := s.priceRoute.Load(key) if !ok { return ErrPriceRouteNotFound diff --git a/services/wallet/transfer/transaction_manager_route.go b/services/wallet/transfer/transaction_manager_route.go index cd3591e3b..321a5a5ad 100644 --- a/services/wallet/transfer/transaction_manager_route.go +++ b/services/wallet/transfer/transaction_manager_route.go @@ -163,6 +163,7 @@ func buildTxForPath(transactor transactions.TransactorIface, path *routes.Path, MaxPriorityFeePerGas: path.TxPriorityFee, // additional fields version 1 + ValueIn: path.AmountIn, ValueOut: path.AmountOut, FromChainID: path.FromChain.ChainID, ToChainID: path.ToChain.ChainID, diff --git a/transactions/types.go b/transactions/types.go index 12f1b300b..7c3dbca77 100644 --- a/transactions/types.go +++ b/transactions/types.go @@ -68,6 +68,7 @@ type SendTxArgs struct { MultiTransactionID wallet_common.MultiTransactionIDType `json:"multiTransactionID"` Symbol string `json:"-"` // additional data - version SendTxArgsVersion1 + ValueIn *hexutil.Big `json:"-"` ValueOut *hexutil.Big `json:"-"` FromChainID uint64 `json:"-"` ToChainID uint64 `json:"-"`