Aller au contenu
login
arrow_backRetour aux issues
Wayfare-labs/wayfare #37

Metric: observed depth vs executable depth, reported separately

ecoDébutant help wanted area:pricing difficulty:hard

descriptionDescription

Written to the standard set by #33 — read that issue first for the expected level of detail and the acceptance criteria every check shares. ## What Report **observed depth** and **executable depth** separately for a corridor, and never collapse them into one number. ## Why it matters **This is the sharpest metric available to this project.** A quote is not proof of liquidity: a market can quote a price for $100 with almost nothing behind it. Observed depth is what the book advertises. Executable depth is what a payment would actually fill against. The gap between them *is* the finding. Wayfare already has the raw material — the ladder shows the receive amount asymptoting hard, 5000 USDC returning only 12.4% more naira than 1000 — but nothing names the gap directly. ## Which layer **Layer 2 — deterministic calculation.** ## This is a metric, not a check Two `MetricResult`s, reported side by side. See "Checks and metrics are separate shapes" in [docs/checks.md](https://github.com/Wayfare-labs/wayfare/blob/main/docs/checks.md). **Report both. Never publish a single "depth" figure**, and never a ratio on its own — a ratio hides which of the two moved. ## Exactly where the code goes - **New file:** `checks/metric_depth.go` - Tests appended to `checks/checks_test.go` - Reads `dex.Client.OrderBook` for observed, and `dex.Client.StrictSendPaths` across sizes for executable ## Where the data comes from - Observed: Horizon `/order_book` via `dex/health.go` - Executable: Horizon `/paths/strict-send` at increasing sizes via `dex/dex.go` — the point at which the destination amount stops rising is the executable ceiling ## What "unmeasurable" means here - No order book → observed is `Determined: false`. **Not zero** - No path at any size → executable is `Determined: false`. **Not zero** — this is the NO-MARKET case, and reporting zero depth would state a measurement where none exists - One available and not the other → report the one you have, undetermined for the other. Do not suppress both ## Acceptance criteria - [ ] Two separate `MetricResult`s; the wire never carries a single merged "depth" - [ ] `decimal.Decimal` throughout; no float64 - [ ] Both return UNABLE-TO-DETERMINE (not zero) when unavailable - [ ] Evidence names the sizes probed and the amounts returned - [ ] Uses the existing `dex` client; does not reimplement pathfinding - [ ] Table tests from `testdata/snapshots` — the KESC snapshot is the no-market case, GHSC the thin one - [ ] Negative test: a corridor with no market at all - [ ] Bounded probing — do not add sizes beyond the existing ladder without saying why - [ ] No new third-party dependencies - [ ] gofmt, vet, test -race, golangci-lint clean - [ ] Does not change the headline integrity state or verdict thresholds ## Out of scope Nothing in `dex/` may change. Nothing in `route/`, `sep38/`, `runstore/runstore.go`. ## How to verify locally ```bash make offline-test go test ./checks/ -run TestDepth -v ```
codeOuvre sur GitHub