@sonarwatch/portfolio-plugins 0.11.194 → 0.11.195

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/CHANGELOG.md +1521 -1517
  2. package/README.md +3 -3
  3. package/package.json +2 -2
  4. package/src/index.js +4 -0
  5. package/src/index.js.map +1 -1
  6. package/src/plugins/balancer/helpers/pools.js +21 -21
  7. package/src/plugins/kriya/constants.d.ts +13 -0
  8. package/src/plugins/kriya/constants.js +30 -0
  9. package/src/plugins/kriya/constants.js.map +1 -0
  10. package/src/plugins/kriya/farmsFetcher.d.ts +3 -0
  11. package/src/plugins/kriya/farmsFetcher.js +104 -0
  12. package/src/plugins/kriya/farmsFetcher.js.map +1 -0
  13. package/src/plugins/kriya/farmsJob.d.ts +3 -0
  14. package/src/plugins/kriya/farmsJob.js +47 -0
  15. package/src/plugins/kriya/farmsJob.js.map +1 -0
  16. package/src/plugins/kriya/index.d.ts +6 -0
  17. package/src/plugins/kriya/index.js +15 -0
  18. package/src/plugins/kriya/index.js.map +1 -0
  19. package/src/plugins/kriya/types.d.ts +155 -0
  20. package/src/plugins/kriya/types.js +16 -0
  21. package/src/plugins/kriya/types.js.map +1 -0
  22. package/src/plugins/kriya/vaultsFetcher.d.ts +3 -0
  23. package/src/plugins/kriya/vaultsFetcher.js +94 -0
  24. package/src/plugins/kriya/vaultsFetcher.js.map +1 -0
  25. package/src/plugins/kriya/vaultsJob.d.ts +3 -0
  26. package/src/plugins/kriya/vaultsJob.js +57 -0
  27. package/src/plugins/kriya/vaultsJob.js.map +1 -0
  28. package/src/plugins/sushiswap/helpers.js +24 -24
  29. package/src/plugins/uniswap-v2/helpers.js +22 -22
  30. package/src/utils/sei/constants.js +8 -8
  31. package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
  32. package/src/utils/sui/mulitpleGetBalances.d.ts +3 -0
  33. package/src/utils/sui/mulitpleGetBalances.js +19 -0
  34. package/src/utils/sui/mulitpleGetBalances.js.map +1 -0
  35. package/src/utils/sui/multipleGetDynamicFieldsObjects.d.ts +4 -0
  36. package/src/utils/sui/multipleGetDynamicFieldsObjects.js +25 -0
  37. package/src/utils/sui/multipleGetDynamicFieldsObjects.js.map +1 -0
@@ -0,0 +1,94 @@
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 mulitpleGetBalances_1 = require("../../utils/sui/mulitpleGetBalances");
20
+ const constants_2 = require("../cetus/constants");
21
+ const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
22
+ const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
23
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
24
+ const client = (0, clients_1.getClientSui)();
25
+ const vaultsBalances = yield (0, mulitpleGetBalances_1.getMultipleBalances)(client, owner, constants_1.vaultsInfo.map((vault) => vault.tokenType));
26
+ if (!vaultsBalances.some((balance) => balance.totalBalance !== '0'))
27
+ return [];
28
+ const poolInfos = yield cache.getItems(constants_1.vaultsInfo.map((vault) => vault.underlyingPool), { prefix: constants_2.clmmPoolsPrefix, networkId: portfolio_core_1.NetworkId.sui });
29
+ const vaultsPositionInfo = yield cache.getItem(constants_1.vaultsInfoKey, {
30
+ prefix: constants_1.platformId,
31
+ networkId: portfolio_core_1.NetworkId.sui,
32
+ });
33
+ if (!vaultsPositionInfo)
34
+ return [];
35
+ const tokenPriceById = yield cache.getTokenPricesAsMap(poolInfos
36
+ .map((pool) => (pool ? [pool.coinTypeA, pool.coinTypeB] : []))
37
+ .flat(), portfolio_core_1.NetworkId.sui);
38
+ let totalValue = 0;
39
+ const liquidities = [];
40
+ for (let i = 0; i < vaultsBalances.length; i++) {
41
+ const balance = vaultsBalances[i];
42
+ const pool = poolInfos[i];
43
+ const vault = vaultsPositionInfo[i];
44
+ if (!pool || !vault)
45
+ continue;
46
+ const totalSupply = new bignumber_js_1.default(vault.totalSupply);
47
+ const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(vault.liquidity), pool.current_tick_index, vault.lowerTick, vault.upperTick, false);
48
+ const shares = new bignumber_js_1.default(balance.totalBalance).dividedBy(totalSupply);
49
+ const [tokenPriceA, tokenPriceB] = [
50
+ tokenPriceById.get((0, portfolio_core_1.formatMoveTokenAddress)(pool.coinTypeA)),
51
+ tokenPriceById.get((0, portfolio_core_1.formatMoveTokenAddress)(pool.coinTypeB)),
52
+ ];
53
+ if (!tokenPriceA || !tokenPriceB)
54
+ continue;
55
+ const amountA = tokenAmountA
56
+ .times(shares)
57
+ .dividedBy(Math.pow(10, tokenPriceA.decimals));
58
+ const amountB = tokenAmountB
59
+ .times(shares)
60
+ .dividedBy(Math.pow(10, tokenPriceB.decimals));
61
+ const assetA = (0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, amountA.toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceA);
62
+ const assetB = (0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, amountB.toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceB);
63
+ const value = (0, portfolio_core_1.getUsdValueSum)([assetA.value, assetB.value]);
64
+ totalValue = (0, portfolio_core_1.getUsdValueSum)([totalValue, value]);
65
+ liquidities.push({
66
+ assets: [assetA, assetB],
67
+ assetsValue: value,
68
+ rewardAssets: [],
69
+ rewardAssetsValue: null,
70
+ value,
71
+ yields: [],
72
+ });
73
+ }
74
+ return [
75
+ {
76
+ type: 'liquidity',
77
+ data: {
78
+ liquidities,
79
+ },
80
+ label: 'LiquidityPool',
81
+ networkId: portfolio_core_1.NetworkId.sui,
82
+ platformId: constants_1.platformId,
83
+ value: totalValue,
84
+ name: 'Vaults',
85
+ },
86
+ ];
87
+ });
88
+ const fetcher = {
89
+ id: `${constants_1.platformId}-vaults`,
90
+ networkId: portfolio_core_1.NetworkId.sui,
91
+ executor,
92
+ };
93
+ exports.default = fetcher;
94
+ //# sourceMappingURL=vaultsFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vaultsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/kriya/vaultsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAGrC,2CAAoE;AACpE,iDAAmD;AACnD,6EAA0E;AAE1E,kDAAqD;AAErD,wFAAyF;AACzF,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,cAAc,GAAG,MAAM,IAAA,yCAAmB,EAC9C,MAAM,EACN,KAAK,EACL,sBAAU,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAC3C,CAAC;IAEF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,YAAY,KAAK,GAAG,CAAC;QACjE,OAAO,EAAE,CAAC;IAEZ,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC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AC;QACjD,WAAW,CAAC,IAAI,CAAC;YACf,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;YACxB,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,EAAE;YAChB,iBAAiB,EAAE,IAAI;YACvB,KAAK;YACL,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC;IACD,OAAO;QACL;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE;gBACJ,WAAW;aACZ;YACD,KAAK,EAAE,eAAe;YACtB,SAAS,EAAE,0BAAS,CAAC,GAAG;YACxB,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,QAAQ;SACf;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,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,57 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
13
+ const clients_1 = require("../../utils/clients");
14
+ const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
15
+ const multipleGetDynamicFieldsObjects_1 = require("../../utils/sui/multipleGetDynamicFieldsObjects");
16
+ const constants_1 = require("./constants");
17
+ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
18
+ var _a, _b, _c, _d;
19
+ const client = (0, clients_1.getClientSui)();
20
+ const [vaultsObjects, vaultsDynamicFields] = yield Promise.all([
21
+ (0, multiGetObjects_1.multiGetObjects)(client, constants_1.vaultsInfo.map((vault) => vault.id)),
22
+ (0, multipleGetDynamicFieldsObjects_1.multipleGetDynamicFieldsObjects)(client, constants_1.vaultsInfo.map((vault) => vault.id)),
23
+ ]);
24
+ const vaultsInfos = [];
25
+ for (let i = 0; i < vaultsObjects.length; i++) {
26
+ const vault = (_b = (_a = vaultsObjects[i].data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields;
27
+ if (!vault)
28
+ continue;
29
+ const dynamicFields = vaultsDynamicFields[i];
30
+ let vaultPosition;
31
+ for (const fields of dynamicFields) {
32
+ if (((_c = fields.data) === null || _c === void 0 ? void 0 : _c.type) === constants_1.dynamicFieldPositionType)
33
+ vaultPosition = (_d = fields.data.content) === null || _d === void 0 ? void 0 : _d.fields;
34
+ }
35
+ if (!vaultPosition)
36
+ continue;
37
+ const vaultPositionInfo = {
38
+ id: vault.id.id,
39
+ liquidity: vaultPosition.value.fields.liquidity,
40
+ lowerTick: vault.lower_tick,
41
+ upperTick: vault.upper_tick,
42
+ totalSupply: vault.treasury_cap.fields.total_supply.fields.value,
43
+ };
44
+ vaultsInfos.push(vaultPositionInfo);
45
+ }
46
+ yield cache.setItem(constants_1.vaultsInfoKey, vaultsInfos, {
47
+ prefix: constants_1.platformId,
48
+ networkId: portfolio_core_1.NetworkId.sui,
49
+ });
50
+ });
51
+ const job = {
52
+ id: `${constants_1.platformId}-vaults`,
53
+ executor,
54
+ label: 'normal',
55
+ };
56
+ exports.default = job;
57
+ //# sourceMappingURL=vaultsJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vaultsJob.js","sourceRoot":"","s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AE,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE;YACf,SAAS,EAAE,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS;YAC/C,SAAS,EAAE,KAAK,CAAC,UAAU;YAC3B,SAAS,EAAE,KAAK,CAAC,UAAU;YAC3B,WAAW,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK;SACjE,CAAC;QACF,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,KAAK,CAAC,OAAO,CAAC,yBAAa,EAAE,WAAW,EAAE;QAC9C,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,SAAS;IAC1B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
54
54
  }
55
55
  function getV3PairsAddresses(url, length = 300) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
- const query = (0, graphql_request_1.gql) `
58
- {
59
- pools(
60
- orderBy: totalValueLockedUSD
61
- first: ${length}
62
- orderDirection: desc
63
- where: { volumeUSD_not: "0", liquidity_not: "0" }
64
- ) {
65
- id
66
- token0Price
67
- token1Price
68
- liquidity
69
- token0 {
70
- id
71
- totalSupply
72
- decimals
73
- }
74
- token1 {
75
- id
76
- totalSupply
77
- decimals
78
- }
79
- }
80
- }
57
+ const query = (0, graphql_request_1.gql) `
58
+ {
59
+ pools(
60
+ orderBy: totalValueLockedUSD
61
+ first: ${length}
62
+ orderDirection: desc
63
+ where: { volumeUSD_not: "0", liquidity_not: "0" }
64
+ ) {
65
+ id
66
+ token0Price
67
+ token1Price
68
+ liquidity
69
+ token0 {
70
+ id
71
+ totalSupply
72
+ decimals
73
+ }
74
+ token1 {
75
+ id
76
+ totalSupply
77
+ decimals
78
+ }
79
+ }
80
+ }
81
81
  `;
82
82
  const res = yield (0, graphql_request_1.default)(url, query);
83
83
  const pools = res.pools;
@@ -40,28 +40,28 @@ function getPairKey(version) {
40
40
  exports.getPairKey = getPairKey;
41
41
  function getPairsV2FromTheGraph(url, length = 300) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const query = (0, graphql_request_1.gql) `
44
- {
45
- pairs(
46
- orderBy: reserveUSD
47
- first: ${length}
48
- orderDirection: desc
49
- where: { trackedReserveETH_not: "0" }
50
- ) {
51
- id
52
- reserve0
53
- reserve1
54
- totalSupply
55
- token0 {
56
- id
57
- decimals
58
- }
59
- token1 {
60
- id
61
- decimals
62
- }
63
- }
64
- }
43
+ const query = (0, graphql_request_1.gql) `
44
+ {
45
+ pairs(
46
+ orderBy: reserveUSD
47
+ first: ${length}
48
+ orderDirection: desc
49
+ where: { trackedReserveETH_not: "0" }
50
+ ) {
51
+ id
52
+ reserve0
53
+ reserve1
54
+ totalSupply
55
+ token0 {
56
+ id
57
+ decimals
58
+ }
59
+ token1 {
60
+ id
61
+ decimals
62
+ }
63
+ }
64
+ }
65
65
  `;
66
66
  const res = yield (0, graphql_request_1.default)(url, query);
67
67
  const pairs = res.pairs;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.poolQueryMsg = exports.minterQueryMsg = exports.tokenInfoQueryMsg = exports.infoQueryMsg = void 0;
4
- exports.infoQueryMsg = JSON.parse(`{
5
- "info": {}
4
+ exports.infoQueryMsg = JSON.parse(`{
5
+ "info": {}
6
6
  }`);
7
- exports.tokenInfoQueryMsg = JSON.parse(`{
8
- "token_info": {}
7
+ exports.tokenInfoQueryMsg = JSON.parse(`{
8
+ "token_info": {}
9
9
  }`);
10
- exports.minterQueryMsg = JSON.parse(`{
11
- "minter": {}
10
+ exports.minterQueryMsg = JSON.parse(`{
11
+ "minter": {}
12
12
  }`);
13
- exports.poolQueryMsg = JSON.parse(`{
14
- "pool": {}
13
+ exports.poolQueryMsg = JSON.parse(`{
14
+ "pool": {}
15
15
  }`);
16
16
  //# sourceMappingURL=constants.js.map
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function getQueryBalanceByOwner(owner) {
4
- return JSON.parse(`{
5
- "balance": {
6
- "address": "${owner}"
7
- }
4
+ return JSON.parse(`{
5
+ "balance": {
6
+ "address": "${owner}"
7
+ }
8
8
  }`);
9
9
  }
10
10
  exports.default = getQueryBalanceByOwner;
@@ -0,0 +1,3 @@
1
+ import { CoinBalance } from '@mysten/sui.js/dist/cjs/client';
2
+ import { SuiClient } from '../clients/types';
3
+ export declare function getMultipleBalances(client: SuiClient, owner: string, coinsTypes: string[]): Promise<CoinBalance[]>;
@@ -0,0 +1,19 @@
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.getMultipleBalances = void 0;
13
+ function getMultipleBalances(client, owner, coinsTypes) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ return Promise.all(coinsTypes.map((coinType) => client.getBalance({ owner, coinType })));
16
+ });
17
+ }
18
+ exports.getMultipleBalances = getMultipleBalances;
19
+ //# sourceMappingURL=mulitpleGetBalances.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mulitpleGetBalances.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/sui/mulitpleGetBalances.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAsB,mBAAmB,CACvC,MAAiB,EACjB,KAAa,EACb,UAAoB;;QAEpB,OAAO,OAAO,CAAC,GAAG,CAChB,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CACrE,CAAC;IACJ,CAAC;CAAA;AARD,kDAQC"}
@@ -0,0 +1,4 @@
1
+ import { SuiObjectDataOptions } from '@mysten/sui.js/dist/cjs/client';
2
+ import { SuiClient } from '../clients/types';
3
+ import { ObjectResponse } from './types';
4
+ export declare function multipleGetDynamicFieldsObjects<K>(client: SuiClient, parentIds: string[], options?: SuiObjectDataOptions): Promise<ObjectResponse<K>[][]>;
@@ -0,0 +1,25 @@
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
+ exports.multipleGetDynamicFieldsObjects = void 0;
16
+ const runInBatch_1 = __importDefault(require("../misc/runInBatch"));
17
+ const getDynamicFieldObjects_1 = require("./getDynamicFieldObjects");
18
+ function multipleGetDynamicFieldsObjects(client, parentIds, options) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const result = yield (0, runInBatch_1.default)(parentIds.map((parentId) => () => (0, getDynamicFieldObjects_1.getDynamicFieldObjects)(client, parentId, options)), 10);
21
+ return result.flatMap((r) => (r.status === 'fulfilled' ? [r.value] : []));
22
+ });
23
+ }
24
+ exports.multipleGetDynamicFieldsObjects = multipleGetDynamicFieldsObjects;
25
+ //# sourceMappingURL=multipleGetDynamicFieldsObjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multipleGetDynamicFieldsObjects.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/sui/multipleGetDynamicFieldsObjects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,oEAA4C;AAC5C,qEAAkE;AAGlE,SAAsB,+BAA+B,CACnD,MAAiB,EACjB,SAAmB,EACnB,OAA8B;;QAE9B,MAAM,MAAM,GAAG,MAAM,IAAA,oBAAU,EAC7B,SAAS,CAAC,GAAG,CACX,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,IAAA,+CAAsB,EAAI,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CACzE,EACD,EAAE,CACH,CAAC;QAEF,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;CAAA;AAbD,0EAaC"}