Skip to content

fix: align token/custody field names with live API (renders predict odds) - #4

Merged
Kaleb-Rupe merged 1 commit into
mainfrom
fix/flash-api-field-renames
Jul 7, 2026
Merged

Kaleb-Rupe merged 1 commit into
mainfrom
fix/flash-api-field-renames

Conversation

@Kaleb-Rupe

Copy link
Copy Markdown
Collaborator

Follow-up to #2 (now merged). #2 restored the base reads; the predict market cards were still stuck on the loading skeleton because the live API also renamed fields the SDK + all three apps read under old names — undefined at runtime (compiles only because the SDK type lied about the shape).

Renames (verified against the live API)

old (SDK/apps) new (live) where
TokenInfo.mintKey mint SDK type + all consumers
custody account.tokenMint mint hooks.ts custody parse only*
pricing.minInitialLeverage/maxInitialLeverage minInitLeverage/maxInitLeverage custody parse
pricing.tradeSpreadLong/tradeSpreadShort (per-side, gone) tradeSpreadMin (base spread) custody parse
spread scale /10_000 /1_000_000 custody parse

*The deposit/withdraw request field stays tokenMint (confirmed in the live DepositDirectDto/RequestWithdrawalDto) — funds.ts/lifecycle.ts untouched.

The spread was derived empirically, not guessed

Quoting real positions via /transaction-builder/open-position (owner omitted): effective fill spread entry/oracle − 1 matches tradeSpreadMin / 1e6 exactly — SOL 0.010%, BTC 0.010%, ETH 0.020% — and grows toward tradeSpreadMax with size. The old /1e4 was 100× too large.

Verification (end-to-end, live)

Ran the real headlineMarket engine with live-derived limits:

pre-fix: tokens.find(SOL).mintKey = undefined  → limits null → permanent skeleton
SOL: spread 0.010% vs live-quote 0.010% [match] | YES 55¢ NO 45¢  PASS
BTC: spread 0.010% vs live-quote 0.010% [match] | YES 59¢ NO 41¢  PASS
ETH: spread 0.020% vs live-quote 0.020% [match] | YES 77¢ NO 23¢  PASS

All four packages (flash-v2, predict, tap-trade, copy-trade) typecheck clean. Also fixes the collateral-mint (usdc.mint) deposit/withdraw path in all three apps.

Closes #3.

🤖 Generated with Claude Code

https://claude.ai/code/session_018mbtvTiYt1YDqKKfrVvjUu

…redict odds)

Second half of the API-version divergence (follows the /v2->root fix). The
live Flash V2 API renamed fields the vendored SDK + all three apps still
read under the old names, so every read returned undefined at runtime and
the predict market cards were stuck on the loading skeleton (limits never
built). Only compiled because the SDK type lied about the shape.

Renames (verified against flashapi.trade this change targets):
- TokenInfo.mintKey -> mint            (packages/flash-v2 type + all consumers)
- custody account.tokenMint -> mint    (hooks.ts custody parse only; the
  deposit/withdraw REQUEST field stays tokenMint, confirmed in the live
  DepositDirectDto/RequestWithdrawalDto — funds.ts/lifecycle.ts untouched)
- pricing.minInitialLeverage/maxInitialLeverage -> minInitLeverage/maxInitLeverage
- pricing.tradeSpreadLong/tradeSpreadShort (per-side, gone) -> tradeSpreadMin
  (the base spread), and the SCALE changed: /10_000 -> /1_000_000

The spread scale was derived empirically, not guessed: quoting real
positions via /transaction-builder/open-position (owner omitted) gives an
effective fill spread of entry/oracle-1 that matches tradeSpreadMin/1e6
exactly on SOL (0.010%), BTC (0.010%) and ETH (0.020%), and grows toward
tradeSpreadMax with size. The old code's /1e4 was 100x too large.

Verified end-to-end against the live API by running the real headlineMarket
engine with live-derived limits: limits build, odds render sane
(SOL 55/45, BTC 59/41, ETH 77/23), spread matches the live quote. All four
packages typecheck clean.

Fixes the collateral-mint (usdc.mint) path used by deposit/withdraw across
all three apps as a side effect. Refs the tracking issue.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018mbtvTiYt1YDqKKfrVvjUu
@Kaleb-Rupe
Kaleb-Rupe merged commit 3e6202e into main Jul 7, 2026
1 check passed
@Kaleb-Rupe
Kaleb-Rupe deleted the fix/flash-api-field-renames branch July 7, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flash V2 API contract divergence: field renames + spread-model change (odds stuck in skeleton, collateral mint undefined)

1 participant