@juicedollar/jusd 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +356 -0
  3. package/contracts/Equity.sol +457 -0
  4. package/contracts/JuiceDollar.sol +363 -0
  5. package/contracts/Leadrate.sol +79 -0
  6. package/contracts/MintingHubV2/MintingHub.sol +445 -0
  7. package/contracts/MintingHubV2/Position.sol +810 -0
  8. package/contracts/MintingHubV2/PositionFactory.sol +69 -0
  9. package/contracts/MintingHubV2/PositionRoller.sol +159 -0
  10. package/contracts/MintingHubV2/interface/IMintingHub.sol +26 -0
  11. package/contracts/MintingHubV2/interface/IPosition.sol +90 -0
  12. package/contracts/MintingHubV2/interface/IPositionFactory.sol +20 -0
  13. package/contracts/Savings.sol +141 -0
  14. package/contracts/SavingsVaultJUSD.sol +140 -0
  15. package/contracts/StablecoinBridge.sol +109 -0
  16. package/contracts/StartUSD.sol +16 -0
  17. package/contracts/gateway/CoinLendingGateway.sol +223 -0
  18. package/contracts/gateway/FrontendGateway.sol +224 -0
  19. package/contracts/gateway/MintingHubGateway.sol +87 -0
  20. package/contracts/gateway/SavingsGateway.sol +51 -0
  21. package/contracts/gateway/interface/ICoinLendingGateway.sol +73 -0
  22. package/contracts/gateway/interface/IFrontendGateway.sol +49 -0
  23. package/contracts/gateway/interface/IMintingHubGateway.sol +12 -0
  24. package/contracts/impl/ERC3009.sol +171 -0
  25. package/contracts/interface/IJuiceDollar.sol +54 -0
  26. package/contracts/interface/ILeadrate.sol +7 -0
  27. package/contracts/interface/IReserve.sol +9 -0
  28. package/contracts/interface/ISavingsJUSD.sol +49 -0
  29. package/contracts/test/FreakToken.sol +25 -0
  30. package/contracts/test/Math.sol +339 -0
  31. package/contracts/test/MockEquity.sol +15 -0
  32. package/contracts/test/PositionExpirationTest.sol +75 -0
  33. package/contracts/test/PositionRollingTest.sol +65 -0
  34. package/contracts/test/TestFlashLoan.sol +84 -0
  35. package/contracts/test/TestFlashLoanGateway.sol +49 -0
  36. package/contracts/test/TestMathUtil.sol +40 -0
  37. package/contracts/test/TestToken.sol +45 -0
  38. package/contracts/test/TestWcBTC.sol +35 -0
  39. package/contracts/utils/MathUtil.sol +61 -0
  40. package/dist/index.d.mts +8761 -0
  41. package/dist/index.d.ts +8761 -0
  42. package/dist/index.js +11119 -0
  43. package/dist/index.mjs +11073 -0
  44. package/exports/abis/MintingHubV2/PositionFactoryV2.ts +90 -0
  45. package/exports/abis/MintingHubV2/PositionRoller.ts +183 -0
  46. package/exports/abis/MintingHubV2/PositionV2.ts +999 -0
  47. package/exports/abis/core/CoinLendingGateway.ts +427 -0
  48. package/exports/abis/core/Equity.ts +1286 -0
  49. package/exports/abis/core/FrontendGateway.ts +906 -0
  50. package/exports/abis/core/JuiceDollar.ts +1366 -0
  51. package/exports/abis/core/MintingHubGateway.ts +865 -0
  52. package/exports/abis/core/SavingsGateway.ts +559 -0
  53. package/exports/abis/core/SavingsVaultJUSD.ts +920 -0
  54. package/exports/abis/utils/ERC20.ts +310 -0
  55. package/exports/abis/utils/ERC20PermitLight.ts +520 -0
  56. package/exports/abis/utils/Leadrate.ts +175 -0
  57. package/exports/abis/utils/MintingHubV2.ts +682 -0
  58. package/exports/abis/utils/Ownable.ts +76 -0
  59. package/exports/abis/utils/Savings.ts +453 -0
  60. package/exports/abis/utils/StablecoinBridge.ts +209 -0
  61. package/exports/abis/utils/StartUSD.ts +315 -0
  62. package/exports/abis/utils/UniswapV3Pool.ts +638 -0
  63. package/exports/address.config.ts +48 -0
  64. package/exports/index.ts +28 -0
  65. package/package.json +87 -0
@@ -0,0 +1,682 @@
1
+ export const MintingHubV2ABI = [
2
+ {
3
+ inputs: [
4
+ {
5
+ internalType: 'address',
6
+ name: '_jusd',
7
+ type: 'address',
8
+ },
9
+ {
10
+ internalType: 'address',
11
+ name: '_leadrate',
12
+ type: 'address',
13
+ },
14
+ {
15
+ internalType: 'address',
16
+ name: '_roller',
17
+ type: 'address',
18
+ },
19
+ {
20
+ internalType: 'address',
21
+ name: '_factory',
22
+ type: 'address',
23
+ },
24
+ ],
25
+ stateMutability: 'nonpayable',
26
+ type: 'constructor',
27
+ },
28
+ {
29
+ inputs: [],
30
+ name: 'ChallengeTimeTooShort',
31
+ type: 'error',
32
+ },
33
+ {
34
+ inputs: [],
35
+ name: 'IncompatibleCollateral',
36
+ type: 'error',
37
+ },
38
+ {
39
+ inputs: [],
40
+ name: 'InitPeriodTooShort',
41
+ type: 'error',
42
+ },
43
+ {
44
+ inputs: [],
45
+ name: 'InsufficientCollateral',
46
+ type: 'error',
47
+ },
48
+ {
49
+ inputs: [],
50
+ name: 'InvalidCollateralDecimals',
51
+ type: 'error',
52
+ },
53
+ {
54
+ inputs: [],
55
+ name: 'InvalidPos',
56
+ type: 'error',
57
+ },
58
+ {
59
+ inputs: [],
60
+ name: 'InvalidReservePPM',
61
+ type: 'error',
62
+ },
63
+ {
64
+ inputs: [],
65
+ name: 'InvalidRiskPremium',
66
+ type: 'error',
67
+ },
68
+ {
69
+ inputs: [
70
+ {
71
+ internalType: 'uint256',
72
+ name: 'amount',
73
+ type: 'uint256',
74
+ },
75
+ ],
76
+ name: 'LeaveNoDust',
77
+ type: 'error',
78
+ },
79
+ {
80
+ inputs: [],
81
+ name: 'UnexpectedPrice',
82
+ type: 'error',
83
+ },
84
+ {
85
+ anonymous: false,
86
+ inputs: [
87
+ {
88
+ indexed: true,
89
+ internalType: 'address',
90
+ name: 'position',
91
+ type: 'address',
92
+ },
93
+ {
94
+ indexed: false,
95
+ internalType: 'uint256',
96
+ name: 'number',
97
+ type: 'uint256',
98
+ },
99
+ {
100
+ indexed: false,
101
+ internalType: 'uint256',
102
+ name: 'size',
103
+ type: 'uint256',
104
+ },
105
+ ],
106
+ name: 'ChallengeAverted',
107
+ type: 'event',
108
+ },
109
+ {
110
+ anonymous: false,
111
+ inputs: [
112
+ {
113
+ indexed: true,
114
+ internalType: 'address',
115
+ name: 'challenger',
116
+ type: 'address',
117
+ },
118
+ {
119
+ indexed: true,
120
+ internalType: 'address',
121
+ name: 'position',
122
+ type: 'address',
123
+ },
124
+ {
125
+ indexed: false,
126
+ internalType: 'uint256',
127
+ name: 'size',
128
+ type: 'uint256',
129
+ },
130
+ {
131
+ indexed: false,
132
+ internalType: 'uint256',
133
+ name: 'number',
134
+ type: 'uint256',
135
+ },
136
+ ],
137
+ name: 'ChallengeStarted',
138
+ type: 'event',
139
+ },
140
+ {
141
+ anonymous: false,
142
+ inputs: [
143
+ {
144
+ indexed: true,
145
+ internalType: 'address',
146
+ name: 'position',
147
+ type: 'address',
148
+ },
149
+ {
150
+ indexed: false,
151
+ internalType: 'uint256',
152
+ name: 'number',
153
+ type: 'uint256',
154
+ },
155
+ {
156
+ indexed: false,
157
+ internalType: 'uint256',
158
+ name: 'bid',
159
+ type: 'uint256',
160
+ },
161
+ {
162
+ indexed: false,
163
+ internalType: 'uint256',
164
+ name: 'acquiredCollateral',
165
+ type: 'uint256',
166
+ },
167
+ {
168
+ indexed: false,
169
+ internalType: 'uint256',
170
+ name: 'challengeSize',
171
+ type: 'uint256',
172
+ },
173
+ ],
174
+ name: 'ChallengeSucceeded',
175
+ type: 'event',
176
+ },
177
+ {
178
+ anonymous: false,
179
+ inputs: [
180
+ {
181
+ indexed: false,
182
+ internalType: 'address',
183
+ name: 'pos',
184
+ type: 'address',
185
+ },
186
+ {
187
+ indexed: false,
188
+ internalType: 'uint256',
189
+ name: 'amount',
190
+ type: 'uint256',
191
+ },
192
+ {
193
+ indexed: false,
194
+ internalType: 'uint256',
195
+ name: 'priceE36MinusDecimals',
196
+ type: 'uint256',
197
+ },
198
+ ],
199
+ name: 'ForcedSale',
200
+ type: 'event',
201
+ },
202
+ {
203
+ anonymous: false,
204
+ inputs: [
205
+ {
206
+ indexed: true,
207
+ internalType: 'address',
208
+ name: 'owner',
209
+ type: 'address',
210
+ },
211
+ {
212
+ indexed: true,
213
+ internalType: 'address',
214
+ name: 'position',
215
+ type: 'address',
216
+ },
217
+ {
218
+ indexed: false,
219
+ internalType: 'address',
220
+ name: 'original',
221
+ type: 'address',
222
+ },
223
+ {
224
+ indexed: false,
225
+ internalType: 'address',
226
+ name: 'collateral',
227
+ type: 'address',
228
+ },
229
+ ],
230
+ name: 'PositionOpened',
231
+ type: 'event',
232
+ },
233
+ {
234
+ anonymous: false,
235
+ inputs: [
236
+ {
237
+ indexed: false,
238
+ internalType: 'address',
239
+ name: 'collateral',
240
+ type: 'address',
241
+ },
242
+ {
243
+ indexed: true,
244
+ internalType: 'address',
245
+ name: 'beneficiary',
246
+ type: 'address',
247
+ },
248
+ {
249
+ indexed: false,
250
+ internalType: 'uint256',
251
+ name: 'amount',
252
+ type: 'uint256',
253
+ },
254
+ ],
255
+ name: 'PostponedReturn',
256
+ type: 'event',
257
+ },
258
+ {
259
+ inputs: [],
260
+ name: 'CHALLENGER_REWARD',
261
+ outputs: [
262
+ {
263
+ internalType: 'uint256',
264
+ name: '',
265
+ type: 'uint256',
266
+ },
267
+ ],
268
+ stateMutability: 'view',
269
+ type: 'function',
270
+ },
271
+ {
272
+ inputs: [],
273
+ name: 'EXPIRED_PRICE_FACTOR',
274
+ outputs: [
275
+ {
276
+ internalType: 'uint256',
277
+ name: '',
278
+ type: 'uint256',
279
+ },
280
+ ],
281
+ stateMutability: 'view',
282
+ type: 'function',
283
+ },
284
+ {
285
+ inputs: [],
286
+ name: 'JUSD',
287
+ outputs: [
288
+ {
289
+ internalType: 'contract IJuiceDollar',
290
+ name: '',
291
+ type: 'address',
292
+ },
293
+ ],
294
+ stateMutability: 'view',
295
+ type: 'function',
296
+ },
297
+ {
298
+ inputs: [],
299
+ name: 'OPENING_FEE',
300
+ outputs: [
301
+ {
302
+ internalType: 'uint256',
303
+ name: '',
304
+ type: 'uint256',
305
+ },
306
+ ],
307
+ stateMutability: 'view',
308
+ type: 'function',
309
+ },
310
+ {
311
+ inputs: [],
312
+ name: 'RATE',
313
+ outputs: [
314
+ {
315
+ internalType: 'contract ILeadrate',
316
+ name: '',
317
+ type: 'address',
318
+ },
319
+ ],
320
+ stateMutability: 'view',
321
+ type: 'function',
322
+ },
323
+ {
324
+ inputs: [],
325
+ name: 'ROLLER',
326
+ outputs: [
327
+ {
328
+ internalType: 'contract PositionRoller',
329
+ name: '',
330
+ type: 'address',
331
+ },
332
+ ],
333
+ stateMutability: 'view',
334
+ type: 'function',
335
+ },
336
+ {
337
+ inputs: [
338
+ {
339
+ internalType: 'uint32',
340
+ name: '_challengeNumber',
341
+ type: 'uint32',
342
+ },
343
+ {
344
+ internalType: 'uint256',
345
+ name: 'size',
346
+ type: 'uint256',
347
+ },
348
+ {
349
+ internalType: 'bool',
350
+ name: 'postponeCollateralReturn',
351
+ type: 'bool',
352
+ },
353
+ ],
354
+ name: 'bid',
355
+ outputs: [],
356
+ stateMutability: 'nonpayable',
357
+ type: 'function',
358
+ },
359
+ {
360
+ inputs: [
361
+ {
362
+ internalType: 'contract IPosition',
363
+ name: 'pos',
364
+ type: 'address',
365
+ },
366
+ {
367
+ internalType: 'uint256',
368
+ name: 'upToAmount',
369
+ type: 'uint256',
370
+ },
371
+ ],
372
+ name: 'buyExpiredCollateral',
373
+ outputs: [
374
+ {
375
+ internalType: 'uint256',
376
+ name: '',
377
+ type: 'uint256',
378
+ },
379
+ ],
380
+ stateMutability: 'nonpayable',
381
+ type: 'function',
382
+ },
383
+ {
384
+ inputs: [
385
+ {
386
+ internalType: 'address',
387
+ name: '_positionAddr',
388
+ type: 'address',
389
+ },
390
+ {
391
+ internalType: 'uint256',
392
+ name: '_collateralAmount',
393
+ type: 'uint256',
394
+ },
395
+ {
396
+ internalType: 'uint256',
397
+ name: 'minimumPrice',
398
+ type: 'uint256',
399
+ },
400
+ ],
401
+ name: 'challenge',
402
+ outputs: [
403
+ {
404
+ internalType: 'uint256',
405
+ name: '',
406
+ type: 'uint256',
407
+ },
408
+ ],
409
+ stateMutability: 'nonpayable',
410
+ type: 'function',
411
+ },
412
+ {
413
+ inputs: [
414
+ {
415
+ internalType: 'uint256',
416
+ name: '',
417
+ type: 'uint256',
418
+ },
419
+ ],
420
+ name: 'challenges',
421
+ outputs: [
422
+ {
423
+ internalType: 'address',
424
+ name: 'challenger',
425
+ type: 'address',
426
+ },
427
+ {
428
+ internalType: 'uint40',
429
+ name: 'start',
430
+ type: 'uint40',
431
+ },
432
+ {
433
+ internalType: 'contract IPosition',
434
+ name: 'position',
435
+ type: 'address',
436
+ },
437
+ {
438
+ internalType: 'uint256',
439
+ name: 'size',
440
+ type: 'uint256',
441
+ },
442
+ ],
443
+ stateMutability: 'view',
444
+ type: 'function',
445
+ },
446
+ {
447
+ inputs: [
448
+ {
449
+ internalType: 'address',
450
+ name: 'parent',
451
+ type: 'address',
452
+ },
453
+ {
454
+ internalType: 'uint256',
455
+ name: '_initialCollateral',
456
+ type: 'uint256',
457
+ },
458
+ {
459
+ internalType: 'uint256',
460
+ name: '_initialMint',
461
+ type: 'uint256',
462
+ },
463
+ {
464
+ internalType: 'uint40',
465
+ name: 'expiration',
466
+ type: 'uint40',
467
+ },
468
+ ],
469
+ name: 'clone',
470
+ outputs: [
471
+ {
472
+ internalType: 'address',
473
+ name: '',
474
+ type: 'address',
475
+ },
476
+ ],
477
+ stateMutability: 'nonpayable',
478
+ type: 'function',
479
+ },
480
+ {
481
+ inputs: [
482
+ {
483
+ internalType: 'address',
484
+ name: 'owner',
485
+ type: 'address',
486
+ },
487
+ {
488
+ internalType: 'address',
489
+ name: 'parent',
490
+ type: 'address',
491
+ },
492
+ {
493
+ internalType: 'uint256',
494
+ name: '_initialCollateral',
495
+ type: 'uint256',
496
+ },
497
+ {
498
+ internalType: 'uint256',
499
+ name: '_initialMint',
500
+ type: 'uint256',
501
+ },
502
+ {
503
+ internalType: 'uint40',
504
+ name: 'expiration',
505
+ type: 'uint40',
506
+ },
507
+ ],
508
+ name: 'clone',
509
+ outputs: [
510
+ {
511
+ internalType: 'address',
512
+ name: '',
513
+ type: 'address',
514
+ },
515
+ ],
516
+ stateMutability: 'nonpayable',
517
+ type: 'function',
518
+ },
519
+ {
520
+ inputs: [
521
+ {
522
+ internalType: 'contract IPosition',
523
+ name: 'pos',
524
+ type: 'address',
525
+ },
526
+ ],
527
+ name: 'expiredPurchasePrice',
528
+ outputs: [
529
+ {
530
+ internalType: 'uint256',
531
+ name: '',
532
+ type: 'uint256',
533
+ },
534
+ ],
535
+ stateMutability: 'view',
536
+ type: 'function',
537
+ },
538
+ {
539
+ inputs: [
540
+ {
541
+ internalType: 'address',
542
+ name: '_collateralAddress',
543
+ type: 'address',
544
+ },
545
+ {
546
+ internalType: 'uint256',
547
+ name: '_minCollateral',
548
+ type: 'uint256',
549
+ },
550
+ {
551
+ internalType: 'uint256',
552
+ name: '_initialCollateral',
553
+ type: 'uint256',
554
+ },
555
+ {
556
+ internalType: 'uint256',
557
+ name: '_mintingMaximum',
558
+ type: 'uint256',
559
+ },
560
+ {
561
+ internalType: 'uint40',
562
+ name: '_initPeriodSeconds',
563
+ type: 'uint40',
564
+ },
565
+ {
566
+ internalType: 'uint40',
567
+ name: '_expirationSeconds',
568
+ type: 'uint40',
569
+ },
570
+ {
571
+ internalType: 'uint40',
572
+ name: '_challengeSeconds',
573
+ type: 'uint40',
574
+ },
575
+ {
576
+ internalType: 'uint24',
577
+ name: '_riskPremium',
578
+ type: 'uint24',
579
+ },
580
+ {
581
+ internalType: 'uint256',
582
+ name: '_liqPrice',
583
+ type: 'uint256',
584
+ },
585
+ {
586
+ internalType: 'uint24',
587
+ name: '_reservePPM',
588
+ type: 'uint24',
589
+ },
590
+ ],
591
+ name: 'openPosition',
592
+ outputs: [
593
+ {
594
+ internalType: 'address',
595
+ name: '',
596
+ type: 'address',
597
+ },
598
+ ],
599
+ stateMutability: 'nonpayable',
600
+ type: 'function',
601
+ },
602
+ {
603
+ inputs: [
604
+ {
605
+ internalType: 'address',
606
+ name: 'collateral',
607
+ type: 'address',
608
+ },
609
+ {
610
+ internalType: 'address',
611
+ name: 'owner',
612
+ type: 'address',
613
+ },
614
+ ],
615
+ name: 'pendingReturns',
616
+ outputs: [
617
+ {
618
+ internalType: 'uint256',
619
+ name: 'amount',
620
+ type: 'uint256',
621
+ },
622
+ ],
623
+ stateMutability: 'view',
624
+ type: 'function',
625
+ },
626
+ {
627
+ inputs: [
628
+ {
629
+ internalType: 'uint32',
630
+ name: 'challengeNumber',
631
+ type: 'uint32',
632
+ },
633
+ ],
634
+ name: 'price',
635
+ outputs: [
636
+ {
637
+ internalType: 'uint256',
638
+ name: '',
639
+ type: 'uint256',
640
+ },
641
+ ],
642
+ stateMutability: 'view',
643
+ type: 'function',
644
+ },
645
+ {
646
+ inputs: [
647
+ {
648
+ internalType: 'address',
649
+ name: 'collateral',
650
+ type: 'address',
651
+ },
652
+ {
653
+ internalType: 'address',
654
+ name: 'target',
655
+ type: 'address',
656
+ },
657
+ ],
658
+ name: 'returnPostponedCollateral',
659
+ outputs: [],
660
+ stateMutability: 'nonpayable',
661
+ type: 'function',
662
+ },
663
+ {
664
+ inputs: [
665
+ {
666
+ internalType: 'bytes4',
667
+ name: 'interfaceId',
668
+ type: 'bytes4',
669
+ },
670
+ ],
671
+ name: 'supportsInterface',
672
+ outputs: [
673
+ {
674
+ internalType: 'bool',
675
+ name: '',
676
+ type: 'bool',
677
+ },
678
+ ],
679
+ stateMutability: 'view',
680
+ type: 'function',
681
+ },
682
+ ] as const;