fix(swap): correct fee simulation display with proper decimal conversion#11
Merged
MinaraAgent merged 3 commits intomainfrom Apr 3, 2026
Merged
Conversation
- Add TokenInfoDto and CrossChainSwapsSimulateResultDto types matching updated API schema - Use token.decimals for token amount conversion (previously raw BigInt strings) - Use 10^18 divisor for USD fee values (wei format) - Add formatWeiToUsd() and formatTokenAmount() helper functions - Handle priceImpact=-1 as "negligible" instead of displaying "-1%" - Add sanity check warning for fees exceeding $1000
There was a problem hiding this comment.
Code Review
This pull request introduces structured types and enhanced formatting for cross-chain swap simulations. It updates the API client to use the new CrossChainSwapsSimulateResponseDto and adds a dedicated printSwapSimulation formatter to provide detailed, human-readable output for token changes and fees. Review feedback identified a logic error in how simulation results are accessed from the API response and noted that token.realDecimals should be used for accurate amount formatting as per the type definitions.
The API client already extracts .data from the response, so the function should return CrossChainSwapsSimulateItem[] not wrapped in ResponseDto.
The implementation uses token.decimals for amount conversion as per the requirement that display decimals should match the token's standard.
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.
Summary
$339,562,475,978,087,550.00)/v1/tx/cross-chain/swaps-simulatedecimalsfieldChanges
TokenInfoDto,TokenChangeDto,CrossChainSwapsSimulateResultDtomatching the updated OpenAPI schemaformatWeiToUsd()andformatTokenAmount()helpers for proper unit conversionprintSwapSimulation()functionDetails
token.decimalsfrom API responsepriceImpact=-1now displays as— (negligible)instead of-1%Test plan
./bin/minara.js swap -s buy -t "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" -a 5 --chain ethereum --dry-run