Skip to content

feat(rfq): add reference RFQ settlement adapter and quote signer#21

Open
0xMuang wants to merge 3 commits into
mainfrom
feature/rfq-v1
Open

feat(rfq): add reference RFQ settlement adapter and quote signer#21
0xMuang wants to merge 3 commits into
mainfrom
feature/rfq-v1

Conversation

@0xMuang

@0xMuang 0xMuang commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #20.

RFQ v1 reference settlement를 구현하고, 현재 코드 상태에 맞춰 roadmap / milestone 문서를 최신화했습니다.

이번 PR은 루트 Foundry 구조를 옮기지 않고, RFQ를 AMM과 같은 ExecutionRouter / Adapter 구조에 붙는 모듈형 venue로 추가합니다. 온체인에서는 signed RFQ quote를 검증하고 settlement하며, 오프체인에는 quote를 생성·서명하는 최소 TypeScript reference service를 추가했습니다.

What changed

Onchain RFQ settlement

  • RFQAdapter를 실제 동작하는 reference adapter로 구현했습니다.
  • RFQQuote type을 추가했습니다.
  • maker가 서명한 EIP-712 typed quote를 검증합니다.
  • quote는 다음 값에 바인딩됩니다.
    • maker
    • taker
    • tokenIn / tokenOut
    • amountIn / amountOut
    • venue
    • nonce
    • expiry
    • chainId / verifyingContract domain
  • Router를 통하지 않는 direct adapter call은 거부합니다.
  • maker별 nonce replay를 방지합니다.
  • settlement는 SafeERC20.transferFrom 기반으로 taker → maker, maker → taker를 원자적으로 수행합니다.
  • v1은 full-fill only, exact-taker only입니다.

RFQ reference service

services/rfq에 최소 TypeScript quote signer reference service를 추가했습니다.

이 서비스는 다음만 담당합니다.

  • RFQ quote 생성
  • expiry 부여
  • nonce 부여
  • EIP-712 typed data 생성
  • 외부 signer를 통한 signature 생성 요청

보강한 안전장치:

  • 온체인 정수 필드에 unsafe JavaScript number 입력을 거부합니다.
  • 기본 nonce fallback은 같은 millisecond 안에서도 충돌하지 않도록 monotonic하게 증가합니다.
  • fresh checkout / CI에서 동작하도록 package-lock.jsonnpm ci 경로를 추가했습니다.

명시적으로 포함하지 않은 것:

  • production pricing engine
  • dealer inventory 관리
  • custody
  • websocket / order discovery
  • orderbook matching
  • compliance 판단

Tests

RFQAdapter 테스트를 추가했습니다.

커버한 케이스:

  • valid signed RFQ quote가 Router를 통해 settlement됨
  • invalid signature 거부
  • expired quote 거부
  • reused nonce / replay 거부
  • wrong taker 거부
  • token / amount / venue mismatch 거부
  • direct RFQAdapter call bypass 거부
  • compliance rejection 시 settlement 전 중단

RFQ service smoke test는 다음을 검증합니다.

  • EIP-712 typed-data shape
  • expiry / nonce 부여
  • unsafe number 거부
  • default nonce monotonic fallback

Docs / project state

  • README에 RFQ reference service 사용법과 non-goals를 추가했습니다.
  • venue architecture 문서에 RFQ v1 scope를 반영했습니다.
  • skeleton guide에서 RFQ를 더 이상 revert-only stub로 설명하지 않도록 수정했습니다.
  • ROADMAP에 현재 구현 상태, 남은 production milestone, near-term issues를 최신화했습니다.
  • FEATURES.md, PROGRESS.md, QUALITY.md, docs/testing.md, docs/security.md를 현재 코드 상태에 맞췄습니다.
  • scripts/check.sh와 GitHub Actions CI에 RFQ service smoke test를 포함했습니다.

Non-goals

이번 PR에서 의도적으로 제외한 범위입니다.

  • partial fill
  • orderbook
  • complex dealer approval
  • production pricing engine
  • dealer inventory
  • custody 모델 확장
  • websocket / quote discovery
  • production RFQ API server
  • 루트 Foundry 프로젝트 구조 이동

Verification

다음 검증을 통과했습니다.

forge fmt
forge build
forge test --offline
cd services/rfq && npm test
git diff --check
scripts/check.sh

결과:

  • Foundry tests: 122 passed
  • RFQ service smoke: passed
  • deploy-v3 tests via scripts/check.sh: 10 passed
  • whitespace check: passed

Notes / remaining follow-up

  • RFQ v1은 reference settlement path입니다.
  • production RFQ로 가려면 dealer approval, quote cancellation, custody, partial fill 정책은 별도 feature/ADR로 다뤄야 합니다.
  • backend는 compliance 결정을 하지 않고, 실제 compliance gate는 Router가 fill 시점에 최신 ComplianceEngine.evaluate()로 수행합니다.
  • Order Book은 matching / custody / surveillance 모델 결정 후 별도 작업으로 구현합니다.

0xMuang added 3 commits June 25, 2026 00:52
Implement the smallest reference RFQ path that preserves the existing Router/Adapter boundary while adding an offchain quote signer seam for future dealer work.

Constraint: Keep the root Foundry layout and use the existing ExecutionRouter/VenueRegistry adapter slot.

Rejected: Production dealer pricing, inventory, custody, cancellation, and partial-fill support | outside RFQ v1 reference settlement scope.

Confidence: high

Scope-risk: moderate

Directive: Keep services/rfq reference-only until production dealer, custody, and cancellation decisions are specified.

Tested: forge fmt; forge build; forge test --offline; cd services/rfq && npm test; git diff --check; scripts/check.sh

Not-tested: Production dealer approval, custody, quote cancellation, partial fill, and live backend API deployment.
Refresh the roadmap and quality/testing/security docs so the branch describes the implemented foundation, AMM/RFQ reference paths, and remaining production milestones instead of the old Counter-era state.

Constraint: Keep this as documentation and CI scope only; do not change runtime contracts after RFQ validation.

Rejected: Large roadmap rewrite or new production RFQ policy decisions | the branch only needs current-state alignment before PR.

Confidence: high

Scope-risk: narrow

Directive: Treat RFQ dealer approval, custody, cancellation, partial fill, and Order Book as follow-up features until separately specified.

Tested: scripts/check.sh; git diff --check

Not-tested: GitHub-hosted CI execution after adding RFQ service smoke step.
The CI install only includes TypeScript, so the smoke test should not rely on Node ambient globals unless @types/node is intentionally added.

Constraint: Avoid adding dependencies for the minimal RFQ reference service.

Rejected: Add @types/node | unnecessary for a one-line failure path.

Confidence: high

Scope-risk: narrow

Directive: Keep services/rfq dependency-light until a real API/runtime requires Node typings.

Tested: cd services/rfq && npm test

Not-tested: GitHub-hosted CI rerun after push.
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.

feat(rfq): add reference RFQ settlement path

1 participant