Skip to content

feat: render existing referral state without API auth - #18

Merged
mertcicekci0 merged 1 commit into
mainfrom
feat/referral-onchain-state
May 18, 2026
Merged

feat: render existing referral state without API auth#18
mertcicekci0 merged 1 commit into
mainfrom
feat/referral-onchain-state

Conversation

@mertcicekci0

Copy link
Copy Markdown
Collaborator

Public /v1/referral/info endpoint + web wires it up so wallets with a registered code see their dashboard immediately.

…ut API auth

The /referrals page kept showing the CreateCodeCard for users that
already had a code registered on-chain, because the dashboard load
went through the API key handshake (closed beta). For non-beta
wallets that was a dead end.

  - api: add public GET /v1/referral/info?address=G... that returns
    { self, binding } from the indexer's referrers projection. No
    auth required — same data shape as /v1/referral/me, just looked
    up by query parameter instead of authed owner.
  - sdk-web client: getReferralInfo(address) wraps the new endpoint.
  - ReferralSignIn: probe getReferralInfo on wallet connect. If the
    user already has a code, render ReferralStats + ClaimFeesCard
    + ShareLinkCard immediately. Otherwise fall through to the
    existing CreateCodeCard. The optional 'Advanced — full
    dashboard' panel is still available for whitelisted wallets to
    unlock the trade-by-trade activity tables.
@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
noether Ready Ready Preview, Comment May 18, 2026 2:25pm

Request Review

@mertcicekci0
mertcicekci0 merged commit 0c56a5a into main May 18, 2026
8 checks passed
@mertcicekci0
mertcicekci0 deleted the feat/referral-onchain-state branch May 18, 2026 14:26
mertcicekci0 added a commit that referenced this pull request May 18, 2026
Was meant to ship in #18 but got dropped from the staging set.
Returns { self, binding } looked up by address (same shape as the
authed /v1/referral/me, just keyed by query param). Lets the web
referrals page render an existing code without going through the
closed-beta API key handshake.
y4hyya added a commit that referenced this pull request Jul 18, 2026
…aluation (V-4)

Closes the cross-vault drain and the deposit-timing wealth transfer:

- V-1 isolation: DELETE sync_total_usdc (assigned the whole factory balance
  to one vault). Every leader op now credits a MEASURED balance delta to its
  own vault, and position/order → vault ownership maps (PositionVault/
  OrderVault + capped VaultPositions/VaultOrders) gate leader_close/cancel
  with #16 NotVaultPosition. Fixes latent arity bugs (open/close now pass
  acceptable_price for the L0-10 market).
- V-4 valuation: full_nav = liquid + Σ position equity (market.get_position
  _equity) + Σ pending-order collateral, fail-closed (#18). deposit/withdraw/
  claim price at full NAV; withdraw caps payout at liquid cash (#17 Liquidity
  Deployed, never a silent haircut); claim measures gain on full NAV, capped
  by liquid + post-payout HWM reset.
- reconcile_order (permissionless, idempotent): binds a keeper-executed order
  to its position, or credits a cancelled order's refund; order_reconciled event.
- Launch controls: create_vault leader allowlist + max-vaults cap (#20), admin
  set_leader_allowlist/set_max_vaults, and the factory's first upgrade() hook.

vault_factory 46,639 B optimized (84KB headroom). 12 new tests; 49 factory,
137 market pass. Off-chain (indexer decoders, api navFull, web full-NAV +
#16-20, keeper reconcile) tracked for the sweep.
y4hyya added a commit that referenced this pull request Jul 18, 2026
…IF passthrough

Leaders can now set protective orders on vault positions:
- leader_set_stop_loss / leader_set_take_profit / leader_place_trailing_stop
  attach to a vault position (ownership via L0-20's PositionVault map, #16 on
  a foreign position); they lock nothing, so no delta accounting.
- leader_place_stop_limit prefunds → measured-delta + OrderVault, reconciled
  by the existing reconcile_order (stop-limit drops the TIF arg — Soroban's
  10-param cap; TIF passthrough lives on leader_place_limit_order, whose
  hardcoded GTC is replaced by a real time_in_force param — ARITY BUMP,
  tx-builders/SDK deferred to sweep).

Executed-close reconciliation (the subtle path): a keeper-fired protective
close settles proceeds to the factory with NO factory call, so the market
now records each full close/liquidation's trader-proceeds in TEMPORARY
storage (ClosedProceeds + get_closed_proceeds view). reconcile_position reads
the EXACT amount and credits it — no fragile global-surplus attribution.
While a stale position lingers, full_nav fail-closes (#18), so the keeper
reconciles promptly. Partial-liq of a vault position stays a documented edge.

market 99,667 B, vault_factory 52,919 B optimized. 6 new tests (5 factory +
1 market); 142 market + 54 factory pass.
y4hyya added a commit that referenced this pull request Jul 20, 2026
Global PauseBanner polls get_pause_state every 30s: mode 1 renders the
amber exit-only strip (closes/protective orders/cancels/withdrawals work),
mode 2 the red full-freeze strip; a pre-Batch-1 market (null read) renders
nothing. Vault detail gains a Full NAV stat from the factory's get_full_nav
— liquid + live position equity + pending order collateral, with honest
'—' copy while the contract fail-closes (#18) awaiting reconciliation
(which the keeper now performs automatically). Row omitted entirely on the
pre-L0-20 factory. Recovery needs no user surface: the vault flow is
admin-only and timelocked; withdrawals stay open by design.
y4hyya added a commit that referenced this pull request Jul 20, 2026
Indexer: trade_recorded decodes both the 6-field Batch-1 payload and the
5-field legacy one (volume NULL); migration 004 adds
referral_trades.volume; handler + fixtures cover both generations.
Types: canonical + vendored ReferralTradeRecordedEvent gain volume.
Gateway: /v1/referral trade rows expose volume.

tx-builders: Referral.buildReferralClaimOp/Args/Tx — the single source of
truth for the wallet-only claim (XDR snapshot pinned).

Web: ClaimFeesCard goes live behind a SAFETY GATE — claims enable only
when the deployed registry reports referral_v1 (the v0 claim() would
zero an earned balance without paying), with the earn/save economics
line sourced from get_config, never hardcoded. ReferralError #16-#18
friendly copy added. Promise-copy elsewhere stays dark until the deploy
by design (never advertise unpaid economics).
y4hyya added a commit that referenced this pull request Jul 21, 2026
…fail-soft)

PauseStateService: cached get_pause_state read (effective mode, 72h
degrade applied read-side) surfaced as health.market.pauseState;
supported:false on the pre-Batch-1 market — unknown is never 'live'.

VaultsService gains chain-backed fullNav(id) via the factory's
get_full_nav view, served as navFull on /v1/vaults/:id (null =
pre-Batch-1 / #18 fail-closed / transport failure — never a fabricated
zero). Both optional deps so db-only test setups stay untouched.
21 api test files green.
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.

1 participant