fix(earn-quest): use per-asset decimals in convert_reward_amount (#1947) - #2167
Merged
RUKAYAT-CODER merged 1 commit intoAug 18, 2026
Conversation
Contributor
|
Thank you for contributing to the project |
2 tasks
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.
Closes #1947
Summary
convert_reward_amounthardcoded a 7-decimal assumption (10_000_000) for every conversion, silently producing incorrect results for reward tokens with a different decimal count. This PR makes the conversion use each asset's actual decimals.Changes
src/lib.rs:convert_reward_amountnow looks up each asset's actual decimals via the SEP-41TokenClient::decimals()interface and uses the oracle price's reported decimals. The conversion scales by10^(from_decimals + price_decimals - to_decimals)instead of the hardcoded constant.src/oracle.rs:get_aggregated_pricenow reports the decimal precision of the underlying price sources instead of a fixed 7.tests/test_reward_conversion.rs: new integration tests covering 6/7/18-decimal assets, non-7 price quotes (8 decimals), Stellar asset contracts, mixed decimals with non-integer prices, legacy 7/7 behavior preservation, and theAmountTooLargeoverflow guard.Verification
cargo fmt --checkandcargo clippy --all-targets --all-features -- -D warningsclean