@sonarwatch/portfolio-plugins 0.14.151 → 0.14.153

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 (184) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/src/plugins/allbridge/constants.d.ts +0 -6
  4. package/src/plugins/allbridge/constants.js +1 -9
  5. package/src/plugins/allbridge/constants.js.map +1 -1
  6. package/src/plugins/allbridge/helpers.d.ts +1 -1
  7. package/src/plugins/allbridge/helpers.js +1 -3
  8. package/src/plugins/allbridge/helpers.js.map +1 -1
  9. package/src/plugins/allbridge/positionsFetcher.js +2 -1
  10. package/src/plugins/allbridge/positionsFetcher.js.map +1 -1
  11. package/src/plugins/allbridge/structs.d.ts +13 -0
  12. package/src/plugins/allbridge/structs.js +14 -0
  13. package/src/plugins/allbridge/structs.js.map +1 -0
  14. package/src/plugins/allbridge/types.d.ts +0 -6
  15. package/src/plugins/bonfida/constants.js +1 -1
  16. package/src/plugins/bonfida/constants.js.map +1 -1
  17. package/src/plugins/divvy/constants.d.ts +0 -2
  18. package/src/plugins/divvy/constants.js +1 -7
  19. package/src/plugins/divvy/constants.js.map +1 -1
  20. package/src/plugins/divvy/houseJob.js +6 -3
  21. package/src/plugins/divvy/houseJob.js.map +1 -1
  22. package/src/plugins/divvy/housePoolFetcher.js +9 -11
  23. package/src/plugins/divvy/housePoolFetcher.js.map +1 -1
  24. package/src/plugins/divvy/stakingFetcher.js +7 -12
  25. package/src/plugins/divvy/stakingFetcher.js.map +1 -1
  26. package/src/plugins/divvy/structs.d.ts +57 -0
  27. package/src/plugins/divvy/structs.js +57 -0
  28. package/src/plugins/divvy/structs.js.map +1 -0
  29. package/src/plugins/drift/spotMarketsJob.js +0 -1
  30. package/src/plugins/drift/spotMarketsJob.js.map +1 -1
  31. package/src/plugins/elemental/constants.d.ts +4 -2
  32. package/src/plugins/elemental/constants.js +3 -7
  33. package/src/plugins/elemental/constants.js.map +1 -1
  34. package/src/plugins/elemental/filters.d.ts +0 -1
  35. package/src/plugins/elemental/filters.js +1 -6
  36. package/src/plugins/elemental/filters.js.map +1 -1
  37. package/src/plugins/elemental/helpers.js +2 -2
  38. package/src/plugins/elemental/helpers.js.map +1 -1
  39. package/src/plugins/elemental/poolsJob.js +4 -4
  40. package/src/plugins/elemental/poolsJob.js.map +1 -1
  41. package/src/plugins/ensofi/constants.d.ts +4 -2
  42. package/src/plugins/ensofi/constants.js +3 -7
  43. package/src/plugins/ensofi/constants.js.map +1 -1
  44. package/src/plugins/ensofi/idl.d.ts +149 -6
  45. package/src/plugins/ensofi/idl.js +1074 -61
  46. package/src/plugins/ensofi/idl.js.map +1 -1
  47. package/src/plugins/ensofi/index.js +2 -1
  48. package/src/plugins/ensofi/index.js.map +1 -1
  49. package/src/plugins/ensofi/solanaLoansFetcher.js +23 -37
  50. package/src/plugins/ensofi/solanaLoansFetcher.js.map +1 -1
  51. package/src/plugins/ensofi/solanaLoansJob.d.ts +3 -0
  52. package/src/plugins/ensofi/solanaLoansJob.js +63 -0
  53. package/src/plugins/ensofi/solanaLoansJob.js.map +1 -0
  54. package/src/plugins/ensofi/structs.d.ts +58 -0
  55. package/src/plugins/ensofi/structs.js +60 -0
  56. package/src/plugins/ensofi/structs.js.map +1 -0
  57. package/src/plugins/jupiter/governance/constants.js +3 -3
  58. package/src/plugins/jupiter/governance/constants.js.map +1 -1
  59. package/src/plugins/jupiter/launchpad/constants.d.ts +1 -0
  60. package/src/plugins/jupiter/launchpad/constants.js +8 -7
  61. package/src/plugins/jupiter/launchpad/constants.js.map +1 -1
  62. package/src/plugins/jupiter/pricingJob.js +2 -1
  63. package/src/plugins/jupiter/pricingJob.js.map +1 -1
  64. package/src/plugins/kamino/reservesJob.js +35 -0
  65. package/src/plugins/kamino/reservesJob.js.map +1 -1
  66. package/src/plugins/loopscale/constants.d.ts +2 -3
  67. package/src/plugins/loopscale/constants.js +3 -4
  68. package/src/plugins/loopscale/constants.js.map +1 -1
  69. package/src/plugins/loopscale/helpers.d.ts +6 -33
  70. package/src/plugins/loopscale/helpers.js +39 -142
  71. package/src/plugins/loopscale/helpers.js.map +1 -1
  72. package/src/plugins/loopscale/index.js +10 -3
  73. package/src/plugins/loopscale/index.js.map +1 -1
  74. package/src/plugins/loopscale/lendFetcher.js +57 -0
  75. package/src/plugins/loopscale/lendFetcher.js.map +1 -0
  76. package/src/plugins/loopscale/lendVaultsFetcher.d.ts +6 -0
  77. package/src/plugins/loopscale/lendVaultsFetcher.js +68 -0
  78. package/src/plugins/loopscale/lendVaultsFetcher.js.map +1 -0
  79. package/src/plugins/loopscale/loansFetcher.d.ts +3 -0
  80. package/src/plugins/loopscale/loansFetcher.js +79 -0
  81. package/src/plugins/loopscale/loansFetcher.js.map +1 -0
  82. package/src/plugins/loopscale/structs.d.ts +116 -86
  83. package/src/plugins/loopscale/structs.js +101 -79
  84. package/src/plugins/loopscale/structs.js.map +1 -1
  85. package/src/plugins/loopscale/types.d.ts +6 -0
  86. package/src/plugins/loopscale/types.js.map +1 -0
  87. package/src/plugins/loopscale/vaultsJob.d.ts +3 -0
  88. package/src/plugins/loopscale/vaultsJob.js +121 -0
  89. package/src/plugins/loopscale/vaultsJob.js.map +1 -0
  90. package/src/plugins/lulo/depositsFetcher.js +9 -29
  91. package/src/plugins/lulo/depositsFetcher.js.map +1 -1
  92. package/src/plugins/marginfi/banksJob.js +6 -2
  93. package/src/plugins/marginfi/banksJob.js.map +1 -1
  94. package/src/plugins/marginfi/constants.d.ts +5 -3
  95. package/src/plugins/marginfi/constants.js +8 -7
  96. package/src/plugins/marginfi/constants.js.map +1 -1
  97. package/src/plugins/marginfi/depositsFetcher.js +50 -27
  98. package/src/plugins/marginfi/depositsFetcher.js.map +1 -1
  99. package/src/plugins/marginfi/getMarginFiAccounts.d.ts +6 -0
  100. package/src/plugins/marginfi/getMarginFiAccounts.js +44 -0
  101. package/src/plugins/marginfi/getMarginFiAccounts.js.map +1 -0
  102. package/src/plugins/marginfi/helpers.d.ts +0 -5
  103. package/src/plugins/marginfi/helpers.js +1 -81
  104. package/src/plugins/marginfi/helpers.js.map +1 -1
  105. package/src/plugins/marginfi/structs/MarginfiAccount.d.ts +5 -0
  106. package/src/plugins/marginfi/structs/MarginfiAccount.js.map +1 -1
  107. package/src/plugins/orca/getWhirlpoolPositions.js +7 -7
  108. package/src/plugins/orca/getWhirlpoolPositions.js.map +1 -1
  109. package/src/plugins/orca/types.d.ts +2 -0
  110. package/src/plugins/picasso/constants.d.ts +0 -2
  111. package/src/plugins/picasso/constants.js +1 -7
  112. package/src/plugins/picasso/constants.js.map +1 -1
  113. package/src/plugins/picasso/helpers.js +7 -4
  114. package/src/plugins/picasso/helpers.js.map +1 -1
  115. package/src/plugins/picasso/structs.d.ts +39 -0
  116. package/src/plugins/picasso/structs.js +37 -0
  117. package/src/plugins/picasso/structs.js.map +1 -0
  118. package/src/plugins/picasso/unstakingNftsJob.js +2 -1
  119. package/src/plugins/picasso/unstakingNftsJob.js.map +1 -1
  120. package/src/plugins/picasso/unstakingPositionsFetcher.js +4 -4
  121. package/src/plugins/picasso/unstakingPositionsFetcher.js.map +1 -1
  122. package/src/plugins/raydium/ammV2ApiJob.js +24 -0
  123. package/src/plugins/raydium/ammV2ApiJob.js.map +1 -1
  124. package/src/plugins/raydium/constants.d.ts +1 -0
  125. package/src/plugins/raydium/constants.js +2 -1
  126. package/src/plugins/raydium/constants.js.map +1 -1
  127. package/src/plugins/raydium/getRaydiumCLMMPositions.js +9 -5
  128. package/src/plugins/raydium/getRaydiumCLMMPositions.js.map +1 -1
  129. package/src/plugins/raydium/types.d.ts +14 -4
  130. package/src/plugins/sanctum/s1AirdropFetcher.js +2 -2
  131. package/src/plugins/sanctum/s1AirdropFetcher.js.map +1 -1
  132. package/src/plugins/sharky/collectionsJob.js +8 -9
  133. package/src/plugins/sharky/collectionsJob.js.map +1 -1
  134. package/src/plugins/sharky/constants.d.ts +0 -2
  135. package/src/plugins/sharky/constants.js +1 -7
  136. package/src/plugins/sharky/constants.js.map +1 -1
  137. package/src/plugins/sharky/loansFetcher.js +25 -19
  138. package/src/plugins/sharky/loansFetcher.js.map +1 -1
  139. package/src/plugins/sharky/structs.d.ts +96 -0
  140. package/src/plugins/sharky/structs.js +103 -0
  141. package/src/plugins/sharky/structs.js.map +1 -0
  142. package/src/plugins/sharky/types.d.ts +0 -15
  143. package/src/plugins/sharky/types.js +0 -8
  144. package/src/plugins/sharky/types.js.map +1 -1
  145. package/src/plugins/stabble/constants.d.ts +0 -3
  146. package/src/plugins/stabble/constants.js +1 -13
  147. package/src/plugins/stabble/constants.js.map +1 -1
  148. package/src/plugins/stabble/poolsJob.js +14 -9
  149. package/src/plugins/stabble/poolsJob.js.map +1 -1
  150. package/src/plugins/stabble/structs.d.ts +43 -0
  151. package/src/plugins/stabble/structs.js +42 -0
  152. package/src/plugins/stabble/structs.js.map +1 -0
  153. package/src/plugins/suilend/helpers.js +2 -0
  154. package/src/plugins/suilend/helpers.js.map +1 -1
  155. package/src/utils/misc/getLendingMarketAprs.d.ts +3 -1
  156. package/src/utils/misc/getLendingMarketAprs.js +24 -1
  157. package/src/utils/misc/getLendingMarketAprs.js.map +1 -1
  158. package/src/utils/solana/beets/ParsedGpa.d.ts +1 -0
  159. package/src/utils/solana/beets/ParsedGpa.js +9 -0
  160. package/src/utils/solana/beets/ParsedGpa.js.map +1 -1
  161. package/src/plugins/divvy/types.d.ts +0 -28
  162. package/src/plugins/divvy/types.js.map +0 -1
  163. package/src/plugins/loopscale/filters.d.ts +0 -9
  164. package/src/plugins/loopscale/filters.js +0 -62
  165. package/src/plugins/loopscale/filters.js.map +0 -1
  166. package/src/plugins/loopscale/positionsFetcher.js +0 -119
  167. package/src/plugins/loopscale/positionsFetcher.js.map +0 -1
  168. package/src/plugins/marginfi/filters.d.ts +0 -5
  169. package/src/plugins/marginfi/filters.js +0 -45
  170. package/src/plugins/marginfi/filters.js.map +0 -1
  171. package/src/plugins/picasso/types.d.ts +0 -17
  172. package/src/plugins/picasso/types.js +0 -3
  173. package/src/plugins/picasso/types.js.map +0 -1
  174. package/src/plugins/sharky/filters.d.ts +0 -8
  175. package/src/plugins/sharky/filters.js +0 -43
  176. package/src/plugins/sharky/filters.js.map +0 -1
  177. package/src/plugins/stabble/filters.d.ts +0 -5
  178. package/src/plugins/stabble/filters.js +0 -20
  179. package/src/plugins/stabble/filters.js.map +0 -1
  180. package/src/plugins/stabble/types.d.ts +0 -40
  181. package/src/plugins/stabble/types.js +0 -3
  182. package/src/plugins/stabble/types.js.map +0 -1
  183. /package/src/plugins/loopscale/{positionsFetcher.d.ts → lendFetcher.d.ts} +0 -0
  184. /package/src/plugins/{divvy → loopscale}/types.js +0 -0
@@ -0,0 +1,57 @@
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 web3_js_1 = require("@solana/web3.js");
17
+ const bn_js_1 = __importDefault(require("bn.js"));
18
+ const constants_1 = require("./constants");
19
+ const clients_1 = require("../../utils/clients");
20
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
21
+ const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
22
+ const structs_1 = require("./structs");
23
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
24
+ const connection = (0, clients_1.getClientSolana)();
25
+ const strategys = yield ParsedGpa_1.ParsedGpa.build(connection, structs_1.strategyStruct, constants_1.loopscaleProgramId)
26
+ .addFilter('accountDiscriminator', [174, 110, 39, 119, 82, 106, 169, 102])
27
+ .addFilter('lender', new web3_js_1.PublicKey(owner))
28
+ .run();
29
+ if (!strategys.length)
30
+ return [];
31
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
32
+ strategys.forEach((strategy) => {
33
+ const amount = new bn_js_1.default(strategy.external_yield_amount.array.reverse()).toNumber() +
34
+ new bn_js_1.default(strategy.current_deployed_amount.array.reverse()).toNumber() +
35
+ new bn_js_1.default(strategy.token_balance.array.reverse()).toNumber();
36
+ if (strategy.principal_mint === web3_js_1.PublicKey.default) {
37
+ return;
38
+ }
39
+ const element = elementRegistry.addElementBorrowlend({
40
+ label: 'Lending',
41
+ ref: strategy.pubkey,
42
+ link: 'https://app.loopscale.com/lend',
43
+ });
44
+ element.addSuppliedAsset({
45
+ address: strategy.principal_mint,
46
+ amount,
47
+ });
48
+ });
49
+ return elementRegistry.getElements(cache);
50
+ });
51
+ const fetcher = {
52
+ id: `${constants_1.platformId}-lend`,
53
+ networkId: portfolio_core_1.NetworkId.solana,
54
+ executor,
55
+ };
56
+ exports.default = fetcher;
57
+ //# sourceMappingURL=lendFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lendFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/lendFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,6CAA4C;AAC5C,kDAAuB;AAEvB,2CAA6D;AAE7D,iDAAsD;AACtD,gFAA6E;AAC7E,kEAA+D;AAC/D,uCAA2C;AAE3C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,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H,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,OAAO;IACxB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ import { MemoizedCache } from '../../utils/misc/MemoizedCache';
3
+ import { CachedVault } from './types';
4
+ export declare const vaultsMemo: MemoizedCache<CachedVault[], Map<string, CachedVault>>;
5
+ declare const fetcher: Fetcher;
6
+ export default fetcher;
@@ -0,0 +1,68 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.vaultsMemo = void 0;
13
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
14
+ const web3_js_1 = require("@solana/web3.js");
15
+ const constants_1 = require("./constants");
16
+ const clients_1 = require("../../utils/clients");
17
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
18
+ const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
19
+ const structs_1 = require("./structs");
20
+ const helpers_1 = require("./helpers");
21
+ const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
22
+ const arrayToMap_1 = require("../../utils/misc/arrayToMap");
23
+ exports.vaultsMemo = new MemoizedCache_1.MemoizedCache(constants_1.vaultsCacheKey, {
24
+ prefix: constants_1.platformId,
25
+ networkId: portfolio_core_1.NetworkId.solana,
26
+ }, (arr) => (0, arrayToMap_1.arrayToMap)(arr || [], 'pubkey'));
27
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const connection = (0, clients_1.getClientSolana)();
29
+ const userVaultStakes = yield ParsedGpa_1.ParsedGpa.build(connection, structs_1.vaultStakeStruct, constants_1.loopscaleProgramId)
30
+ .addFilter('accountDiscriminator', [225, 34, 128, 53, 167, 239, 182, 107])
31
+ .addFilter('user', new web3_js_1.PublicKey(owner))
32
+ .run();
33
+ if (!userVaultStakes.length)
34
+ return [];
35
+ const vaults = yield exports.vaultsMemo.getItem(cache);
36
+ if (!vaults.size)
37
+ throw new Error('Vaults not cached');
38
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
39
+ userVaultStakes.forEach((stakeAccount) => {
40
+ const vault = vaults.get(stakeAccount.vault.toString());
41
+ if (!vault)
42
+ return;
43
+ const amount = (0, helpers_1.bytesToNumberLE)(new Uint8Array(stakeAccount.amount.array));
44
+ const element = elementRegistry.addElementMultiple({
45
+ label: 'Deposit',
46
+ ref: stakeAccount.pubkey,
47
+ sourceRefs: [
48
+ {
49
+ name: 'Vault',
50
+ address: vault.pubkey.toString(),
51
+ },
52
+ ],
53
+ link: `https://app.loopscale.com/vault/AXanCP4dJHtWd7zY4X7nwxN5t5Gysfy2uG3XTxSmXdaB${vault.pubkey}`,
54
+ });
55
+ element.addAsset({
56
+ address: vault.lp_mint,
57
+ amount,
58
+ });
59
+ });
60
+ return elementRegistry.getElements(cache);
61
+ });
62
+ const fetcher = {
63
+ id: `${constants_1.platformId}-lend-vaults`,
64
+ networkId: portfolio_core_1.NetworkId.solana,
65
+ executor,
66
+ };
67
+ exports.default = fetcher;
68
+ //# sourceMappingURL=lendVaultsFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AAC;IAE1E,eAAe,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,MAAM,MAAM,GAAG,IAAA,yBAAe,EAAC,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG,eAAe,CAAC,kBAAkB,CAAC;YACjD,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,YAAY,CAAC,MAAM;YACxB,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;iBACjC;aACF;YACD,IAAI,EAAE,+EAA+E,KAAK,CAAC,MAAM,EAAE;SACpG,CAAC,CAAC;QACH,OAAO,CAAC,QAAQ,CAAC;YACf,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM;SACP,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,79 @@
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 web3_js_1 = require("@solana/web3.js");
17
+ const bn_js_1 = __importDefault(require("bn.js"));
18
+ const constants_1 = require("./constants");
19
+ const clients_1 = require("../../utils/clients");
20
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
21
+ const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
22
+ const structs_1 = require("./structs");
23
+ const helpers_1 = require("./helpers");
24
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
25
+ const connection = (0, clients_1.getClientSolana)();
26
+ const accounts = yield ParsedGpa_1.ParsedGpa.build(connection, structs_1.loanStruct, constants_1.loopscaleProgramId)
27
+ .addFilter('accountDiscriminator', [20, 195, 70, 117, 165, 227, 182, 1])
28
+ .addFilter('borrower', new web3_js_1.PublicKey(owner))
29
+ .run();
30
+ if (!accounts.length)
31
+ return [];
32
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
33
+ accounts.forEach((account) => {
34
+ const element = elementRegistry.addElementBorrowlend({
35
+ label: 'Lending',
36
+ ref: account.pubkey,
37
+ link: `https://app.loopscale.com/loan/${account.pubkey}`,
38
+ });
39
+ account.collateral.forEach((collateralData, i) => {
40
+ if (collateralData.asset_identifier.toString() ===
41
+ web3_js_1.PublicKey.default.toString()) {
42
+ return;
43
+ }
44
+ element.addSuppliedAsset({
45
+ address: collateralData.asset_identifier,
46
+ amount: new bn_js_1.default(collateralData.amount.array.reverse()).toNumber(),
47
+ });
48
+ element.addSuppliedLtv((0, helpers_1.bytesToNumberLE)(new Uint8Array(account.ltv_matrix[i][0].array)));
49
+ });
50
+ account.ledgers.forEach((ledger, i) => {
51
+ if (ledger.principal_mint.toString() === web3_js_1.PublicKey.default.toString()) {
52
+ return;
53
+ }
54
+ element.addBorrowedAsset({
55
+ address: ledger.principal_mint,
56
+ amount: new bn_js_1.default(ledger.principal_due.array.reverse()).toNumber() -
57
+ new bn_js_1.default(ledger.principal_repaid.array.reverse()).toNumber() +
58
+ new bn_js_1.default(ledger.interest_due.array.reverse()).toNumber() -
59
+ new bn_js_1.default(ledger.interest_repaid.array.reverse()).toNumber(),
60
+ });
61
+ element.addBorrowedWeight((0, helpers_1.bytesToNumberLE)(new Uint8Array(account.weight_matrix[i][0].array)));
62
+ const apy = (0, helpers_1.bytesToNumberLE)(new Uint8Array(ledger.apy.array)) / 10000;
63
+ element.addBorrowedYield([
64
+ {
65
+ apy,
66
+ apr: (0, portfolio_core_1.apyToApr)(apy),
67
+ },
68
+ ]);
69
+ });
70
+ });
71
+ return elementRegistry.getElements(cache);
72
+ });
73
+ const fetcher = {
74
+ id: `${constants_1.platformId}-loans`,
75
+ networkId: portfolio_core_1.NetworkId.solana,
76
+ executor,
77
+ };
78
+ exports.default = fetcher;
79
+ //# sourceMappingURL=loansFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/loopscale/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAiE;AACjE,6CAA4C;AAC5C,kDAAuB;AAEvB,2CAA6D;AAE7D,iDAAsD;AACtD,gFAA6E;AAC7E,kEAA+D;AAC/D,uCAAuC;AACvC,uCAA4C;AAE5C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IACrC,MAA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OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -1,102 +1,132 @@
1
- /// <reference types="node" />
2
1
  /// <reference types="@drift-labs/sdk/node_modules/@solana/web3.js" />
3
2
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
4
3
  import { PublicKey } from '@solana/web3.js';
5
4
  import BigNumber from 'bignumber.js';
6
- import { BeetStruct, FixableBeetStruct } from '@metaplex-foundation/beet';
7
- export type RoleAccount = {
8
- buffer: Buffer;
9
- user: PublicKey;
10
- organization: PublicKey;
11
- type: number;
5
+ import { BeetStruct } from '@metaplex-foundation/beet';
6
+ export type PodU32 = {
7
+ array: number[];
12
8
  };
13
- export declare const roleAccountStruct: BeetStruct<RoleAccount, Partial<RoleAccount>>;
14
- export type LoanVault = {
15
- buffer: Buffer;
16
- order: PublicKey;
17
- lender: PublicKey;
18
- borrower: PublicKey;
19
- collateral: PublicKey;
20
- debt_note: PublicKey;
21
- credit_note: PublicKey;
22
- credit_claimed: boolean;
23
- debt_claimed: boolean;
24
- loan_start_time: BigNumber;
25
- num_fees_outstanding: BigNumber;
26
- fees_received: BigNumber;
9
+ export declare const podU32Struct: BeetStruct<PodU32, Partial<PodU32>>;
10
+ export type Duration = {
11
+ duration: PodU32;
12
+ duration_type: number;
27
13
  };
28
- export declare const loanVaultStruct: BeetStruct<LoanVault, Partial<LoanVault>>;
29
- export type EscrowAccount = {
30
- buffer: Buffer;
31
- organization_identifier: PublicKey;
32
- num_escrowed: BigNumber;
33
- nonce: PublicKey;
34
- origination_cap: BigNumber;
35
- cumulative_amount_originated: BigNumber;
36
- external_yield_source: number;
14
+ export declare const durationStruct: BeetStruct<Duration, Partial<Duration>>;
15
+ export type PodDecimal = {
16
+ array: number[];
37
17
  };
38
- export declare const escrowAccountStruct: BeetStruct<EscrowAccount, Partial<EscrowAccount>>;
39
- export type Order = {
40
- buffer: Buffer;
41
- version: number;
18
+ export declare const podDecimalStruct: BeetStruct<PodDecimal, Partial<PodDecimal>>;
19
+ export type PodU128 = {
20
+ array: number[];
21
+ };
22
+ export declare const podU128Struct: BeetStruct<PodU128, Partial<PodU128>>;
23
+ export type PodU32CBPS = {
24
+ array: number[];
25
+ };
26
+ export declare const podU32CBPSStruct: BeetStruct<PodU32CBPS, Partial<PodU32CBPS>>;
27
+ export type PodU64 = {
28
+ array: number[];
29
+ };
30
+ export declare const podU64Struct: BeetStruct<PodU64, Partial<PodU64>>;
31
+ export type PodU64CBPS = {
32
+ array: number[];
33
+ };
34
+ export declare const podU64CBPSStruct: BeetStruct<PodU64CBPS, Partial<PodU64CBPS>>;
35
+ export type PodBool = {
36
+ value: number;
37
+ };
38
+ export declare const podBoolStruct: BeetStruct<PodBool, Partial<PodBool>>;
39
+ export type Vault = {
40
+ accountDiscriminator: number[];
41
+ manager: PublicKey;
42
42
  nonce: PublicKey;
43
- maker: PublicKey;
44
- designated_taker: PublicKey;
43
+ bump: number;
44
+ lp_supply: PodU64;
45
+ lp_mint: PublicKey;
45
46
  principal_mint: PublicKey;
46
- principal_amount: BigNumber;
47
- collateral_mint: PublicKey;
48
- collateral_amount: BigNumber;
49
- maker_role: number;
50
- last_updated_slot: BigNumber;
51
- max_outstanding_payments: BigNumber;
52
- last_payment_id: BigNumber;
53
- final_payment_id: BigNumber;
54
- final_payment_time_offset: BigNumber;
55
- status: number;
56
- default_type: number;
57
- created_at: BigNumber;
58
- funding_type: number;
59
- allow_early_repayments: boolean;
60
- origination_fee: BigNumber;
61
- liquidation_manager: PublicKey;
62
- market_manager: PublicKey;
63
- liquidation_threshold: BigNumber;
64
- refinance_enabled: boolean;
65
- max_refinance_apy: BigNumber;
66
- refinance_duration: BigNumber;
67
- refinance_duration_type: number;
47
+ cumulative_principal_deposited: PodU64;
48
+ deposits_enabled: PodBool;
49
+ max_early_unstake_fee: PodU64CBPS;
68
50
  };
69
- export declare const orderStruct: BeetStruct<Order, Partial<Order>>;
51
+ export declare const vaultStruct: BeetStruct<Vault, Partial<Vault>>;
52
+ export type VaultStake = {
53
+ accountDiscriminator: number[];
54
+ vault: PublicKey;
55
+ nonce: PublicKey;
56
+ bump: number;
57
+ user: PublicKey;
58
+ amount: PodU64;
59
+ duration: Duration;
60
+ start_time: PodU64;
61
+ end_time: PodU64;
62
+ unstake_time: PodU64;
63
+ unstake_fee_applied: PodU64;
64
+ };
65
+ export declare const vaultStakeStruct: BeetStruct<VaultStake, Partial<VaultStake>>;
70
66
  export type Ledger = {
71
- ledger_id: BigNumber;
72
- principal_due: BigNumber;
73
- principal_repaid: BigNumber;
74
- interest_due: BigNumber;
75
- interest_repaid: BigNumber;
76
- due_time_offset: BigNumber;
77
- paid_time: BigNumber;
78
- payment_type: number;
79
- is_filled: boolean;
80
- grace_period: BigNumber;
81
- late_payment_fee: BigNumber;
82
- early_payment_fee: BigNumber;
83
- payment_window: BigNumber;
84
- reserve: number[];
67
+ status: number;
68
+ strategy: PublicKey;
69
+ principal_mint: PublicKey;
70
+ market_information: PublicKey;
71
+ principal_due: PodU64;
72
+ principal_repaid: PodU64;
73
+ interest_due: PodU64;
74
+ interest_repaid: PodU64;
75
+ duration: Duration;
76
+ interest_per_second: PodDecimal;
77
+ start_time: PodU64;
78
+ end_time: PodU64;
79
+ apy: PodU64CBPS;
85
80
  };
86
81
  export declare const ledgerStruct: BeetStruct<Ledger, Partial<Ledger>>;
87
- export type OrderLedger = {
88
- buffer: Buffer;
82
+ export type Strategy = {
83
+ accountDiscriminator: number[];
89
84
  version: number;
90
- order: PublicKey;
91
- ledgers: Ledger[];
92
- };
93
- export declare const orderLedgerStruct: FixableBeetStruct<OrderLedger, Partial<OrderLedger>>;
94
- export type Lockbox = {
95
- buffer: Buffer;
96
85
  nonce: PublicKey;
97
- name: Buffer;
98
- initialization_time: BigNumber;
99
- nft_mint: PublicKey;
100
- state: number;
86
+ bump: number;
87
+ principal_mint: PublicKey;
88
+ lender: PublicKey;
89
+ originations_enabled: PodBool;
90
+ external_yield_source: number;
91
+ interest_per_second: PodDecimal;
92
+ last_accrued_timestamp: PodU64;
93
+ liquidity_buffer: PodU64CBPS;
94
+ token_balance: PodU64;
95
+ interest_fee: PodU64CBPS;
96
+ principal_fee: PodU64CBPS;
97
+ origination_fee: PodU64CBPS;
98
+ origination_cap: PodU64;
99
+ external_yield_amount: PodU64;
100
+ current_deployed_amount: PodU64;
101
+ outstanding_interest_amount: PodU64;
102
+ fee_claimable: PodU64;
103
+ cumulative_principal_originated: PodU128;
104
+ cumulative_interest_accrued: PodU128;
105
+ cumulative_loan_count: PodU64;
106
+ active_loan_count: PodU64;
107
+ market_information: PublicKey;
108
+ collateral_map: PodU64[][];
109
+ };
110
+ export declare const strategyStruct: BeetStruct<Strategy, Partial<Strategy>>;
111
+ export type CollateralData = {
112
+ asset_mint: PublicKey;
113
+ amount: PodU64;
114
+ asset_type: number;
115
+ asset_identifier: PublicKey;
116
+ };
117
+ export declare const collateralDataStruct: BeetStruct<CollateralData, Partial<CollateralData>>;
118
+ export type Loan = {
119
+ accountDiscriminator: number[];
120
+ version: number;
121
+ bump: number;
122
+ loan_type: number;
123
+ borrower: PublicKey;
124
+ nonce: BigNumber;
125
+ start_time: PodU64;
126
+ ledgers: Ledger[];
127
+ collateral: CollateralData[];
128
+ weight_matrix: PodU32CBPS[][];
129
+ ltv_matrix: PodU32CBPS[][];
130
+ lqt_matrix: PodU32CBPS[][];
101
131
  };
102
- export declare const lockboxStruct: FixableBeetStruct<Lockbox, Partial<Lockbox>>;
132
+ export declare const loanStruct: BeetStruct<Loan, Partial<Loan>>;