-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.yaml
More file actions
557 lines (532 loc) · 15.3 KB
/
Copy pathopenapi.yaml
File metadata and controls
557 lines (532 loc) · 15.3 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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
openapi: 3.0.3
info:
title: Solder Cortex API
description: |
DeFi Agent Memory Layer - Pre-indexed on-chain data for AI agents.
Cortex solves the problem that AI DeFi agents cannot "remember" a wallet's on-chain history
without re-querying raw chain data. It pre-indexes Solana DeFi data and serves it via fast JSON APIs.
## Data Provider
Cortex uses **LYS Labs** for real-time Solana blockchain data via WebSocket streaming, providing:
- Sub-second latency on transaction events
- Pre-decoded DeFi transactions (swaps, deposits, borrows)
- Support for major DEXs: Jupiter, Raydium, Meteora, Orca, Pump.fun
## Supported Protocols
| Protocol | Type | Supported Operations |
|----------|------|---------------------|
| Jupiter | DEX Aggregator | Swaps |
| Raydium | DEX (AMM/CLMM) | Swaps, LP |
| Kamino | Lending | Supply, Borrow, Withdraw, Repay |
| Meteora | DEX (DLMM) | Swaps |
| Orca | DEX (Whirlpool) | Swaps |
| Pump.fun | Token Launchpad | Swaps |
version: 0.1.0
contact:
name: Solder
license:
name: MIT
servers:
- url: http://localhost:3000
description: Local development server
tags:
- name: Health
description: Service health endpoints
- name: User
description: User wallet data endpoints
- name: Indexer
description: Wallet indexing endpoints
paths:
/health:
get:
tags:
- Health
summary: Health check
description: Returns service health status including database connectivity.
operationId: healthCheck
responses:
'200':
description: Service is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
status: ok
version: 0.1.0
database: connected
/api/v1/user/{wallet}/summary:
get:
tags:
- User
summary: Get user summary
description: |
Returns high-level wallet state including PnL, risk metrics, and protocol exposure.
**Risk Score Interpretation:**
- 0-25: Low risk (diversified, multiple protocols)
- 26-50: Moderate risk (some concentration)
- 51-75: Elevated risk (high concentration)
- 76-100: High risk (single position/protocol dominance)
operationId: getUserSummary
parameters:
- $ref: '#/components/parameters/WalletPath'
responses:
'200':
description: Wallet summary retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UserSummary'
'400':
description: Invalid wallet address
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "Invalid wallet address: xyz"
code: INVALID_WALLET
'404':
description: Wallet not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "Wallet has no indexed data"
code: WALLET_NOT_FOUND
/api/v1/user/{wallet}/pnl:
get:
tags:
- User
summary: Get user PnL
description: Returns detailed PnL breakdown by protocol within a time window.
operationId: getUserPnl
parameters:
- $ref: '#/components/parameters/WalletPath'
- name: window
in: query
description: Time window for PnL calculation
required: false
schema:
type: string
enum:
- 24h
- 7d
- 30d
- all
default: 7d
responses:
'200':
description: PnL data retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UserPnl'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Wallet not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/user/{wallet}/positions:
get:
tags:
- User
summary: Get user positions
description: |
Returns all current open positions across supported protocols.
**Position Types:**
- `lending_supply`: Tokens supplied to lending protocol
- `lending_borrow`: Tokens borrowed from lending protocol
- `lp`: Liquidity pool position
operationId: getUserPositions
parameters:
- $ref: '#/components/parameters/WalletPath'
responses:
'200':
description: Positions retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UserPositions'
'400':
description: Invalid wallet address
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Wallet not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api/v1/index:
post:
tags:
- Indexer
summary: Index wallet
description: |
Triggers real-time indexing for a wallet. This connects to the LYS Labs WebSocket
stream and collects transactions for the specified wallet.
Since LYS Labs provides real-time streaming data, this endpoint streams transactions
as they occur. The indexing process will collect transactions for a configurable
timeout period (default: 60 seconds) or until the transaction limit is reached.
operationId: indexWallet
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/IndexRequest'
example:
wallet: 95n9a8yd6aZzKGMtbWSjqbijZ1u99z1GQF79HkbCvtwN
responses:
'200':
description: Indexing started successfully
content:
application/json:
schema:
$ref: '#/components/schemas/IndexResponse'
'400':
description: Invalid wallet address
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'502':
description: LYS Labs connection error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "Failed to connect to LYS Labs WebSocket"
code: EXTERNAL_API_ERROR
components:
parameters:
WalletPath:
name: wallet
in: path
description: Solana wallet address (base58 encoded)
required: true
schema:
type: string
pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$
example: 95n9a8yd6aZzKGMtbWSjqbijZ1u99z1GQF79HkbCvtwN
schemas:
HealthResponse:
type: object
required:
- status
- version
- database
properties:
status:
type: string
description: Service status
example: ok
version:
type: string
description: API version
example: 0.1.0
database:
type: string
description: Database connection status
example: connected
UserSummary:
type: object
required:
- wallet
- total_value_usd
- pnl
- risk
- protocols
properties:
wallet:
type: string
description: Solana wallet address
example: 95n9a8yd6aZzKGMtbWSjqbijZ1u99z1GQF79HkbCvtwN
total_value_usd:
type: number
format: double
description: Total portfolio value in USD
example: 15420.50
pnl:
$ref: '#/components/schemas/PnlSummary'
risk:
$ref: '#/components/schemas/RiskMetrics'
last_activity:
type: string
format: date-time
description: Timestamp of last wallet activity
example: "2026-01-14T10:30:00Z"
protocols:
type: array
items:
type: string
enum:
- jupiter
- raydium
- kamino
- meteora
- orca
- pumpfun
description: List of protocols the wallet has interacted with
example: ["jupiter", "raydium", "kamino"]
PnlSummary:
type: object
required:
- realized_24h
- realized_7d
- realized_30d
- unrealized
properties:
realized_24h:
type: number
format: double
description: Realized PnL in the last 24 hours (USD)
example: 120.30
realized_7d:
type: number
format: double
description: Realized PnL in the last 7 days (USD)
example: 540.00
realized_30d:
type: number
format: double
description: Realized PnL in the last 30 days (USD)
example: 1250.00
unrealized:
type: number
format: double
description: Unrealized PnL (USD)
example: 890.25
RiskMetrics:
type: object
required:
- score
- largest_position_pct
- protocol_count
properties:
score:
type: integer
minimum: 0
maximum: 100
description: Risk score (0-100, higher = more risk)
example: 45
largest_position_pct:
type: number
format: double
minimum: 0
maximum: 1
description: Percentage of portfolio in largest position
example: 0.35
protocol_count:
type: integer
description: Number of protocols used
example: 3
UserPnl:
type: object
required:
- wallet
- window
- total_realized
- total_unrealized
- by_protocol
properties:
wallet:
type: string
description: Solana wallet address
example: 95n9a8yd6aZzKGMtbWSjqbijZ1u99z1GQF79HkbCvtwN
window:
type: string
enum:
- 24h
- 7d
- 30d
- all
description: Time window for PnL calculation
example: 7d
total_realized:
type: number
format: double
description: Total realized PnL in window (USD)
example: 540.00
total_unrealized:
type: number
format: double
description: Total unrealized PnL (USD)
example: 890.25
by_protocol:
type: array
items:
$ref: '#/components/schemas/ProtocolPnl'
ProtocolPnl:
type: object
required:
- protocol
- realized
- unrealized
- trade_count
properties:
protocol:
type: string
enum:
- jupiter
- raydium
- kamino
- meteora
- orca
- pumpfun
description: Protocol name
example: jupiter
realized:
type: number
format: double
description: Realized PnL for this protocol (USD)
example: 320.00
unrealized:
type: number
format: double
description: Unrealized PnL for this protocol (USD)
example: 0
trade_count:
type: integer
description: Number of trades in this protocol
example: 12
UserPositions:
type: object
required:
- wallet
- positions
- total_value_usd
properties:
wallet:
type: string
description: Solana wallet address
example: 95n9a8yd6aZzKGMtbWSjqbijZ1u99z1GQF79HkbCvtwN
positions:
type: array
items:
$ref: '#/components/schemas/Position'
total_value_usd:
type: number
format: double
description: Total value of all positions (USD)
example: 7500.0
Position:
type: object
required:
- protocol
- type
- token
- amount
- usd_value
properties:
protocol:
type: string
enum:
- jupiter
- raydium
- kamino
- meteora
- orca
- pumpfun
description: Protocol where position is held
example: kamino
type:
type: string
enum:
- lending_supply
- lending_borrow
- lp
description: Type of position
example: lending_supply
token:
type: string
description: Token mint address or LP pair name
example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
pool:
type: string
description: Pool address (for LP positions)
example: 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2
amount:
type: number
format: double
description: Token amount
example: 5000.0
usd_value:
type: number
format: double
description: Position value in USD
example: 5000.0
apy:
type: number
format: double
description: Annual percentage yield (for lending positions)
example: 0.082
unrealized_pnl:
type: number
format: double
description: Unrealized profit/loss (USD)
example: 0
IndexRequest:
type: object
required:
- wallet
properties:
wallet:
type: string
description: Solana wallet address to index
pattern: ^[1-9A-HJ-NP-Za-km-z]{32,44}$
example: 95n9a8yd6aZzKGMtbWSjqbijZ1u99z1GQF79HkbCvtwN
IndexResponse:
type: object
required:
- wallet
- status
- message
properties:
wallet:
type: string
description: Solana wallet address being indexed
example: 95n9a8yd6aZzKGMtbWSjqbijZ1u99z1GQF79HkbCvtwN
status:
type: string
enum:
- indexing
- completed
- error
description: Indexing status
example: indexing
message:
type: string
description: Status message
example: Wallet indexing started. Streaming real-time transactions.
Error:
type: object
required:
- error
- code
properties:
error:
type: string
description: Human-readable error message
example: Invalid wallet address
code:
type: string
enum:
- WALLET_NOT_FOUND
- INVALID_WALLET
- INVALID_PARAM
- DATABASE_ERROR
- EXTERNAL_API_ERROR
- INTERNAL_ERROR
description: Machine-readable error code
example: INVALID_WALLET