@@ -34,6 +34,7 @@ Now accessing `GET /pay/hello.json` requires NIP-98 authentication and 1 sat of
3434| ` --pay-address <addr> ` | Address for receiving MRC20 token deposits | - |
3535| ` --pay-token <ticker> ` | Token to sell (enables buy/withdraw/sell/swap) | - |
3636| ` --pay-rate <n> ` | Sats per token for buy/withdraw | ` 1 ` |
37+ | ` --pay-chains <ids> ` | Multi-chain deposits + AMM (e.g. ` "tbtc3,tbtc4" ` ) | - |
3738
3839### Environment Variables
3940
@@ -44,6 +45,7 @@ export JSS_PAY_MEMPOOL_URL=https://mempool.space/testnet4
4445export JSS_PAY_ADDRESS=tb1q...
4546export JSS_PAY_TOKEN=PODS
4647export JSS_PAY_RATE=10
48+ export JSS_PAY_CHAINS=tbtc3,tbtc4
4749```
4850
4951## API Endpoints
@@ -52,19 +54,21 @@ export JSS_PAY_RATE=10
5254
5355| Method | Path | Description |
5456| --------| ------| -------------|
55- | GET | ` /pay/.info ` | Payment config: cost, token info, available routes |
57+ | GET | ` /pay/.info ` | Payment config: cost, token info, chains, pool |
5658| GET | ` /pay/.offers ` | Open sell orders (secondary market) |
59+ | GET | ` /pay/.pool ` | AMM pool state (requires ` --pay-chains ` ) |
5760
5861### Authenticated (NIP-98)
5962
6063| Method | Path | Description |
6164| --------| ------| -------------|
62- | GET | ` /pay/.balance ` | Check your sat balance |
65+ | GET | ` /pay/.balance ` | Check your balance (includes per-chain balances) |
6366| POST | ` /pay/.deposit ` | Deposit sats (TXO URI) or MRC20 tokens |
6467| POST | ` /pay/.buy ` | Buy tokens with sat balance |
6568| POST | ` /pay/.withdraw ` | Withdraw balance as portable tokens |
6669| POST | ` /pay/.sell ` | Create a sell order |
6770| POST | ` /pay/.swap ` | Execute a swap against a sell order |
71+ | POST | ` /pay/.pool ` | AMM: swap, add-liquidity, remove-liquidity |
6872| GET | ` /pay/* ` | Access a paid resource (deducts balance) |
6973
7074## How It Works
@@ -219,13 +223,103 @@ curl -X POST -H "Authorization: Nostr <token>" \
219223
220224The pod transfers tokens from seller to buyer on the Bitcoin trail, debits the buyer's sats, and credits the seller's sats.
221225
226+ ## Multi-Chain AMM
227+
228+ When ` --pay-chains ` is configured with two or more chain IDs, the pod enables multi-chain deposits and an automated market maker.
229+
230+ ``` bash
231+ jss start --pay --pay-chains " tbtc3,tbtc4"
232+ ```
233+
234+ ### Supported Chains
235+
236+ | Chain ID | Network | Explorer |
237+ | ----------| ---------| ----------|
238+ | ` btc ` | Bitcoin mainnet | mempool.space |
239+ | ` tbtc3 ` | Bitcoin Testnet3 | mempool.space/testnet |
240+ | ` tbtc4 ` | Bitcoin Testnet4 | mempool.space/testnet4 |
241+ | ` ltc ` | Litecoin | litecoinspace.org |
242+ | ` signet ` | Bitcoin Signet | mempool.space/signet |
243+
244+ ### Multi-Chain Deposits
245+
246+ Deposits detect the chain from the TXO URI prefix:
247+
248+ ``` bash
249+ # Deposit testnet3 sats
250+ curl -X POST -H " Authorization: Nostr <token>" \
251+ https://example.com/pay/.deposit \
252+ -d " txo:tbtc3:<txid>:<vout>"
253+
254+ # Deposit testnet4 sats
255+ curl -X POST -H " Authorization: Nostr <token>" \
256+ https://example.com/pay/.deposit \
257+ -d " txo:tbtc4:<txid>:<vout>"
258+ ```
259+
260+ Each chain's balance is tracked separately in the webledger using multi-currency format. The ` .balance ` endpoint returns per-chain balances:
261+
262+ ``` json
263+ {
264+ "did" : " did:nostr:<pubkey>" ,
265+ "balance" : 0 ,
266+ "balances" : { "tbtc3" : 10000 , "tbtc4" : 50000 }
267+ }
268+ ```
269+
270+ ### AMM Pool
271+
272+ The pool uses a constant-product formula (x × y = k) with a 0.3% fee on swaps.
273+
274+ ** Add liquidity:**
275+ ``` bash
276+ curl -X POST -H " Authorization: Nostr <token>" \
277+ -H " Content-Type: application/json" \
278+ https://example.com/pay/.pool \
279+ -d ' {"action": "add-liquidity", "tbtc3": 1000, "tbtc4": 5000}'
280+ ```
281+
282+ ** Swap:**
283+ ``` bash
284+ curl -X POST -H " Authorization: Nostr <token>" \
285+ -H " Content-Type: application/json" \
286+ https://example.com/pay/.pool \
287+ -d ' {"action": "swap", "sell": "tbtc3", "amount": 100, "minReceived": 400}'
288+ ```
289+
290+ ** Remove liquidity:**
291+ ``` bash
292+ curl -X POST -H " Authorization: Nostr <token>" \
293+ -H " Content-Type: application/json" \
294+ https://example.com/pay/.pool \
295+ -d ' {"action": "remove-liquidity", "shares": 50}'
296+ ```
297+
298+ ** Pool state (public):**
299+ ``` bash
300+ curl https://example.com/pay/.pool
301+ ```
302+
303+ ``` json
304+ {
305+ "pair" : [" tbtc3" , " tbtc4" ],
306+ "reserves" : { "tbtc3" : 10000 , "tbtc4" : 50000 },
307+ "k" : 500000000 ,
308+ "fee" : 0.003 ,
309+ "totalShares" : 22360 ,
310+ "lpShares" : { "did:nostr:<pubkey>" : 22360 }
311+ }
312+ ```
313+
222314## Use Cases
223315
224316- ** Paid APIs** — AI agents, data feeds, premium content, all metered per-request
225317- ** Agent Economy** — Agents self-provision access with a funded Bitcoin UTXO
226318- ** Pod Monetization** — Pod owners mint tokens and sell access
227319- ** Portable Credits** — Buy on one pod, withdraw, deposit on another
228320- ** Micropayments** — No Lightning channels, no payment processor, just Bitcoin UTXOs
321+ - ** Cross-chain trading** — AMM pool between any two UTXO chains (e.g. testnet3 ↔ testnet4)
322+ - ** Liquidity provision** — Earn 0.3% fees by providing liquidity to AMM pools
229323
230324## Balance Tracking
231325
0 commit comments