Skip to content

feat(exchange): real on-chain buy/sell + live UZS price - #48

Merged
temrjan merged 1 commit into
mainfrom
feat/stage5-exchange
Jul 28, 2026
Merged

feat(exchange): real on-chain buy/sell + live UZS price#48
temrjan merged 1 commit into
mainfrom
feat/stage5-exchange

Conversation

@temrjan

@temrjan temrjan commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Stage 5 (scope-C, final screen). Real on-chain price (/rates, UZS) + real two-step swap (approve → Exchange.buy/sell) signed by the wallet, replacing the hardcoded $85 fallbacks. Frontend-only (backend /rates+/quote already exist). Gate-2 APPROVED (/security-review + /typescript-review clean; 2 suggestions applied: fresh quote before signing + quote.side check). Gates: tsc + eslint 0 err + vitest 21/21 (computeMinOut red→green). On-chain staging proven: BUY 1000 UZD→+0.000634 OLTIN minted; SELL 0.1 OLTIN→+157603.83 UZD from treasury; all receipts success. Report: .claude/reports/2026-07-29-stage5-exchange.md. FLAGGED follow-up (Reviewer, pre-demo priority): history feed misrepresents multi-token swap/transfer events by symbol.

Stage 5 (scope-C, final screen). Replace the hardcoded $85 exchange screen
(the /exchange/* endpoints never existed -> 404 -> frontend fallbacks) with the
real on-chain price and a real two-step swap signed by the user's wallet.

- contracts: UZD -> V3.1 (was retired V2); add EXCHANGE + EXCHANGE_ABI
- chain: approveForExchange / exchangeBuy / exchangeSell (viem, wallet-signed)
- api: getRates (public /rates) + getQuote (auth /quote); drop the dead
  getPrice/getOrderbook/getSwapQuote/executeSwap
- format: computeMinOut (client-side slippage floor from estimated_out_wei) + vitest
- exchange page: price from /rates in UZS (no $, no fake bid/ask spread); quote
  from /quote; swap = approve -> buy/sell, each receipt-gated (status==success),
  pending by step; minOut with 1% slippage (buy minOltinOut>0); on-chain error
  mapping (stale/treasury/dust/gas, approve-already-spent note); wei amounts
  (parseTokenAmount), balance checked in wei
- useRates hook; Rates/Quote types
@temrjan
temrjan merged commit 9dde1a7 into main Jul 28, 2026
1 check passed
@temrjan
temrjan deleted the feat/stage5-exchange branch July 28, 2026 18:16
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