Feature/price oracle integration - #556
Merged
OxDev-max merged 5 commits intoJul 28, 2026
Merged
Conversation
…rences (OpenLedger-Foundation#505) Add convert_with_decimals() function that correctly applies 10^(to_decimals - from_decimals) rescaling alongside the price ratio calculation. This fixes conversion between tokens with differing decimal places (e.g., 6 vs 7 decimals). Add regression test demonstrating the old math would have been off by a power of ten for mismatched decimals.
…pair directions (OpenLedger-Foundation#506) When setting a price, validate that the reverse pair (if already registered) is reciprocal-consistent within 1% tolerance. This prevents admin errors or manipulation where A→B and B→A rates diverge, causing value leaks through round-trip conversions. Add tests for consistent/inconsistent reversal and round-trip conversion accuracy.
…ing (OpenLedger-Foundation#503) Add price_oracle to MarketplaceConfig. In fund_invoice(), apply currency conversion when invoice.currency differs from listing.token's symbol, using oracle.convert_with_decimals(). This ensures investors' contributions are credited based on true relative value, not raw token units. Also fix missing referrer_split_bps parameter in initialize(). Hard-coded invoice_decimals to 7 pending issue OpenLedger-Foundation#36 (token registry with decimal metadata).
…ion (OpenLedger-Foundation#504) Add set_price_oracle() setter for post-deployment oracle configuration, and add get_total_collected_value() view to aggregate collected fees across multiple tokens and convert them to a common reference currency via the oracle. Gracefully skips tokens with unavailable prices. Returns 0 if oracle is unconfigured. Function signature includes explicit token list and decimals pending issue OpenLedger-Foundation#36 (token registry with automatic discovery). Update treasury.md with new API and storage layout documentation.
|
@Almikefred 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! 🚀 |
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
Implements comprehensive cross-currency support for the Kora Protocol by integrating the price oracle across three contracts (marketplace, treasury,
and price_oracle itself). Enables investors to contribute to invoices in any whitelisted token while maintaining accurate relative-value accounting.
Changes
#505 — price_oracle: decimal-aware conversion
convert_with_decimals()function that correctly applies 10^(to_decimals - from_decimals) rescaling alongside price ratio calculation#506 — price_oracle: reciprocal-consistency validation
set_price()— validates that reverse pair (if exists) is within 1% tolerance of mathematical reciprocal#503 — marketplace: cross-currency funding
price_oracle: Addressto MarketplaceConfigfund_invoice(), apply currency conversion when invoice.currency differs from listing.token's symbolreferrer_split_bpsparameter ininitialize()invoice_decimalsto 7 pending issue Refactor Risk Registry Contracts #36 (token registry)#504 — treasury: multi-token fee valuation
set_price_oracle()setter for post-deployment configurationget_total_collected_value()view to aggregate collected fees across multiple tokens in a single reference currencyDocumentation
docs/treasury.mdwith new API and storage layout for price oracle integrationTest Plan
Dependencies
Pending issue #36 (token registry with decimal metadata), decimal values are:
Once #36 is resolved, these can be automatically looked up.
Notes
Closes #503, Closes #505, Closes #506, Closes #504