Skip to content

Commit cadb6f4

Browse files
author
CloudLobster
committed
feat: BaseMail v2 — Attention Bond mechanism
Smart contract: - AttentionBondEscrow.sol: USDC escrow, 7-day response window, whitelist, dynamic pricing, protocol fee (10%) Database: - attention_config: per-account pricing params (p₀, α, β, γ) - attention_bonds: escrow tracking (active/refunded/forfeited) - attention_whitelist: sender exemptions - sender_reputation: per-pair reply rates - qaf_scores: Quadratic Attention Value cache API (11 new endpoints): - GET /api/attention/price/:handle — dynamic attention pricing - GET /api/attention/price/:handle/for/:sender — sender-specific price - GET /api/attention/qaf/:handle — QAF score (breadth premium) - PUT /api/attention/config — configure attention bonds - POST /api/attention/bond — record bond deposit - POST /api/attention/reply/:email_id — mark reply → refund - GET/POST/DELETE /api/attention/whitelist — manage exemptions - GET /api/attention/stats — bond dashboard Based on: 'Connection-Oriented Quadratic Attention Funding' Ko, Tang, Weyl (2026)
1 parent a113d6d commit cadb6f4

File tree

5 files changed

+995
-2
lines changed

5 files changed

+995
-2
lines changed

ATTENTION-BOND-PLAN.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# BaseMail v2: Attention Bond Implementation Plan
2+
3+
## Overview
4+
Add the Attention Bond layer to BaseMail: "from agents have email → email has a price."
5+
6+
## Architecture
7+
8+
### 1. Smart Contract: `AttentionBondEscrow.sol`
9+
- USDC escrow for attention bonds (Base Mainnet)
10+
- Sender deposits bond → 7-day window → recipient replies (refund) or ignores (forfeit)
11+
- Whitelist: exempted senders (zero bond)
12+
- Protocol fee τ = 10%
13+
14+
### 2. DB Schema Changes
15+
- `attention_config` table: per-account attention price settings
16+
- `attention_bonds` table: bond escrow tracking
17+
- `whitelist` table: sender whitelist per account
18+
- `reputation` table: sender reputation scores (reply rates)
19+
- `qaf_scores` table: per-account QAF attention value cache
20+
21+
### 3. API Changes
22+
23+
#### New Endpoints
24+
- `GET /api/attention/:handle` — Get attention price for a recipient
25+
- `PUT /api/attention/config` — Set your attention price (p₀, α, β, γ)
26+
- `GET /api/attention/qaf/:handle` — Get QAF score for a recipient
27+
- `POST /api/attention/bond` — Submit bond tx_hash when sending
28+
- `POST /api/attention/reply/:email_id` — Mark reply → trigger refund
29+
- `GET /api/attention/whitelist` — List whitelist
30+
- `POST /api/attention/whitelist` — Add to whitelist
31+
- `DELETE /api/attention/whitelist/:address` — Remove from whitelist
32+
- `GET /api/attention/stats` — Dashboard: bonds received/refunded/forfeited, QAF score
33+
34+
#### Modified Endpoints
35+
- `POST /api/send` — Add optional `attention_bond: { tx_hash, amount }` field
36+
- `GET /api/inbox` — Include bond status per email (bonded/refunded/forfeited)
37+
38+
### 4. Smart Contract Design
39+
40+
```solidity
41+
AttentionBondEscrow {
42+
// Core
43+
deposit(recipient, emailId, amount) → escrow USDC
44+
reply(emailId) → refund (1-τ) to sender, τ to protocol
45+
forfeit(emailId) → after 7 days, transfer to recipient
46+
47+
// Config
48+
setAttentionPrice(basePrice) → set p₀
49+
setWhitelist(sender, status) → exempt/unexempt
50+
51+
// View
52+
getBond(emailId) → bond details
53+
getAttentionPrice(recipient) → current price
54+
}
55+
```
56+
57+
### 5. QAF Calculation (off-chain, worker)
58+
- On each bond deposit, recalculate recipient's QAF: AV = (Σ√bᵢ)²
59+
- Store in `qaf_scores` table
60+
- CO-QAF: when sender graph data available, apply α_ij discount
61+
62+
### 6. Dynamic Pricing (worker)
63+
- p(t,s) = p₀ · (1 + α·D(t))^β · (1 - γ·R̄ₛ(t))
64+
- D(t): message count in rolling 7-day window
65+
- R̄ₛ(t): sender's historical reply rate with this recipient
66+
67+
## Implementation Order
68+
1. ✅ Smart contract (`AttentionBondEscrow.sol`)
69+
2. ✅ DB schema migration
70+
3. ✅ Attention config & whitelist APIs
71+
4. ✅ Bond deposit verification in send flow
72+
5. ✅ Reply/forfeit flow
73+
6. ✅ QAF calculation
74+
7. ✅ Dynamic pricing
75+
8. ✅ Stats dashboard API

0 commit comments

Comments
 (0)