Commit cdca219
Rotwang9000
feat(x402): pay-per-call premium tier on /v1/premium/* + MCP
Adds an honest revenue mechanism for the data API: per-request USDC
payment via the x402 protocol on Base mainnet. The paywall is off by
default (X402_RECIPIENT_ADDRESS unset → 503 paywall_not_configured) so
the public service keeps shipping the free surface untouched. When the
operator sets a recipient, unsigned requests get HTTP 402 + machine
readable PaymentRequirements; the @x402/fastify middleware delegates
verification + EIP-3009 settlement to the configured facilitator
(default https://x402.org/facilitator).
First paid endpoint: GET /v1/premium/opportunities. Returns the
uncapped at-risk borrower catalogue joined with realised 7d market
intel (top liquidators, win rate per (collateral,debt) pair, our own
attempt outcomes per Morpho market) and ranked by expected value
(debt × bonus × historical win-rate). Pure SQL over data we already
collect; no live RPC.
MCP surface gains two tools mirrored from the REST routes:
- seneschal_paywall_info (free, exposes price/recipient/network)
- seneschal_premium_opportunities (returns the feed; MCP transports
don't yet negotiate payment, so this stays free until the spec
lands a transport-level 402)
Dashboard + landing page surface the premium tier when configured.
.github/FUNDING.yml adds GitHub Sponsors visibility + a custom link
to /v1/paywall.
Tests: 108 passing (+33 new). Unit-tests cover config validation,
describePaywall projection, market-intel aggregation, EV ranking,
parameter validation, and REST 402/503 wire-up.1 parent 6b36277 commit cdca219
17 files changed
Lines changed: 15720 additions & 3961 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
153 | 197 | | |
154 | 198 | | |
155 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
50 | 66 | | |
51 | 67 | | |
52 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
264 | 271 | | |
265 | 272 | | |
266 | 273 | | |
| |||
580 | 587 | | |
581 | 588 | | |
582 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
583 | 625 | | |
584 | 626 | | |
585 | 627 | | |
| |||
640 | 682 | | |
641 | 683 | | |
642 | 684 | | |
| 685 | + | |
643 | 686 | | |
644 | 687 | | |
645 | 688 | | |
| |||
0 commit comments