Skip to content

Store the share price with 14 decimals instead of WAD #431

Open

Description

@hpmaxi

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: replace WAD_SCALE with a 10^14 price scale
  • contracts/nav-oracle/src/lib.rs:59,67,71: the scale constant, MIN_ANSWER and MAX_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 local WAD in app/src/pages/vaultRequests.ts:58
  • scripts/harness/lib/amounts.ts:3-4 and the oracle bounds in scripts/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 WAD or _000_000_000_000_000_000 price 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions