Fix EVM token swap pending metadata showing 0#466
Open
j0ntz wants to merge 1 commit into
Open
Conversation
For Thorchain and Maya EVM token swaps (e.g. USDT to ETH) the spend target nativeAmount was set to 0, so the recorded transaction amount and its fiat and percentage metadata displayed 0 while the swap was pending. Use the actual token amount for the spend target; the broadcast contract call is unchanged because the currency engine forces zero parent-currency value for token contract calls.
Contributor
Author
Contributor
Author
📸 Test evidence — real Maya USDT(ETH)→ETH swap, pending metadata now non-zero (followup verification)agent proof 1211543001846210 01 maya quote agent proof 1211543001846210 02 swap success agent proof 1211543001846210 03 pending metadata nonzero agent proof 1211543001846210 04 exchange details onchain Captured by the agent's in-app test run (build-and-test). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Asana: https://app.asana.com/0/1215088146871429/1211543001846210
Fixes a Maya/Thorchain bug where swapping an EVM ERC20 token (e.g. USDT on Ethereum) to a native asset showed 0 for the value (coins, USD, percentage) in the transaction metadata while the swap was pending.
Root cause: in
makeThorchainBasedPlugin(src/swap/defi/thorchain/thorchainCommon.ts), EVM token swaps set the spend targetnativeAmountto0(it reused theethNativeAmountvalue, which is the parent-currency txvalueand is 0 for token contract calls). The currency engine derives the pendingEdgeTransaction.nativeAmountfromspendTarget.nativeAmount, so the token swap recorded 0 and the pending-transaction metadata rendered 0. Once the tx mined, the engine re-read the real on-chain token amount, which is why only the pending state was wrong.Fix: set the spend target
nativeAmounttofromNativeAmount(the token amount being spent). The broadcast transaction is unchanged: for an EVM token contract call the engine sends the routerdepositWithExpirycalldata and forces the txvalueto 0 regardless ofspendTarget.nativeAmount(getTxParameterInformationreturnsvalue: undefinedandsignTxhard-setstxValue = 0x00for token contract calls), sospendTarget.nativeAmountonly drives the displayed amount and the balance check. Native EVM, RUNE/CACAO, ZEC and UTXO paths already passedfromNativeAmount, so this is a no-op for them.Applies to both Maya and Thorchain since they share this code.
Testing
tsc --noEmit, eslint, and the jest suite pass (verify-repo).Note
Low Risk
Metadata and spend-target labeling fix in shared Thorchain/Maya quote code; EVM token broadcast behavior is documented as unchanged.
Overview
Fixes Thorchain/Maya pending swap UI showing 0 coins, USD, and percentage when swapping an EVM ERC-20 (e.g. USDT on Ethereum) to another asset.
In
thorchainCommon.ts, EVM token swaps no longer set the spend targetnativeAmountto0. They now usefromNativeAmount(the token amount being spent), matching native EVM and other chain paths. The oldethNativeAmountoverride existed because the routerdepositWithExpirycall sends zero parent-chainvaluefor tokens; that on-chain behavior is unchanged—the currency engine still forcesvalueto 0 for token contract calls.spendTarget.nativeAmountonly drives pending transaction metadata and balance checks, so pending state now shows the correct from-amount until the tx confirms.Reviewed by Cursor Bugbot for commit a6144fb. Bugbot is set up for automated code reviews on this repo. Configure here.