@sonarwatch/portfolio-plugins 0.14.30 → 0.14.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/src/index.js +6 -2
  4. package/src/index.js.map +1 -1
  5. package/src/plugins/banx/loansFetcher.js +2 -1
  6. package/src/plugins/banx/loansFetcher.js.map +1 -1
  7. package/src/plugins/cetus/clmmsFetcher.js +5 -7
  8. package/src/plugins/cetus/clmmsFetcher.js.map +1 -1
  9. package/src/plugins/cetus/constants.d.ts +1 -0
  10. package/src/plugins/cetus/constants.js +17 -1
  11. package/src/plugins/cetus/constants.js.map +1 -1
  12. package/src/plugins/cetus/farmsFetcher.js +3 -7
  13. package/src/plugins/cetus/farmsFetcher.js.map +1 -1
  14. package/src/plugins/cetus/getPools.d.ts +3 -0
  15. package/src/plugins/cetus/getPools.js +50 -0
  16. package/src/plugins/cetus/getPools.js.map +1 -0
  17. package/src/plugins/cetus/poolsJob.js +4 -3
  18. package/src/plugins/cetus/poolsJob.js.map +1 -1
  19. package/src/plugins/cetus/types.d.ts +32 -31
  20. package/src/plugins/drift-market-maker-vault/constants.d.ts +2 -0
  21. package/src/plugins/drift-market-maker-vault/constants.js +11 -1
  22. package/src/plugins/drift-market-maker-vault/constants.js.map +1 -1
  23. package/src/plugins/drift-market-maker-vault/depositsFetcher.d.ts +2 -0
  24. package/src/plugins/drift-market-maker-vault/depositsFetcher.js +4 -2
  25. package/src/plugins/drift-market-maker-vault/depositsFetcher.js.map +1 -1
  26. package/src/plugins/drift-market-maker-vault/index.js +1 -0
  27. package/src/plugins/drift-market-maker-vault/index.js.map +1 -1
  28. package/src/plugins/kai/constants.d.ts +9 -0
  29. package/src/plugins/kai/constants.js +37 -2
  30. package/src/plugins/kai/constants.js.map +1 -1
  31. package/src/plugins/kai/helpers.d.ts +8 -0
  32. package/src/plugins/kai/helpers.js +49 -0
  33. package/src/plugins/kai/helpers.js.map +1 -0
  34. package/src/plugins/kai/index.js +4 -2
  35. package/src/plugins/kai/index.js.map +1 -1
  36. package/src/plugins/kai/lpVaultsFetcher.d.ts +3 -0
  37. package/src/plugins/kai/lpVaultsFetcher.js +112 -0
  38. package/src/plugins/kai/lpVaultsFetcher.js.map +1 -0
  39. package/src/plugins/kai/supplyPoolsJob.d.ts +3 -0
  40. package/src/plugins/kai/supplyPoolsJob.js +35 -0
  41. package/src/plugins/kai/supplyPoolsJob.js.map +1 -0
  42. package/src/plugins/kai/types.d.ts +107 -0
  43. package/src/plugins/kai/vaultsJob.js +19 -12
  44. package/src/plugins/kai/vaultsJob.js.map +1 -1
  45. package/src/plugins/metaplex/constants.d.ts +7 -0
  46. package/src/plugins/metaplex/constants.js +17 -0
  47. package/src/plugins/metaplex/constants.js.map +1 -0
  48. package/src/plugins/metaplex/helpers.d.ts +3 -0
  49. package/src/plugins/metaplex/helpers.js +19 -0
  50. package/src/plugins/metaplex/helpers.js.map +1 -0
  51. package/src/plugins/metaplex/index.d.ts +6 -0
  52. package/src/plugins/metaplex/index.js +12 -0
  53. package/src/plugins/metaplex/index.js.map +1 -0
  54. package/src/plugins/metaplex/resizableNftFetcher.d.ts +3 -0
  55. package/src/plugins/metaplex/resizableNftFetcher.js +75 -0
  56. package/src/plugins/metaplex/resizableNftFetcher.js.map +1 -0
  57. package/src/plugins/native-stake/solana/solanaValidatorsJob.js +2 -1
  58. package/src/plugins/native-stake/solana/solanaValidatorsJob.js.map +1 -1
  59. package/src/plugins/native-stake/solana/types.d.ts +3 -1
  60. package/src/plugins/pyth/pricingJob.js +98 -2
  61. package/src/plugins/pyth/pricingJob.js.map +1 -1
  62. package/src/plugins/symmetry/basketsJob.js +8 -2
  63. package/src/plugins/symmetry/basketsJob.js.map +1 -1
  64. package/src/utils/solana/pyth/helpers.d.ts +11 -6
  65. package/src/utils/solana/pyth/helpers.js +13 -18
  66. package/src/utils/solana/pyth/helpers.js.map +1 -1
  67. package/src/utils/sui/constants.d.ts +2 -0
  68. package/src/utils/sui/constants.js +3 -1
  69. package/src/utils/sui/constants.js.map +1 -1
@@ -7,3 +7,12 @@ export declare const vaultsInfo: {
7
7
  lpType: string;
8
8
  decimals: number;
9
9
  }[];
10
+ export declare const supplyPoolsCacheKey = "supply-pools";
11
+ export declare const vaults: {
12
+ name: string;
13
+ configId: string;
14
+ poolObjectId: string;
15
+ lendFacilCap: string;
16
+ supplyPoolXInfo: string;
17
+ supplyPoolYInfo: string;
18
+ }[];
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.vaultsInfo = exports.platform = exports.platformId = void 0;
3
+ exports.vaults = exports.supplyPoolsCacheKey = exports.vaultsInfo = exports.platform = exports.platformId = void 0;
4
4
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
5
+ const constants_1 = require("../../utils/sui/constants");
5
6
  exports.platformId = 'kai';
6
7
  exports.platform = {
7
8
  id: exports.platformId,
@@ -13,7 +14,7 @@ exports.platform = {
13
14
  };
14
15
  exports.vaultsInfo = [
15
16
  {
16
- // USDC
17
+ // wUSDC
17
18
  id: '0x7a2f75a3e50fd5f72dfc2f8c9910da5eaa3a1486e4eb1e54a825c09d82214526',
18
19
  tType: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',
19
20
  lpType: '0x1c389a85310b47e7630a9361d4e71025bc35e4999d3a645949b1b68b26f2273::ywhusdce::YWHUSDCE',
@@ -33,5 +34,39 @@ exports.vaultsInfo = [
33
34
  lpType: '0xb8dc843a816b51992ee10d2ddc6d28aab4f0a1d651cd7289a7897902eb631613::ysui::YSUI',
34
35
  decimals: 9,
35
36
  },
37
+ {
38
+ // USDC
39
+ id: '0x5663035df5f403ad5a015cc2a3264de30370650bc043c4dab4d0012ea5cb7671',
40
+ tType: constants_1.usdcSuiType,
41
+ lpType: '0xa4184b1a5829e7cced8e51e8e385b16d02642634cd3e72a50d31cdf4a78bfd5c::yusdc::YUSDC',
42
+ decimals: 6,
43
+ },
44
+ ];
45
+ exports.supplyPoolsCacheKey = 'supply-pools';
46
+ exports.vaults = [
47
+ {
48
+ name: 'Cetus wUSDT/wUSDC',
49
+ configId: '0x2d52e5fe8af24f2c750250fca6ce5d595d22287f12d29c6ffbae490f5650478d',
50
+ poolObjectId: '0xc8d7a1503dc2f9f5b05449a87d8733593e2f0f3e7bffd90541252782e4d2ca20',
51
+ lendFacilCap: '0xf61382ca5e79c6bdccba39fc375c7b34daa02c7076369a8a34741f22980607ff',
52
+ supplyPoolXInfo: '0x372b6948ae06dacce75fdc3546865b2e777d4050114d93db0717b40cf677634c',
53
+ supplyPoolYInfo: '0x86c5ca41be63b5b9a8da0b4ca0f8268d6e87f8cdda8c9e88b25c43efcd5f3074',
54
+ },
55
+ {
56
+ name: 'Cetus USDC/wUSDT',
57
+ configId: '0xc64d5b0102b85b823d8f8ae5685ea1c153d1c18dcf13a4719798fdf591a9a1b9',
58
+ poolObjectId: '0x6bd72983b0b5a77774af8c77567bb593b418ae3cd750a5926814fcd236409aaa',
59
+ lendFacilCap: '0x085807ffff95935d311a714cdffa0d10ec7dc80e6bd393cee2b644f6aece5b01',
60
+ supplyPoolXInfo: '0x3bcadd850b776542b49be5d68d2e62b63f3c7543695c55a973d3364501b5c26c',
61
+ supplyPoolYInfo: '0x372b6948ae06dacce75fdc3546865b2e777d4050114d93db0717b40cf677634c',
62
+ },
63
+ {
64
+ name: 'Cetus USDC/SUI',
65
+ configId: '0xd6a055c8143f2bb97fdcb34f91ac723708d71473e7dff670a9a2218cc91eab16',
66
+ poolObjectId: '0xb8d7d9e66a60c239e7a60110efcf8de6c705580ed924d0dde141f4a0e2c90105',
67
+ lendFacilCap: '0x590468991d9ed6993953e46dad98b9ec5b003ce99d213346b4349c12880547b2',
68
+ supplyPoolXInfo: '0x3bcadd850b776542b49be5d68d2e62b63f3c7543695c55a973d3364501b5c26c',
69
+ supplyPoolYInfo: '0x1b4c4e0869ab3771a0901a538c0dbf536ca72e1525fd66e6c5a197623cd55cc8',
70
+ },
36
71
  ];
37
72
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/constants.ts"],"names":[],"mappings":";;;AAAA,+DAAkE;AAErD,QAAA,UAAU,GAAG,KAAK,CAAC;AACnB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,4CAA4C;IACnD,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE,qCAAqC;IAC9C,WAAW,EAAE,aAAa,EAAE,sCAAsC;CACnE,CAAC;AAEW,QAAA,UAAU,GAAG;IACxB;QACE,OAAO;QACP,EAAE,EAAE,oEAAoE;QACxE,KAAK,EACH,gFAAgF;QAClF,MAAM,EACJ,uFAAuF;QACzF,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,OAAO;QACP,EAAE,EAAE,oEAAoE;QACxE,KAAK,EACH,gFAAgF;QAClF,MAAM,EACJ,wFAAwF;QAC1F,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,MAAM;QACN,EAAE,EAAE,oEAAoE;QACxE,KAAK,EAAE,2BAAU,CAAC,MAAM,CAAC,OAAO;QAChC,MAAM,EACJ,gFAAgF;QAClF,QAAQ,EAAE,CAAC;KACZ;CACF,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/constants.ts"],"names":[],"mappings":";;;AAAA,+DAAkE;AAClE,yDAAwD;AAE3C,QAAA,UAAU,GAAG,KAAK,CAAC;AACnB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,4CAA4C;IACnD,OAAO,EAAE,qBAAqB;IAC9B,OAAO,EAAE,qCAAqC;IAC9C,WAAW,EAAE,aAAa,EAAE,sCAAsC;CACnE,CAAC;AAEW,QAAA,UAAU,GAAG;IACxB;QACE,QAAQ;QACR,EAAE,EAAE,oEAAoE;QACxE,KAAK,EACH,gFAAgF;QAClF,MAAM,EACJ,uFAAuF;QACzF,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,OAAO;QACP,EAAE,EAAE,oEAAoE;QACxE,KAAK,EACH,gFAAgF;QAClF,MAAM,EACJ,wFAAwF;QAC1F,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,MAAM;QACN,EAAE,EAAE,oEAAoE;QACxE,KAAK,EAAE,2BAAU,CAAC,MAAM,CAAC,OAAO;QAChC,MAAM,EACJ,gFAAgF;QAClF,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,OAAO;QACP,EAAE,EAAE,oEAAoE;QACxE,KAAK,EAAE,uBAAW;QAClB,MAAM,EACJ,kFAAkF;QACpF,QAAQ,EAAE,CAAC;KACZ;CACF,CAAC;AAEW,QAAA,mBAAmB,GAAG,cAAc,CAAC;AACrC,QAAA,MAAM,GAAG;IACpB;QACE,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EACN,oEAAoE;QACtE,YAAY,EACV,oEAAoE;QACtE,YAAY,EACV,oEAAoE;QACtE,eAAe,EACb,oEAAoE;QACtE,eAAe,EACb,oEAAoE;KACvE;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,QAAQ,EACN,oEAAoE;QACtE,YAAY,EACV,oEAAoE;QACtE,YAAY,EACV,oEAAoE;QACtE,eAAe,EACb,oEAAoE;QACtE,eAAe,EACb,oEAAoE;KACvE;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EACN,oEAAoE;QACtE,YAAY,EACV,oEAAoE;QACtE,YAAY,EACV,oEAAoE;QACtE,eAAe,EACb,oEAAoE;QACtE,eAAe,EACb,oEAAoE;KACvE;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { SupplyPool } from './types';
3
+ import { ObjectResponse } from '../../utils/sui/types';
4
+ export declare const calcDebtByShares: (lendFacilCap: string, supplyPool: ObjectResponse<SupplyPool>, debtShares: number) => 0 | BigNumber;
5
+ export declare const calcEquityValues: (debtX: BigNumber, debtY: BigNumber, s: BigNumber, a: BigNumber, poolPrice: BigNumber) => {
6
+ x: BigNumber;
7
+ y: BigNumber;
8
+ };
@@ -0,0 +1,49 @@
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.calcEquityValues = exports.calcDebtByShares = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const calcDebtByShares = (lendFacilCap, supplyPool, debtShares) => {
9
+ var _a, _b;
10
+ const lendFacilInfo = (_b = (_a = supplyPool.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.debt_info.fields.contents.find((di) => di.fields.key === lendFacilCap);
11
+ if (!lendFacilInfo)
12
+ return 0;
13
+ const debtRegistry = lendFacilInfo.fields.value.fields.debt_registry;
14
+ if (!debtRegistry || debtRegistry.fields.supply_x64 === '0')
15
+ return 0;
16
+ const updatedLiabilityX64 = BigInt(lendFacilInfo.fields.value.fields.debt_registry.fields.liability_value_x64);
17
+ return new bignumber_js_1.default(updatedLiabilityX64.toString())
18
+ .multipliedBy(debtShares.toString())
19
+ .div(debtRegistry.fields.supply_x64)
20
+ .dividedBy(Math.pow(2, 64));
21
+ };
22
+ exports.calcDebtByShares = calcDebtByShares;
23
+ const calcEquityValues = (debtX, debtY, s, a, poolPrice) => {
24
+ if (s.lt(debtX) && a.lt(debtY))
25
+ return {
26
+ x: new bignumber_js_1.default(0),
27
+ y: new bignumber_js_1.default(0),
28
+ };
29
+ if (s.gte(debtX) && a.gte(debtY))
30
+ return {
31
+ x: s.minus(debtX),
32
+ y: a.minus(debtY),
33
+ };
34
+ if (a.lt(debtY)) {
35
+ const l = debtY.minus(a).div(poolPrice);
36
+ return {
37
+ x: s.minus(debtX).minus(l),
38
+ y: new bignumber_js_1.default(0),
39
+ };
40
+ }
41
+ const l = debtX.minus(s).multipliedBy(poolPrice);
42
+ const d = a.minus(debtY).minus(l);
43
+ return {
44
+ x: new bignumber_js_1.default(0),
45
+ y: d,
46
+ };
47
+ };
48
+ exports.calcEquityValues = calcEquityValues;
49
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAI9B,MAAM,gBAAgB,GAAG,CAC9B,YAAoB,EACpB,UAAsC,EACtC,UAAkB,EAClB,EAAE;;IACF,MAAM,aAAa,GACjB,MAAA,MAAA,UAAU,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAC7D,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,KAAK,YAAY,CACvC,CAAC;IACJ,IAAI,CAAC,aAAa;QAAE,OAAO,CAAC,CAAC;IAC7B,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;IACrE,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,CAAC,UAAU,KAAK,GAAG;QAAE,OAAO,CAAC,CAAC;IAEtE,MAAM,mBAAmB,GAAG,MAAM,CAChC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,mBAAmB,CAC3E,CAAC;IAEF,OAAO,IAAI,sBAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC;SACjD,YAAY,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;SACnC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC;SACnC,SAAS,CAAC,SAAA,CAAC,EAAI,EAAE,C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C;AAjCW,QAAA,gBAAgB,oBAiC3B"}
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchers = exports.jobs = exports.platforms = void 0;
7
7
  const constants_1 = require("./constants");
8
8
  const vaultsJob_1 = __importDefault(require("./vaultsJob"));
9
+ const lpVaultsFetcher_1 = __importDefault(require("./lpVaultsFetcher"));
10
+ const supplyPoolsJob_1 = __importDefault(require("./supplyPoolsJob"));
9
11
  exports.platforms = [constants_1.platform];
10
- exports.jobs = [vaultsJob_1.default];
11
- exports.fetchers = [];
12
+ exports.jobs = [vaultsJob_1.default, supplyPoolsJob_1.default];
13
+ exports.fetchers = [lpVaultsFetcher_1.default];
12
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,4DAAoC;AAEvB,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,mBAAS,CAAC,CAAC;AAC1B,QAAA,QAAQ,GAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,4DAAoC;AACpC,wEAAgD;AAChD,sEAA8C;AAEjC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,mBAAS,EAAE,wBAAc,CAAC,CAAC;AAC1C,QAAA,QAAQ,GAAc,CAAC,yBAAe,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,112 @@
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 getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
20
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
21
+ const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
22
+ const constants_2 = require("../cetus/constants");
23
+ const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
24
+ const bitsToNumber_1 = require("../../utils/sui/bitsToNumber");
25
+ const helpers_1 = require("./helpers");
26
+ const getPools_1 = require("../cetus/getPools");
27
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
28
+ var _a, _b, _c, _d, _e, _f;
29
+ const client = (0, clients_1.getClientSui)();
30
+ const positionCaps = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
31
+ filter: {
32
+ StructType: '0x51e0ccce48f0763f98f1cb4856847c2e1531adacada99cdd7626ab999db57523::position_core_clmm::PositionCap',
33
+ },
34
+ });
35
+ if (positionCaps.length === 0)
36
+ return [];
37
+ const positions = yield (0, multiGetObjects_1.multiGetObjects)(client, positionCaps
38
+ .map((p) => { var _a, _b; return (_b = (_a = p.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.position_id; })
39
+ .filter((s) => s !== undefined));
40
+ if (positionCaps.length === 0)
41
+ return [];
42
+ const [pools, configs, supplyPools] = yield Promise.all([
43
+ (0, getPools_1.getPools)(positions
44
+ .map((position) => { var _a, _b; return (_b = (_a = position.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.lp_position.fields.pool; })
45
+ .filter((s) => s !== null), cache).then((res) => res.filter((p) => p !== null)),
46
+ (0, multiGetObjects_1.multiGetObjects)(client, positions
47
+ .map((p) => { var _a, _b; return (_b = (_a = p.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.config_id; })
48
+ .filter((s) => s !== null)),
49
+ cache.getItem(constants_1.supplyPoolsCacheKey, {
50
+ prefix: constants_1.platformId,
51
+ networkId: portfolio_core_1.NetworkId.sui,
52
+ }),
53
+ ]);
54
+ if (!supplyPools)
55
+ return [];
56
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
57
+ for (const position of positions) {
58
+ const i = positions.indexOf(position);
59
+ if (!((_a = position.data) === null || _a === void 0 ? void 0 : _a.content))
60
+ continue;
61
+ const parsedTypeString = (0, portfolio_core_1.parseTypeString)(position.data.type);
62
+ const isCetus = parsedTypeString.keys && parsedTypeString.keys[2].type === constants_2.clmmType;
63
+ if (!isCetus)
64
+ continue;
65
+ const pool = pools[i];
66
+ if (!pool)
67
+ continue;
68
+ const config = configs[i];
69
+ if (!((_b = config === null || config === void 0 ? void 0 : config.data) === null || _b === void 0 ? void 0 : _b.content))
70
+ continue;
71
+ const vaultInfo = constants_1.vaults.find((v) => { var _a, _b; return v.poolObjectId === ((_b = (_a = config.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.pool_object_id); });
72
+ if (!vaultInfo)
73
+ continue;
74
+ const supplyPoolX = supplyPools.find((s) => { var _a, _b; return ((_b = (_a = s.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.id.id) === vaultInfo.supplyPoolXInfo; });
75
+ const supplyPoolY = supplyPools.find((s) => { var _a, _b; return ((_b = (_a = s.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.id.id) === vaultInfo.supplyPoolYInfo; });
76
+ if (!supplyPoolX || !supplyPoolY)
77
+ continue;
78
+ const element = elementRegistry.addElementLiquidity({
79
+ label: 'Leverage',
80
+ name: vaultInfo.name,
81
+ });
82
+ const liquidity = element.addLiquidity();
83
+ const tickLowerIndex = (0, bitsToNumber_1.bitsToNumber)(position.data.content.fields.lp_position.fields.tick_lower_index.fields
84
+ .bits);
85
+ const tickUpperIndex = (0, bitsToNumber_1.bitsToNumber)(position.data.content.fields.lp_position.fields.tick_upper_index.fields
86
+ .bits);
87
+ const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(position.data.content.fields.lp_position.fields.liquidity), pool.current_tick_index, tickLowerIndex, tickUpperIndex, false);
88
+ const debtX = new bignumber_js_1.default((0, helpers_1.calcDebtByShares)(config.data.content.fields.lend_facil_cap.fields.id.id, supplyPoolX, Number(((_d = (_c = position.data.content) === null || _c === void 0 ? void 0 : _c.fields.debt_bag.fields.inner.fields.infos.find((db) => `0x${db.fields.asset_type.fields.name}` === pool.coinTypeA)) === null || _d === void 0 ? void 0 : _d.fields.amount) || 0)));
89
+ const debtY = new bignumber_js_1.default((0, helpers_1.calcDebtByShares)(config.data.content.fields.lend_facil_cap.fields.id.id, supplyPoolY, Number(((_f = (_e = position.data.content) === null || _e === void 0 ? void 0 : _e.fields.debt_bag.fields.inner.fields.infos.find((db) => `0x${db.fields.asset_type.fields.name}` === pool.coinTypeB)) === null || _f === void 0 ? void 0 : _f.fields.amount) || 0)));
90
+ const { x, y } = (0, helpers_1.calcEquityValues)(debtX, debtY, tokenAmountA.plus(position.data.content.fields.col_x), tokenAmountB.plus(position.data.content.fields.col_y), new bignumber_js_1.default(pool.current_sqrt_price)
91
+ .pow(2)
92
+ .div(new bignumber_js_1.default(2).pow(128)));
93
+ liquidity.addAsset({
94
+ address: pool.coinTypeA,
95
+ amount: x,
96
+ });
97
+ liquidity.addAsset({
98
+ address: pool.coinTypeB,
99
+ amount: y,
100
+ });
101
+ if (tokenAmountA.isZero() || tokenAmountB.isZero())
102
+ element.addTag('Out Of Range');
103
+ }
104
+ return elementRegistry.getElements(cache);
105
+ });
106
+ const fetcher = {
107
+ id: `${constants_1.platformId}-lpvaults`,
108
+ networkId: portfolio_core_1.NetworkId.sui,
109
+ executor,
110
+ };
111
+ exports.default = fetcher;
112
+ //# sourceMappingURL=lpVaultsFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lpVaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/lpVaultsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAwE;AACxE,gEAAqC;AAGrC,2CAAsE;AACtE,iDAAmD;AACnD,qEAAkE;AAClE,gFAA6E;AAC7E,qEAAkE;AAElE,kDAA8C;AAE9C,wFAAyF;AACzF,+DAA4D;AAC5D,uCAA+D;AAE/D,gDAA6C;AAE7C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,YAAY,GAAG,MAAM,IAAA,iCAAe,EAAc,MAAM,EAAE,KAAK,EAAE;QACrE,MAAM,EAAE;YACN,UAAU,EACR,qGAAqG;SACxG;KACF,CAAC,CAAC;IACH,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEzC,MAAM,SAAS,GAAG,MAAM,IAAA,iCAAe,EACrC,MAAM,EACN,YAAY;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,eAAC,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AC;QAEF,SAAS,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,CAAC;SACV,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,CAAC;SACV,CAAC,CAAC;QAEH,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,YAAY,CAAC,MAAM,EAAE;YAChD,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Job } from '../../Job';
2
+ declare const job: Job;
3
+ export default job;
@@ -0,0 +1,35 @@
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 constants_1 = require("./constants");
14
+ const clients_1 = require("../../utils/clients");
15
+ const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
16
+ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const client = (0, clients_1.getClientSui)();
18
+ const supplyPools = new Set();
19
+ constants_1.vaults.forEach((v) => {
20
+ supplyPools.add(v.supplyPoolXInfo);
21
+ supplyPools.add(v.supplyPoolYInfo);
22
+ });
23
+ const objects = yield (0, multiGetObjects_1.multiGetObjects)(client, [...supplyPools]);
24
+ yield cache.setItem(constants_1.supplyPoolsCacheKey, objects, {
25
+ networkId: portfolio_core_1.NetworkId.sui,
26
+ prefix: constants_1.platformId,
27
+ });
28
+ });
29
+ const job = {
30
+ id: `${constants_1.platformId}-supply-pools`,
31
+ executor,
32
+ label: 'normal',
33
+ };
34
+ exports.default = job;
35
+ //# sourceMappingURL=supplyPoolsJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supplyPoolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/supplyPoolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAsE;AACtE,iDAAmD;AACnD,qEAAkE;AAGlE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;IAC3C,kBAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACnB,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QACnC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EAAa,MAAM,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAE5E,MAAM,KAAK,CAAC,OAAO,CAAC,+BAAmB,EAAE,OAAO,EAAE;QAChD,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,MAAM,EAAE,sBAAU;KACnB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,eAAe;IAChC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { ID } from '../../utils/sui/structs/id';
2
+ import { LpPosition } from '../cetus/types';
2
3
  export interface Vault {
3
4
  free_balance: string;
4
5
  id: ID;
@@ -52,3 +53,109 @@ export interface Vault {
52
53
  version: string;
53
54
  withdraw_ticket_issued: boolean;
54
55
  }
56
+ export type PositionCap = {
57
+ id: ID;
58
+ position_id: string;
59
+ };
60
+ export type Position = {
61
+ id: ID;
62
+ col_x: string;
63
+ col_y: string;
64
+ config_id: string;
65
+ debt_bag: {
66
+ type: string;
67
+ fields: {
68
+ facil_id: string;
69
+ id: ID;
70
+ inner: {
71
+ type: string;
72
+ fields: {
73
+ id: ID;
74
+ bag: {
75
+ fields: {
76
+ id: ID;
77
+ size: string;
78
+ };
79
+ type: string;
80
+ };
81
+ infos: {
82
+ type: string;
83
+ fields: {
84
+ amount: string;
85
+ asset_type: {
86
+ type: string;
87
+ fields: {
88
+ name: string;
89
+ };
90
+ };
91
+ share_type: {
92
+ type: string;
93
+ fields: {
94
+ name: string;
95
+ };
96
+ };
97
+ };
98
+ }[];
99
+ };
100
+ };
101
+ };
102
+ };
103
+ lp_position: LpPosition;
104
+ ticket_active: boolean;
105
+ version: number;
106
+ };
107
+ export type PositionConfig = {
108
+ allow_new_positions: boolean;
109
+ base_deleverage_factor_bps: number;
110
+ base_liq_factor_bps: number;
111
+ current_global_l: string;
112
+ deleverage_margin_bps: number;
113
+ id: ID;
114
+ lend_facil_cap: {
115
+ type: string;
116
+ fields: {
117
+ id: ID;
118
+ };
119
+ };
120
+ liq_bonus_bps: number;
121
+ liq_fee_bps: number;
122
+ liq_margin_bps: number;
123
+ max_global_l: string;
124
+ max_position_l: string;
125
+ min_init_margin_bps: number;
126
+ min_liq_start_price_delta_bps: number;
127
+ pool_object_id: string;
128
+ position_creation_fee_sui: string;
129
+ rebalance_fee_bps: number;
130
+ version: number;
131
+ };
132
+ export type SupplyPool = {
133
+ available_balance: string;
134
+ id: ID;
135
+ debt_info: {
136
+ type: string;
137
+ fields: {
138
+ contents: {
139
+ fields: {
140
+ key: string;
141
+ value: {
142
+ type: string;
143
+ fields: {
144
+ debt_registry: {
145
+ type: string;
146
+ fields: {
147
+ liability_value_x64: string;
148
+ supply_x64: string;
149
+ };
150
+ };
151
+ max_liability_outstanding: string;
152
+ max_utilization_bps: string;
153
+ };
154
+ };
155
+ };
156
+ type: string;
157
+ }[];
158
+ };
159
+ };
160
+ last_update_ts_sec: string;
161
+ };
@@ -17,7 +17,7 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
17
17
  const constants_1 = require("./constants");
18
18
  const clients_1 = require("../../utils/clients");
19
19
  const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
20
- const getLpTokenSourceRawOld_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRawOld"));
20
+ const getLpTokenSourceRaw_1 = require("../../utils/misc/getLpTokenSourceRaw");
21
21
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
22
22
  var _a, _b, _c;
23
23
  const client = (0, clients_1.getClientSui)();
@@ -36,19 +36,26 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
36
36
  (_c = (_b = object.data) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.fields.strategies.fields.contents.forEach((c) => {
37
37
  amount = amount.plus(c.fields.value.fields.borrowed);
38
38
  });
39
- const lpSource = (0, getLpTokenSourceRawOld_1.default)(portfolio_core_1.NetworkId.sui, constants_1.platformId, constants_1.platformId, {
40
- address: vaultInfo.lpType,
41
- decimals: vaultInfo.decimals,
42
- supplyRaw: new bignumber_js_1.default(vault.lp_treasury.fields.total_supply.fields.value),
43
- }, [
44
- {
45
- address: vaultInfo.tType,
39
+ const lpSource = (0, getLpTokenSourceRaw_1.getLpTokenSourceRaw)({
40
+ networkId: portfolio_core_1.NetworkId.sui,
41
+ sourceId: constants_1.platformId,
42
+ platformId: constants_1.platformId,
43
+ lpDetails: {
44
+ address: vaultInfo.lpType,
46
45
  decimals: vaultInfo.decimals,
47
- reserveAmountRaw: amount,
48
- price: tokenPrice.price,
46
+ supplyRaw: new bignumber_js_1.default(vault.lp_treasury.fields.total_supply.fields.value),
49
47
  },
50
- ], 'Vaults');
51
- yield cache.setTokenPriceSource(lpSource);
48
+ poolUnderlyingsRaw: [
49
+ {
50
+ address: vaultInfo.tType,
51
+ decimals: vaultInfo.decimals,
52
+ reserveAmountRaw: amount,
53
+ tokenPrice,
54
+ },
55
+ ],
56
+ elementName: 'Vaults',
57
+ });
58
+ yield cache.setTokenPriceSources(lpSource);
52
59
  }
53
60
  });
54
61
  const job = {
@@ -1 +1 @@
1
- {"version":3,"file":"vaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kai/vaultsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAA2E;AAG3E,2CAAqD;AACrD,iDAAmD;AACnD,qEAAkE;AAElE,qGAA6E;AAE7E,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EACnC,MAAM,EACN,sBAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5B,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACjD,sBAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAC9B,0BAAS,CAAC,GAAG,CACd,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE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AU,SAAS;IAC1B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import { Platform } from '@sonarwatch/portfolio-core';
3
+ export declare const platformId = "metaplex";
4
+ export declare const platform: Platform;
5
+ export declare const amountPerMasterEdition = 0.00232464;
6
+ export declare const amountPerBasicEdition = 0.00188616;
7
+ export declare const metadatProgram: PublicKey;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.metadatProgram = exports.amountPerBasicEdition = exports.amountPerMasterEdition = exports.platform = exports.platformId = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ exports.platformId = 'metaplex';
6
+ exports.platform = {
7
+ id: exports.platformId,
8
+ name: 'Metaplex',
9
+ image: 'https://sonar.watch/img/platforms/metaplex.webp',
10
+ website: 'https://resize.metaplex.com',
11
+ twitter: 'https://x.com/metaplex',
12
+ // defiLlamaId: 'metaplex', // from https://defillama.com/docs/api
13
+ };
14
+ exports.amountPerMasterEdition = 0.00232464;
15
+ exports.amountPerBasicEdition = 0.00188616;
16
+ exports.metadatProgram = new web3_js_1.PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');
17
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/metaplex/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,UAAU,CAAC;AACxB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,iDAAiD;IACxD,OAAO,EAAE,6BAA6B;IACtC,OAAO,EAAE,wBAAwB;IACjC,kEAAkE;CACnE,CAAC;AAEW,QAAA,sBAAsB,GAAG,UAAU,CAAC;AACpC,QAAA,qBAAqB,GAAG,UAAU,CAAC;AACnC,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ export declare function getEditionPubkeyOfNft(mint: PublicKey): PublicKey;
3
+ export declare function getMetadataPubkey(mint: PublicKey): PublicKey;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMetadataPubkey = exports.getEditionPubkeyOfNft = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const constants_1 = require("./constants");
6
+ function getEditionPubkeyOfNft(mint) {
7
+ return web3_js_1.PublicKey.findProgramAddressSync([
8
+ Buffer.from('metadata'),
9
+ constants_1.metadatProgram.toBuffer(),
10
+ mint.toBuffer(),
11
+ Buffer.from('edition'),
12
+ ], constants_1.metadatProgram)[0];
13
+ }
14
+ exports.getEditionPubkeyOfNft = getEditionPubkeyOfNft;
15
+ function getMetadataPubkey(mint) {
16
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('metadata'), constants_1.metadatProgram.toBuffer(), mint.toBuffer()], constants_1.metadatProgram)[0];
17
+ }
18
+ exports.getMetadataPubkey = getMetadataPubkey;
19
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/metaplex/helpers.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,2CAA6C;AAE7C,SAAgB,qBAAqB,CAAC,IAAe;IACnD,OAAO,mBAAS,CAAC,sBAAsB,CACrC;QACE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QACvB,0BAAc,CAAC,QAAQ,EAAE;QACzB,IAAI,CAAC,QAAQ,EAAE;QACf,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;KACvB,EACD,0BAAc,CACf,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AAVD,sDAUC;AAED,SAAgB,iBAAiB,CAAC,IAAe;IAC/C,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,0BAAc,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EACrE,0BAAc,CACf,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AALD,8CAKC"}
@@ -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,12 @@
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 resizableNftFetcher_1 = __importDefault(require("./resizableNftFetcher"));
9
+ exports.platforms = [constants_1.platform];
10
+ exports.jobs = [];
11
+ exports.fetchers = [resizableNftFetcher_1.default];
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/metaplex/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,gFAAsD;AAEzC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,CAAC,6BAAiB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;