fix: implement Reflector oracle as primary price source with CoinGecko fallback#26
Merged
Uchechukwu-Ekezie merged 1 commit intoJun 28, 2026
Conversation
…o fallback
Resolves the gap between the advertised Reflector oracle integration and
the actual backend behaviour. Previously ReflectorService fetched all
prices exclusively from CoinGecko, leaving the SorobanRpc import unused.
Price resolution order is now:
Reflector contract (on-chain, via Soroban simulation)
→ CoinGecko (for any assets the oracle did not return)
→ hardcoded fallback (existing behaviour)
Changes:
- Add fetchPricesFromReflector() which uses SorobanRpc.Server to
simulate a lastprice() call against the Reflector contract for each
asset and parses the i128/10^7-scaled PriceData response
- Update getFreshPrices() to call Reflector first and only hit CoinGecko
for assets missing from the oracle response
- Read REFLECTOR_CONTRACT_ID and SOROBAN_RPC_URL from env in constructor
- Add both variables (with testnet defaults) to backend/.env.example
Closes grantFoxin#8
c1926d9 to
0cfaa73
Compare
Contributor
|
LGTM |
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
ReflectorService— previously theSorobanRpcimport was unused and all prices came exclusively from CoinGeckofetchPricesFromReflector()which usesSorobanRpc.Server.simulateTransactionto calllastprice()on the Reflector contract for each asset and parses thei128/10^7-scaledPriceDataresponseREFLECTOR_CONTRACT_IDandSOROBAN_RPC_URLfrom env; logs a warning on startup if the contract ID is absent so operators know the oracle is inactivebackend/.env.exampleTest plan
REFLECTOR_CONTRACT_IDandSOROBAN_RPC_URLin.env; confirm price responses include"source": "reflector"for assets the oracle returnsREFLECTOR_CONTRACT_ID; confirm service falls back to CoinGecko and startup logs the warningCloses #8