@sonarwatch/portfolio-plugins 0.14.131 → 0.14.133

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 (75) hide show
  1. package/CHANGELOG.md +2136 -2128
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/src/plugins/balancer/helpers/pools.js +21 -21
  5. package/src/plugins/citrus/loansFetcher.js +34 -68
  6. package/src/plugins/citrus/loansFetcher.js.map +1 -1
  7. package/src/plugins/debridge/dlmmVaultsFetcher.js +1 -0
  8. package/src/plugins/debridge/dlmmVaultsFetcher.js.map +1 -1
  9. package/src/plugins/jupiter/exchange/helpersPerps.d.ts +2 -0
  10. package/src/plugins/jupiter/exchange/helpersPerps.js +3 -1
  11. package/src/plugins/jupiter/exchange/helpersPerps.js.map +1 -1
  12. package/src/plugins/jupiter/exchange/perpetualFetcher.js +27 -1
  13. package/src/plugins/jupiter/exchange/perpetualFetcher.js.map +1 -1
  14. package/src/plugins/jupiter/exchange/structs.d.ts +35 -1
  15. package/src/plugins/jupiter/exchange/structs.js +36 -1
  16. package/src/plugins/jupiter/exchange/structs.js.map +1 -1
  17. package/src/plugins/jupiter/exchange/valueAverageFetcher.js +1 -1
  18. package/src/plugins/jupiter/exchange/valueAverageFetcher.js.map +1 -1
  19. package/src/plugins/jupiter/filters.d.ts +1 -0
  20. package/src/plugins/jupiter/filters.js +11 -1
  21. package/src/plugins/jupiter/filters.js.map +1 -1
  22. package/src/plugins/rain/banksFetcher.js +47 -0
  23. package/src/plugins/rain/banksFetcher.js.map +1 -0
  24. package/src/plugins/rain/collectionsJob.js +9 -7
  25. package/src/plugins/rain/collectionsJob.js.map +1 -1
  26. package/src/plugins/rain/constants.d.ts +7 -2
  27. package/src/plugins/rain/constants.js +11 -3
  28. package/src/plugins/rain/constants.js.map +1 -1
  29. package/src/plugins/rain/defiBorrowsFetcher.d.ts +3 -0
  30. package/src/plugins/rain/defiBorrowsFetcher.js +52 -0
  31. package/src/plugins/rain/defiBorrowsFetcher.js.map +1 -0
  32. package/src/plugins/rain/index.js +10 -3
  33. package/src/plugins/rain/index.js.map +1 -1
  34. package/src/plugins/rain/nftBorrowsFetcher.d.ts +3 -0
  35. package/src/plugins/rain/nftBorrowsFetcher.js +76 -0
  36. package/src/plugins/rain/nftBorrowsFetcher.js.map +1 -0
  37. package/src/plugins/rain/poolsFetcher.js +79 -42
  38. package/src/plugins/rain/poolsFetcher.js.map +1 -1
  39. package/src/plugins/rain/structs.d.ts +455 -0
  40. package/src/plugins/rain/structs.js +425 -0
  41. package/src/plugins/rain/structs.js.map +1 -0
  42. package/src/plugins/rain/types.d.ts +18 -144
  43. package/src/plugins/sharky/loansFetcher.js +38 -73
  44. package/src/plugins/sharky/loansFetcher.js.map +1 -1
  45. package/src/plugins/sushiswap/helpers.js +24 -24
  46. package/src/plugins/uniswap-v2/helpers.js +22 -22
  47. package/src/plugins/zeta/airdropFetcher.js +14 -14
  48. package/src/utils/elementbuilder/AssetCollectibleBuilder.d.ts +10 -0
  49. package/src/utils/elementbuilder/AssetCollectibleBuilder.js +53 -0
  50. package/src/utils/elementbuilder/AssetCollectibleBuilder.js.map +1 -0
  51. package/src/utils/elementbuilder/ElementBorrowlendBuilder.d.ts +9 -1
  52. package/src/utils/elementbuilder/ElementBorrowlendBuilder.js +41 -3
  53. package/src/utils/elementbuilder/ElementBorrowlendBuilder.js.map +1 -1
  54. package/src/utils/elementbuilder/ElementRegistry.js +9 -1
  55. package/src/utils/elementbuilder/ElementRegistry.js.map +1 -1
  56. package/src/utils/elementbuilder/Params.d.ts +14 -0
  57. package/src/utils/sei/constants.js +8 -8
  58. package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
  59. package/src/utils/solana/das/heliusAssetToAssetCollectible.js +3 -2
  60. package/src/utils/solana/das/heliusAssetToAssetCollectible.js.map +1 -1
  61. package/src/plugins/rain/filters.d.ts +0 -7
  62. package/src/plugins/rain/filters.js +0 -53
  63. package/src/plugins/rain/filters.js.map +0 -1
  64. package/src/plugins/rain/helpers.d.ts +0 -9
  65. package/src/plugins/rain/helpers.js +0 -66
  66. package/src/plugins/rain/helpers.js.map +0 -1
  67. package/src/plugins/rain/loansFetcher.js +0 -139
  68. package/src/plugins/rain/loansFetcher.js.map +0 -1
  69. package/src/plugins/rain/structs/loan.d.ts +0 -86
  70. package/src/plugins/rain/structs/loan.js +0 -86
  71. package/src/plugins/rain/structs/loan.js.map +0 -1
  72. package/src/plugins/rain/structs/pool.d.ts +0 -79
  73. package/src/plugins/rain/structs/pool.js +0 -76
  74. package/src/plugins/rain/structs/pool.js.map +0 -1
  75. /package/src/plugins/rain/{loansFetcher.d.ts → banksFetcher.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.partialUnstakeFilter = exports.escrowFilter = exports.perpetualsPositionsFilter = void 0;
3
+ exports.partialUnstakeFilter = exports.escrowFilter = exports.positionRequestFilters = exports.perpetualsPositionsFilter = void 0;
4
4
  const perpetualsPositionsFilter = (owner) => [
5
5
  {
6
6
  memcmp: {
@@ -11,6 +11,16 @@ const perpetualsPositionsFilter = (owner) => [
11
11
  { dataSize: 216 },
12
12
  ];
13
13
  exports.perpetualsPositionsFilter = perpetualsPositionsFilter;
14
+ const positionRequestFilters = (owner) => [
15
+ {
16
+ memcmp: {
17
+ offset: 8,
18
+ bytes: owner,
19
+ },
20
+ },
21
+ { dataSize: 312 },
22
+ ];
23
+ exports.positionRequestFilters = positionRequestFilters;
14
24
  const escrowFilter = (owner) => [
15
25
  {
16
26
  memcmp: {
@@ -1 +1 @@
1
- {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/filters.ts"],"names":[],"mappings":";;;AAEO,MAAM,yBAAyB,GAAG,CACvC,KAAa,EACe,EAAE,CAAC;IAC/B;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,KAAK;SACb;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AAVW,QAAA,yBAAyB,6BAUpC;AAEK,MAAM,YAAY,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IACzE;QACE,MAAM,EAAE;YACN,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,KAAK;SACb;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEK,MAAM,oBAAoB,GAAG,CAClC,MAAc,EACc,EAAE,CAAC;IAC/B;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,MAAM;SACd;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AAVW,QAAA,oBAAoB,wBAU/B"}
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/jupiter/filters.ts"],"names":[],"mappings":";;;AAEO,MAAM,yBAAyB,GAAG,CACvC,KAAa,EACe,EAAE,CAAC;IAC/B;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,KAAK;SACb;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AAVW,QAAA,yBAAyB,6BAUpC;AAEK,MAAM,sBAAsB,GAAG,CACpC,KAAa,EACe,EAAE,CAAC;IAC/B;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,KAAK;SACb;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AAVW,QAAA,sBAAsB,0BAUjC;AAEK,MAAM,YAAY,GAAG,CAAC,KAAa,EAA8B,EAAE,CAAC;IACzE;QACE,MAAM,EAAE;YACN,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,KAAK;SACb;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEK,MAAM,oBAAoB,GAAG,CAClC,MAAc,EACc,EAAE,CAAC;IAC/B;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,MAAM;SACd;KACF;IACD,EAAE,QAAQ,EAAE,GAAG,EAAE;CAClB,CAAC;AAVW,QAAA,oBAAoB,wBAU/B"}
@@ -0,0 +1,47 @@
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
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
13
+ const web3_js_1 = require("@solana/web3.js");
14
+ const constants_1 = require("./constants");
15
+ const clients_1 = require("../../utils/clients");
16
+ const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
17
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
18
+ const structs_1 = require("./structs");
19
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const client = (0, clients_1.getClientSolana)();
21
+ const accounts = yield ParsedGpa_1.ParsedGpa.build(client, structs_1.bankStruct, constants_1.bankProgramId)
22
+ .addFilter('accountDiscriminator', [142, 49, 166, 242, 50, 66, 97, 188])
23
+ .addFilter('owner', new web3_js_1.PublicKey(owner))
24
+ .run();
25
+ if (!accounts.length)
26
+ return [];
27
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
28
+ accounts.forEach((account) => {
29
+ const element = elementRegistry.addElementMultiple({
30
+ label: 'Deposit',
31
+ name: 'Vault',
32
+ ref: account.pubkey,
33
+ });
34
+ element.addAsset({
35
+ address: account.mint,
36
+ amount: account.availableLiquidity,
37
+ });
38
+ });
39
+ return elementRegistry.getElements(cache);
40
+ });
41
+ const fetcher = {
42
+ id: `${constants_1.platformId}-banks`,
43
+ networkId: portfolio_core_1.NetworkId.solana,
44
+ executor,
45
+ };
46
+ exports.default = fetcher;
47
+ //# sourceMappingURL=banksFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"banksFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/banksFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AACvD,6CAA4C;AAG5C,2CAAwD;AACxD,iDAAsD;AACtD,kEAA+D;AAC/D,gFAA6E;AAC7E,uCAAuC;AAEvC,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,QAAQ,GAAG,MAAM,qBAAS,CAAC,KAAK,CAAC,MAAM,EAAE,oBAAU,EAAE,yBAAa,CAAC;SACtE,SAAS,CAAC,sBAAsB,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;SACvE,SAAS,CAAC,OAAO,EAAE,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC;SACxC,GAAG,EAAE,CAAC;IAET,IAAI,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEhC,MAAM,eAAe,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,MAAM,EAAE,sBAAU,CAAC,CAAC;IAE1E,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,eAAe,CAAC,kBAAkB,CAAC;YACjD,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,OAAO,CAAC,MAAM;SACpB,CAAC,CAAC;QAEH,OAAO,CAAC,QAAQ,CAAC;YACf,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,MAAM,EAAE,OAAO,CAAC,kBAAkB;SACnC,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,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -8,17 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
+ const axios_1 = __importDefault(require("axios"));
13
17
  const constants_1 = require("./constants");
14
- const helpers_1 = require("./helpers");
15
- const pick_1 = require("../../utils/misc/pick");
16
18
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
17
- const collections = yield (0, helpers_1.getCollections)();
18
- const filteredCollections = collections
19
- .filter((c) => !c.isDefi)
20
- .map((c) => (0, pick_1.pick)(c, ['collectionId', 'name', 'floorPrice']));
21
- yield cache.setItem(constants_1.collectionsKey, filteredCollections, {
19
+ const getCollectionsRes = yield axios_1.default.get(`${constants_1.rainApiV3}collection/collections`);
20
+ if (!getCollectionsRes || !getCollectionsRes.data)
21
+ throw new Error('No collections');
22
+ const { collections } = getCollectionsRes.data;
23
+ yield cache.setItem(constants_1.collectionsKey, collections, {
22
24
  prefix: constants_1.platformId,
23
25
  networkId: portfolio_core_1.NetworkId.solana,
24
26
  });
@@ -1 +1 @@
1
- {"version":3,"file":"collectionsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/collectionsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAyD;AACzD,uCAA2C;AAC3C,gDAA6C;AAG7C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAc,GAAE,CAAC;IAC3C,MAAM,mBAAmB,GAAG,WAAW;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;SACxB,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,CAAC,CAAqB,CAC3E,CAAC;IAEJ,MAAM,KAAK,CAAC,OAAO,CAAC,0BAAc,EAAE,mBAAmB,EAAE;QACvD,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,QAAQ;IACR,MAAM,EAAE,CAAC,QAAQ,CAAC;CACnB,CAAC;AACF,kBAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"collectionsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/collectionsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,kDAA6C;AAG7C,2CAAoE;AAGpE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,iBAAiB,GACrB,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,qBAAS,wBAAwB,CAAC,CAAC;IACxD,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,IAAI;QAC/C,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC;IAE/C,MAAM,KAAK,CAAC,OAAO,CAAC,0BAAc,EAAE,WAAW,EAAE;QAC/C,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,cAAc;IAC/B,QAAQ;IACR,MAAM,EAAE,CAAC,QAAQ,CAAC;CACnB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -2,8 +2,13 @@
2
2
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
3
3
  import { PublicKey } from '@solana/web3.js';
4
4
  import { Platform } from '@sonarwatch/portfolio-core';
5
+ import { MemoizedCache } from '../../utils/misc/MemoizedCache';
6
+ import { Collection } from './types';
5
7
  export declare const platformId = "rain";
6
8
  export declare const platform: Platform;
7
- export declare const programId: PublicKey;
8
- export declare const rainApi = "https://api-v2.rain.fi";
9
+ export declare const nftLendingProgramId: PublicKey;
10
+ export declare const defiLendingProgramId: PublicKey;
11
+ export declare const bankProgramId: PublicKey;
12
+ export declare const rainApiV3 = "https://api-v3.rain.fi/api/";
9
13
  export declare const collectionsKey = "collections";
14
+ export declare const collectionsMemo: MemoizedCache<Collection[], Collection[]>;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.collectionsKey = exports.rainApi = exports.programId = exports.platform = exports.platformId = void 0;
3
+ exports.collectionsMemo = exports.collectionsKey = exports.rainApiV3 = exports.bankProgramId = exports.defiLendingProgramId = exports.nftLendingProgramId = exports.platform = exports.platformId = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
6
+ const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
5
7
  exports.platformId = 'rain';
6
8
  exports.platform = {
7
9
  id: exports.platformId,
@@ -11,7 +13,13 @@ exports.platform = {
11
13
  website: 'https://rain.fi/',
12
14
  twitter: 'https://twitter.com/RainFi_',
13
15
  };
14
- exports.programId = new web3_js_1.PublicKey('RainEraPU5yDoJmTrHdYynK9739GkEfDsE4ffqce2BR');
15
- exports.rainApi = 'https://api-v2.rain.fi';
16
+ exports.nftLendingProgramId = new web3_js_1.PublicKey('rNfTQD84kwMbcRpWpLR92BVmxbuwrZc3o5HTauAZiXs');
17
+ exports.defiLendingProgramId = new web3_js_1.PublicKey('rDeFiHPjHZRLiz4iBzMw3zv6unZs4VwdU6qQcVd3NSK');
18
+ exports.bankProgramId = new web3_js_1.PublicKey('rain2M5b9GeFCk792swkwUu51ZihHJb3SUQ8uHxSRJf');
19
+ exports.rainApiV3 = 'https://api-v3.rain.fi/api/';
16
20
  exports.collectionsKey = 'collections';
21
+ exports.collectionsMemo = new MemoizedCache_1.MemoizedCache(exports.collectionsKey, {
22
+ prefix: exports.platformId,
23
+ networkId: portfolio_core_1.NetworkId.solana,
24
+ });
17
25
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,6CAA6C;IACpD,WAAW,EAAE,SAAS,EAAE,sCAAsC;IAC9D,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,6BAA6B;CACvC,CAAC;AAEW,QAAA,SAAS,GAAG,IAAI,mBAAS,CACpC,6CAA6C,CAC9C,CAAC;AAEW,QAAA,OAAO,GAAG,wBAAwB,CAAC;AACnC,QAAA,cAAc,GAAG,aAAa,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,+DAAiE;AACjE,kEAA+D;AAGlD,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,6CAA6C;IACpD,WAAW,EAAE,SAAS,EAAE,sCAAsC;IAC9D,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,6BAA6B;CACvC,CAAC;AAEW,QAAA,mBAAmB,GAAG,IAAI,mBAAS,CAC9C,6CAA6C,CAC9C,CAAC;AACW,QAAA,oBAAoB,GAAG,IAAI,mBAAS,CAC/C,6CAA6C,CAC9C,CAAC;AACW,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,6CAA6C,CAC9C,CAAC;AAEW,QAAA,SAAS,GAAG,6BAA6B,CAAC;AAE1C,QAAA,cAAc,GAAG,aAAa,CAAC;AAE/B,QAAA,eAAe,GAAG,IAAI,6BAAa,CAAe,sBAAc,EAAE;IAC7E,MAAM,EAAE,kBAAU;IAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;CAC5B,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,52 @@
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
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
13
+ const web3_js_1 = require("@solana/web3.js");
14
+ const constants_1 = require("./constants");
15
+ const clients_1 = require("../../utils/clients");
16
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
17
+ const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
18
+ const structs_1 = require("./structs");
19
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const client = (0, clients_1.getClientSolana)();
21
+ const loans = yield ParsedGpa_1.ParsedGpa.build(client, structs_1.defiLoanStruct, constants_1.defiLendingProgramId)
22
+ .addFilter('accountDiscriminator', [20, 195, 70, 117, 165, 227, 182, 1])
23
+ .addFilter('borrower', new web3_js_1.PublicKey(owner))
24
+ .run();
25
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
26
+ loans.forEach((loan) => {
27
+ if (loan.status !== structs_1.LoanStatus.Ongoing)
28
+ return;
29
+ const element = elementRegistry.addElementBorrowlend({
30
+ label: 'Lending',
31
+ ref: loan.pubkey,
32
+ link: `https://app.rain.fi/dashboard/loans?address=${loan.pubkey}`,
33
+ });
34
+ element.setFixedTerms(false, loan.expiredAt.multipliedBy(1000));
35
+ element.addSuppliedAsset({
36
+ address: loan.collateral,
37
+ amount: loan.collateralAmount,
38
+ });
39
+ element.addBorrowedAsset({
40
+ address: loan.principal,
41
+ amount: loan.borrowedAmount,
42
+ });
43
+ });
44
+ return elementRegistry.getElements(cache);
45
+ });
46
+ const fetcher = {
47
+ id: `${constants_1.platformId}-defi-borrows`,
48
+ networkId: portfolio_core_1.NetworkId.solana,
49
+ executor,
50
+ };
51
+ exports.default = fetcher;
52
+ //# sourceMappingURL=defiBorrowsFetcher.js.map
@@ -0,0 +1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YACxB,MAAM,EAAE,IAAI,CAAC,gBAAgB;SAC9B,CAAC,CAAC;QAEH,OAAO,CAAC,gBAAgB,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,cAAc;SAC5B,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,eAAe;IAChC,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -5,10 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchers = exports.jobs = exports.platforms = void 0;
7
7
  const constants_1 = require("./constants");
8
- const poolsFetcher_1 = __importDefault(require("./poolsFetcher"));
9
- const loansFetcher_1 = __importDefault(require("./loansFetcher"));
10
8
  const collectionsJob_1 = __importDefault(require("./collectionsJob"));
9
+ const poolsFetcher_1 = __importDefault(require("./poolsFetcher"));
10
+ const banksFetcher_1 = __importDefault(require("./banksFetcher"));
11
+ const defiBorrowsFetcher_1 = __importDefault(require("./defiBorrowsFetcher"));
12
+ const nftBorrowsFetcher_1 = __importDefault(require("./nftBorrowsFetcher"));
11
13
  exports.platforms = [constants_1.platform];
12
14
  exports.jobs = [collectionsJob_1.default];
13
- exports.fetchers = [poolsFetcher_1.default, loansFetcher_1.default];
15
+ exports.fetchers = [
16
+ defiBorrowsFetcher_1.default,
17
+ nftBorrowsFetcher_1.default,
18
+ poolsFetcher_1.default,
19
+ banksFetcher_1.default,
20
+ ];
14
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,kEAA0C;AAC1C,kEAA0C;AAC1C,sEAA8C;AAEjC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,wBAAc,CAAC,CAAC;AAC/B,QAAA,QAAQ,GAAc,CAAC,sBAAY,EAAE,sBAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,sEAA8C;AAC9C,kEAA0C;AAC1C,kEAA0C;AAC1C,8EAAsD;AACtD,4EAAoD;AAEvC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,wBAAc,CAAC,CAAC;AAC/B,QAAA,QAAQ,GAAc;IACjC,4BAAkB;IAClB,2BAAiB;IACjB,sBAAY;IACZ,sBAAY;CACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,76 @@
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 bignumber_js_1 = __importDefault(require("bignumber.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 client = (0, clients_1.getClientSolana)();
25
+ const loans = yield ParsedGpa_1.ParsedGpa.build(client, structs_1.nftLoanStruct, constants_1.nftLendingProgramId)
26
+ .addFilter('accountDiscriminator', [20, 195, 70, 117, 165, 227, 182, 1])
27
+ .addFilter('borrower', new web3_js_1.PublicKey(owner))
28
+ .run();
29
+ if (!loans.length)
30
+ return [];
31
+ const [collections, solTokenPrice] = yield Promise.all([
32
+ constants_1.collectionsMemo.getItem(cache),
33
+ cache.getTokenPrice(portfolio_core_1.solanaNativeAddress, portfolio_core_1.NetworkId.solana),
34
+ ]);
35
+ if (!collections.length)
36
+ throw new Error('Collections not cached');
37
+ if (!solTokenPrice)
38
+ throw new Error('Sol price not cached');
39
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
40
+ loans.forEach((loan) => {
41
+ if (loan.status !== structs_1.LoanStatus.Ongoing)
42
+ return;
43
+ const collection = collections.find((c) => c.collectionId === loan.collection);
44
+ if (!collection)
45
+ return;
46
+ const element = elementRegistry.addElementBorrowlend({
47
+ label: 'Lending',
48
+ ref: loan.pubkey,
49
+ link: `https://app.rain.fi/dashboard/loans?address=${loan.pubkey}`,
50
+ });
51
+ element.setFixedTerms(false, loan.expiredAt.multipliedBy(1000));
52
+ element.addSuppliedCollectibleAsset({
53
+ address: loan.collateral.toString(),
54
+ collection: {
55
+ name: collection.name,
56
+ floorPrice: new bignumber_js_1.default(collection.floorPrice)
57
+ .shiftedBy(-solTokenPrice.decimals)
58
+ .multipliedBy(solTokenPrice.price),
59
+ imageUri: collection.metadata.thumbnail,
60
+ },
61
+ attributes: { tags: [portfolio_core_1.collectibleFreezedTag] },
62
+ });
63
+ element.addBorrowedAsset({
64
+ address: loan.principal,
65
+ amount: loan.borrowedAmount,
66
+ });
67
+ });
68
+ return elementRegistry.getElements(cache);
69
+ });
70
+ const fetcher = {
71
+ id: `${constants_1.platformId}-nft-borrows`,
72
+ networkId: portfolio_core_1.NetworkId.solana,
73
+ executor,
74
+ };
75
+ exports.default = fetcher;
76
+ //# sourceMappingURL=nftBorrowsFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nftBorrowsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/nftBorrowsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAGrC,2CAA+E;AAC/E,iDAAsD;AACtD,gFAA6E;AAC7E,kEAA+D;AAC/D,uCAAsD;AAEtD,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,KAAK,GAAG,MAAM,qBAAS,CAAC,KAAK,CACjC,MAAM,EACN,uBAAa,EACb,+BAAmB,CACpB;SACE,SAAS,CAAC,sBAAsB,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACvE,SAAS,CAAC,UAAU,EAAE,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC;SAC3C,GAAG,EAAE,CAAC;IAET,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAE7B,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACrD,2BAAe,CAAC,OAAO,CAAC,KAAK,CAAC;QAC9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AAU,CAAC,QAAQ,CAAC,SAAS;aACxC;YACD,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,sCAAqB,CAAC,EAAE;SAC9C,CAAC,CAAC;QAEH,OAAO,CAAC,gBAAgB,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,cAAc;SAC5B,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"}
@@ -13,54 +13,91 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
16
18
  const constants_1 = require("./constants");
17
19
  const clients_1 = require("../../utils/clients");
18
- const pool_1 = require("./structs/pool");
19
- const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
20
- const helpers_1 = require("./helpers");
21
- const getParsedAccountInfo_1 = require("../../utils/solana/getParsedAccountInfo");
20
+ const ParsedGpa_1 = require("../../utils/solana/beets/ParsedGpa");
21
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
22
+ const structs_1 = require("./structs");
22
23
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
23
24
  const client = (0, clients_1.getClientSolana)();
24
- // Trying to get https://solscan.io/account/4g5zooignaoVrS6NdUWEcNLxZmJGN9UJBAGtrUiBwieF
25
- const poolAccount = yield (0, getParsedAccountInfo_1.getParsedAccountInfo)(client, pool_1.poolStruct, (0, helpers_1.getPoolPda)(owner));
26
- if (!poolAccount || poolAccount.totalAmount.isZero())
25
+ const pools = yield ParsedGpa_1.ParsedGpa.build(client, structs_1.poolStruct, constants_1.defiLendingProgramId)
26
+ .addFilter('accountDiscriminator', [241, 154, 109, 4, 17, 177, 109, 188])
27
+ .addFilter('owner', new web3_js_1.PublicKey(owner))
28
+ .run();
29
+ if (!pools.length)
27
30
  return [];
28
- const tokenPrice = yield cache.getTokenPrice(poolAccount.currency.toString(), portfolio_core_1.NetworkId.solana);
29
- if (!tokenPrice)
31
+ const allDefiLoans = yield Promise.all(pools.map((pool) => ParsedGpa_1.ParsedGpa.build(client, structs_1.defiLoanStruct, constants_1.defiLendingProgramId)
32
+ .addFilter('accountDiscriminator', [20, 195, 70, 117, 165, 227, 182, 1])
33
+ .addFilter('pool', pool.pubkey)
34
+ .run()));
35
+ const allNftsLoans = yield Promise.all(pools.map((pool) => ParsedGpa_1.ParsedGpa.build(client, structs_1.nftLoanStruct, constants_1.nftLendingProgramId)
36
+ .addFilter('accountDiscriminator', [20, 195, 70, 117, 165, 227, 182, 1])
37
+ .addFilter('pool', pool.pubkey)
38
+ .run()));
39
+ if (allDefiLoans.flat().length === 0 && allNftsLoans.flat().length === 0)
30
40
  return [];
31
- const borrowedAssets = [];
32
- const borrowedYields = [];
33
- const suppliedAssets = [];
34
- const suppliedYields = [];
35
- const rewardAssets = [];
36
- const amount = poolAccount.totalAmount
37
- .dividedBy(Math.pow(10, tokenPrice.decimals))
38
- .toNumber();
39
- suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPrice.address, amount, portfolio_core_1.NetworkId.solana, tokenPrice));
40
- if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
41
- return [];
42
- const { borrowedValue, healthRatio, rewardValue, suppliedValue, value } = (0, portfolio_core_1.getElementLendingValues)({ suppliedAssets, borrowedAssets, rewardAssets });
43
- return [
44
- {
45
- type: portfolio_core_1.PortfolioElementType.borrowlend,
46
- networkId: portfolio_core_1.NetworkId.solana,
47
- platformId: constants_1.platformId,
48
- label: 'Lending',
49
- value,
50
- data: {
51
- borrowedAssets,
52
- borrowedValue,
53
- borrowedYields,
54
- suppliedAssets,
55
- suppliedValue,
56
- suppliedYields,
57
- healthRatio,
58
- rewardValue,
59
- rewardAssets,
60
- value,
61
- },
62
- },
63
- ];
41
+ const [collections, solTokenPrice] = yield Promise.all([
42
+ constants_1.collectionsMemo.getItem(cache),
43
+ cache.getTokenPrice(portfolio_core_1.solanaNativeAddress, portfolio_core_1.NetworkId.solana),
44
+ ]);
45
+ if (!collections.length)
46
+ throw new Error('Collections not cached');
47
+ if (!solTokenPrice)
48
+ throw new Error('Sol price not cached');
49
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
50
+ pools.forEach((pool, i) => {
51
+ const defiLoans = allDefiLoans[i];
52
+ const nftLoans = allNftsLoans[i];
53
+ defiLoans.forEach((loan) => {
54
+ if (loan.status !== structs_1.LoanStatus.Ongoing)
55
+ return;
56
+ const element = elementRegistry.addElementBorrowlend({
57
+ label: 'Lending',
58
+ ref: loan.pubkey,
59
+ link: `https://app.rain.fi/dashboard/loans?address=${loan.pubkey}`,
60
+ });
61
+ element.setFixedTerms(true, loan.expiredAt.multipliedBy(1000));
62
+ element.addSuppliedAsset({
63
+ address: loan.principal,
64
+ amount: loan.borrowedAmount,
65
+ });
66
+ element.addBorrowedAsset({
67
+ address: loan.collateral,
68
+ amount: loan.collateralAmount,
69
+ });
70
+ });
71
+ nftLoans.forEach((loan) => {
72
+ if (loan.status !== structs_1.LoanStatus.Ongoing)
73
+ return;
74
+ const collection = collections.find((c) => c.collectionId === loan.collection);
75
+ if (!collection)
76
+ return;
77
+ const element = elementRegistry.addElementBorrowlend({
78
+ label: 'Lending',
79
+ ref: loan.pubkey,
80
+ link: `https://app.rain.fi/dashboard/loans?address=${loan.pubkey}`,
81
+ });
82
+ element.setFixedTerms(false, loan.expiredAt.multipliedBy(1000));
83
+ element.addBorrowedCollectibleAsset({
84
+ address: loan.collateral.toString(),
85
+ collection: {
86
+ name: collection.name,
87
+ floorPrice: new bignumber_js_1.default(collection.floorPrice)
88
+ .shiftedBy(-solTokenPrice.decimals)
89
+ .multipliedBy(solTokenPrice.price),
90
+ imageUri: collection.metadata.thumbnail,
91
+ },
92
+ attributes: { tags: [portfolio_core_1.collectibleFreezedTag] },
93
+ });
94
+ element.addSuppliedAsset({
95
+ address: loan.principal,
96
+ amount: loan.borrowedAmount,
97
+ });
98
+ });
99
+ });
100
+ return elementRegistry.getElements(cache);
64
101
  });
65
102
  const fetcher = {
66
103
  id: `${constants_1.platformId}-pools`,
@@ -1 +1 @@
1
- {"version":3,"file":"poolsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/poolsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,2CAAyC;AACzC,iDAAsD;AACtD,yCAA4C;AAC5C,qGAA6E;AAC7E,uCAAuC;AACvC,kFAA+E;AAE/E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,wFAAwF;IAExF,MAAM,WAAW,GAAG,MAAM,IAAA,2CAAoB,EAC5C,MAAM,EACN,iBAAU,EACV,IAAA,oBAAU,EAAC,KAAK,CAAC,CAClB,CAAC;IACF,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC;IAEhE,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,aAAa,CAC1C,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAC/B,0BAAS,CAAC,MAAM,CACjB,CAAC;IACF,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,YAAY,GAAqB,EAAE,CAAC;IAE1C,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW;SACnC,SAAS,CAAC,SAAA,EAAE,EAAI,UAAU,CAAC,QAAQ,CAAA,CAAC;SACpC,QAAQ,EAAE,CAAC;IACd,cAAc,CAAC,IAAI,CACjB,IAAA,gCAAsB,EACpB,UAAU,CAAC,OAAO,EAClB,MAAM,EACN,0BAAS,CAAC,MAAM,EAChB,UAAU,CACX,CACF,CAAC;IAEF,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE1E,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,GACrE,IAAA,wCAAuB,EAAC,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;IAE5E,OAAO;QACL;YACE,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,SAAS;YAChB,KAAK;YACL,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,WAAW;gBACX,WAAW;gBACX,YAAY;gBACZ,KAAK;aACN;SACF;KACF,CAAC;AACJ,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
+ {"version":3,"file":"poolsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/poolsFetcher.ts"],"names":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