Repository navigation
Description
Priority
Low
User story / Problem statement
The oracle and the vault keep the share price in WAD (18 decimals): nav_per_share is asset base units per share base unit, scaled by 10^18. Price feeds on Stellar use 14 decimals; the live Reflector oracles on mainnet all report decimals() = 14. The SEP-40 feed (#236) converts the price to 14 decimals when it publishes it, so integrators who read the feed are covered. Anyone who reads the oracle directly still gets 18.
As a maintainer, I want the share price stored and attested in the same 14-decimal scale the SEP-40 feed publishes, so the oracle, the vault, the app and the feed share one scale and the feed needs no conversion.
Expected outcome
The oracle accepts and stores nav_per_share with 14 decimals, the vault prices epochs with that scale, and the app, the harness, the tests and the docs use it.
Scope (measured on feedback at ac91a85)
-
contracts/async-vault/src/pricing.rs:2,23,33: replaceWAD_SCALEwith a 10^14 price scale -
contracts/nav-oracle/src/lib.rs:59,67,71: the scale constant,MIN_ANSWERandMAX_ANSWER - About 8 doc comments that say "in WAD" (
async-vault/src/lib.rs,pricing.rs,state.rs,nav-oracle/src/lib.rs,state.rs) -
app-lib/format.ts:84(PRICE_DECIMALS) and the localWADinapp/src/pages/vaultRequests.ts:58 -
scripts/harness/lib/amounts.ts:3-4and the oracle bounds inscripts/harness/lib/network.ts:38-39 - 56 WAD or 10^18 literals in the contract tests (31 in
async-vault/src/test/conversions.rs), and the price fixtures in the app tests - The docs that state the scale (3 files)
- A testnet redeploy afterwards: stored reports and epoch prices on the current deployment are in WAD
Acceptance criteria
- No
WADor_000_000_000_000_000_000price literal remains in contracts, tests, app or harness, except where a value is not a price - The vault's rounding and dust bounds are unchanged (the existing conversion and dust tests pass with 14-decimal values)
- The SEP-40 feed publishes the stored price without a scale conversion when the asset and the share have the same decimals
- Testnet is redeployed and the README points at it
Technical notes
Do this before the first mainnet deployment: after that, stored reports and epoch prices would need a migration. Independent of #236, which converts at the edge until this lands.
Activity