-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathindexer.yaml
More file actions
494 lines (465 loc) · 12.1 KB
/
Copy pathindexer.yaml
File metadata and controls
494 lines (465 loc) · 12.1 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
openapi: 3.0.3
info:
title: TrusTrove Indexer API
version: 1.0.0
description: |
Structured API documentation for the TrusTrove Go indexer/API service.
## SEP-10 authentication flow
1. The frontend calls `GET /auth?address=<stellar_public_key>` to request an authentication challenge.
2. The client signs the returned SEP-10 challenge transaction with Freighter or another Stellar wallet.
3. The client sends the signed challenge to `POST /auth`.
4. The indexer validates the signed challenge and returns a JWT.
5. Protected endpoints use `Authorization: Bearer <jwt>`.
servers:
- url: http://localhost:8080
description: Local development
- url: https://trusttrove-app.onrender.com
description: Production
tags:
- name: Health
- name: Auth
- name: Invoices
- name: Stats
- name: Pool
- name: Events
security:
- bearerAuth: []
paths:
/health:
get:
tags: [Health]
summary: Health check
security: []
responses:
"200":
description: API is alive
content:
application/json:
schema:
$ref: "#/components/schemas/HealthResponse"
examples:
ok:
value:
status: ok
/auth:
get:
tags: [Auth]
summary: Create SEP-10 challenge
description: Returns a SEP-10 challenge transaction for the supplied Stellar account.
security: []
parameters:
- name: address
in: query
required: true
schema:
type: string
example: GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF
responses:
"200":
description: Challenge transaction generated
content:
application/json:
schema:
$ref: "#/components/schemas/AuthChallengeResponse"
examples:
challenge:
value:
transaction: AAAAAgAAA...
network_passphrase: Test SDF Network ; September 2015
"400":
$ref: "#/components/responses/BadRequest"
post:
tags: [Auth]
summary: Exchange signed SEP-10 challenge for JWT
description: Validates the signed challenge transaction and returns a bearer token.
security: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/AuthRequest"
examples:
signedChallenge:
value:
transaction: AAAAAgAAA...signed...
responses:
"200":
description: Authentication successful
content:
application/json:
schema:
$ref: "#/components/schemas/AuthTokenResponse"
examples:
token:
value:
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
expires_in: 86400
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
/events:
get:
tags: [Events]
summary: List indexed Soroban events
security: []
parameters:
- $ref: "#/components/parameters/Limit"
responses:
"200":
description: Indexed events
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Event"
/invoices:
get:
tags: [Invoices]
summary: List invoices
security: []
parameters:
- name: status
in: query
required: false
schema:
type: string
enum: [Created, Listed, Funded, Active, Confirmed, Repaid, Defaulted]
- name: issuer
in: query
required: false
schema:
type: string
- $ref: "#/components/parameters/Limit"
- name: page
in: query
required: false
schema:
type: integer
default: 1
minimum: 1
responses:
"200":
description: Invoice list
content:
application/json:
schema:
$ref: "#/components/schemas/PaginatedInvoices"
post:
tags: [Invoices]
summary: Create invoice
description: Creates an off-chain/indexed invoice record. Requires JWT from the SEP-10 auth flow.
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateInvoiceRequest"
examples:
invoice:
value:
buyer: GBUYERAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
face_value: "1000.00"
due_date: 1735689600
asset: USDC
responses:
"201":
description: Invoice created
content:
application/json:
schema:
$ref: "#/components/schemas/Invoice"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
/invoices/{id}:
get:
tags: [Invoices]
summary: Get invoice by ID
security: []
parameters:
- name: id
in: path
required: true
schema:
type: string
example: a3f8c1d27e904b6a8d5f0139c2e7ab64f0d8c3b19a6e52f7b4c0d91e8a2735bc
responses:
"200":
description: Invoice found
content:
application/json:
schema:
$ref: "#/components/schemas/Invoice"
"404":
$ref: "#/components/responses/NotFound"
/stats:
get:
tags: [Stats]
summary: Protocol statistics
security: []
responses:
"200":
description: Protocol aggregate stats
content:
application/json:
schema:
$ref: "#/components/schemas/ProtocolStats"
/pool/stats:
get:
tags: [Pool]
summary: Liquidity pool statistics
security: []
responses:
"200":
description: Pool aggregate stats
content:
application/json:
schema:
$ref: "#/components/schemas/PoolStats"
/pool/position/{address}:
get:
tags: [Pool]
summary: LP position by address
security: []
parameters:
- name: address
in: path
required: true
schema:
type: string
example: GLPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
responses:
"200":
description: LP position
content:
application/json:
schema:
$ref: "#/components/schemas/LPPosition"
"404":
$ref: "#/components/responses/NotFound"
/pool/snapshots:
get:
tags: [Pool]
summary: Historical pool snapshots
description: Returns historical liquidity pool snapshots used for charts and trend analysis.
security: []
responses:
"200":
description: Pool snapshots
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/PoolSnapshot"
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
parameters:
Limit:
name: limit
in: query
required: false
schema:
type: integer
minimum: 1
maximum: 100
default: 20
responses:
BadRequest:
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
Unauthorized:
description: Authentication required or invalid
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
schemas:
Error:
type: object
properties:
error:
type: string
required: [error]
HealthResponse:
type: object
properties:
status:
type: string
required: [status]
AuthChallengeResponse:
type: object
properties:
transaction:
type: string
network_passphrase:
type: string
required: [transaction, network_passphrase]
AuthRequest:
type: object
properties:
transaction:
type: string
required: [transaction]
AuthTokenResponse:
type: object
properties:
token:
type: string
expires_in:
type: integer
required: [token, expires_in]
CreateInvoiceRequest:
type: object
properties:
buyer:
type: string
face_value:
type: string
due_date:
type: integer
format: int64
asset:
type: string
required: [buyer, face_value, due_date, asset]
Invoice:
type: object
properties:
id:
type: string
description: Hexadecimal BytesN<32> invoice identifier.
pattern: "^[0-9a-fA-F]{64}$"
issuer:
type: string
buyer:
type: string
face_value:
type: string
funded_amount:
type: string
due_date:
type: integer
format: int64
status:
type: string
enum: [Created, Listed, Funded, Active, Confirmed, Repaid, Defaulted]
created_at:
type: integer
format: int64
required: [id, issuer, buyer, face_value, due_date, status]
PaginatedInvoices:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/Invoice"
total:
type: integer
page:
type: integer
limit:
type: integer
totalPages:
type: integer
required: [data, total, page, limit, totalPages]
Event:
type: object
properties:
id:
type: string
contract_id:
type: string
type:
type: string
ledger:
type: integer
format: int64
transaction_hash:
type: string
data:
type: object
additionalProperties: true
required: [id, contract_id, type]
ProtocolStats:
type: object
properties:
total_usdc_financed:
type: string
active_invoice_count:
type: integer
total_invoices:
type: integer
total_repaid:
type: integer
total_defaulted:
type: integer
average_yield_bps:
type: integer
pool_utilization_bps:
type: integer
PoolStats:
type: object
properties:
total_deposits:
type: string
total_funded:
type: string
available_liquidity:
type: string
utilization_rate_bps:
type: integer
total_yield_distributed:
type: string
active_invoice_count:
type: integer
LPPosition:
type: object
properties:
shares:
type: string
usdc_value:
type: string
yield_earned:
type: string
deposit_count:
type: integer
PoolSnapshot:
type: object
properties:
total_deposits:
type: string
total_funded:
type: string
available_liquidity:
type: string
utilization_rate_bps:
type: integer
total_yield_distributed:
type: string
active_invoice_count:
type: integer
total_shares:
type: string
updated_at:
type: string
format: date-time