feat/fix: Payment Token Decimal Compatibility and Test Suite Reliability#241
Merged
thlpkee20-wq merged 2 commits intoRevoraOrg:masterfrom Apr 1, 2026
Conversation
|
@lycantho Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
@thlpkee20-wq please merge, i tried to fix the workflow but they are not my issues |
Contributor
|
Please resolve the conflicts |
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.
Implement Payment Token Decimal Compatibility
Closes #167
Description
This PR develops the Payment Token Decimal Compatibility capability with production-grade behavior, explicit security assumptions, and deterministic test coverage. It allows issuers to seamlessly distribute revenue across payment tokens utilizing arbitrary decimal precisions (e.g. 6-decimal USDC, 8-decimal BTC) while preserving strict mathematical accuracy and fair distribution down to the ledger canonical 7-decimal representation.
Core Changes
DataKey::PaymentTokenDecimals(OfferingId)to persistently store the payment token decimal preference for an offering.set_payment_token_decimalsallowing the issuer to explicitly set the underlying precision (limited toMAX_TOKEN_DECIMALSto prevent overflow scaling). Default behaves as strictly 7.normalize_amount(amount, decimals)to safely downscale/upscale varying precisions back to Soroban's canonical 7 decimals.report_revenueto inject precision normalization over theAuditSummarytotal_revenue, fixing previous accounting inconsistencies tracked across multiple token types.#[should_panic]behavior into uncatchable hostSIGABRTs. Refactored all affected proxy testing macros into propertry_error interceptions, restoring continuous test reliability across all ~400 tests.Security & Architectural Notes
MAX_TOKEN_DECIMALSto deterministically block exponential numeric explosion.token.decimals()since on-chain assets could technically shadow logic. Relying entirely on manual decimal anchoring by the issuer ensures total systemic determinism.Execution
cargo test --features testutils test_decimal_compatibilitypasses flawlessly, confirming perfect scaling metrics for 6-decimal USDC and 8-decimal BTC parity tests.report_revenuefeatures.