-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.json
More file actions
443 lines (443 loc) · 13.5 KB
/
openapi.json
File metadata and controls
443 lines (443 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
{
"openapi": "3.1.0",
"info": {
"title": "RigoBlock Agent Trader API",
"description": "AI-powered DeFi trading API for autonomous agents. All endpoints are protected by the x402 payment protocol \u2014 no API key required. Agents pay per request in USDC on Base (chain ID 8453) via the Coinbase Developer Platform facilitator.\n\n## x402 Payment Flow\n1. Agent makes a request \u2192 server responds `402 Payment Required` with a payment payload\n2. Agent pays in USDC on Base via `api.cdp.coinbase.com`\n3. Agent retries with the `X-Payment` header \u2192 receives structured data\n\n**Facilitator:** `api.cdp.coinbase.com` \n**Payment token:** USDC on Base (chain ID 8453) \n**Integration guide:** https://github.com/rigoblock/agent-sdk",
"version": "1.0.0",
"contact": {
"name": "RigoBlock",
"url": "https://rigoblock.com",
"email": "gab@rigoblock.com"
},
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "https://trader.rigoblock.com",
"description": "Production"
}
],
"paths": {
"/api/quote": {
"get": {
"operationId": "getDexQuote",
"summary": "Get DEX swap quote",
"description": "Returns the best swap quote routed automatically across Uniswap V2, V3, and V4. No vault or wallet context required \u2014 any agent can call this endpoint.\n\n**Price:** $0.002 USDC per request (paid via x402)",
"tags": [
"Quotes"
],
"parameters": [
{
"name": "sell",
"in": "query",
"required": true,
"description": "Token to sell \u2014 ticker symbol (e.g. `ETH`) or ERC-20 contract address.",
"schema": {
"type": "string",
"example": "ETH"
}
},
{
"name": "buy",
"in": "query",
"required": true,
"description": "Token to buy \u2014 ticker symbol (e.g. `USDC`) or ERC-20 contract address.",
"schema": {
"type": "string",
"example": "USDC"
}
},
{
"name": "amount",
"in": "query",
"required": true,
"description": "Human-readable amount of the sell token (e.g. `1` for 1 ETH).",
"schema": {
"type": "string",
"example": "1"
}
},
{
"name": "chain",
"in": "query",
"required": false,
"description": "Target chain. Accepts chain name or chain ID.",
"schema": {
"type": "string",
"default": "base",
"enum": [
"base",
"arbitrum",
"ethereum",
"optimism",
"polygon",
"bsc",
"unichain"
],
"example": "base"
}
}
],
"responses": {
"200": {
"description": "Successful quote response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/QuoteResponse"
}
}
}
},
"402": {
"description": "Payment required (x402). Pay in USDC on Base and retry with `X-Payment` header.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/X402PaymentRequired"
}
}
}
},
"400": {
"description": "Bad request \u2014 missing or invalid parameters",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"security": [
{
"x402": []
}
]
}
},
"/api/chat": {
"post": {
"operationId": "agentChat",
"summary": "AI-powered DeFi agent chat",
"description": "Natural language DeFi interface for autonomous agents. Send a message describing a trading intent and receive swap calldata, position summaries, or market analysis \u2014 ready for on-chain execution.\n\n**Price:** $0.01 USDC per request (paid via x402)",
"tags": [
"Agent"
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChatRequest"
},
"example": {
"messages": [
{
"role": "user",
"content": "Swap 0.1 ETH for USDC on Base"
}
],
"vaultAddress": "0xYourVaultAddress"
}
}
}
},
"responses": {
"200": {
"description": "AI response with DeFi action or analysis",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChatResponse"
}
}
}
},
"402": {
"description": "Payment required (x402). Pay in USDC on Base and retry with `X-Payment` header.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/X402PaymentRequired"
}
}
}
},
"400": {
"description": "Bad request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
},
"security": [
{
"x402": []
}
]
}
}
},
"components": {
"securitySchemes": {
"x402": {
"type": "apiKey",
"in": "header",
"name": "X-Payment",
"description": "x402 payment header. Flow:\n1. Make the request without this header \u2192 receive `402 Payment Required`\n2. Submit USDC payment on Base (chain 8453) via `api.cdp.coinbase.com`\n3. Retry the request with this header set to the payment receipt\n\nSee https://github.com/rigoblock/agent-sdk for full integration."
}
},
"schemas": {
"QuoteResponse": {
"type": "object",
"description": "Best swap quote across Uniswap V2/V3/V4",
"properties": {
"sellToken": {
"type": "string",
"description": "Address of the token being sold",
"example": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
},
"buyToken": {
"type": "string",
"description": "Address of the token being bought",
"example": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
},
"sellAmount": {
"type": "string",
"description": "Sell amount in token base units (wei)",
"example": "1000000000000000000"
},
"buyAmount": {
"type": "string",
"description": "Buy amount in token base units",
"example": "2485000000"
},
"price": {
"type": "string",
"description": "Exchange rate (buy per sell)",
"example": "2485.00"
},
"source": {
"type": "string",
"description": "DEX source routing the quote",
"example": "Uniswap_V3"
},
"chain": {
"type": "string",
"description": "Chain the quote is valid on",
"example": "base"
},
"calldata": {
"type": "string",
"description": "Encoded calldata for on-chain execution"
},
"to": {
"type": "string",
"description": "Contract address to send the swap transaction to"
},
"value": {
"type": "string",
"description": "ETH value to attach (for native token swaps)",
"example": "1000000000000000000"
},
"gasEstimate": {
"type": "string",
"description": "Estimated gas units for the transaction",
"example": "180000"
}
}
},
"ChatRequest": {
"type": "object",
"required": [
"messages"
],
"properties": {
"messages": {
"type": "array",
"description": "Conversation history in OpenAI message format",
"items": {
"type": "object",
"required": [
"role",
"content"
],
"properties": {
"role": {
"type": "string",
"enum": [
"user",
"assistant",
"system"
]
},
"content": {
"type": "string"
}
}
}
},
"vaultAddress": {
"type": "string",
"description": "RigoBlock vault (smart pool) address for vault-scoped operations",
"example": "0xYourVaultAddress"
},
"chain": {
"type": "string",
"description": "Target chain context",
"default": "base",
"enum": [
"base",
"arbitrum",
"ethereum",
"optimism",
"polygon",
"bsc",
"unichain"
]
}
}
},
"ChatResponse": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "AI-generated response text"
},
"action": {
"type": "object",
"description": "Executable on-chain action, if applicable",
"properties": {
"type": {
"type": "string",
"enum": [
"swap",
"position",
"analysis"
],
"description": "Action type"
},
"to": {
"type": "string",
"description": "Contract address"
},
"calldata": {
"type": "string",
"description": "Encoded transaction calldata"
},
"value": {
"type": "string",
"description": "ETH value to attach"
},
"gasEstimate": {
"type": "string",
"description": "Estimated gas"
}
}
}
}
},
"X402PaymentRequired": {
"type": "object",
"description": "Standard x402 payment challenge",
"properties": {
"x402Version": {
"type": "integer",
"example": 1
},
"error": {
"type": "string",
"example": "X-PAYMENT-REQUIRED"
},
"accepts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"scheme": {
"type": "string",
"example": "exact"
},
"network": {
"type": "string",
"example": "base"
},
"maxAmountRequired": {
"type": "string",
"example": "2000"
},
"resource": {
"type": "string",
"example": "https://trader.rigoblock.com/api/quote"
},
"description": {
"type": "string"
},
"mimeType": {
"type": "string",
"example": "application/json"
},
"payTo": {
"type": "string",
"description": "USDC recipient address on Base"
},
"maxTimeoutSeconds": {
"type": "integer",
"example": 300
},
"asset": {
"type": "string",
"description": "USDC contract address on Base",
"example": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
},
"extra": {
"type": "object",
"properties": {
"name": {
"type": "string",
"example": "USDC"
},
"version": {
"type": "string",
"example": "2"
}
}
}
}
}
}
}
},
"ErrorResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"message": {
"type": "string"
}
}
}
}
},
"tags": [
{
"name": "Quotes",
"description": "DEX price quotes \u2014 no wallet or vault context required"
},
{
"name": "Agent",
"description": "AI-powered DeFi agent interface \u2014 natural language to calldata"
}
]
}