@sonarwatch/portfolio-plugins 0.12.186 → 0.12.188

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/CHANGELOG.md +13 -5
  2. package/package.json +1 -1
  3. package/src/plugins/aave/constants.js +1 -1
  4. package/src/plugins/abex/constants.d.ts +8 -1
  5. package/src/plugins/abex/constants.js +9 -2
  6. package/src/plugins/abex/constants.js.map +1 -1
  7. package/src/plugins/abex/getVaultInfo.d.ts +3 -0
  8. package/src/plugins/abex/getVaultInfo.js +65 -0
  9. package/src/plugins/abex/getVaultInfo.js.map +1 -0
  10. package/src/plugins/abex/helpers.d.ts +25 -0
  11. package/src/plugins/abex/helpers.js +353 -0
  12. package/src/plugins/abex/helpers.js.map +1 -0
  13. package/src/plugins/abex/index.js +7 -1
  14. package/src/plugins/abex/index.js.map +1 -1
  15. package/src/plugins/abex/marketsJob.js +13 -7
  16. package/src/plugins/abex/marketsJob.js.map +1 -1
  17. package/src/plugins/abex/ordersFetcher.d.ts +3 -0
  18. package/src/plugins/abex/ordersFetcher.js +49 -0
  19. package/src/plugins/abex/ordersFetcher.js.map +1 -0
  20. package/src/plugins/abex/parseValue.d.ts +1 -0
  21. package/src/plugins/abex/parseValue.js +30 -0
  22. package/src/plugins/abex/parseValue.js.map +1 -0
  23. package/src/plugins/abex/positionsFetcher.js +39 -57
  24. package/src/plugins/abex/positionsFetcher.js.map +1 -1
  25. package/src/plugins/abex/stakingFetcher.d.ts +3 -0
  26. package/src/plugins/abex/stakingFetcher.js +87 -0
  27. package/src/plugins/abex/stakingFetcher.js.map +1 -0
  28. package/src/plugins/abex/types.d.ts +172 -10
  29. package/src/plugins/balancer/index.js +4 -2
  30. package/src/plugins/balancer/index.js.map +1 -1
  31. package/src/plugins/bluemove/poolsJob.js +13 -11
  32. package/src/plugins/bluemove/poolsJob.js.map +1 -1
  33. package/src/plugins/liquiditypools-sei/index.js +4 -2
  34. package/src/plugins/liquiditypools-sei/index.js.map +1 -1
  35. package/src/plugins/pancakeswap/index.js +2 -2
  36. package/src/plugins/pancakeswap/index.js.map +1 -1
  37. package/src/plugins/sushiswap/index.js +5 -5
  38. package/src/plugins/sushiswap/index.js.map +1 -1
  39. package/src/plugins/whalesmarket/constants.d.ts +1 -1
  40. package/src/plugins/whalesmarket/constants.js +1 -1
  41. package/src/plugins/whalesmarket/constants.js.map +1 -1
  42. package/src/plugins/whalesmarket/tokensJob.js +2 -0
  43. package/src/plugins/whalesmarket/tokensJob.js.map +1 -1
  44. package/src/utils/elementbuilder/ElementLeverageBuilder.d.ts +13 -0
  45. package/src/utils/elementbuilder/ElementLeverageBuilder.js +40 -0
  46. package/src/utils/elementbuilder/ElementLeverageBuilder.js.map +1 -0
  47. package/src/utils/elementbuilder/ElementRegistry.d.ts +2 -0
  48. package/src/utils/elementbuilder/ElementRegistry.js +6 -0
  49. package/src/utils/elementbuilder/ElementRegistry.js.map +1 -1
  50. package/src/utils/elementbuilder/LevPositionBuilder.d.ts +9 -0
  51. package/src/utils/elementbuilder/LevPositionBuilder.js +49 -0
  52. package/src/utils/elementbuilder/LevPositionBuilder.js.map +1 -0
  53. package/src/utils/elementbuilder/LevPositionParams.d.ts +14 -0
  54. package/src/utils/elementbuilder/LevPositionParams.js +3 -0
  55. package/src/utils/elementbuilder/LevPositionParams.js.map +1 -0
  56. package/src/utils/misc/Memoized.d.ts +8 -0
  57. package/src/utils/misc/Memoized.js +31 -0
  58. package/src/utils/misc/Memoized.js.map +1 -0
@@ -21,9 +21,19 @@ const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
21
21
  const getLpTokenSourceRawOld_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRawOld"));
22
22
  const getObject_1 = require("../../utils/sui/getObject");
23
23
  const constants_2 = require("../tokens/constants");
24
+ const helpers_1 = require("./helpers");
24
25
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
25
- var _a, _b, _c, _d, _e, _f, _g, _h;
26
+ var _a, _b, _c, _d, _e, _f;
26
27
  const client = (0, clients_1.getClientSui)();
28
+ // Abex market
29
+ const marketInfo = yield (0, helpers_1.getMarketInfo)(client);
30
+ const { lpSupply } = marketInfo;
31
+ if (!lpSupply)
32
+ return;
33
+ yield cache.setItem(constants_1.abexMarketCacheKey, marketInfo, {
34
+ prefix: constants_1.platformId,
35
+ networkId: portfolio_core_1.NetworkId.sui,
36
+ });
27
37
  // Pool
28
38
  const poolObject = yield (0, getObject_1.getObject)(client, constants_1.poolObjectId);
29
39
  const accRewardPerShare = (_b = (_a = poolObject.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.acc_reward_per_share;
@@ -33,10 +43,6 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
33
43
  networkId: portfolio_core_1.NetworkId.sui,
34
44
  });
35
45
  }
36
- const lpObject = yield (0, getObject_1.getObject)(client, constants_1.alpSupplyObjectId);
37
- const lpSupply = (_d = (_c = lpObject.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.lp_supply.fields.value;
38
- if (!lpSupply)
39
- return;
40
46
  const depositVaultFields = yield (0, getDynamicFields_1.getDynamicFields)(client, constants_1.depositVaultRegistry);
41
47
  const objects = yield (0, multiGetObjects_1.multiGetObjects)(client, depositVaultFields.map((f) => f.objectId));
42
48
  const uTypes = [];
@@ -54,10 +60,10 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
54
60
  const lpUnderlyings = [];
55
61
  for (let i = 0; i < objects.length; i++) {
56
62
  const object = objects[i];
57
- const market = (_f = (_e = object.data) === null || _e === void 0 ? void 0 : _e.content) === null || _f === void 0 ? void 0 : _f.fields;
63
+ const market = (_d = (_c = object.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields;
58
64
  if (!market)
59
65
  return;
60
- const uType = (_h = (_g = (0, portfolio_core_1.parseTypeString)(market.value.type).keys) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.type;
66
+ const uType = (_f = (_e = (0, portfolio_core_1.parseTypeString)(market.value.type).keys) === null || _e === void 0 ? void 0 : _e.at(0)) === null || _f === void 0 ? void 0 : _f.type;
61
67
  if (!uType)
62
68
  return;
63
69
  const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(uType, portfolio_core_1.NetworkId.sui));
@@ -1 +1 @@
1
- {"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/marketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAQqB;AACrB,iDAAmD;AACnD,uEAAoE;AAEpE,qEAAkE;AAClE,qGAEiD;AACjD,yDAAsD;AACtD,mDAA2D;AAE3D,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,OAAO;IACP,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAS,EAAO,MAAM,EAAE,wBAAY,CAAC,CAAC;IAC/D,MAAM,iBAAiB,GACrB,MAAA,MAAA,UAAU,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,CAAC,oBAAoB,CAAC;IACxD,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,KAAK,CAAC,OAAO,CAAC,oCAAwB,EAAE,iBAAiB,EAAE;YAC/D,MAAM,EAAE,sBAAU;YAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;SACzB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAS,EAAY,MAAM,EAAE,6BAAiB,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,MAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC;IACvE,IAAI,CAAC,QAAQ;QAAE,OAAO;IAEtB,MAAM,kBAAkB,GAAG,MAAM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AU,UAAU;IAC3B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"marketsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/marketsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAQqB;AACrB,iDAAmD;AACnD,uEAAoE;AAEpE,qEAAkE;AAClE,qGAEiD;AACjD,yDAAsD;AACtD,mDAA2D;AAC3D,uCAA0C;AAE1C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,cAAc;IACd,MAAM,UAAU,GAAG,MAAM,IAAA,uBAAa,EAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC;IAChC,IAAI,CAAC,QAAQ;QAAE,OAAO;IAEtB,MAAM,KAAK,CAAC,OAAO,CAAC,8BAAkB,EAAE,UAAU,EAAE;QAClD,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IAEH,OAAO;IACP,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAS,EAAO,MAAM,EAAE,wBAAY,CAAC,CAAC;IAC/D,MAAM,iBAAiB,GACrB,MAAA,MAAA,UAAU,CAAC,IAAI,0CAAE,OAAO,0CAAE,MAAM,CAAC,oBAAoB,CAAC;IACxD,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,KAAK,CAAC,OAAO,CAAC,oCAAwB,EAAE,iBAAiB,EAAE;YAC/D,MAAM,EAAE,sBAAU;YAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;SACzB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAM,IAAA,mCAAgB,EAC/C,MAAM,EACN,gCAAoB,CACrB,CAAC;IACF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C;AACF,kBAAe,GAAG,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,49 @@
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 helpers_1 = require("./helpers");
16
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
17
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const client = (0, clients_1.getClientSui)();
19
+ const orderCapInfoList = yield (0, helpers_1.getOrderCapInfoList)(client, owner);
20
+ if (!orderCapInfoList.length)
21
+ return [];
22
+ const positionInfoList = yield (0, helpers_1.getOrderInfoList)(client, orderCapInfoList, owner);
23
+ if (!positionInfoList.length)
24
+ return [];
25
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
26
+ const element = elementRegistry.addElementMultiple({
27
+ label: 'Deposit',
28
+ tags: ['Orders'],
29
+ });
30
+ positionInfoList.forEach((positionInfo) => {
31
+ var _a;
32
+ if (positionInfo.executed)
33
+ return;
34
+ if (!((_a = positionInfo.openOrder) === null || _a === void 0 ? void 0 : _a.collateralAmount))
35
+ return;
36
+ element.addAsset({
37
+ address: positionInfo.collateralToken,
38
+ amount: positionInfo.openOrder.collateralAmount,
39
+ });
40
+ });
41
+ return elementRegistry.getElements(cache);
42
+ });
43
+ const fetcher = {
44
+ id: `${constants_1.platformId}-orders`,
45
+ networkId: portfolio_core_1.NetworkId.sui,
46
+ executor,
47
+ };
48
+ exports.default = fetcher;
49
+ //# sourceMappingURL=ordersFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordersFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/ordersFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAEvD,2CAAyC;AAEzC,iDAAmD;AACnD,uCAAkE;AAClE,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,gBAAgB,GAAG,MAAM,IAAA,6BAAmB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAElE,IAAI,CAAC,gBAAgB,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAExC,MAAM,gBAAgB,GAAG,MAAM,IAAA,0BAAgB,EAC7C,MAAM,EACN,gBAAgB,EAChB,KAAK,CACN,CAAC;IAEF,IAAI,CAAC,gBAAgB,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAExC,MAAM,eAAe,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,GAAG,EAAE,sBAAU,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,eAAe,CAAC,kBAAkB,CAAC;QACjD,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,CAAC,QAAQ,CAAC;KACjB,CAAC,CAAC;IAEH,gBAAgB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;;QACxC,IAAI,YAAY,CAAC,QAAQ;YAAE,OAAO;QAClC,IAAI,CAAC,CAAA,MAAA,YAAY,CAAC,SAAS,0CAAE,gBAAgB,CAAA;YAAE,OAAO;QACtD,OAAO,CAAC,QAAQ,CAAC;YACf,OAAO,EAAE,YAAY,CAAC,eAAe;YACrC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,gBAAgB;SAChD,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,SAAS;IAC1B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const parseValue: (field: any) => number;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseValue = void 0;
4
+ const decimalToObject = (decimal) => Number(BigInt(decimal.value)) / 1e18;
5
+ const rateToObject = (rate) => Number(BigInt(rate.value)) / 1e18;
6
+ const srateToObject = (srate) => {
7
+ const sign = srate.fields.is_positive ? 1 : -1;
8
+ return (Number(BigInt(srate.fields.value.fields.value)) / 1e18) * sign;
9
+ };
10
+ const sdecimalToObject = (sdecimal) => {
11
+ const sign = sdecimal.fields.is_positive ? 1 : -1;
12
+ return (Number(BigInt(sdecimal.fields.value.fields.value)) / 1e18) * sign;
13
+ };
14
+ const parseValue = (field) => {
15
+ if (field.type && field.type.endsWith('::decimal::Decimal')) {
16
+ return decimalToObject({ value: field.fields.value });
17
+ }
18
+ if (field.type && field.type.endsWith('::rate::Rate')) {
19
+ return rateToObject({ value: field.fields.value });
20
+ }
21
+ if (field.type && field.type.endsWith('::srate::SRate')) {
22
+ return srateToObject(field);
23
+ }
24
+ if (field.type && field.type.endsWith('::sdecimal::SDecimal')) {
25
+ return sdecimalToObject(field);
26
+ }
27
+ return parseInt(field, 10);
28
+ };
29
+ exports.parseValue = parseValue;
30
+ //# sourceMappingURL=parseValue.js.map
@@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,CAAC,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACtD,OAAO,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACxD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC9D,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC,CAAC;AAdW,QAAA,UAAU,cAcrB"}
@@ -16,72 +16,54 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
16
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
17
  const constants_1 = require("./constants");
18
18
  const clients_1 = require("../../utils/clients");
19
- const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
20
- const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
19
+ const helpers_1 = require("./helpers");
20
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
21
21
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
22
- var _a, _b, _c, _d;
23
22
  const client = (0, clients_1.getClientSui)();
24
- const objects = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
25
- filter: {
26
- Package: '0xc985ff436f334f864d74f35c3da9e116419b63a0c027cbe2ac7815afc4abc450',
27
- },
28
- });
29
- if (objects.length === 0)
23
+ const positionCapInfoList = yield (0, helpers_1.getPositionCapInfoList)(client, owner);
24
+ if (positionCapInfoList.length === 0)
30
25
  return [];
31
- const [alpPrice, suiPrice] = yield cache.getTokenPrices([constants_1.alpType, portfolio_core_1.suiNativeAddress], portfolio_core_1.NetworkId.sui);
32
- const poolAccRewardPerShareStr = yield cache.getItem(constants_1.poolAccRewardPerShareKey, {
26
+ const marketInfo = yield cache.getItem(constants_1.abexMarketCacheKey, {
33
27
  prefix: constants_1.platformId,
34
28
  networkId: portfolio_core_1.NetworkId.sui,
35
29
  });
36
- const poolAccRewardPerShare = poolAccRewardPerShareStr
37
- ? new bignumber_js_1.default(poolAccRewardPerShareStr)
38
- : undefined;
39
- let alpAmount = new bignumber_js_1.default(0);
40
- let claimmableAmount = new bignumber_js_1.default(0);
41
- for (let i = 0; i < objects.length; i++) {
42
- const object = objects[i];
43
- const cAlpAmount = (_b = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.stake;
44
- if (!cAlpAmount)
45
- continue;
46
- alpAmount = alpAmount.plus(cAlpAmount);
47
- if (!poolAccRewardPerShare)
30
+ if (!marketInfo)
31
+ return [];
32
+ const positionInfoList = yield (0, helpers_1.getPositionInfoList)(client, positionCapInfoList, marketInfo, cache, owner);
33
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
34
+ for (const positionInfo of positionInfoList) {
35
+ if (positionInfo.closed)
48
36
  continue;
49
- const accRewardPerShare = (_d = (_c = object.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.acc_reward_per_share;
50
- if (!accRewardPerShare)
37
+ const element = elementRegistry.addElementLeverage({
38
+ label: 'Leverage',
39
+ });
40
+ const tokenPrices = yield cache.getTokenPricesAsMap([positionInfo.indexToken, positionInfo.collateralToken], portfolio_core_1.NetworkId.sui);
41
+ const tokenPriceIndex = tokenPrices.get(positionInfo.indexToken);
42
+ const tokenPriceCollateral = tokenPrices.get(positionInfo.collateralToken);
43
+ if (!tokenPriceCollateral)
51
44
  continue;
52
- const cClaimmableAmount = poolAccRewardPerShare
53
- .minus(accRewardPerShare)
54
- .times(cAlpAmount)
55
- .div(Math.pow(10, 18));
56
- claimmableAmount = claimmableAmount.plus(cClaimmableAmount);
45
+ let pnlValue;
46
+ let leverage;
47
+ if (tokenPriceIndex) {
48
+ const calcPnl = yield (0, helpers_1.calculatePNL)(positionInfo, tokenPriceIndex, tokenPriceCollateral);
49
+ if (calcPnl) {
50
+ pnlValue = new bignumber_js_1.default(calcPnl.pnlValue);
51
+ leverage = calcPnl.leverage;
52
+ }
53
+ }
54
+ element.addPosition({
55
+ address: positionInfo.collateralToken,
56
+ collateralValue: new bignumber_js_1.default(positionInfo.collateralAmount)
57
+ .multipliedBy(tokenPriceCollateral.price)
58
+ .dividedBy(Math.pow(10, tokenPriceCollateral.decimals))
59
+ .toNumber(),
60
+ side: positionInfo.long ? portfolio_core_1.LeverageSide.long : portfolio_core_1.LeverageSide.short,
61
+ sizeValue: new bignumber_js_1.default(positionInfo.positionSize),
62
+ pnlValue,
63
+ leverage,
64
+ });
57
65
  }
58
- const asset = (0, tokenPriceToAssetToken_1.default)(constants_1.alpType, alpAmount.dividedBy(Math.pow(10, constants_1.alpDecimals)).toNumber(), portfolio_core_1.NetworkId.sui, alpPrice);
59
- const rewardAsset = (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.suiNativeAddress, claimmableAmount.dividedBy(Math.pow(10, portfolio_core_1.suiNativeDecimals)).toNumber(), portfolio_core_1.NetworkId.sui, suiPrice, undefined, {
60
- isClaimable: true,
61
- });
62
- if (claimmableAmount.isZero() && alpAmount.isZero())
63
- return [];
64
- const value = (0, portfolio_core_1.getUsdValueSum)([rewardAsset.value, asset.value]);
65
- const element = {
66
- networkId: portfolio_core_1.NetworkId.sui,
67
- label: 'Staked',
68
- platformId: constants_1.platformId,
69
- type: 'liquidity',
70
- data: {
71
- liquidities: [
72
- {
73
- assets: [asset],
74
- assetsValue: asset.value,
75
- rewardAssets: [rewardAsset],
76
- rewardAssetsValue: rewardAsset.value,
77
- value,
78
- yields: [],
79
- },
80
- ],
81
- },
82
- value,
83
- };
84
- return [element];
66
+ return elementRegistry.getElements(cache);
85
67
  });
86
68
  const fetcher = {
87
69
  id: `${constants_1.platformId}-positions`,
@@ -1 +1 @@
1
- {"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAErC,2CAKqB;AAErB,iDAAmD;AACnD,qEAAkE;AAElE,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EAAa,MAAM,EAAE,KAAK,EAAE;QAC/D,MAAM,EAAE;YACN,OAAO,EACL,oEAAoE;SACvE;KACF,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,KAAK,CAAC,cAAc,CACrD,CAAC,mBAAO,EAAE,iCAAgB,CAAC,EAC3B,0BAAS,CAAC,GAAG,CACd,CAAC;IACF,MAAM,wBAAwB,GAAG,MAAM,KAAK,CAAC,OAAO,CAClD,oCAAwB,EACxB;QACE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CACF,CAAC;IACF,MAAM,qBAAqB,GAAG,wBAAwB;QACpD,CAAC,CAAC,IAAI,sBAAS,CAAC,wBAAwB,CAAC;QACzC,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,SAAS,GAAG,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;IACj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E,IAAI;KAClB,CACF,CAAC;IAEF,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAA,+BAAc,EAAC,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,MAAM,OAAO,GAA8B;QACzC,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,KAAK,EAAE,QAAQ;QACf,UAAU,EAAV,sBAAU;QACV,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX;oBACE,MAAM,EAAE,CAAC,KAAK,CAAC;oBACf,WAAW,EAAE,KAAK,CAAC,KAAK;oBACxB,YAAY,EAAE,CAAC,WAAW,CAAC;oBAC3B,iBAAiB,EAAE,WAAW,CAAC,KAAK;oBACpC,KAAK;oBACL,MAAM,EAAE,EAAE;iBACX;aACF;SACF;QACD,KAAK;KACN,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAqE;AACrE,gEAAqC;AAErC,2CAA6D;AAE7D,iDAAmD;AACnD,uCAImB;AACnB,gFAA6E;AAG7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,mBAAmB,GAAG,MAAM,IAAA,gCAAsB,EAAC,MAAM,EAAE,KAAK,CAA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GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC3C,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,OAAO,CAAC,WAAW,CAAC;YAClB,OAAO,EAAE,YAAY,CAAC,eAAe;YACrC,eAAe,EAAE,IAAI,sBAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC;iBAC1D,YAAY,CAAC,oBAAoB,CAAC,KAAK,CAAC;iBACxC,SAAS,CAAC,SAAA,EAAE,EAAI,oBAAoB,CAAC,QAAQ,CAAA,CAAC;iBAC9C,QAAQ,EAAE;YACb,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,6BAAY,CAAC,IAAI,CAAC,CAAC,CAAC,6BAAY,CAAC,KAAK;YAChE,SAAS,EAAE,IAAI,sBAAS,CAAC,YAAY,CAAC,YAAY,CAAC;YACnD,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,87 @@
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 executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
22
+ var _a, _b, _c, _d;
23
+ const client = (0, clients_1.getClientSui)();
24
+ const objects = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
25
+ filter: {
26
+ MoveModule: {
27
+ package: constants_1.stakingPackage,
28
+ module: 'pool',
29
+ },
30
+ },
31
+ });
32
+ if (objects.length === 0)
33
+ return [];
34
+ const poolAccRewardPerShareStr = yield cache.getItem(constants_1.poolAccRewardPerShareKey, {
35
+ prefix: constants_1.platformId,
36
+ networkId: portfolio_core_1.NetworkId.sui,
37
+ });
38
+ const poolAccRewardPerShare = poolAccRewardPerShareStr
39
+ ? new bignumber_js_1.default(poolAccRewardPerShareStr)
40
+ : undefined;
41
+ let alpAmount = new bignumber_js_1.default(0);
42
+ let claimableAmount = new bignumber_js_1.default(0);
43
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
44
+ const element = elementRegistry.addElementLiquidity({
45
+ label: 'Staked',
46
+ });
47
+ const liquidity = element.addLiquidity();
48
+ for (let i = 0; i < objects.length; i++) {
49
+ const object = objects[i];
50
+ const cAlpAmount = (_b = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.stake;
51
+ if (!cAlpAmount)
52
+ continue;
53
+ alpAmount = alpAmount.plus(cAlpAmount);
54
+ if (!poolAccRewardPerShare)
55
+ continue;
56
+ const accRewardPerShare = (_d = (_c = object.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.acc_reward_per_share;
57
+ if (!accRewardPerShare)
58
+ continue;
59
+ const cClaimableAmount = poolAccRewardPerShare
60
+ .minus(accRewardPerShare)
61
+ .times(cAlpAmount)
62
+ .div(Math.pow(10, 18));
63
+ claimableAmount = claimableAmount.plus(cClaimableAmount);
64
+ }
65
+ liquidity.addAsset({
66
+ address: constants_1.alpType,
67
+ amount: alpAmount,
68
+ });
69
+ if (claimableAmount.isGreaterThan(0))
70
+ liquidity.addRewardAsset({
71
+ address: portfolio_core_1.suiNativeAddress,
72
+ amount: claimableAmount,
73
+ attributes: {
74
+ isClaimable: true,
75
+ },
76
+ });
77
+ if (claimableAmount.isZero() && alpAmount.isZero())
78
+ return [];
79
+ return elementRegistry.getElements(cache);
80
+ });
81
+ const fetcher = {
82
+ id: `${constants_1.platformId}-staking`,
83
+ networkId: portfolio_core_1.NetworkId.sui,
84
+ executor,
85
+ };
86
+ exports.default = fetcher;
87
+ //# sourceMappingURL=stakingFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stakingFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/abex/stakingFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAyE;AACzE,gEAAqC;AAErC,2CAKqB;AAErB,iDAAmD;AACnD,qEAAkE;AAElE,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,IAAA,iCAAe,EAAa,MAAM,EAAE,KAAK,EAAE;QAC/D,MAAM,EAAE;YACN,UAAU,EAAE;gBACV,OAAO,EAAE,0B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AAoB,CAAC;QAC5E,IAAI,CAAC,iBAAiB;YAAE,SAAS;QAEjC,MAAM,gBAAgB,GAAG,qBAAqB;aAC3C,KAAK,CAAC,iBAAiB,CAAC;aACxB,KAAK,CAAC,UAAU,CAAC;aACjB,GAAG,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC,CAAC;QACjB,eAAe,GAAG,eAAe,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC3D,CAAC;IAED,SAAS,CAAC,QAAQ,CAAC;QACjB,OAAO,EAAE,mBAAO;QAChB,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;IAEH,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC;QAClC,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,iCAAgB;YACzB,MAAM,EAAE,eAAe;YACvB,UAAU,EAAE;gBACV,WAAW,EAAE,IAAI;aAClB;SACF,CAAC,CAAC;IAEL,IAAI,eAAe,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC;IAE9D,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -1,3 +1,4 @@
1
+ import BigNumber from 'bignumber.js';
1
2
  import { ID } from '../../utils/sui/structs/id';
2
3
  export type Credential = {
3
4
  acc_reward_per_share: string;
@@ -16,16 +17,6 @@ export type Pool = {
16
17
  staked_amount: string;
17
18
  start_time: string;
18
19
  };
19
- export type AlpMarket = {
20
- fun_mask: string;
21
- id: ID;
22
- lp_supply: {
23
- type: string;
24
- fields: {
25
- value: string;
26
- };
27
- };
28
- };
29
20
  export type Market = {
30
21
  id: ID;
31
22
  name: {
@@ -73,3 +64,174 @@ export type MarketFields = {
73
64
  };
74
65
  };
75
66
  };
67
+ export interface IMarketInfo {
68
+ lpSupply: string;
69
+ positionId: string;
70
+ vaultId: string;
71
+ symbolId: string;
72
+ referralId: string;
73
+ orderId: string;
74
+ rebaseFeeModel: string;
75
+ lpSupplyWithDecimals: number;
76
+ }
77
+ export interface IRebaseFeeModel {
78
+ base: number;
79
+ multiplier: number;
80
+ }
81
+ export interface IReservingFeeModel {
82
+ multiplier: number;
83
+ }
84
+ export interface IFundingFeeModel {
85
+ multiplier: number;
86
+ max: number;
87
+ }
88
+ export interface IVaultInfo {
89
+ liquidity: number;
90
+ reservedAmount: number;
91
+ unrealisedReservingFeeAmount: number;
92
+ accReservingRate: number;
93
+ enabled: boolean;
94
+ weight: number;
95
+ lastUpdate: number;
96
+ reservingFeeModel: IReservingFeeModel;
97
+ priceConfig: {
98
+ maxInterval: number;
99
+ maxConfidence: number;
100
+ precision: number;
101
+ feeder: string;
102
+ };
103
+ }
104
+ export interface ISymbolInfo {
105
+ openingSize: number;
106
+ openingAmount: number;
107
+ accFundingRate: number;
108
+ realisedPnl: number;
109
+ unrealisedFundingFeeValue: number;
110
+ openEnabled: boolean;
111
+ liquidateEnabled: boolean;
112
+ decreaseEnabled: boolean;
113
+ lastUpdate: number;
114
+ fundingFeeModel: IFundingFeeModel;
115
+ long: boolean;
116
+ priceConfig: {
117
+ maxInterval: number;
118
+ maxConfidence: number;
119
+ precision: number;
120
+ feeder: string;
121
+ };
122
+ }
123
+ export interface IPositionInfo {
124
+ id: string;
125
+ long: boolean;
126
+ owner: string;
127
+ version: number;
128
+ collateralToken: string;
129
+ indexToken: string;
130
+ collateralAmount: number;
131
+ positionAmount: number;
132
+ reservedAmount: number;
133
+ positionSize: number;
134
+ lastFundingRate: number;
135
+ lastReservingRate: number;
136
+ reservingFeeAmount: number;
137
+ fundingFeeValue: number;
138
+ closed: boolean;
139
+ openTimestamp: number;
140
+ openFeeBps: number;
141
+ }
142
+ export interface IPositionCapInfo {
143
+ positionCapId: string;
144
+ symbol0: string;
145
+ symbol1: string;
146
+ long: boolean;
147
+ }
148
+ export interface IOrderCapInfo {
149
+ orderCapId: string;
150
+ symbol0: string;
151
+ symbol1: string;
152
+ long: boolean;
153
+ positionId: string | null;
154
+ }
155
+ export interface IOrderInfo {
156
+ id: string;
157
+ capId: string;
158
+ executed: boolean;
159
+ owner: string;
160
+ collateralToken: string;
161
+ indexToken: string;
162
+ feeToken: string;
163
+ collateralPriceThreshold: number;
164
+ feeAmount: BigNumber;
165
+ long: boolean;
166
+ indexPrice: number;
167
+ openOrder?: {
168
+ reserveAmount: BigNumber;
169
+ collateralAmount: BigNumber;
170
+ openAmount: BigNumber;
171
+ };
172
+ decreaseOrder?: {
173
+ decreaseAmount: BigNumber;
174
+ takeProfit: boolean;
175
+ };
176
+ orderType: 'OPEN_POSITION' | 'DECREASE_POSITION';
177
+ createdAt: number;
178
+ v11Order: boolean;
179
+ }
180
+ export interface IMarketValuationInfo {
181
+ marketCap: number;
182
+ alpPrice: number;
183
+ alpSupply: number;
184
+ apr?: number;
185
+ }
186
+ export interface IPositionConfig {
187
+ decreaseFeeBps: number;
188
+ liquidationBonus: number;
189
+ liquidationThreshold: number;
190
+ maxLeverage: number;
191
+ minHoldingDuration: number;
192
+ openFeeBps: number;
193
+ maxReservedMultiplier: number;
194
+ minCollateralValue: number;
195
+ }
196
+ export interface IHistory {
197
+ owner: string;
198
+ txid: string;
199
+ id: string;
200
+ created: number;
201
+ eventName: string;
202
+ parsedDetail: {
203
+ [key: string]: any;
204
+ };
205
+ detailRaw: string;
206
+ volume: number;
207
+ network: string;
208
+ }
209
+ export interface IStaked {
210
+ credentials: ICredential[];
211
+ amount: bigint;
212
+ claimable: bigint;
213
+ }
214
+ export interface ICredential {
215
+ id: string;
216
+ lockUntil: number;
217
+ accRewardPerShare: bigint;
218
+ amount: bigint;
219
+ claimable: bigint;
220
+ }
221
+ export interface IStakePool {
222
+ id: string;
223
+ enabled: boolean;
224
+ lastUpdatedTime: number;
225
+ stakedAmount: bigint;
226
+ reward: bigint;
227
+ startTime: number;
228
+ endTime: number;
229
+ accRewardPerShare: bigint;
230
+ lockDuration: number;
231
+ }
232
+ export interface ICoin {
233
+ decimals: number;
234
+ module: string;
235
+ metadata: string;
236
+ treasury?: string | null;
237
+ }
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchers = exports.jobs = exports.platforms = void 0;
7
7
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
8
8
  const constants_1 = require("./constants");
9
- const v2Job_1 = __importDefault(require("./v2Job"));
9
+ // import v2Job from './v2Job';
10
10
  const getV2Fetcher_1 = __importDefault(require("./getV2Fetcher"));
11
11
  exports.platforms = [constants_1.platform];
12
- exports.jobs = [v2Job_1.default];
12
+ exports.jobs = [
13
+ /* v2Job */
14
+ ];
13
15
  exports.fetchers = [
14
16
  (0, getV2Fetcher_1.default)(portfolio_core_1.NetworkId.ethereum),
15
17
  (0, getV2Fetcher_1.default)(portfolio_core_1.NetworkId.avalanche),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/balancer/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAiE;AAGjE,2CAAuC;AACvC,oDAA4B;AAC5B,kEAA0C;AAE7B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,eAAK,CAAC,CAAC;AACtB,QAAA,QAAQ,GAAc;IACjC,IAAA,sBAAY,EAAC,0BAAS,CAAC,QAAQ,CAAC;IAChC,IAAA,sBAAY,EAAC,0BAAS,CAAC,SAAS,CAAC;IACjC,IAAA,sBAAY,EAAC,0BAAS,CAAC,OAAO,CAAC;CAChC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/balancer/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAiE;AAGjE,2CAAuC;AACvC,+BAA+B;AAC/B,kEAA0C;AAE7B,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU;AACzB,WAAW;CACZ,CAAC;AACW,QAAA,QAAQ,GAAc;IACjC,IAAA,sBAAY,EAAC,0BAAS,CAAC,QAAQ,CAAC;IAChC,IAAA,sBAAY,EAAC,0BAAS,CAAC,SAAS,CAAC;IACjC,IAAA,sBAAY,EAAC,0BAAS,CAAC,OAAO,CAAC;CAChC,CAAC"}