@sonarwatch/portfolio-plugins 0.11.140 → 0.11.142

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.11.142](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.141...plugins-0.11.142) (2024-03-22)
6
+
7
+
8
+
9
+ ## [0.11.141](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.140...plugins-0.11.141) (2024-03-21)
10
+
11
+
12
+
5
13
  ## [0.11.140](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.139...plugins-0.11.140) (2024-03-21)
6
14
 
7
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonarwatch/portfolio-plugins",
3
- "version": "0.11.140",
3
+ "version": "0.11.142",
4
4
  "type": "commonjs",
5
5
  "generators": "./generators.json",
6
6
  "dependencies": {
@@ -41,7 +41,7 @@
41
41
  "web3-v1": "npm:web3@^1.5.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "@sonarwatch/portfolio-core": "0.11.140"
44
+ "@sonarwatch/portfolio-core": "0.11.142"
45
45
  },
46
46
  "main": "./src/index.js",
47
47
  "types": "./src/index.d.ts"
@@ -17,12 +17,11 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
17
17
  const aptos_1 = require("../../utils/aptos");
18
18
  const clients_1 = require("../../utils/clients");
19
19
  const constants_1 = require("./constants");
20
- const getTokensPricesMap_1 = __importDefault(require("../../utils/misc/getTokensPricesMap"));
21
20
  const getDecimalsForToken_1 = require("../../utils/misc/getDecimalsForToken");
22
21
  const getLpUnderlyingTokenSource_1 = __importDefault(require("../../utils/misc/getLpUnderlyingTokenSource"));
23
22
  const getLpTokenSourceRaw_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRaw"));
24
23
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
25
- var _a, _b, _c;
24
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
26
25
  const client = (0, clients_1.getClientAptos)();
27
26
  const resources = yield (0, aptos_1.getAccountResources)(client, constants_1.programAddress);
28
27
  if (!resources)
@@ -31,51 +30,52 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
31
30
  resources.forEach((resource) => {
32
31
  resourcesByType.set(resource.type, resource);
33
32
  });
34
- const tokenPriceById = yield (0, getTokensPricesMap_1.default)(resources
33
+ const tokenPrices = yield cache.getTokenPricesAsMap(resources
35
34
  .map((resource) => {
36
35
  const { keys } = (0, aptos_1.parseTypeString)(resource.type);
37
36
  return keys ? keys.map((key) => key.type) : [];
38
37
  })
39
- .flat(), portfolio_core_1.NetworkId.aptos, cache);
38
+ .flat(), portfolio_core_1.NetworkId.aptos);
39
+ const lpSources = [];
40
40
  for (let i = 0; i < resources.length; i++) {
41
41
  const resource = resources[i];
42
42
  if (!resource.type.startsWith(constants_1.lpCoinInfoTypePrefix))
43
43
  continue;
44
- const lpType = (0, aptos_1.getNestedType)(resource.type);
44
+ const lpType = (_b = (_a = (0, aptos_1.parseTypeString)(resource.type).keys) === null || _a === void 0 ? void 0 : _a.at(0)) === null || _b === void 0 ? void 0 : _b.type;
45
+ if (!lpType)
46
+ continue;
45
47
  const lpInfoData = resource.data;
46
- const lpSupplyString = (_c = (_b = (_a = lpInfoData.supply) === null || _a === void 0 ? void 0 : _a.vec[0]) === null || _b === void 0 ? void 0 : _b.integer.vec[0]) === null || _c === void 0 ? void 0 : _c.value;
48
+ const lpSupplyString = (_e = (_d = (_c = lpInfoData.supply) === null || _c === void 0 ? void 0 : _c.vec[0]) === null || _d === void 0 ? void 0 : _d.integer.vec[0]) === null || _e === void 0 ? void 0 : _e.value;
47
49
  if (!lpSupplyString)
48
50
  continue;
49
51
  const lpDecimals = lpInfoData.decimals;
50
52
  const lpSupply = new bignumber_js_1.default(lpSupplyString);
51
53
  if (lpSupply.isZero())
52
54
  continue;
53
- const poolId = (0, aptos_1.getNestedType)(lpType);
54
- const splits = poolId.split(', ');
55
- const typeX = splits.at(0);
56
- const typeY = splits.at(1);
55
+ const parsedLpType = (0, aptos_1.parseTypeString)(lpType);
56
+ const poolId = (_f = parsedLpType.keys) === null || _f === void 0 ? void 0 : _f.map((t) => t.type).join(', ');
57
+ const typeX = (_h = (_g = parsedLpType.keys) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.type;
58
+ const typeY = (_k = (_j = parsedLpType.keys) === null || _j === void 0 ? void 0 : _j.at(1)) === null || _k === void 0 ? void 0 : _k.type;
59
+ if (!typeX || !typeY || !poolId)
60
+ continue;
57
61
  const poolResource = resourcesByType.get(`${constants_1.programAddress}::amm::Pool<${poolId}>`);
58
62
  if (!poolResource)
59
63
  throw new Error(`Failed to get poolResource: ${lpType}`);
60
- if (!typeX)
61
- throw new Error(`Failed to get typeX: ${lpType}`);
62
- if (!typeY)
63
- throw new Error(`Failed to get typeY: ${lpType}`);
64
64
  const tokenPairData = poolResource.data;
65
65
  const [tokenPriceX, tokenPriceY] = [
66
- tokenPriceById.get(typeX),
67
- tokenPriceById.get(typeY),
66
+ tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(typeX, portfolio_core_1.NetworkId.aptos)),
67
+ tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(typeY, portfolio_core_1.NetworkId.aptos)),
68
68
  ];
69
69
  const [decimalsX, decimalsY] = yield Promise.all([
70
70
  (0, getDecimalsForToken_1.getDecimalsForToken)(cache, typeX, portfolio_core_1.NetworkId.aptos),
71
71
  (0, getDecimalsForToken_1.getDecimalsForToken)(cache, typeY, portfolio_core_1.NetworkId.aptos),
72
72
  ]);
73
+ if (!decimalsX || !decimalsY)
74
+ continue;
73
75
  const [reserveAmountRawX, reserveAmountRawY] = [
74
76
  new bignumber_js_1.default(tokenPairData.x_reserve.value),
75
77
  new bignumber_js_1.default(tokenPairData.y_reserve.value),
76
78
  ];
77
- if (!decimalsX || !decimalsY)
78
- continue;
79
79
  const underlyingSource = (0, getLpUnderlyingTokenSource_1.default)(lpType, portfolio_core_1.NetworkId.aptos, {
80
80
  address: typeX,
81
81
  decimals: decimalsX,
@@ -88,7 +88,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
88
88
  tokenPrice: tokenPriceY,
89
89
  });
90
90
  if (underlyingSource)
91
- yield cache.setTokenPriceSource(underlyingSource);
91
+ lpSources.push(underlyingSource);
92
92
  if (!tokenPriceX || !tokenPriceY)
93
93
  continue;
94
94
  const lpSource = (0, getLpTokenSourceRaw_1.default)(portfolio_core_1.NetworkId.aptos, lpType, constants_1.platformId, {
@@ -109,8 +109,9 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
109
109
  reserveAmountRaw: reserveAmountRawY,
110
110
  },
111
111
  ], '');
112
- yield cache.setTokenPriceSource(lpSource);
112
+ lpSources.push(lpSource);
113
113
  }
114
+ yield cache.setTokenPriceSources(lpSources);
114
115
  });
115
116
  const job = {
116
117
  id: `${constants_1.platformId}-aptos-lp`,
@@ -1 +1 @@
1
- {"version":3,"file":"aptosLpJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/auxexchange/aptosLpJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAAuD;AAGvD,6CAM2B;AAC3B,iDAAqD;AACrD,2CAA+E;AAC/E,6FAAoE;AACpE,8EAA2E;AAC3E,6GAAqF;AACrF,+FAAuE;AAOvE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,MAAM,EAAE,0BAAc,CAAC,CAAC;IACpE,IAAI,CAAC,SAAS;QAAE,OAAO;IAEvB,MAAM,eAAe,GAAuC,IAAI,GAAG,EAAE,CAAC;IACtE,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,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YACnB,gBAAgB,EAAE,iBAAiB;YACnC,UAAU,EAAE,WAAW;SACxB,CACF,CAAC;QACF,IAAI,gBAAgB;YAAE,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAEvD,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW;YAAE,SAAS;QAC3C,MAAM,QAAQ,GAAG,IAAA,6BAAmB,EAClC,0BAAS,CAAC,KAAK,EACf,MAAM,EACN,sBAAU,EACV;YACE,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,QAAQ;SACpB,EACD;YACE;gBACE,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,gBAAgB,EAAE,iBAAiB;aACpC;YACD;gBACE,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,gBAAgB,EAAE,iBAAiB;aACpC;SACF,EACD,EAAE,CACH,CAAC;QACF,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -17,9 +17,7 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
17
17
  const aptos_1 = require("../../utils/aptos");
18
18
  const clients_1 = require("../../utils/clients");
19
19
  const constants_1 = require("./constants");
20
- const getTokensPricesMap_1 = __importDefault(require("../../utils/misc/getTokensPricesMap"));
21
20
  const getLpTokenSourceRaw_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRaw"));
22
- const runInBatch_1 = __importDefault(require("../../utils/misc/runInBatch"));
23
21
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
24
22
  var _a, _b, _c;
25
23
  const client = (0, clients_1.getClientAptos)();
@@ -59,8 +57,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
59
57
  }
60
58
  resourcesByType.set(resource.type, resource);
61
59
  });
62
- const tokenPriceById = yield (0, getTokensPricesMap_1.default)(tokens, portfolio_core_1.NetworkId.aptos, cache);
63
- // const decimalsByToken: Map<string, number> = new Map();
60
+ const tokenPrices = yield cache.getTokenPricesAsMap(tokens, portfolio_core_1.NetworkId.aptos);
64
61
  const sources = [];
65
62
  for (let i = 0; i < lpsCoinInfo.length; i++) {
66
63
  const lpInfoResource = lpsCoinInfo[i];
@@ -83,42 +80,13 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
83
80
  liquidityPoolData.coin_y_reserve.value === '0')
84
81
  continue;
85
82
  const [tokenPriceX, tokenPriceY] = [
86
- tokenPriceById.get(typeX),
87
- tokenPriceById.get(typeY),
83
+ tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(typeX, portfolio_core_1.NetworkId.aptos)),
84
+ tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(typeY, portfolio_core_1.NetworkId.aptos)),
88
85
  ];
89
86
  const [reserveAmountRawX, reserveAmountRawY] = [
90
87
  new bignumber_js_1.default(liquidityPoolData.coin_x_reserve.value),
91
88
  new bignumber_js_1.default(liquidityPoolData.coin_y_reserve.value),
92
89
  ];
93
- // const cachedDecimalsX = decimalsByToken.get(typeX);
94
- // const cachedDecimalsY = decimalsByToken.get(typeY);
95
- // const decimalsX =
96
- // cachedDecimalsX ||
97
- // (await getDecimalsForToken(cache, typeX, NetworkId.aptos));
98
- // const decimalsY =
99
- // cachedDecimalsY ||
100
- // (await getDecimalsForToken(cache, typeY, NetworkId.aptos));
101
- // if (!decimalsX || !decimalsY) continue;
102
- // if (!cachedDecimalsX) decimalsByToken.set(typeX, decimalsX);
103
- // if (!cachedDecimalsY) decimalsByToken.set(typeY, decimalsY);
104
- // const underlyingSource = getLpUnderlyingTokenSource(
105
- // lpType,
106
- // platformId,
107
- // NetworkId.aptos,
108
- // {
109
- // address: typeX,
110
- // decimals: decimalsX,
111
- // reserveAmountRaw: reserveAmountRawX,
112
- // tokenPrice: tokenPriceX,
113
- // },
114
- // {
115
- // address: typeY,
116
- // decimals: decimalsY,
117
- // reserveAmountRaw: reserveAmountRawY,
118
- // tokenPrice: tokenPriceY,
119
- // }
120
- // );
121
- // if (underlyingSource) sources.push(underlyingSource);
122
90
  if (!tokenPriceX || !tokenPriceY)
123
91
  continue;
124
92
  const lpSource = (0, getLpTokenSourceRaw_1.default)(portfolio_core_1.NetworkId.aptos, lpType, constants_1.platformId, {
@@ -141,7 +109,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
141
109
  ], undefined);
142
110
  sources.push(lpSource);
143
111
  }
144
- yield (0, runInBatch_1.default)(sources.map((tokenPriceSource) => () => cache.setTokenPriceSource(tokenPriceSource)), 50);
112
+ yield cache.setTokenPriceSources(sources);
145
113
  });
146
114
  const job = {
147
115
  id: `${constants_1.platformId}-aptos-lp`,
@@ -1 +1 @@
1
- {"version":3,"file":"aptosLpJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/liquidswap/aptosLpJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAAuD;AAOvD,6CAK2B;AAC3B,iDAAqD;AACrD,2CAKqB;AACrB,6FAAoE;AACpE,+FAAuE;AACvE,6EAAqD;AAErD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,MAAM,EAAE,0BAAc,CAAC,CAAC;IACpE,IAAI,CAAC,SAAS;QAAE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M,EACN,sBAAU,EACV;YACE,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,QAAQ;SACpB,EACD;YACE;gBACE,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,gBAAgB,EAAE,iBAAiB;aACpC;YACD;gBACE,OAAO,EAAE,WAAW,CAAC,OAAO;gBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,gBAAgB,EAAE,iBAAiB;aACpC;SACF,EACD,SAAS,CACV,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,IAAA,oBAAU,EACd,OAAO,CAAC,GAAG,CACT,CAAC,gBAAgB,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CACxE,EACD,EAAE,CACH,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"aptosLpJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/liquidswap/aptosLpJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAA2E;AAO3E,6CAK2B;AAC3B,iDAAqD;AACrD,2CAKqB;AACrB,+FAAuE;AAEvE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,MAAM,EAAE,0BAAc,CAAC,CAAC;IACpE,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BAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,gBAAgB,EAAE,iBAAiB;aACpC;SACF,EACD,SAAS,CACV,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -21,7 +21,7 @@ exports.fetchers = [
21
21
  (0, getPositionsV2Fetcher_1.default)(portfolio_core_1.NetworkId.ethereum, constants_1.platform.id, 'v2'),
22
22
  (0, getPositionsV2Fetcher_1.default)(portfolio_core_1.NetworkId.polygon, constants_1.platform.id, 'v2'),
23
23
  (0, getPositionsV2Fetcher_1.default)(portfolio_core_1.NetworkId.avalanche, constants_1.platform.id, 'v2'),
24
- (0, getPositionsV2Fetcher_1.default)(portfolio_core_1.NetworkId.bnb, constants_1.platform.id, 'v2'),
24
+ // getPositionsV2Fetcher(NetworkId.bnb, platform.id, 'v2'),
25
25
  // getUniV3PositionsFetcher(
26
26
  // {
27
27
  // networkId: NetworkId.ethereum,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/sushiswap/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAiE;AAGjE,2CAMqB;AACrB,4EAAoD;AACpD,gGAAwE;AACxE,gEAA6C;AAEhC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU;IACzB,kBAAa;IACb,IAAA,qBAAW,EAAC,0BAAS,CAAC,QAAQ,EAAE,oBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,8BAAkB,CAAC;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AAS,CAAC,OAAO,EAAE,oBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,6BAAiB,CAAC;IACpE,IAAA,qBAAW,EAAC,0BAAS,CAAC,SAAS,EAAE,oBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,+BAAmB,CAAC;IACxE,IAAA,qBAAW,EAAC,0BAAS,CAAC,GAAG,EAAE,oBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,yBAAa,CAAC;CAC7D,CAAC;AACW,QAAA,QAAQ,GAAc;IACjC,IAAA,+BAAqB,EAAC,0BAAS,CAAC,QAAQ,EAAE,oBAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAC5D,IAAA,+BAAqB,EAAC,0BAAS,CAAC,OAAO,EAAE,oBAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAC3D,IAAA,+BAAqB,EAAC,0BAAS,CAAC,SAAS,EAAE,oBAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAC7D,2DAA2D;IAC3D,4BAA4B;IAC5B,MAAM;IACN,qCAAqC;IACrC,6DAA6D;IAC7D,qEAAqE;IACrE,OAAO;IACP,iBAAiB;IACjB,SAAS;IACT,KAAK;CACN,CAAC"}
@@ -125,7 +125,7 @@ function checkComputeAndStoreTokensPrices(cache, source, networkId, tokenX, toke
125
125
  else {
126
126
  decimalsTokenY = yield (0, getDecimalsForToken_1.getDecimalsForToken)(cache, tokenY.mint, networkId);
127
127
  }
128
- if (decimalsTokenX === undefined || decimalsTokenY === undefined)
128
+ if (decimalsTokenX === null || decimalsTokenY === null)
129
129
  return undefined;
130
130
  const tokenXReserve = tokenX.rawReserve.dividedBy(Math.pow(10, decimalsTokenX));
131
131
  const tokenYReserve = tokenY.rawReserve.dividedBy(Math.pow(10, decimalsTokenY));
@@ -1 +1 @@
1
- {"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;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,CAAC,YAAY,CAAC,CAAC,CAAC,CACnD,CAAC;YAEF,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;YACxD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC;YAC/D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAE7C,MAAM,oBAAoB,GAAqB;gBAC7C,EAAE,EAAE,MAAM;gBACV,MAAM;gBACN,OAAO;gBACP,SAAS;gBACT,UAAU,EAAE,gCAAoB,CAAC,EAAE;gBACnC,QAAQ;gBACR,KAAK;gBACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,MAAM,KAAK,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;YACtD,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA;AArID,mDAqIC"}
1
+ {"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,wEAAgD;AAChD,+DAA4D;AAC5D,8DAAsE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,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;YACxD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC;YAC/D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAE7C,MAAM,oBAAoB,GAAqB;gBAC7C,EAAE,EAAE,MAAM;gBACV,MAAM;gBACN,OAAO;gBACP,SAAS;gBACT,UAAU,EAAE,gCAAoB,CAAC,EAAE;gBACnC,QAAQ;gBACR,KAAK;gBACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,MAAM,KAAK,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;YACtD,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA;AApID,mDAoIC"}
@@ -9,4 +9,4 @@ import { Cache } from '../../Cache';
9
9
  *
10
10
  * @returns The number of decimals or undefined if unsucessful request.
11
11
  */
12
- export declare function getDecimalsForToken(cache: Cache, address: string, networkId: NetworkIdType): Promise<number | undefined>;
12
+ export declare function getDecimalsForToken(cache: Cache, address: string, networkId: NetworkIdType): Promise<number | null>;
@@ -14,11 +14,12 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
14
14
  const web3_js_1 = require("@solana/web3.js");
15
15
  const core_1 = require("@sei-js/core");
16
16
  const clients_1 = require("../clients");
17
- const aptos_1 = require("../aptos");
18
17
  const constants_1 = require("../clients/constants");
19
18
  const sei_1 = require("../sei");
20
19
  const constants_2 = require("../../plugins/tokens/constants");
21
- const solMints = [portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeWrappedAddress];
20
+ const getDecimals_1 = require("../aptos/getDecimals");
21
+ const getDecimals_2 = require("../solana/getDecimals");
22
+ const getDecimals_3 = require("../sui/getDecimals");
22
23
  /**
23
24
  * Return the decimals of a token on any network using RPC calls or TokenList.
24
25
  *
@@ -39,24 +40,11 @@ function getDecimalsForToken(cache, address, networkId) {
39
40
  switch (networkId) {
40
41
  case 'aptos': {
41
42
  const client = (0, clients_1.getClientAptos)();
42
- const viewRes = (yield client.view({
43
- payload: {
44
- function: aptos_1.coinDecimals,
45
- typeArguments: [address],
46
- functionArguments: [],
47
- },
48
- }));
49
- if (viewRes.length !== 1)
50
- return undefined;
51
- return viewRes[0];
43
+ return (0, getDecimals_1.getDecimals)(client, address);
52
44
  }
53
45
  case 'solana': {
54
46
  const client = (0, clients_1.getClientSolana)();
55
- if (solMints.includes(address)) {
56
- return 9;
57
- }
58
- const res = yield client.getTokenSupply(new web3_js_1.PublicKey(address));
59
- return res.value.decimals ? res.value.decimals : undefined;
47
+ return (0, getDecimals_2.getDecimals)(client, new web3_js_1.PublicKey(address));
60
48
  }
61
49
  case 'sei': {
62
50
  if (address.startsWith('factory')) {
@@ -69,21 +57,18 @@ function getDecimalsForToken(cache, address, networkId) {
69
57
  }
70
58
  if (address.startsWith('ibc')) {
71
59
  // No solution yet for IBC tokens
72
- return undefined;
60
+ return null;
73
61
  }
74
62
  if (address.startsWith('sei')) {
75
63
  const client = yield (0, core_1.getCosmWasmClient)((0, constants_1.getUrlEndpoint)(portfolio_core_1.NetworkId.sei));
76
64
  const tokenInfo = (yield client.queryContractSmart(address, sei_1.tokenInfoQueryMsg));
77
- return tokenInfo.decimals || undefined;
65
+ return tokenInfo.decimals || null;
78
66
  }
79
- return undefined;
67
+ return null;
80
68
  }
81
69
  case 'sui': {
82
70
  const client = (0, clients_1.getClientSui)();
83
- const coinMetadata = yield client.getCoinMetadata({ coinType: address });
84
- if (coinMetadata)
85
- return coinMetadata.decimals;
86
- return undefined;
71
+ return (0, getDecimals_3.getDecimals)(client, address);
87
72
  }
88
73
  default:
89
74
  throw new Error('getDecimalsForToken : Network not supported');
@@ -1 +1 @@
1
- {"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAMoC;AACpC,6CAA4C;AAC5C,uCAAiD;AACjD,wCAKoB;AACpB,oCAAwC;AACxC,oDAAsD;AACtD,gCAAsD;AAEtD,8DAAyE;AAGzE,MAAM,QAAQ,GAAG,CAAC,oCAAmB,EAAE,2CAA0B,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACH,SAAsB,mBAAmB,CACvC,KAAY,EACZ,OAAe,EACf,SAAwB;;QAExB,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CACtC,IAAA,mCAAkB,EAAC,OAAO,EAAE,SAAS,CAAC,EACtC;YACE,MAAM,EAAE,mCAAuB;YAC/B,SAAS;SACV,CACF,CAAC;QACF,IAAI,YAAY;YAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;QAE/C,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,OAAO,CAAC,CAAC,CAAC;gBACb,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;gBAChC,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC;oBACjC,OAAO,EAAE;wBACP,QAAQ,EAAE,oBAAY;wBACtB,aAAa,EAAE,CAAC,OAA4C,CAAC;wBAC7D,iBAAiB,EAAE,EAAE;qBACtB;iBACF,CAAC,CAAa,CA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Ac,EAAC,0BAAS,CAAC,GAAG,CAAC,CAAC,CAAC;oBACtE,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAChD,OAAO,EACP,uBAAiB,CAClB,CAAc,CAAC;oBAChB,OAAO,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC;gBACzC,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,KAAK,KAAK,CAAC,CAAC,CAAC;gBACX,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;gBAC9B,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;gBACzE,IAAI,YAAY;oBAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;gBAC/C,OAAO,SAAS,CAAC;YACnB,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CAAA;AAnED,kDAmEC"}
1
+ {"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAC5C,uCAAiD;AACjD,wCAKoB;AACpB,oDAAsD;AACtD,gCAAsD;AAEtD,8DAAyE;AAEzE,sDAAuE;AACvE,uDAAyE;AACzE,oDAAmE;AAEnE;;;;;;;;GAQG;AACH,SAAsB,mBAAmB,CACvC,KAAY,EACZ,OAAe,EACf,SAAwB;;QAExB,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CACtC,IAAA,mCAAkB,EAAC,OAAO,EAAE,SAAS,CAAC,EACtC;YACE,MAAM,EAAE,mCAAuB;YAC/B,SAAS;SACV,CACF,CAAC;QACF,IAAI,YAAY;YAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;QAE/C,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,OA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,OAAO,IAAI,CAAC;YACd,CAAC;YACD,KAAK,KAAK,CAAC,CAAC,CAAC;gBACX,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;gBAC9B,OAAO,IAAA,yBAAc,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CAAA;AArDD,kDAqDC"}
@@ -1,3 +1,7 @@
1
1
  import { NetworkIdType, TokenPrice } from '@sonarwatch/portfolio-core';
2
2
  import { Cache } from '../../Cache';
3
+ /**
4
+ * @deprecated
5
+ * This function has been deprecated. Use the cache.getTokenPricesAsMap() instead.
6
+ */
3
7
  export default function getTokenPricesMap(tokensAddresses: string[], networkId: NetworkIdType, cache: Cache): Promise<Map<string, TokenPrice>>;
@@ -13,6 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const runInBatch_1 = __importDefault(require("./runInBatch"));
16
+ /**
17
+ * @deprecated
18
+ * This function has been deprecated. Use the cache.getTokenPricesAsMap() instead.
19
+ */
16
20
  function getTokenPricesMap(tokensAddresses, networkId, cache) {
17
21
  return __awaiter(this, void 0, void 0, function* () {
18
22
  const tokensGroups = [];
@@ -1 +1 @@
1
- {"version":3,"file":"getTokensPricesMap.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getTokensPricesMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,8DAAsC;AAEtC,SAA8B,iBAAiB,CAC7C,eAAyB,EACzB,SAAwB,EACxB,KAAY;;QAEZ,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;YACpD,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,cAAc,GAA4B,IAAI,GAAG,EAAE,CAAC;QAC1D,MAAM,GAAG,GAAG,MAAM,IAAA,oBAAU,EAC1B,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAC1E,CAAC;QACF,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAChB,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU;gBAAE,OAAO;YACpC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAAE,OAAO;YACrB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC7B,IAAI,UAAU;oBAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACrE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,cAAc,CAAC;IACxB,CAAC;CAAA;AArBD,oCAqBC"}
1
+ {"version":3,"file":"getTokensPricesMap.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getTokensPricesMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,8DAAsC;AAEtC;;;GAGG;AACH,SAA8B,iBAAiB,CAC7C,eAAyB,EACzB,SAAwB,EACxB,KAAY;;QAEZ,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;YACpD,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,cAAc,GAA4B,IAAI,GAAG,EAAE,CAAC;QAC1D,MAAM,GAAG,GAAG,MAAM,IAAA,oBAAU,EAC1B,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAC1E,CAAC;QACF,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAChB,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU;gBAAE,OAAO;YACpC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAAE,OAAO;YACrB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC7B,IAAI,UAAU;oBAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACrE,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,cAAc,CAAC;IACxB,CAAC;CAAA;AArBD,oCAqBC"}
@@ -10,21 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getMultipleDecimals = void 0;
13
- const portfolio_core_1 = require("@sonarwatch/portfolio-core");
14
- const structs_1 = require("./structs");
15
- const getParsedMultipleAccountsInfo_1 = require("./getParsedMultipleAccountsInfo");
16
- const solMints = [portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeWrappedAddress];
13
+ const getMultipleDecimalsAsMap_1 = require("./getMultipleDecimalsAsMap");
17
14
  function getMultipleDecimals(connection, mints) {
18
15
  return __awaiter(this, void 0, void 0, function* () {
19
- const mintAccounts = yield (0, getParsedMultipleAccountsInfo_1.getParsedMultipleAccountsInfo)(connection, structs_1.mintAccountStruct, mints.filter((m) => solMints.includes(m.toString())));
20
- const decimalsMap = new Map();
21
- decimalsMap.set(portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeDecimals);
22
- decimalsMap.set(portfolio_core_1.solanaNativeWrappedAddress, portfolio_core_1.solanaNativeDecimals);
23
- mintAccounts.forEach((acc) => {
24
- if (!acc)
25
- return;
26
- decimalsMap.set(acc.pubkey.toString(), acc.decimals);
27
- });
16
+ const decimalsMap = yield (0, getMultipleDecimalsAsMap_1.getMultipleDecimalsAsMap)(connection, mints);
28
17
  return mints.map((m) => decimalsMap.get(m.toString()) || null);
29
18
  });
30
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getMultipleDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+DAIoC;AAEpC,uCAA8C;AAC9C,mFAAgF;AAEhF,MAAM,QAAQ,GAAG,CAAC,oCAAmB,EAAE,2CAA0B,CAAC,CAAC;AAEnE,SAAsB,mBAAmB,CACvC,UAAwB,EACxB,KAAkB;;QAElB,MAAM,YAAY,GAAG,MAAM,IAAA,6DAA6B,EACtD,UAAU,EACV,2BAAiB,EACjB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CACrD,CAAC;QACF,MAAM,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;QACnD,WAAW,CAAC,GAAG,CAAC,oCAAmB,EAAE,qCAAoB,CAAC,CAAC;QAC3D,WAAW,CAAC,GAAG,CAAC,2CAA0B,EAAE,qCAAoB,CAAC,CAAC;QAClE,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC3B,IAAI,CAAC,GAAG;gBAAE,OAAO;YACjB,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;IACjE,CAAC;CAAA;AAjBD,kDAiBC"}
1
+ {"version":3,"file":"getMultipleDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yEAAsE;AAEtE,SAAsB,mBAAmB,CACvC,UAAwB,EACxB,KAAkB;;QAElB,MAAM,WAAW,GAAG,MAAM,IAAA,mDAAwB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACtE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;IACjE,CAAC;CAAA;AAND,kDAMC"}
@@ -0,0 +1,3 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import { SolanaClient } from '../clients/types';
3
+ export declare function getMultipleDecimalsAsMap(connection: SolanaClient, mints: PublicKey[]): Promise<Map<string, number>>;
@@ -0,0 +1,39 @@
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.getMultipleDecimalsAsMap = void 0;
13
+ const web3_js_1 = require("@solana/web3.js");
14
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
15
+ const structs_1 = require("./structs");
16
+ const getParsedMultipleAccountsInfo_1 = require("./getParsedMultipleAccountsInfo");
17
+ function getMultipleDecimalsAsMap(connection, mints) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const mintsSet = new Set(mints.map((m) => m.toString()));
20
+ const decimalsMap = new Map();
21
+ if (mintsSet.has(portfolio_core_1.solanaNativeAddress)) {
22
+ decimalsMap.set(portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeDecimals);
23
+ mintsSet.delete(portfolio_core_1.solanaNativeAddress);
24
+ }
25
+ if (mintsSet.has(portfolio_core_1.solanaNativeWrappedAddress)) {
26
+ decimalsMap.set(portfolio_core_1.solanaNativeWrappedAddress, portfolio_core_1.solanaNativeDecimals);
27
+ mintsSet.delete(portfolio_core_1.solanaNativeWrappedAddress);
28
+ }
29
+ const mintAccounts = yield (0, getParsedMultipleAccountsInfo_1.getParsedMultipleAccountsInfo)(connection, structs_1.mintAccountStruct, Array.from(mintsSet).map((m) => new web3_js_1.PublicKey(m)));
30
+ mintAccounts.forEach((acc) => {
31
+ if (!acc)
32
+ return;
33
+ decimalsMap.set(acc.pubkey.toString(), acc.decimals);
34
+ });
35
+ return decimalsMap;
36
+ });
37
+ }
38
+ exports.getMultipleDecimalsAsMap = getMultipleDecimalsAsMap;
39
+ //# sourceMappingURL=getMultipleDecimalsAsMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMultipleDecimalsAsMap.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimalsAsMap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAC5C,+DAIoC;AAEpC,uCAA8C;AAC9C,mFAAgF;AAEhF,SAAsB,wBAAwB,CAC5C,UAAwB,EACxB,KAAkB;;QAElB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,WAAW,GAAwB,IAAI,GAAG,EAAE,CAAC;QAEnD,IAAI,QAAQ,CAAC,GAAG,CAAC,oCAAmB,CAAC,EAAE,CAAC;YACtC,WAAW,CAAC,GAAG,CAAC,oCAAmB,EAAE,qCAAoB,CAAC,CAAC;YAC3D,QAAQ,CAAC,MAAM,CAAC,oCAAmB,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,QAAQ,CAAC,GAAG,CAAC,2CAA0B,CAAC,EAAE,CAAC;YAC7C,WAAW,CAAC,GAAG,CAAC,2CAA0B,EAAE,qCAAoB,CAAC,CAAC;YAClE,QAAQ,CAAC,MAAM,CAAC,2CAA0B,CAAC,CAAC;QAC9C,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAA,6DAA6B,EACtD,UAAU,EACV,2BAAiB,EACjB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;QACF,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC3B,IAAI,CAAC,GAAG;gBAAE,OAAO;YACjB,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;IACrB,CAAC;CAAA;AA1BD,4DA0BC"}
@@ -0,0 +1,2 @@
1
+ import { SuiClient } from '../clients/types';
2
+ export declare function getDecimals(client: SuiClient, coinType: string): Promise<number | null>;
@@ -0,0 +1,22 @@
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.getDecimals = void 0;
13
+ function getDecimals(client, coinType) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const coinMetadata = yield client.getCoinMetadata({ coinType });
16
+ if (coinMetadata)
17
+ return coinMetadata.decimals;
18
+ return null;
19
+ });
20
+ }
21
+ exports.getDecimals = getDecimals;
22
+ //# sourceMappingURL=getDecimals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/sui/getDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAsB,WAAW,CAC/B,MAAiB,EACjB,QAAgB;;QAEhB,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChE,IAAI,YAAY;YAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAPD,kCAOC"}