Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Gudahtt
left a comment
There was a problem hiding this comment.
Thanks for taking a look at this! We do need to eliminate this extra dash, but I think this would give the wrong answer in some cases.
|
|
||
| export function removeDash (str = '') { | ||
| return str | ||
| .replace(/[-]/u, '') |
There was a problem hiding this comment.
I think the square brackets here are unnecessary:
| .replace(/[-]/u, '') | |
| .replace(/-/u, '') |
| ? currentAsset.symbol | ||
| : initialTransaction.sourceTokenSymbol | ||
| primaryDisplayValue = swapTokenValue | ||
| primaryDisplayValue = removeDash(swapTokenValue) |
There was a problem hiding this comment.
I think this would give us the wrong answer in any case where the dash exists. It is important to know whether this is a negative value or not.
For example, in this case I encountered:
In this case, isViewingReceivedTokenFromSwap was true, so the prefix would be +. But we're losing ETH here, so the correct prefix is -.
I think we want to do two things here:
- "reverse" the prefix used (e.g. add or remove a dash, or multiply by
-1, whichever) ifisViewingReceivedTokenFromSwapis false, and - add
+if the resulting number is positive.
There was a problem hiding this comment.
This seems like something we should handle in useSwappedTokenValue 🤔 . We already look at isViewingReceivedTokenFromSwap in that hook.
There was a problem hiding this comment.
But we're losing ETH here, so the correct prefix is
-.
Wait if you swap a token to ETH, we are losing ETH?
There was a problem hiding this comment.
Wait if you swap a token to ETH, we are losing ETH?
Potentially, yep! In this case, I lost money because the transaction failed on-chain. I had to pay the gas fee but I got nothing in return.
|
Also, seems when a swap is pending the |

The
swapTokenValueis coming in with a-prefix already during the conversion process. This removes/replaces the-.Before
After