File tree Expand file tree Collapse file tree 2 files changed +225
-19
lines changed Expand file tree Collapse file tree 2 files changed +225
-19
lines changed Original file line number Diff line number Diff line change @@ -5,54 +5,140 @@ module.exports = {
5
5
"instructions" : [ ] ,
6
6
"accounts" : [
7
7
{
8
- "name" : "assetManager " ,
8
+ "name" : "loan " ,
9
9
"type" : {
10
10
"kind" : "struct" ,
11
11
"fields" : [
12
12
{
13
- "name" : "currencyIn" ,
13
+ "name" : "kind" ,
14
+ "type" : {
15
+ "defined" : "LoanKind"
16
+ }
17
+ } ,
18
+ {
19
+ "name" : "status" ,
20
+ "type" : {
21
+ "defined" : "LoanStatus"
22
+ }
23
+ } ,
24
+ {
25
+ "name" : "borrower" ,
14
26
"type" : "publicKey"
15
27
} ,
16
28
{
17
- "name" : "currencyOut " ,
29
+ "name" : "lender " ,
18
30
"type" : "publicKey"
19
31
} ,
20
32
{
21
- "name" : "pythInFeed " ,
33
+ "name" : "pool " ,
22
34
"type" : "publicKey"
23
35
} ,
24
36
{
25
- "name" : "pythOutFeed " ,
37
+ "name" : "mint " ,
26
38
"type" : "publicKey"
27
39
} ,
28
40
{
29
- "name" : "totalAmountTokenized" ,
41
+ "name" : "currency" ,
42
+ "type" : "publicKey"
43
+ } ,
44
+ {
45
+ "name" : "isCustom" ,
46
+ "type" : "bool"
47
+ } ,
48
+ {
49
+ "name" : "isFrozen" ,
50
+ "type" : "bool"
51
+ } ,
52
+ {
53
+ "name" : "price" ,
30
54
"type" : "u64"
31
55
} ,
32
56
{
33
- "name" : "currentAmountTokenized " ,
57
+ "name" : "interest " ,
34
58
"type" : "u64"
35
59
} ,
60
+ {
61
+ "name" : "amount" ,
62
+ "type" : "u64"
63
+ } ,
64
+ {
65
+ "name" : "duration" ,
66
+ "type" : "u64"
67
+ } ,
68
+ {
69
+ "name" : "collection" ,
70
+ "type" : "u32"
71
+ } ,
72
+ {
73
+ "name" : "liquidation" ,
74
+ "type" : "u16"
75
+ } ,
76
+ {
77
+ "name" : "marketplace" ,
78
+ "type" : {
79
+ "defined" : "Marketplace"
80
+ }
81
+ } ,
82
+ {
83
+ "name" : "sale" ,
84
+ "type" : {
85
+ "defined" : "Sale"
86
+ }
87
+ } ,
36
88
{
37
89
"name" : "createdAt" ,
38
90
"type" : "u64"
39
91
} ,
40
92
{
41
- "name" : "updatedAt" ,
93
+ "name" : "expiredAt" ,
94
+ "type" : "u64"
95
+ } ,
96
+ {
97
+ "name" : "repaidAt" ,
98
+ "type" : "u64"
99
+ } ,
100
+ {
101
+ "name" : "soldAt" ,
102
+ "type" : "u64"
103
+ } ,
104
+ {
105
+ "name" : "liquidatedAt" ,
106
+ "type" : "u64"
107
+ } ,
108
+ {
109
+ "name" : "listing" ,
110
+ "type" : {
111
+ "defined" : "Listing"
112
+ }
113
+ } ,
114
+ {
115
+ "name" : "isCompressedLoan" ,
116
+ "type" : "bool"
117
+ } ,
118
+ {
119
+ "name" : "isDefi" ,
120
+ "type" : "bool"
121
+ } ,
122
+ {
123
+ "name" : "collateralAmount" ,
42
124
"type" : "u64"
43
125
} ,
126
+ {
127
+ "name" : "collateralDecimals" ,
128
+ "type" : "u8"
129
+ } ,
44
130
{
45
131
"name" : "padding" ,
46
132
"type" : {
47
133
"array" : [
48
134
"u64" ,
49
- 31
135
+ 5
50
136
]
51
137
}
52
138
} ,
53
139
{
54
- "name" : "totalAmountLiquidated " ,
55
- "type" : "u64 "
140
+ "name" : "padding1 " ,
141
+ "type" : "u32 "
56
142
}
57
143
]
58
144
}
@@ -213,6 +299,40 @@ module.exports = {
213
299
} ,
214
300
] ,
215
301
"types" : [
302
+ {
303
+ "name" : "LoanKind" ,
304
+ "type" : {
305
+ "kind" : "enum" ,
306
+ "variants" : [
307
+ {
308
+ "name" : "Loan"
309
+ } ,
310
+ {
311
+ "name" : "Mortgage"
312
+ }
313
+ ]
314
+ }
315
+ } ,
316
+ {
317
+ "name" : "LoanStatus" ,
318
+ "type" : {
319
+ "kind" : "enum" ,
320
+ "variants" : [
321
+ {
322
+ "name" : "Ongoing"
323
+ } ,
324
+ {
325
+ "name" : "Repaid"
326
+ } ,
327
+ {
328
+ "name" : "Liquidated"
329
+ } ,
330
+ {
331
+ "name" : "Sold"
332
+ }
333
+ ]
334
+ }
335
+ } ,
216
336
{
217
337
"name" : "Curve" ,
218
338
"type" : {
@@ -350,7 +470,80 @@ module.exports = {
350
470
]
351
471
}
352
472
} ,
473
+ {
474
+ "name" : "Marketplace" ,
475
+ "type" : {
476
+ "kind" : "enum" ,
477
+ "variants" : [
478
+ {
479
+ "name" : "None"
480
+ } ,
481
+ {
482
+ "name" : "Auctionhouse"
483
+ } ,
484
+ {
485
+ "name" : "Solanart"
486
+ } ,
487
+ {
488
+ "name" : "Hyperspace"
489
+ } ,
490
+ {
491
+ "name" : "Yaww"
492
+ } ,
493
+ {
494
+ "name" : "Hadeswap"
495
+ } ,
496
+ {
497
+ "name" : "Rain"
498
+ } ,
499
+ {
500
+ "name" : "TensorswapOrder"
501
+ } ,
502
+ {
503
+ "name" : "TensorswapListing"
504
+ } ,
505
+ {
506
+ "name" : "MagicEden"
507
+ }
508
+ ]
509
+ }
510
+ } ,
511
+ {
512
+ "name" : "Sale" ,
513
+ "type" : {
514
+ "kind" : "struct" ,
515
+ "fields" : [
516
+ {
517
+ "name" : "isForSale" ,
518
+ "type" : "bool"
519
+ } ,
520
+ {
521
+ "name" : "salePrice" ,
522
+ "type" : "u64"
523
+ } ,
524
+ {
525
+ "name" : "currency" ,
526
+ "type" : "publicKey"
527
+ }
528
+ ]
529
+ }
530
+ } ,
531
+ {
532
+ "name" : "Listing" ,
533
+ "type" : {
534
+ "kind" : "struct" ,
535
+ "fields" : [
536
+ {
537
+ "name" : "isListed" ,
538
+ "type" : "bool"
539
+ } ,
540
+ {
541
+ "name" : "price" ,
542
+ "type" : "u64"
543
+ }
544
+ ]
545
+ }
546
+ }
353
547
] ,
354
548
"errors" : [ ]
355
- }
356
-
549
+ }
Original file line number Diff line number Diff line change 1
1
const { Program } = require ( "@project-serum/anchor" ) ;
2
+ const bs58 = require ( 'bs58' ) ;
2
3
const { getProvider } = require ( "../helper/solana" ) ;
3
4
const idl = require ( './idl' )
4
5
5
6
async function tvl ( api ) {
6
7
const provider = getProvider ( )
7
- const rainProgram = new Program ( idl , 'RainEraPU5yDoJmTrHdYynK9739GkEfDsE4ffqce2BR' , provider )
8
- const tokenizerProgram = new Program ( idl , 'RtokEFPPbXqDrzAHJHt16fwN6hZmepfPpSvW7y47g5r' , provider )
8
+ const program = new Program ( idl , 'RainEraPU5yDoJmTrHdYynK9739GkEfDsE4ffqce2BR' , provider )
9
9
10
- const pools = await rainProgram . account . pool . all ( )
11
- const assetManagers = await tokenizerProgram . account . assetManager . all ( )
10
+ const pools = await program . account . pool . all ( )
11
+ const loans = await program . account . loan . all ( [
12
+ {
13
+ memcmp : {
14
+ offset : 294 + 8 ,
15
+ bytes : bs58 . encode ( Buffer . from ( [ 1 ] ) ) , // tokens loans only
16
+ } ,
17
+ } ,
18
+ {
19
+ memcmp : {
20
+ offset : 8 + 1 ,
21
+ bytes : bs58 . encode ( Buffer . from ( [ 0 ] ) ) , // active loans only
22
+ } ,
23
+ } ,
24
+ ] )
12
25
13
- for ( const assetManager of assetManagers ) {
14
- api . add ( assetManager . account . currencyIn . toString ( ) , assetManager . account . currentAmountTokenized )
26
+ for ( const loan of loans ) {
27
+ api . add ( loan . account . mint . toString ( ) , loan . account . collateralAmount )
15
28
}
16
29
17
30
for ( const pool of pools )
You can’t perform that action at this time.
0 commit comments