Skip to content

Commit

Permalink
fix(wallet)_: broken swap and bridge for erc20 tokens fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
saledjenic committed Nov 7, 2024
1 parent f15c64c commit 758c477
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check warning on line 389 in services/wallet/router/pathprocessor/processor_bridge_hop.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/router/pathprocessor/processor_bridge_hop.go#L389

Added line #L389 was not covered by tests
bonderFeeIns, ok := h.bonderFee.Load(bonderKey)
if !ok {
return nil, ErrNoBonderFeeFound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Check warning on line 215 in services/wallet/router/pathprocessor/processor_swap_paraswap.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/router/pathprocessor/processor_swap_paraswap.go#L215

Added line #L215 was not covered by tests
priceRouteIns, ok := s.priceRoute.Load(key)
if !ok {
return ErrPriceRouteNotFound
Expand Down Expand Up @@ -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())

Check warning on line 261 in services/wallet/router/pathprocessor/processor_swap_paraswap.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/router/pathprocessor/processor_swap_paraswap.go#L261

Added line #L261 was not covered by tests
priceRouteIns, ok := s.priceRoute.Load(key)
if !ok {
return ErrPriceRouteNotFound
Expand Down
1 change: 1 addition & 0 deletions services/wallet/transfer/transaction_manager_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (tm *TransactionManager) buildTxForPath(path *routes.Path, pathProcessors m
MaxPriorityFeePerGas: path.TxPriorityFee,

// additional fields version 1
ValueIn: path.AmountIn,
ValueOut: path.AmountOut,
FromChainID: path.FromChain.ChainID,
ToChainID: path.ToChain.ChainID,
Expand Down
1 change: 1 addition & 0 deletions transactions/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
Expand Down

0 comments on commit 758c477

Please sign in to comment.