forked from QuorumCredit/QuorumCredit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
535 lines (511 loc) · 14.2 KB
/
Copy pathopenapi.yaml
File metadata and controls
535 lines (511 loc) · 14.2 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
openapi: 3.0.0
info:
title: QuorumCredit API
description: Decentralized microlending platform powered by social trust on Stellar Soroban
version: 1.0.0
contact:
name: QuorumCredit Team
url: https://github.com/QuorumCredit/QuorumCredit
license:
name: MIT
url: https://opensource.org/licenses/MIT
servers:
- url: https://soroban-testnet.stellar.org:443
description: Stellar Testnet
- url: https://rpc.mainnet.stellar.org:443
description: Stellar Mainnet
paths:
/initialize:
post:
summary: Initialize the contract
description: One-time setup of the QuorumCredit contract with admin addresses and token
operationId: initialize
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/InitializeRequest'
responses:
'200':
description: Contract initialized successfully
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionResponse'
'400':
description: Invalid parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/vouch:
post:
summary: Stake tokens to vouch for a borrower
description: Create social collateral by staking XLM for a borrower
operationId: vouch
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/VouchRequest'
responses:
'200':
description: Vouch created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionResponse'
'400':
description: Invalid vouch parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/batch-vouch:
post:
summary: Stake for multiple borrowers atomically
description: Create vouches for multiple borrowers in a single transaction
operationId: batchVouch
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BatchVouchRequest'
responses:
'200':
description: Batch vouch created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionResponse'
'400':
description: Invalid batch vouch parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/request-loan:
post:
summary: Request a loan
description: Borrow funds if sufficient vouches exist
operationId: requestLoan
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RequestLoanRequest'
responses:
'200':
description: Loan disbursed successfully
content:
application/json:
schema:
$ref: '#/components/schemas/LoanResponse'
'400':
description: Loan request failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/repay:
post:
summary: Repay a loan
description: Repay loan principal and distribute yield to vouchers
operationId: repay
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RepayRequest'
responses:
'200':
description: Loan repaid successfully
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionResponse'
'400':
description: Repayment failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/slash:
post:
summary: Slash a defaulted borrower
description: Admin marks default and burns 50% of voucher stakes
operationId: slash
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SlashRequest'
responses:
'200':
description: Slash executed successfully
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionResponse'
'400':
description: Slash failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/get-loan/{borrower}:
get:
summary: Get loan record for a borrower
description: Retrieve active loan details
operationId: getLoan
parameters:
- name: borrower
in: path
required: true
schema:
type: string
description: Borrower address
responses:
'200':
description: Loan record retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/LoanRecord'
'404':
description: No active loan found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/get-vouches/{borrower}:
get:
summary: Get all vouches for a borrower
description: Retrieve list of all vouchers and their stakes
operationId: getVouches
parameters:
- name: borrower
in: path
required: true
schema:
type: string
description: Borrower address
responses:
'200':
description: Vouches retrieved
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/VouchRecord'
'404':
description: No vouches found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/is-eligible/{borrower}:
get:
summary: Check loan eligibility
description: Verify if borrower meets stake threshold
operationId: isEligible
parameters:
- name: borrower
in: path
required: true
schema:
type: string
description: Borrower address
- name: threshold
in: query
required: true
schema:
type: string
description: Minimum stake required in stroops
- name: token
in: query
required: true
schema:
type: string
description: Token contract address
responses:
'200':
description: Eligibility check result
content:
application/json:
schema:
$ref: '#/components/schemas/EligibilityResponse'
/get-config:
get:
summary: Get protocol configuration
description: Retrieve current protocol settings
operationId: getConfig
responses:
'200':
description: Configuration retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/Config'
components:
schemas:
InitializeRequest:
type: object
required:
- deployer
- admins
- admin_threshold
- token
properties:
deployer:
type: string
description: Deployer address (must sign transaction)
admins:
type: array
items:
type: string
description: Admin addresses for governance
admin_threshold:
type: integer
description: Minimum signatures required for admin operations
token:
type: string
description: Primary token contract address
VouchRequest:
type: object
required:
- voucher
- borrower
- stake
- token
properties:
voucher:
type: string
description: Voucher address (must sign)
borrower:
type: string
description: Borrower address
stake:
type: string
description: Stake amount in stroops
token:
type: string
description: Token contract address
BatchVouchRequest:
type: object
required:
- voucher
- borrowers
- stakes
- token
properties:
voucher:
type: string
description: Voucher address (must sign)
borrowers:
type: array
items:
type: string
description: Borrower addresses
stakes:
type: array
items:
type: string
description: Stake amounts in stroops (must match borrowers length)
token:
type: string
description: Token contract address
RequestLoanRequest:
type: object
required:
- borrower
- amount
- threshold
- loan_purpose
- token
properties:
borrower:
type: string
description: Borrower address (must sign)
amount:
type: string
description: Loan amount in stroops
threshold:
type: string
description: Minimum total stake required
loan_purpose:
type: string
description: Purpose of the loan
token:
type: string
description: Token contract address
RepayRequest:
type: object
required:
- borrower
- payment
properties:
borrower:
type: string
description: Borrower address (must sign)
payment:
type: string
description: Repayment amount in stroops
SlashRequest:
type: object
required:
- admin_signers
- borrower
properties:
admin_signers:
type: array
items:
type: string
description: Admin addresses signing the slash
borrower:
type: string
description: Borrower address to slash
LoanRecord:
type: object
properties:
id:
type: string
description: Unique loan ID
borrower:
type: string
description: Borrower address
amount:
type: string
description: Principal amount in stroops
amount_repaid:
type: string
description: Amount repaid so far in stroops
total_yield:
type: string
description: Total yield locked in stroops
status:
type: string
enum: [Active, Repaid, Defaulted]
description: Current loan status
created_at:
type: string
format: date-time
description: Loan creation timestamp
deadline:
type: string
format: date-time
description: Repayment deadline
loan_purpose:
type: string
description: Purpose of the loan
VouchRecord:
type: object
properties:
voucher:
type: string
description: Voucher address
stake:
type: string
description: Staked amount in stroops
vouch_timestamp:
type: string
format: date-time
description: When the vouch was created
token:
type: string
description: Token contract address
Config:
type: object
properties:
admins:
type: array
items:
type: string
description: Admin addresses
admin_threshold:
type: integer
description: Minimum signatures required
token:
type: string
description: Primary token address
allowed_tokens:
type: array
items:
type: string
description: Allowed token addresses
yield_bps:
type: integer
description: Yield rate in basis points
slash_bps:
type: integer
description: Slash rate in basis points
min_loan_amount:
type: string
description: Minimum loan amount in stroops
max_loan_amount:
type: string
description: Maximum loan amount in stroops
loan_duration:
type: integer
description: Loan duration in seconds
EligibilityResponse:
type: object
properties:
eligible:
type: boolean
description: Whether borrower is eligible
total_vouched:
type: string
description: Total vouched amount in stroops
threshold:
type: string
description: Required threshold in stroops
TransactionResponse:
type: object
properties:
transaction_hash:
type: string
description: Transaction hash on Stellar
status:
type: string
enum: [success, pending, failed]
description: Transaction status
timestamp:
type: string
format: date-time
description: Transaction timestamp
LoanResponse:
type: object
properties:
transaction_hash:
type: string
description: Transaction hash
loan_id:
type: string
description: Unique loan ID
amount_disbursed:
type: string
description: Amount disbursed in stroops
deadline:
type: string
format: date-time
description: Repayment deadline
ErrorResponse:
type: object
properties:
code:
type: integer
description: Error code
message:
type: string
description: Error message
details:
type: object
description: Additional error details