100: Add Perps collateral, leverage, value, uPnL and gross-exposure totals in EMC
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
# Verification — issue #100
|
||||
|
||||
Verified locally on 24 October 2026; no live Hub was started or restarted, and no
|
||||
signing, trading, activation, deposits or withdrawals were performed. Changes are
|
||||
uncommitted and unpushed. Existing staged/deleted change-97/change-99 artifacts
|
||||
and the pre-existing untracked NFS log file were left untouched.
|
||||
|
||||
## Build and focused checks
|
||||
|
||||
- `JAVA_HOME=/usr/local/software/java/jfx-25 ./gradlew build` passed against the
|
||||
final sources: 42 existing tests, zero failures/errors. Some intermediate runs
|
||||
encountered transient NFS locks while deleting binary test results; normal
|
||||
reruns succeeded without changing build configuration.
|
||||
- Temporary `/tmp/issue100-check/Issue100Check.java` passed 66 focused checks.
|
||||
No permanent test suite was added. Fixtures exercised gross Long/Short totals,
|
||||
once-only Cross capital/Value, missing components, valid empty scopes, immutable
|
||||
collections, positive/negative PnL, zero/negative denominators, Jupiter response
|
||||
completeness/duplicates/units, Phoenix funding signs and fee overrides,
|
||||
size-dependent tiers and quote-lot rounding, negative base-lot exponents,
|
||||
unsupported spot collateral, funded empty Cross accounts, failed refresh,
|
||||
retained timestamps, recovery to empty, independent wallet/venue attempts,
|
||||
no-I/O snapshot access and Phoenix 429 cooldown.
|
||||
- Hand-checkable Cross fixture: 100 USD Long + 100 USD Short = 200 USD gross
|
||||
exposure; shared collateral 80, price PnL +5, net unsettled funding 0 and
|
||||
exit fees 1 give equity 85 and Value 84. Cross leverage is 200/85. Initial
|
||||
margin requirements of 10 per child are not added to the 80 owned capital.
|
||||
- Tier fixture: 150 base lots at exponent 2 and price 100.009, tick size 100,
|
||||
between tiers (100 lots, 10×) and (200 lots, 5×), uses integer leverage 7
|
||||
and initial margin 21.428572 USD. Exposure remains 150.0135 USD.
|
||||
|
||||
## Read-only live comparison
|
||||
|
||||
The new adapters were read directly, outside the Hub, from
|
||||
**2026-10-24 10:18:38 UTC to 10:19:13 UTC** (12:18–12:19 CEST).
|
||||
The controlled PROD wallet was `H5Yrdm7B4FHhTxhPw9SVwFzQyTEL6bAPptZuTyRxcepq`;
|
||||
the existing TEST wallet was `6NyYEoXmJyBXvU4pvv9aoxZNdyqqtkmPBZFEDkRDHcqp`.
|
||||
The other five PROD wallets remain configured, but were not all read for this
|
||||
preview. Counts and prices are observations, not fixed expectations.
|
||||
|
||||
| Observed scope | Positions | Collateral USD | Gross Exposure USD | Price uPnL USD | Estimated Value USD |
|
||||
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||
| Controlled PROD wallet, Phoenix | 32 | 938.131075 | 4527.060948 | -328.677770 | 608.027266 |
|
||||
| Controlled PROD wallet, Jupiter | 6 | 54.993558 | 704.568047 | -15.752428 | unavailable |
|
||||
| Controlled PROD wallet, combined | 38 | 993.124633 | 5231.628995 | -344.430198 | unavailable |
|
||||
| TEST wallet, both venues | 0 | 0 | 0 | 0 | 0 |
|
||||
|
||||
Jupiter API units and collateral were independently checked against a read-only
|
||||
Solana `getMultipleAccounts` response for all six returned position identities.
|
||||
API `sizeUsd` and `collateralUsd` matched the on-chain values exactly. USD and
|
||||
price fields use six decimal places; percentage fields are already percentage
|
||||
points. The UI's leverage and isolated PnL percentage are derived independently
|
||||
from precise collateral, rather than using rounded API ratios.
|
||||
|
||||
Phoenix uses exact signed quantity × REST mark plus virtual quote for price
|
||||
PnL; quote lots are 1e-6 USD. Estimated equity adds signed unsettled funding,
|
||||
and Value subtracts estimated closing taker fees with the REST account override.
|
||||
Settled funding/fees are not charged again. Tier interpolation and integer price
|
||||
rounding were cross-checked against the official SDK `margin/math.ts`,
|
||||
`margin/compute.ts`, `units.ts` and Rust leverage-tier implementation.
|
||||
|
||||
## JavaFX verification
|
||||
|
||||
A standalone `/tmp/issue100-check/PerpsPreview.java` used the actual immutable
|
||||
read-only PROD/TEST observations above. Controlled edge cases were a separate
|
||||
preview tab and are absent from application sources. It checked eight columns,
|
||||
the visible root, Cross grouping, preserved selection/expansion/row identity on
|
||||
unchanged and changed snapshots, positive/negative/rounded-zero PnL and tooltip
|
||||
definitions. Both 1100-pixel and 600-pixel layouts were inspected; the latter
|
||||
has horizontal scrolling at useful column widths. Root labels use explicit readable text color, including after selection and tab
|
||||
changes; column factories are installed before the initial root.
|
||||
|
||||
Screenshots produced and visually inspected:
|
||||
|
||||
- `/tmp/issue100-check/preview-prod.png`
|
||||
- `/tmp/issue100-check/preview-test.png`
|
||||
- `/tmp/issue100-check/preview-edges.png`
|
||||
- `/tmp/issue100-check/preview-tooltip.png`
|
||||
- `/tmp/issue100-check/preview-small-window.png`
|
||||
|
||||
## OpenSpec and documentation
|
||||
|
||||
The change and all four affected main specifications pass strict validation:
|
||||
|
||||
```text
|
||||
openspec validate 100-perps-capital-and-risk --strict
|
||||
openspec validate evelyn-perps-service --type spec --strict
|
||||
openspec validate evelyn-perps-overview --type spec --strict
|
||||
openspec validate phoenix-perps-service --type spec --strict
|
||||
openspec validate jupiter-perps-overview --type spec --strict
|
||||
```
|
||||
|
||||
Main specs were synchronized; the change remains active for review. Project
|
||||
Evelyn/Phoenix documentation and the shared `r35157_docs/projects/evelyn/README.md`
|
||||
were updated. `git diff --check` passed. Whole-project `openspec validate --all
|
||||
--strict` reports 24 passed and two pre-existing failures: placeholder Purpose
|
||||
sections in `javafx-runtime-service` and `nenjim-process-manager`. Those unrelated
|
||||
specifications were not changed.
|
||||
|
||||
## Known unavailable metrics and valuation limits
|
||||
|
||||
- **Jupiter Value is unavailable**, including higher totals requiring it. The
|
||||
observed API `valueUsd` subtracts opening fees from collateral that already
|
||||
matches post-fee on-chain collateral. Its collateral-valuation/profit-cap
|
||||
treatment is not verified. No fabricated zero, partial total or speculative
|
||||
fee-only correction is displayed; see `docs/JupiterPerpsOverview.md`.
|
||||
- Phoenix Cross position leverage/ROI conventions remain unverified. Those
|
||||
ratios are unavailable; dollar PnL is shown and account effective leverage
|
||||
is provided. Individual Cross position Value is inapplicable.
|
||||
- Nonzero unsupported spot collateral or missing funding/fees/PnL makes the
|
||||
affected collateral/equity/Value unavailable. This version does not claim full
|
||||
account utilization or include open-order risk adjustments in such a metric.
|
||||
- Valuations use periodic reference observations, not executable prices.
|
||||
Slippage, price impact, swaps, network fees, account rent and future funding
|
||||
are excluded. Phoenix state and prices are separate REST observations.
|
||||
Failed refreshes can retain old data indefinitely with explicit status/time.
|
||||
- No changes were made to shared `detag.conf`, wallet lists, trading/alarm
|
||||
implementations, EMC polling cadence or the 60-second post-cycle delay.
|
||||
Reference in New Issue
Block a user