|
| 1 | +# RFQ Backend SDK and MVP Demo Plan |
| 2 | + |
| 3 | +## Status |
| 4 | + |
| 5 | +Planned. This document defines scope before implementation. |
| 6 | + |
| 7 | +## Purpose |
| 8 | + |
| 9 | +Corner Store needs an off-chain RFQ component because a maker must price and sign quotes before a taker submits settlement through `ExecutionRouter` and `RFQAdapter`. |
| 10 | + |
| 11 | +Corner Store should not provide or operate a production RFQ server. The product should provide: |
| 12 | + |
| 13 | +1. TypeScript SDK pieces for integrators to build their own RFQ quote backend. |
| 14 | +2. A local-only reference example that demonstrates those SDK pieces. |
| 15 | +3. A later MVP demo backend that uses the SDK from a user's point of view. |
| 16 | + |
| 17 | +The separation matters: the SDK is reusable product infrastructure; the MVP backend is an application/demo built on top of it. |
| 18 | + |
| 19 | +## Current baseline |
| 20 | + |
| 21 | +Already implemented: |
| 22 | + |
| 23 | +- Solidity `RFQAdapter` with EIP-712 quote verification. |
| 24 | +- Router-only settlement path. |
| 25 | +- full-fill / exact-taker v1 behavior. |
| 26 | +- nonce, expiry, signature and quote-field binding tests. |
| 27 | +- `services/rfq` minimal TypeScript quote signer reference. |
| 28 | + |
| 29 | +Current gap on `main` before the stacked PRs land: |
| 30 | + |
| 31 | +- `services/rfq` is not yet shaped as a backend SDK. |
| 32 | +- signer, nonce, pricing and risk boundaries are not explicit enough for reuse. |
| 33 | +- there is no MVP user-facing RFQ backend flow yet. |
| 34 | + |
| 35 | +Open PR context to preserve when planning implementation: |
| 36 | + |
| 37 | +- PR #24 adds RFQ maker approval and quote cancellation hardening. |
| 38 | +- PR #28 adds protected-router RFQ integration scenarios. |
| 39 | +- PR #29 adds a live-Anvil E2E runner and scripted demo vehicle. |
| 40 | +- PR #30 adds an interactive CLI using the deployed stack and RFQ quote path. |
| 41 | +- PR #35 adds the BUIDL-like ERC-3643 compliance fixture with mock TA facts. |
| 42 | + |
| 43 | +Those PRs should be treated as pending upstream context. The RFQ SDK work should |
| 44 | +not duplicate their contract tests, E2E runner, CLI, or BUIDL fixture; it should |
| 45 | +provide the reusable TypeScript backend boundary those layers can call. |
| 46 | + |
| 47 | +## Layering |
| 48 | + |
| 49 | +```text |
| 50 | +src/execution/adapters/rfq/RFQAdapter.sol |
| 51 | + -> on-chain settlement, signature verification, replay/expiry checks |
| 52 | +
|
| 53 | +services/rfq SDK |
| 54 | + -> quote construction, typed-data shape, validation, signing abstractions |
| 55 | +
|
| 56 | +local reference example |
| 57 | + -> mock pricing + in-memory nonce + local signer for integration guidance |
| 58 | +
|
| 59 | +MVP demo backend |
| 60 | + -> user-facing quote API built from the SDK for demos only |
| 61 | +``` |
| 62 | + |
| 63 | +## Phase 1 — RFQ TypeScript SDK interfaces |
| 64 | + |
| 65 | +Goal: make `services/rfq` usable as the reusable quote-backend integration layer. |
| 66 | + |
| 67 | +Deliverables: |
| 68 | + |
| 69 | +- SDK interfaces: |
| 70 | + - `TypedDataSigner` |
| 71 | + - `NonceStore` |
| 72 | + - `PricingProvider` |
| 73 | + - `InventoryRiskCheck` placeholder |
| 74 | +- quote request/response validation: |
| 75 | + - address format |
| 76 | + - safe integer / bigint / decimal string amount handling |
| 77 | + - positive amount checks |
| 78 | + - TTL and expiry checks |
| 79 | + - chainId and verifyingContract binding |
| 80 | + - venue binding |
| 81 | +- keep EIP-712 typed-data generation compatible with `RFQAdapter`. |
| 82 | +- keep backend compliance as a non-goal; final compliance remains at fill time in `ExecutionRouter`. |
| 83 | +- local reference implementation: |
| 84 | + - in-memory nonce store |
| 85 | + - fixed/mock pricing provider |
| 86 | + - capture/mock signer for tests |
| 87 | +- tests for: |
| 88 | + - quote generation |
| 89 | + - invalid request rejection |
| 90 | + - unsafe number rejection |
| 91 | + - nonce uniqueness |
| 92 | + - typed-data shape compatibility |
| 93 | + |
| 94 | +Acceptance criteria: |
| 95 | + |
| 96 | +- `cd services/rfq && npm test` passes. |
| 97 | +- repo-level check includes the RFQ service test. |
| 98 | +- docs clearly state this is an SDK layer, not a production server. |
| 99 | + |
| 100 | +## Phase 2 — Local reference example |
| 101 | + |
| 102 | +Goal: show how an operator would wire the SDK without implying Corner Store operates the backend. |
| 103 | + |
| 104 | +Deliverables: |
| 105 | + |
| 106 | +- local-only example entrypoint under `services/rfq`. |
| 107 | +- mock pricing. |
| 108 | +- in-memory nonce. |
| 109 | +- test signer or local private-key signer clearly marked as non-production. |
| 110 | +- sample request/response for signed quote generation. |
| 111 | + |
| 112 | +Non-goals: |
| 113 | + |
| 114 | +- no hosted server. |
| 115 | +- no production key custody. |
| 116 | +- no market-making strategy. |
| 117 | +- no inventory management. |
| 118 | +- no compliance final decision. |
| 119 | +- no dashboard. |
| 120 | + |
| 121 | +Acceptance criteria: |
| 122 | + |
| 123 | +- a developer can run a local command to produce a signed quote payload compatible with `RFQAdapter`. |
| 124 | +- documentation explains which parts an operator must replace in production. |
| 125 | + |
| 126 | +## Phase 3 — MVP demo backend |
| 127 | + |
| 128 | +Goal: provide a demo backend that uses the RFQ SDK from a user's point of view. |
| 129 | + |
| 130 | +This is separate from the SDK issue and should be implemented after Phase 1. If |
| 131 | +PR #29/#30 are merged first, this backend should reuse the live-Anvil demo |
| 132 | +runner and CLI configuration instead of creating another deployment/demo path. |
| 133 | +If PR #35 is merged first, the BUIDL-like asset should be the default regulated |
| 134 | +asset scenario for this demo backend. |
| 135 | + |
| 136 | +Target demo flow: |
| 137 | + |
| 138 | +```text |
| 139 | +user requests quote |
| 140 | + -> MVP backend calls RFQ SDK |
| 141 | + -> mock maker prices and signs quote |
| 142 | + -> user receives signed quote |
| 143 | + -> user submits through ExecutionRouter/RFQAdapter |
| 144 | + -> on-chain compliance passes or rejects |
| 145 | + -> UI/CLI shows result |
| 146 | +``` |
| 147 | + |
| 148 | +Potential deliverables: |
| 149 | + |
| 150 | +- local HTTP API or CLI wrapper. |
| 151 | +- `/quote`-style request/response shape if HTTP is chosen. |
| 152 | +- BUIDL-like demo asset pair config. |
| 153 | +- integration guide for local Anvil/Foundry deployment. |
| 154 | +- optional later dashboard issue. |
| 155 | + |
| 156 | +MVP backend non-goals: |
| 157 | + |
| 158 | +- no production RFQ operator service. |
| 159 | +- no real market maker. |
| 160 | +- no real custody. |
| 161 | +- no production signer/key-management claims. |
| 162 | +- no backend-side compliance override. |
| 163 | + |
| 164 | +Acceptance criteria: |
| 165 | + |
| 166 | +- demo flow can generate a quote and settle it through the protected Router path. |
| 167 | +- success and compliance rejection cases are both visible. |
| 168 | +- documentation states that production operators must replace pricing, signer custody, nonce persistence and risk controls. |
| 169 | + |
| 170 | + |
| 171 | +## Documentation audit notes |
| 172 | + |
| 173 | +This planning pass checked the product-spec index, roadmap, RFQ venue architecture, |
| 174 | +feature state, progress notes and open PRs #24, #28, #29, #30 and #35. The gaps |
| 175 | +found in current source-of-truth docs were: |
| 176 | + |
| 177 | +- RFQ backend SDK work was not explicitly separated from production RFQ server operation. |
| 178 | +- MVP demo backend was not listed as a later application/demo layer built on the SDK. |
| 179 | +- near-term roadmap issues jumped from RFQ v1 settlement to production hardening, skipping the SDK and demo-backend bridge. |
| 180 | +- pending E2E/CLI/BUIDL PRs were not called out as context for future RFQ backend planning. |
| 181 | + |
| 182 | +This document fills those gaps. Production RFQ hardening remains a separate track |
| 183 | +for dealer approval, custody, cancellation and partial-fill policy. |
| 184 | + |
| 185 | +## Product boundary |
| 186 | + |
| 187 | +RFQ backend responsibilities remain split: |
| 188 | + |
| 189 | +| Area | Corner Store provides | Operator provides in production | |
| 190 | +| --- | --- | --- | |
| 191 | +| Quote format | SDK and tests | integration into their backend | |
| 192 | +| EIP-712 typed data | SDK | signer custody and policy | |
| 193 | +| Pricing | mock/reference only | actual pricing strategy | |
| 194 | +| Nonce | interface + in-memory demo | persistent nonce store | |
| 195 | +| Inventory/risk | placeholder interface | actual inventory and risk controls | |
| 196 | +| Compliance | on-chain final gate | optional precheck only | |
| 197 | +| Hosting | none | operator-owned infrastructure | |
| 198 | + |
| 199 | +## First implementation issue |
| 200 | + |
| 201 | +Recommended first issue: |
| 202 | + |
| 203 | +```text |
| 204 | +feat(rfq): add TypeScript SDK interfaces for quote backend integration |
| 205 | +``` |
| 206 | + |
| 207 | +That issue should not implement the MVP backend. It should prepare the SDK foundation the MVP backend will use. |
0 commit comments