All tests passing: 101/101 ✓
- Line 437-462:
set_price()- Changed frompersistent()totemporary() - Line 407-420:
get_price()- Changed frompersistent()totemporary() - Line 424-430:
get_price_safe()- Changed frompersistent()totemporary() - Line 437-467:
get_prices()- Changed frompersistent()totemporary()
- Line 283-308:
add_asset()- Changed frompersistent()totemporary() - Line 509-593:
remove_asset()- Changed frompersistent()totemporary()
- Line 549-625:
update_price()- Changed frompersistent()totemporary()
- Line 627-650:
set_price_bounds()- Changed frompersistent()totemporary() - Line 652-659:
get_price_bounds()- Changed frompersistent()totemporary()
- Line 461: Added
PriceUpdatedEventemission when price is unchanged (for dashboard monitoring)
Updated 10 tests to add client.add_asset(&admin, &asset) before calling update_price():
test_update_price_provider_can_store_new_pricetest_update_price_multiple_updatestest_update_price_emits_eventtest_update_price_delta_limit_rejection_emits_anomaly_eventtest_update_price_within_bounds_succeedstest_update_price_below_min_bound_rejectedtest_update_price_above_max_bound_rejectedtest_update_price_at_exact_bounds_succeedstest_update_price_no_bounds_set_allows_any_valid_pricetest_update_price_admin_authority
As per the Stellar best practices and the README changelog:
Oracle price data is time-sensitive and can be recreated by relayers. Using temporary storage is a Stellar-recommended best practice for reducing gas costs on frequent updates.
- Significantly reduced gas costs for frequent price updates
- Ephemeral data handling - prices expire naturally via TTL
- Cost-efficient - temporary storage is cheaper than persistent storage
- No API changes - all public interfaces remain the same
- Existing persistent price data will not be automatically migrated
- Relayers should re-push prices after deployment to repopulate temporary storage
- All price data now respects per-asset TTL for automatic expiration
running 101 tests
test result: ok. 101 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
All tests pass successfully, including:
- Price storage and retrieval
- Authorization and security
- Event emission
- Bounds checking
- Cross-contract calls
- Asset management
- Zero-write optimization
contracts/price-oracle/src/lib.rs- Storage refactor implementationcontracts/price-oracle/src/test.rs- Test updates for asset tracking
Implementation Date: 2025-01-XX
Issue: #127
Status: ✅ Complete and Tested