Overview
Add oracle-priced invoices where the funding target is determined at payment time by an external price oracle contract, not fixed at creation. Use case: invoice 100 USD worth of XLM where the XLM/USD rate is fetched from a Stellar oracle at payment time.
Requirements
- Extend
InvoiceOptions with oracle: Option<Address> and oracle_asset_pair: Option<(Symbol, Symbol)>
- At payment time, if oracle is set, call the oracle contract's
price(asset_pair) function via env.invoke_contract and compute the required token amount dynamically
- Store the oracle address as part of invoice state
- Emit
OraclePriceFetched { invoice_id, rate, computed_amount } event on each payment
- If the oracle call fails (stale/unavailable), panic with
OracleUnavailable
- Write tests using a mock oracle contract that returns configurable rates
- Test: oracle price changes between payments; oracle unavailable; oracle returns zero
Acceptance Criteria
Definition of Done
All CI checks must pass before the PR is reviewed.
Overview
Add oracle-priced invoices where the funding target is determined at payment time by an external price oracle contract, not fixed at creation. Use case: invoice 100 USD worth of XLM where the XLM/USD rate is fetched from a Stellar oracle at payment time.
Requirements
InvoiceOptionswithoracle: Option<Address>andoracle_asset_pair: Option<(Symbol, Symbol)>price(asset_pair)function viaenv.invoke_contractand compute the required token amount dynamicallyOraclePriceFetched { invoice_id, rate, computed_amount }event on each paymentOracleUnavailableAcceptance Criteria
tests/used for all test scenariosOracleUnavailable, not a cryptic errorcargo test --workspacepasses with zero failurescargo clippy --all-targets -- -D warningsproduces zero warningsDefinition of Done
All CI checks must pass before the PR is reviewed.