@sonarwatch/portfolio-plugins 0.12.30 → 0.12.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. package/CHANGELOG.md +1815 -1806
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/src/index.js +8 -0
  5. package/src/index.js.map +1 -1
  6. package/src/plugins/balancer/helpers/pools.js +21 -21
  7. package/src/plugins/banx/calculateLoanRepayValue.d.ts +4 -0
  8. package/src/plugins/banx/calculateLoanRepayValue.js +37 -0
  9. package/src/plugins/banx/calculateLoanRepayValue.js.map +1 -0
  10. package/src/plugins/banx/collectionsJob.d.ts +3 -0
  11. package/src/plugins/banx/collectionsJob.js +40 -0
  12. package/src/plugins/banx/collectionsJob.js.map +1 -0
  13. package/src/plugins/banx/constants.d.ts +8 -0
  14. package/src/plugins/banx/constants.js +13 -1
  15. package/src/plugins/banx/constants.js.map +1 -1
  16. package/src/plugins/banx/filters.d.ts +2 -0
  17. package/src/plugins/banx/filters.js +26 -1
  18. package/src/plugins/banx/filters.js.map +1 -1
  19. package/src/plugins/banx/idl.d.ts +115 -0
  20. package/src/plugins/banx/idl.js +2256 -0
  21. package/src/plugins/banx/idl.js.map +1 -0
  22. package/src/plugins/banx/index.js +9 -2
  23. package/src/plugins/banx/index.js.map +1 -1
  24. package/src/plugins/banx/loansFetcher.d.ts +3 -0
  25. package/src/plugins/banx/loansFetcher.js +158 -0
  26. package/src/plugins/banx/loansFetcher.js.map +1 -0
  27. package/src/plugins/banx/offersFetcher.d.ts +3 -0
  28. package/src/plugins/banx/offersFetcher.js +99 -0
  29. package/src/plugins/banx/offersFetcher.js.map +1 -0
  30. package/src/plugins/banx/types.d.ts +200 -0
  31. package/src/plugins/citrus/collectionsJob.d.ts +3 -0
  32. package/src/plugins/citrus/collectionsJob.js +40 -0
  33. package/src/plugins/citrus/collectionsJob.js.map +1 -0
  34. package/src/plugins/citrus/constants.d.ts +12 -0
  35. package/src/plugins/citrus/constants.js +26 -0
  36. package/src/plugins/citrus/constants.js.map +1 -0
  37. package/src/plugins/citrus/filters.d.ts +2 -0
  38. package/src/plugins/citrus/filters.js +32 -0
  39. package/src/plugins/citrus/filters.js.map +1 -0
  40. package/src/plugins/citrus/idl.d.ts +73 -0
  41. package/src/plugins/citrus/idl.js +292 -0
  42. package/src/plugins/citrus/idl.js.map +1 -0
  43. package/src/plugins/citrus/index.d.ts +6 -0
  44. package/src/plugins/citrus/index.js +13 -0
  45. package/src/plugins/citrus/index.js.map +1 -0
  46. package/src/plugins/citrus/loansFetcher.d.ts +3 -0
  47. package/src/plugins/citrus/loansFetcher.js +150 -0
  48. package/src/plugins/citrus/loansFetcher.js.map +1 -0
  49. package/src/plugins/citrus/types.d.ts +54 -0
  50. package/src/plugins/citrus/types.js +3 -0
  51. package/src/plugins/citrus/types.js.map +1 -0
  52. package/src/plugins/sharky/collectionsJob.d.ts +3 -0
  53. package/src/plugins/sharky/collectionsJob.js +75 -0
  54. package/src/plugins/sharky/collectionsJob.js.map +1 -0
  55. package/src/plugins/sharky/constants.d.ts +12 -0
  56. package/src/plugins/sharky/constants.js +26 -0
  57. package/src/plugins/sharky/constants.js.map +1 -0
  58. package/src/plugins/sharky/filters.d.ts +6 -0
  59. package/src/plugins/sharky/filters.js +43 -0
  60. package/src/plugins/sharky/filters.js.map +1 -0
  61. package/src/plugins/sharky/idl.d.ts +135 -0
  62. package/src/plugins/sharky/idl.js +388 -0
  63. package/src/plugins/sharky/idl.js.map +1 -0
  64. package/src/plugins/sharky/index.d.ts +6 -0
  65. package/src/plugins/sharky/index.js +13 -0
  66. package/src/plugins/sharky/index.js.map +1 -0
  67. package/src/plugins/sharky/loansFetcher.d.ts +3 -0
  68. package/src/plugins/sharky/loansFetcher.js +141 -0
  69. package/src/plugins/sharky/loansFetcher.js.map +1 -0
  70. package/src/plugins/sharky/types.d.ts +66 -0
  71. package/src/plugins/sharky/types.js +11 -0
  72. package/src/plugins/sharky/types.js.map +1 -0
  73. package/src/plugins/sushiswap/helpers.js +24 -24
  74. package/src/plugins/uniswap-v2/helpers.js +22 -22
  75. package/src/utils/sei/constants.js +8 -8
  76. package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
  77. package/src/utils/solana/das/getAssetBatchDas.d.ts +4 -0
  78. package/src/utils/solana/das/getAssetBatchDas.js +68 -0
  79. package/src/utils/solana/das/getAssetBatchDas.js.map +1 -0
  80. package/src/utils/solana/das/heliusAssetToAssetCollectible.d.ts +7 -1
  81. package/src/utils/solana/das/heliusAssetToAssetCollectible.js +13 -9
  82. package/src/utils/solana/das/heliusAssetToAssetCollectible.js.map +1 -1
  83. package/src/utils/solana/das/types.d.ts +5 -0
  84. package/src/utils/solana/getAutoParsedMultipleAccountsInfo.d.ts +4 -0
  85. package/src/utils/solana/getAutoParsedMultipleAccountsInfo.js +33 -0
  86. package/src/utils/solana/getAutoParsedMultipleAccountsInfo.js.map +1 -0
  87. package/src/utils/solana/getAutoParsedProgramAccounts.d.ts +4 -0
  88. package/src/utils/solana/getAutoParsedProgramAccounts.js +37 -0
  89. package/src/utils/solana/getAutoParsedProgramAccounts.js.map +1 -0
  90. package/src/utils/solana/getMultipleAccountsInfoSafe.d.ts +2 -2
  91. package/src/utils/solana/getMultipleAccountsInfoSafe.js +3 -3
  92. package/src/utils/solana/getMultipleAccountsInfoSafe.js.map +1 -1
  93. package/src/utils/solana/getParsedMultipleAccountsInfo.d.ts +2 -2
  94. package/src/utils/solana/getParsedMultipleAccountsInfo.js +2 -2
  95. package/src/utils/solana/getParsedMultipleAccountsInfo.js.map +1 -1
  96. package/src/utils/solana/index.d.ts +2 -0
  97. package/src/utils/solana/index.js +2 -0
  98. package/src/utils/solana/index.js.map +1 -1
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.citrusIdlItem = exports.collectionRefreshInterval = exports.loanDataSize = exports.citrusProgram = exports.collectionsApiUrl = exports.cachePrefix = exports.collectionsCacheKey = exports.platform = exports.platformId = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const idl_1 = require("./idl");
6
+ exports.platformId = 'citrus';
7
+ exports.platform = {
8
+ id: exports.platformId,
9
+ name: 'Citrus',
10
+ image: 'https://sonar.watch/img/platforms/citrus.webp',
11
+ website: 'https://citrus.famousfoxes.com/',
12
+ twitter: 'https://twitter.com/FamousFoxFed',
13
+ defiLlamaId: 'citrus', // from https://defillama.com/docs/api
14
+ };
15
+ exports.collectionsCacheKey = `${exports.platformId}-collections`;
16
+ exports.cachePrefix = `${exports.platformId}`;
17
+ exports.collectionsApiUrl = 'https://citrus.famousfoxes.com/citrus/allCollections';
18
+ exports.citrusProgram = new web3_js_1.PublicKey('JCFRaPv7852ESRwJJGRy2mysUMydXZgVVhrMLmExvmVp');
19
+ exports.loanDataSize = 464;
20
+ exports.collectionRefreshInterval = 3600000;
21
+ exports.citrusIdlItem = {
22
+ programId: exports.citrusProgram.toString(),
23
+ idl: idl_1.CitrusIDL,
24
+ idlType: 'anchor',
25
+ };
26
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/citrus/constants.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE5C,+BAAkC;AAErB,QAAA,UAAU,GAAG,QAAQ,CAAC;AACtB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,+CAA+C;IACtD,OAAO,EAAE,iCAAiC;IAC1C,OAAO,EAAE,kCAAkC;IAC3C,WAAW,EAAE,QAAQ,EAAE,sCAAsC;CAC9D,CAAC;AACW,QAAA,mBAAmB,GAAG,GAAG,kBAAU,cAAc,CAAC;AAClD,QAAA,WAAW,GAAG,GAAG,kBAAU,EAAE,CAAC;AAE9B,QAAA,iBAAiB,GAC5B,sDAAsD,CAAC;AAE5C,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,8CAA8C,CAC/C,CAAC;AAEW,QAAA,YAAY,GAAG,GAAG,CAAC;AACnB,QAAA,yBAAyB,GAAG,OAAO,CAAC;AAEpC,QAAA,aAAa,GAAG;IAC3B,SAAS,EAAE,qBAAa,CAAC,QAAQ,EAAE;IACnC,GAAG,EAAE,eAAS;IACd,OAAO,EAAE,QAAQ;CACP,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { GetProgramAccountsFilter } from '@solana/web3.js';
2
+ export declare function getLoanFilters(owner: string): [GetProgramAccountsFilter[], GetProgramAccountsFilter[]];
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLoanFilters = void 0;
4
+ const constants_1 = require("./constants");
5
+ function getLoanFilters(owner) {
6
+ return [
7
+ [
8
+ {
9
+ dataSize: constants_1.loanDataSize,
10
+ },
11
+ {
12
+ memcmp: {
13
+ bytes: owner,
14
+ offset: 9,
15
+ },
16
+ },
17
+ ],
18
+ [
19
+ {
20
+ dataSize: constants_1.loanDataSize,
21
+ },
22
+ {
23
+ memcmp: {
24
+ bytes: owner,
25
+ offset: 41,
26
+ },
27
+ },
28
+ ],
29
+ ];
30
+ }
31
+ exports.getLoanFilters = getLoanFilters;
32
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/citrus/filters.ts"],"names":[],"mappings":";;;AACA,2CAA2C;AAE3C,SAAgB,cAAc,CAC5B,KAAa;IAEb,OAAO;QACL;YACE;gBACE,QAAQ,EAAE,wBAAY;aACvB;YACD;gBACE,MAAM,EAAE;oBACN,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,CAAC;iBACV;aACF;SACF;QACD;YACE;gBACE,QAAQ,EAAE,wBAAY;aACvB;YACD;gBACE,MAAM,EAAE;oBACN,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,EAAE;iBACX;aACF;SACF;KACF,CAAC;AACJ,CAAC;AA3BD,wCA2BC"}
@@ -0,0 +1,73 @@
1
+ export declare const CitrusIDL: {
2
+ version: string;
3
+ name: string;
4
+ accounts: ({
5
+ name: string;
6
+ type: {
7
+ kind: string;
8
+ fields: ({
9
+ name: string;
10
+ type: {
11
+ option: string;
12
+ };
13
+ } | {
14
+ name: string;
15
+ type: {
16
+ option: {
17
+ array: (string | number)[];
18
+ };
19
+ };
20
+ })[];
21
+ };
22
+ } | {
23
+ name: string;
24
+ type: {
25
+ kind: string;
26
+ fields: ({
27
+ name: string;
28
+ type: string;
29
+ } | {
30
+ name: string;
31
+ type: {
32
+ defined: string;
33
+ option?: undefined;
34
+ };
35
+ } | {
36
+ name: string;
37
+ type: {
38
+ option: {
39
+ defined: string;
40
+ };
41
+ defined?: undefined;
42
+ };
43
+ })[];
44
+ };
45
+ })[];
46
+ types: ({
47
+ name: string;
48
+ type: {
49
+ kind: string;
50
+ fields: ({
51
+ name: string;
52
+ type: string;
53
+ } | {
54
+ name: string;
55
+ type: {
56
+ vec: {
57
+ array: (string | number)[];
58
+ };
59
+ };
60
+ })[];
61
+ variants?: undefined;
62
+ };
63
+ } | {
64
+ name: string;
65
+ type: {
66
+ kind: string;
67
+ variants: {
68
+ name: string;
69
+ }[];
70
+ fields?: undefined;
71
+ };
72
+ })[];
73
+ };
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CitrusIDL = void 0;
4
+ exports.CitrusIDL = {
5
+ version: '0.1.0',
6
+ name: 'citrus',
7
+ accounts: [
8
+ {
9
+ name: 'collectionConfig',
10
+ type: {
11
+ kind: 'struct',
12
+ fields: [
13
+ {
14
+ name: 'collectionKey',
15
+ type: {
16
+ option: 'publicKey',
17
+ },
18
+ },
19
+ {
20
+ name: 'creators',
21
+ type: {
22
+ option: {
23
+ array: ['publicKey', 3],
24
+ },
25
+ },
26
+ },
27
+ {
28
+ name: 'merkleRoot',
29
+ type: {
30
+ option: {
31
+ array: ['u8', 32],
32
+ },
33
+ },
34
+ },
35
+ {
36
+ name: 'feeReduction',
37
+ type: {
38
+ option: 'u16',
39
+ },
40
+ },
41
+ ],
42
+ },
43
+ },
44
+ {
45
+ name: 'loan',
46
+ type: {
47
+ kind: 'struct',
48
+ fields: [
49
+ {
50
+ name: 'bump',
51
+ type: 'u8',
52
+ },
53
+ {
54
+ name: 'lender',
55
+ type: 'publicKey',
56
+ },
57
+ {
58
+ name: 'borrower',
59
+ type: 'publicKey',
60
+ },
61
+ {
62
+ name: 'mint',
63
+ type: 'publicKey',
64
+ },
65
+ {
66
+ name: 'collectionConfig',
67
+ type: 'publicKey',
68
+ },
69
+ {
70
+ name: 'status',
71
+ type: {
72
+ defined: 'LoanStatus',
73
+ },
74
+ },
75
+ {
76
+ name: 'loanTerms',
77
+ type: {
78
+ defined: 'LoanTerms',
79
+ },
80
+ },
81
+ {
82
+ name: 'creationTime',
83
+ type: 'i64',
84
+ },
85
+ {
86
+ name: 'startTime',
87
+ type: 'i64',
88
+ },
89
+ {
90
+ name: 'endTime',
91
+ type: 'i64',
92
+ },
93
+ {
94
+ name: 'fox',
95
+ type: 'bool',
96
+ },
97
+ {
98
+ name: 'mortgage',
99
+ type: 'bool',
100
+ },
101
+ {
102
+ name: 'private',
103
+ type: 'bool',
104
+ },
105
+ {
106
+ name: 'offerType',
107
+ type: {
108
+ defined: 'OfferType',
109
+ },
110
+ },
111
+ {
112
+ name: 'listingPrice',
113
+ type: 'u64',
114
+ },
115
+ {
116
+ name: 'ltvTerms',
117
+ type: {
118
+ option: {
119
+ defined: 'LtvTerms',
120
+ },
121
+ },
122
+ },
123
+ {
124
+ name: 'pool',
125
+ type: 'bool',
126
+ },
127
+ {
128
+ name: 'listedLoan',
129
+ type: {
130
+ option: {
131
+ defined: 'ListedLoan',
132
+ },
133
+ },
134
+ },
135
+ ],
136
+ },
137
+ },
138
+ {
139
+ name: 'borrowAuthority',
140
+ type: {
141
+ kind: 'struct',
142
+ fields: [],
143
+ },
144
+ },
145
+ ],
146
+ types: [
147
+ {
148
+ name: 'LoanTerms',
149
+ type: {
150
+ kind: 'struct',
151
+ fields: [
152
+ {
153
+ name: 'apyBps',
154
+ type: 'u64',
155
+ },
156
+ {
157
+ name: 'duration',
158
+ type: 'u64',
159
+ },
160
+ {
161
+ name: 'principal',
162
+ type: 'u64',
163
+ },
164
+ ],
165
+ },
166
+ },
167
+ {
168
+ name: 'LtvTerms',
169
+ type: {
170
+ kind: 'struct',
171
+ fields: [
172
+ {
173
+ name: 'ltvBps',
174
+ type: 'u64',
175
+ },
176
+ {
177
+ name: 'maxOffer',
178
+ type: 'u64',
179
+ },
180
+ ],
181
+ },
182
+ },
183
+ {
184
+ name: 'ListedLoan',
185
+ type: {
186
+ kind: 'struct',
187
+ fields: [
188
+ {
189
+ name: 'listed',
190
+ type: 'bool',
191
+ },
192
+ {
193
+ name: 'price',
194
+ type: 'u64',
195
+ },
196
+ {
197
+ name: 'sold',
198
+ type: 'bool',
199
+ },
200
+ {
201
+ name: 'fox',
202
+ type: 'bool',
203
+ },
204
+ {
205
+ name: 'listingTime',
206
+ type: 'i64',
207
+ },
208
+ ],
209
+ },
210
+ },
211
+ {
212
+ name: 'MerkleData',
213
+ type: {
214
+ kind: 'struct',
215
+ fields: [
216
+ {
217
+ name: 'index',
218
+ type: 'u64',
219
+ },
220
+ {
221
+ name: 'proof',
222
+ type: {
223
+ vec: {
224
+ array: ['u8', 32],
225
+ },
226
+ },
227
+ },
228
+ ],
229
+ },
230
+ },
231
+ {
232
+ name: 'Cpi',
233
+ type: {
234
+ kind: 'struct',
235
+ fields: [
236
+ {
237
+ name: 'data',
238
+ type: 'bytes',
239
+ },
240
+ {
241
+ name: 'numAccounts',
242
+ type: 'u8',
243
+ },
244
+ ],
245
+ },
246
+ },
247
+ {
248
+ name: 'LoanStatus',
249
+ type: {
250
+ kind: 'enum',
251
+ variants: [
252
+ {
253
+ name: 'WaitingForBorrower',
254
+ },
255
+ {
256
+ name: 'WaitingForLender',
257
+ },
258
+ {
259
+ name: 'Active',
260
+ },
261
+ {
262
+ name: 'Repaid',
263
+ },
264
+ {
265
+ name: 'Defaulted',
266
+ },
267
+ {
268
+ name: 'OnSale',
269
+ },
270
+ ],
271
+ },
272
+ },
273
+ {
274
+ name: 'OfferType',
275
+ type: {
276
+ kind: 'enum',
277
+ variants: [
278
+ {
279
+ name: 'Global',
280
+ },
281
+ {
282
+ name: 'Mortgage',
283
+ },
284
+ {
285
+ name: 'Borrow',
286
+ },
287
+ ],
288
+ },
289
+ },
290
+ ],
291
+ };
292
+ //# sourceMappingURL=idl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idl.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/citrus/idl.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,eAAe;wBACrB,IAAI,EAAE;4BACJ,MAAM,EAAE,WAAW;yBACpB;qBACF;oBACD;wBACE,IAAI,EAAE,UAAU;wBAChB,IAAI,EAAE;4BACJ,MAAM,EAAE;gCACN,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;6BACxB;yBACF;qBACF;oBACD;wBACE,IAAI,EAAE,YAAY;wBAClB,IAAI,EAAE;4BACJ,MAAM,EAAE;gCACN,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;6BAClB;yBACF;qBACF;oBACD;wBACE,IAAI,EAAE,cAAc;wBACpB,IAAI,EAAE;4BACJ,MAAM,EAAE,KAAK;yBACd;qBACF;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,MAAM;wBACZ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ACb,IAAI,EAAE,KAAK;qBACZ;oBACD;wBACE,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE;4BACJ,GAAG,EAAE;gCACH,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;6BAClB;yBACF;qBACF;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,KAAK;YACX,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBACd;oBACD;wBACE,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE,IAAI;qBACX;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,oBAAoB;qBAC3B;oBACD;wBACE,IAAI,EAAE,kBAAkB;qBACzB;oBACD;wBACE,IAAI,EAAE,QAAQ;qBACf;oBACD;wBACE,IAAI,EAAE,QAAQ;qBACf;oBACD;wBACE,IAAI,EAAE,WAAW;qBAClB;oBACD;wBACE,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;QACD;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,QAAQ;qBACf;oBACD;wBACE,IAAI,EAAE,UAAU;qBACjB;oBACD;wBACE,IAAI,EAAE,QAAQ;qBACf;iBACF;aACF;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Platform } from '@sonarwatch/portfolio-core';
2
+ import { Fetcher } from '../../Fetcher';
3
+ import { Job } from '../../Job';
4
+ export declare const platforms: Platform[];
5
+ export declare const jobs: Job[];
6
+ export declare const fetchers: Fetcher[];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchers = exports.jobs = exports.platforms = void 0;
7
+ const constants_1 = require("./constants");
8
+ const collectionsJob_1 = __importDefault(require("./collectionsJob"));
9
+ const loansFetcher_1 = __importDefault(require("./loansFetcher"));
10
+ exports.platforms = [constants_1.platform];
11
+ exports.jobs = [collectionsJob_1.default];
12
+ exports.fetchers = [loansFetcher_1.default];
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/citrus/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,sEAA8C;AAC9C,kEAA0C;AAE7B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,wBAAc,CAAC,CAAC;AAC/B,QAAA,QAAQ,GAAc,CAAC,sBAAY,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
+ const constants_1 = require("./constants");
18
+ const clients_1 = require("../../utils/clients");
19
+ const solana_1 = require("../../utils/solana");
20
+ const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
21
+ const getAssetBatchDas_1 = require("../../utils/solana/das/getAssetBatchDas");
22
+ const getSolanaDasEndpoint_1 = __importDefault(require("../../utils/clients/getSolanaDasEndpoint"));
23
+ const heliusAssetToAssetCollectible_1 = require("../../utils/solana/das/heliusAssetToAssetCollectible");
24
+ const filters_1 = require("./filters");
25
+ const collections = new Map();
26
+ let collectionLastUpdate = 0;
27
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const connection = (0, clients_1.getClientSolana)();
29
+ const dasUrl = (0, getSolanaDasEndpoint_1.default)();
30
+ const [filterA, filterB] = (0, filters_1.getLoanFilters)(owner);
31
+ const allAccounts = (yield Promise.all([
32
+ (0, solana_1.getAutoParsedProgramAccounts)(connection, constants_1.citrusIdlItem, filterA),
33
+ (0, solana_1.getAutoParsedProgramAccounts)(connection, constants_1.citrusIdlItem, filterB),
34
+ ])).flat();
35
+ const accounts = allAccounts.filter((acc) => !acc.status.repaid // hide past loans
36
+ );
37
+ if (accounts.length === 0)
38
+ return [];
39
+ const [solTokenPrice, heliusAssets] = yield Promise.all([
40
+ cache.getTokenPrice(portfolio_core_1.solanaNativeAddress, portfolio_core_1.NetworkId.solana),
41
+ (0, getAssetBatchDas_1.getAssetBatchDasAsMap)(dasUrl, accounts
42
+ .map((acc) => acc.mint)
43
+ .filter((mint) => mint && mint !== '11111111111111111111111111111111')),
44
+ ]);
45
+ if (!solTokenPrice)
46
+ return [];
47
+ if (collectionLastUpdate + constants_1.collectionRefreshInterval < Date.now()) {
48
+ const collectionsArr = yield cache.getItem(constants_1.collectionsCacheKey, {
49
+ prefix: constants_1.cachePrefix,
50
+ networkId: portfolio_core_1.NetworkId.solana,
51
+ });
52
+ if (collectionsArr) {
53
+ collectionsArr.forEach((cc) => {
54
+ collections.set(cc.id, cc);
55
+ });
56
+ }
57
+ collectionLastUpdate = Date.now();
58
+ }
59
+ const elements = [];
60
+ accounts.forEach((acc) => {
61
+ const collection = collections.get(acc.collectionConfig);
62
+ if (!collection)
63
+ return;
64
+ const borrowedAssets = [];
65
+ const suppliedAssets = [];
66
+ let mintAsset = null;
67
+ if (acc.mint && acc.mint !== '11111111111111111111111111111111') {
68
+ const heliusAsset = heliusAssets.get(acc.mint);
69
+ if (heliusAsset) {
70
+ const assetValue = new bignumber_js_1.default(collection.floor)
71
+ .multipliedBy(solTokenPrice.price)
72
+ .toNumber();
73
+ mintAsset = (0, heliusAssetToAssetCollectible_1.heliusAssetToAssetCollectible)(heliusAsset, {
74
+ tags: [portfolio_core_1.collectibleFreezedTag],
75
+ collection: {
76
+ name: collection.name,
77
+ floorPrice: assetValue,
78
+ },
79
+ });
80
+ }
81
+ }
82
+ const solAsset = (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.solanaNativeAddress, new bignumber_js_1.default(acc.ltvTerms ? acc.ltvTerms.maxOffer : acc.loanTerms.principal)
83
+ .dividedBy(Math.pow(10, portfolio_core_1.solanaNativeDecimals))
84
+ .toNumber(), portfolio_core_1.NetworkId.solana, solTokenPrice);
85
+ let name;
86
+ if (acc.lender === owner.toString()) {
87
+ // LENDER
88
+ suppliedAssets.push(solAsset);
89
+ if (mintAsset)
90
+ borrowedAssets.push(mintAsset);
91
+ if (acc.status.waitingForBorrower) {
92
+ name = `Lend Offer on ${collection.name}`;
93
+ }
94
+ else if (acc.status.active || acc.status.onSale) {
95
+ name = `Active Loan on ${collection.name}`;
96
+ }
97
+ else if (acc.status.defaulted) {
98
+ name = `Defaulted Loan on ${collection.name}`;
99
+ }
100
+ }
101
+ else {
102
+ // BORROWER
103
+ if (mintAsset) {
104
+ suppliedAssets.push(mintAsset);
105
+ }
106
+ borrowedAssets.push(solAsset);
107
+ if (acc.status.waitingForLender) {
108
+ name = `Borrow Offer on ${collection.name}`;
109
+ }
110
+ else if (acc.status.active || acc.status.onSale) {
111
+ name = `Active Loan on ${collection.name}`;
112
+ }
113
+ else if (acc.status.defaulted) {
114
+ name = `Expired Loan on ${collection.name}`;
115
+ }
116
+ }
117
+ if (suppliedAssets.length > 0) {
118
+ const { borrowedValue, suppliedValue, healthRatio, rewardValue } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, []);
119
+ elements.push({
120
+ networkId: portfolio_core_1.NetworkId.solana,
121
+ label: 'Lending',
122
+ platformId: constants_1.platformId,
123
+ type: portfolio_core_1.PortfolioElementType.borrowlend,
124
+ value: suppliedValue,
125
+ name,
126
+ data: {
127
+ borrowedAssets,
128
+ borrowedValue,
129
+ borrowedYields: [],
130
+ suppliedAssets,
131
+ suppliedValue,
132
+ suppliedYields: [],
133
+ collateralRatio: null,
134
+ rewardAssets: [],
135
+ rewardValue,
136
+ healthRatio,
137
+ value: suppliedValue,
138
+ },
139
+ });
140
+ }
141
+ });
142
+ return elements;
143
+ });
144
+ const fetcher = {
145
+ id: `${constants_1.platformId}-loans`,
146
+ networkId: portfolio_core_1.NetworkId.solana,
147
+ executor,
148
+ };
149
+ exports.default = fetcher;
150
+ //# sourceMappingURL=loansFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/citrus/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAUoC;AACpC,gEAAqC;AAErC,2CAMqB;AAErB,iDAAsD;AAEtD,+CAG4B;AAC5B,qGAA6E;AAC7E,8EAAgF;AAChF,oGAA4E;AAC5E,wGAAqG;AACrG,uCAA2C;AAE3C,MAAM,WAAW,GAA4B,IAAI,GAAG,EAAE,CAAC;AACvD,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAE7B,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,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