@sonarwatch/portfolio-plugins 0.14.8 → 0.14.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/CHANGELOG.md +1620 -1612
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/src/index.js +8 -0
  5. package/src/index.js.map +1 -1
  6. package/src/plugins/balancer/helpers/pools.js +21 -21
  7. package/src/plugins/cetus/clmmsFetcher.js +59 -55
  8. package/src/plugins/cetus/clmmsFetcher.js.map +1 -1
  9. package/src/plugins/cetus/farmsFetcher.js +66 -37
  10. package/src/plugins/cetus/farmsFetcher.js.map +1 -1
  11. package/src/plugins/cetus/helpers.d.ts +3 -1
  12. package/src/plugins/cetus/helpers.js +102 -1
  13. package/src/plugins/cetus/helpers.js.map +1 -1
  14. package/src/plugins/cetus/types.d.ts +28 -0
  15. package/src/plugins/cetus/types.js.map +1 -1
  16. package/src/plugins/loverflow/airdropClaimFetcher.d.ts +3 -0
  17. package/src/plugins/loverflow/airdropClaimFetcher.js +42 -0
  18. package/src/plugins/loverflow/airdropClaimFetcher.js.map +1 -0
  19. package/src/plugins/loverflow/constants.d.ts +6 -0
  20. package/src/plugins/loverflow/constants.js +16 -0
  21. package/src/plugins/loverflow/constants.js.map +1 -0
  22. package/src/plugins/loverflow/helpers.d.ts +2 -0
  23. package/src/plugins/loverflow/helpers.js +9 -0
  24. package/src/plugins/loverflow/helpers.js.map +1 -0
  25. package/src/plugins/loverflow/index.d.ts +6 -0
  26. package/src/plugins/loverflow/index.js +12 -0
  27. package/src/plugins/loverflow/index.js.map +1 -0
  28. package/src/plugins/loverflow/structs.d.ts +16 -0
  29. package/src/plugins/loverflow/structs.js +18 -0
  30. package/src/plugins/loverflow/structs.js.map +1 -0
  31. package/src/plugins/loverflow/types.d.ts +5 -0
  32. package/src/plugins/loverflow/types.js +3 -0
  33. package/src/plugins/loverflow/types.js.map +1 -0
  34. package/src/plugins/sandglass/constants.d.ts +1 -0
  35. package/src/plugins/sandglass/constants.js +8 -1
  36. package/src/plugins/sandglass/constants.js.map +1 -1
  37. package/src/plugins/sandglass/depositFetcher.js +11 -43
  38. package/src/plugins/sandglass/depositFetcher.js.map +1 -1
  39. package/src/plugins/sushiswap/helpers.js +24 -24
  40. package/src/plugins/uniswap-v2/helpers.js +22 -22
  41. package/src/plugins/zelo/constants.d.ts +5 -0
  42. package/src/plugins/zelo/constants.js +15 -0
  43. package/src/plugins/zelo/constants.js.map +1 -0
  44. package/src/plugins/zelo/index.d.ts +6 -0
  45. package/src/plugins/zelo/index.js +12 -0
  46. package/src/plugins/zelo/index.js.map +1 -0
  47. package/src/plugins/zelo/positionsFetcher.d.ts +3 -0
  48. package/src/plugins/zelo/positionsFetcher.js +40 -0
  49. package/src/plugins/zelo/positionsFetcher.js.map +1 -0
  50. package/src/plugins/zelo/structs.d.ts +11 -0
  51. package/src/plugins/zelo/structs.js +13 -0
  52. package/src/plugins/zelo/structs.js.map +1 -0
  53. package/src/plugins/zeta/airdropFetcher.js +14 -14
  54. package/src/utils/elementbuilder/AssetBuilder.d.ts +1 -1
  55. package/src/utils/elementbuilder/AssetBuilder.js +2 -2
  56. package/src/utils/elementbuilder/AssetBuilder.js.map +1 -1
  57. package/src/utils/elementbuilder/ElementBuilder.d.ts +2 -1
  58. package/src/utils/elementbuilder/ElementBuilder.js +5 -0
  59. package/src/utils/elementbuilder/ElementBuilder.js.map +1 -1
  60. package/src/utils/elementbuilder/LiquidityBuilder.js +1 -1
  61. package/src/utils/elementbuilder/LiquidityBuilder.js.map +1 -1
  62. package/src/utils/sei/constants.js +8 -8
  63. package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # @sonarwatch/portfolio-plugins
2
-
3
- This library is @sonarwatch/portfolio-plugins
1
+ # @sonarwatch/portfolio-plugins
2
+
3
+ This library is @sonarwatch/portfolio-plugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonarwatch/portfolio-plugins",
3
- "version": "0.14.8",
3
+ "version": "0.14.10",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "peerDependencies": {
package/src/index.js CHANGED
@@ -148,6 +148,8 @@ const joule_1 = require("./plugins/joule");
148
148
  const meso_1 = require("./plugins/meso");
149
149
  const loopscale_1 = require("./plugins/loopscale");
150
150
  const vaultka_1 = require("./plugins/vaultka");
151
+ const loverflow_1 = require("./plugins/loverflow");
152
+ const zelo_1 = require("./plugins/zelo");
151
153
  var constants_1 = require("./plugins/tokens/constants");
152
154
  Object.defineProperty(exports, "walletTokensPlatform", { enumerable: true, get: function () { return constants_1.walletTokensPlatform; } });
153
155
  Object.defineProperty(exports, "walletNftsPlatform", { enumerable: true, get: function () { return constants_1.walletNftsPlatform; } });
@@ -289,6 +291,8 @@ exports.platforms = [
289
291
  ...meso_1.platforms,
290
292
  ...loopscale_1.platforms,
291
293
  ...vaultka_1.platforms,
294
+ ...loverflow_1.platforms,
295
+ ...zelo_1.platforms,
292
296
  ];
293
297
  // JOBS //
294
298
  exports.jobs = [
@@ -414,6 +418,8 @@ exports.jobs = [
414
418
  ...meso_1.jobs,
415
419
  ...loopscale_1.jobs,
416
420
  ...vaultka_1.jobs,
421
+ ...loverflow_1.jobs,
422
+ ...zelo_1.jobs,
417
423
  ];
418
424
  // FETCHERS //
419
425
  exports.fetchers = [
@@ -540,6 +546,8 @@ exports.fetchers = [
540
546
  ...meso_1.fetchers,
541
547
  ...loopscale_1.fetchers,
542
548
  ...vaultka_1.fetchers,
549
+ ...loverflow_1.fetchers,
550
+ ...zelo_1.fetchers,
543
551
  ];
544
552
  exports.fetchersByAddressSystem = (0, getFetchersByAddressSystem_1.getFetchersByAddressSystem)(exports.fetchers);
545
553
  exports.airdropFetchers = [
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/plugins/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,wFAAqF;AACrF,wE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AG,iBAAc;IACjB,GAAG,gBAAa;IAChB,GAAG,gBAAa;IAChB,GAAG,eAAY;IACf,GAAG,kBAAe;IAClB,GAAG,kBAAe;IAClB,GAAG,mBAAgB;IACnB,GAAG,uBAAoB;IACvB,GAAG,mBAAgB;IACnB,GAAG,iBAAc;IACjB,GAAG,mBAAgB;IACnB,GAAG,kBAAe;IAClB,GAAG,iBAAc;IACjB,GAAG,iBAAc;IACjB,GAAG,kBAAe;IAClB,GAAG,oBAAiB;IACpB,GAAG,8BAA2B;IAC9B,GAAG,oBAAiB;IACpB,GAAG,kBAAe;IAClB,GAAG,kBAAe;IAClB,GAAG,kBAAe;IAClB,GAAG,iBAAc;IACjB,GAAG,mBAAgB;IACnB,GAAG,mBAAgB;IACnB,GAAG,gBAAa;IAChB,GAAG,mBAAgB;IACnB,GAAG,kBAAe;IAClB,GAAG,gBAAa;IAChB,GAAG,oBAAiB;IACpB,GAAG,mBAAgB;IACnB,GAAG,kBAAe;IAClB,GAAG,mBAAgB;IACnB,GAAG,mBAAgB;IACnB,GAAG,oBAAiB;IACpB,GAAG,iBAAc;IACjB,GAAG,gBAAa;IAChB,GAAG,eAAY;IACf,GAAG,oBAAiB;IACpB,GAAG,kBAAe;CACnB,CAAC;AACW,QAAA,uBAAuB,GAAG,IAAA,uDAA0B,EAAC,gBAAQ,CAAC,CAAC;AAE/D,QAAA,eAAe,GAAqB;IAC/C,GAAG,yBAAsB;IACzB,GAAG,wBAAqB;IACxB,GAAG,yBAAsB;IACzB,sBAAmB;IACnB,sBAAmB;IACnB,yBAAsB;IACtB,sBAAmB;IACnB,GAAG,0BAAuB;CAC3B,CAAC;AACW,QAAA,8BAA8B,GACzC,IAAA,uDAA0B,EAAC,uBAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/plugins/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,wFAAqF;AACrF,wEAAgD;AAChD,6CAI0B;AAC1B,y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oolsV2 = void 0;
36
36
  const graphql_request_1 = __importStar(require("graphql-request"));
37
37
  function getBalancerPoolsV2(url) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- const query = (0, graphql_request_1.gql) `
40
- query pools {
41
- pools(
42
- first: 1000
43
- orderBy: totalLiquidity
44
- orderDirection: desc
45
- where: { totalLiquidity_gt: "500" }
46
- ) {
47
- id
48
- address
49
- symbol
50
- totalLiquidity
51
- totalShares
52
- tokens {
53
- balance
54
- decimals
55
- symbol
56
- address
57
- }
58
- }
59
- }
39
+ const query = (0, graphql_request_1.gql) `
40
+ query pools {
41
+ pools(
42
+ first: 1000
43
+ orderBy: totalLiquidity
44
+ orderDirection: desc
45
+ where: { totalLiquidity_gt: "500" }
46
+ ) {
47
+ id
48
+ address
49
+ symbol
50
+ totalLiquidity
51
+ totalShares
52
+ tokens {
53
+ balance
54
+ decimals
55
+ symbol
56
+ address
57
+ }
58
+ }
59
+ }
60
60
  `;
61
61
  const res = yield (0, graphql_request_1.default)(url, query);
62
62
  const pools = res.pools;
@@ -17,10 +17,10 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
17
  const constants_1 = require("./constants");
18
18
  const clients_1 = require("../../utils/clients");
19
19
  const helpers_1 = require("./helpers");
20
- const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
21
20
  const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
22
21
  const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
23
22
  const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
23
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
24
24
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
25
25
  const client = (0, clients_1.getClientSui)();
26
26
  const ownerRes = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
@@ -48,74 +48,78 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
48
48
  if (clmmPositions.length === 0)
49
49
  return [];
50
50
  const poolsIds = clmmPositions.map((position) => position.pool);
51
- // const pools = await cache.getItems<Pool>(poolsIds, {
52
- // prefix: clmmPoolsPrefix,
53
- // networkId: NetworkId.sui,
54
- // });
55
51
  const poolsById = new Map();
56
- // pools.forEach((pool) => {
57
- // if (pool) {
58
- // poolsById.set(pool.poolAddress, pool);
59
- // }
60
- // });
61
- // if (poolsById.size === 0) return [];
62
- const mints = [];
63
52
  const poolsObjects = yield (0, multiGetObjects_1.multiGetObjects)(client, [...new Set(poolsIds)]);
64
53
  poolsObjects.forEach((poolObj) => {
65
54
  var _a, _b;
66
55
  if ((_b = (_a = poolObj.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields) {
67
56
  const pool = (0, helpers_1.getPoolFromObject)(poolObj);
68
57
  poolsById.set(poolObj.data.objectId, pool);
69
- mints.push(pool.coinTypeA, pool.coinTypeB);
70
58
  }
71
59
  });
72
- const tokenPriceById = yield cache.getTokenPricesAsMap(mints, portfolio_core_1.NetworkId.sui);
73
- const assets = [];
74
- let totalLiquidityValue = 0;
75
- for (const clmmPosition of clmmPositions) {
60
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
61
+ const [allFees, allRewards] = yield Promise.all([
62
+ (0, helpers_1.fetchPosFeeAmount)(clmmPositions.map((clmmPosition) => ({
63
+ poolAddress: clmmPosition.pool,
64
+ positionId: clmmPosition.pos_object_id,
65
+ coinTypeA: clmmPosition.coin_type_a,
66
+ coinTypeB: clmmPosition.coin_type_b,
67
+ }))),
68
+ (0, helpers_1.fetchPosRewardersAmount)(clmmPositions
69
+ .map((clmmPosition) => {
70
+ if (!clmmPosition)
71
+ return null;
72
+ const pool = poolsById.get(clmmPosition.pool);
73
+ if (!pool)
74
+ return null;
75
+ return {
76
+ poolAddress: clmmPosition.pool,
77
+ positionId: clmmPosition.pos_object_id,
78
+ coinTypeA: clmmPosition.coin_type_a,
79
+ coinTypeB: clmmPosition.coin_type_b,
80
+ rewarderInfo: pool.rewarder_infos,
81
+ };
82
+ })
83
+ .filter((v) => v !== null)),
84
+ ]);
85
+ clmmPositions.forEach((clmmPosition, i) => {
76
86
  const pool = poolsById.get(clmmPosition.pool);
77
87
  if (!pool)
78
- continue;
88
+ return;
89
+ const fees = allFees[i];
90
+ const rewards = allRewards[i];
79
91
  const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(clmmPosition.liquidity), pool.current_tick_index, clmmPosition.tick_lower_index, clmmPosition.tick_upper_index, false);
80
- const tokenPriceA = tokenPriceById.get(pool.coinTypeA);
81
- if (!tokenPriceA)
82
- continue;
83
- const assetTokenA = (0, tokenPriceToAssetToken_1.default)(pool.coinTypeA, tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceA);
84
- const tokenPriceB = tokenPriceById.get(pool.coinTypeB);
85
- if (!tokenPriceB)
86
- continue;
87
- const assetTokenB = (0, tokenPriceToAssetToken_1.default)(pool.coinTypeB, tokenAmountB.dividedBy(Math.pow(10, tokenPriceB.decimals)).toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceB);
88
- if (!assetTokenA ||
89
- !assetTokenB ||
90
- assetTokenA.value === null ||
91
- assetTokenB.value === null)
92
- continue;
93
- const value = assetTokenA.value + assetTokenB.value;
94
- assets.push({
95
- assets: [assetTokenA, assetTokenB],
96
- assetsValue: value,
97
- rewardAssets: [],
98
- rewardAssetsValue: 0,
99
- value,
100
- yields: [],
101
- });
102
- totalLiquidityValue += value;
103
- }
104
- if (assets.length === 0)
105
- return [];
106
- return [
107
- {
108
- type: portfolio_core_1.PortfolioElementType.liquidity,
109
- networkId: portfolio_core_1.NetworkId.sui,
110
- platformId: constants_1.platformId,
92
+ const element = elementRegistry.addElementLiquidity({
111
93
  label: 'LiquidityPool',
112
94
  tags: ['Concentrated'],
113
- value: totalLiquidityValue,
114
- data: {
115
- liquidities: assets,
116
- },
117
- },
118
- ];
95
+ });
96
+ const liquidity = element.addLiquidity();
97
+ liquidity.addAsset({
98
+ address: pool.coinTypeA,
99
+ amount: tokenAmountA,
100
+ });
101
+ liquidity.addAsset({
102
+ address: pool.coinTypeB,
103
+ amount: tokenAmountB,
104
+ });
105
+ liquidity.addRewardAsset({
106
+ address: pool.coinTypeA,
107
+ amount: fees.feeOwedA,
108
+ });
109
+ liquidity.addRewardAsset({
110
+ address: pool.coinTypeB,
111
+ amount: fees.feeOwedB,
112
+ });
113
+ rewards.rewarderAmountOwed.forEach((rewarderAmountOwed) => {
114
+ liquidity.addRewardAsset({
115
+ address: rewarderAmountOwed.coin_address,
116
+ amount: rewarderAmountOwed.amount_owed,
117
+ });
118
+ });
119
+ if (tokenAmountA.isZero() || tokenAmountB.isZero())
120
+ element.addTag('Out Of Range');
121
+ });
122
+ return elementRegistry.getElements(cache);
119
123
  });
120
124
  const fetcher = {
121
125
  id: `${constants_1.platformId}-clmms`,
@@ -1 +1 @@
1
- {"version":3,"file":"clmmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/clmmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAAsE;AACtE,iDAAmD;AACnD,uCAImB;AAGnB,qGAA6E;AAC7E,wFAAyF;AACzF,qEAAkE;AAClE,qEAAkE;AAElE,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,MAAM,IAAA,iCAAe,EAAC,MAAM,EAAE,KAAK,EAAE;QACpD,OAAO,EAAE;YACP,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,IAAI;SAChB;QAC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C,YAAY,EAAE,CAAC;QAEzC,SAAS,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC;QAEH,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,QAAQ;SACtB,CAAC,CAAC;QAEH,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,QAAQ;SACtB,CAAC,CAAC;QAEH,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACxD,SAAS,CAAC,cAAc,CAAC;gBACvB,OAAO,EAAE,kBAAkB,CAAC,YAAY;gBACxC,MAAM,EAAE,kBAAkB,CAAC,WAAW;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,YAAY,CAAC,MAAM,EAAE;YAChD,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -16,11 +16,12 @@ 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 tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
20
19
  const getOwnedObjects_1 = require("../../utils/sui/getOwnedObjects");
21
20
  const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
22
21
  const bitsToNumber_1 = require("../../utils/sui/bitsToNumber");
23
22
  const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
23
+ const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
24
+ const helpers_1 = require("./helpers");
24
25
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
25
26
  const client = (0, clients_1.getClientSui)();
26
27
  const positions = yield (0, getOwnedObjects_1.getOwnedObjects)(client, owner, {
@@ -33,7 +34,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
33
34
  });
34
35
  if (positions.length === 0)
35
36
  return [];
36
- const [farms, pools] = yield Promise.all([
37
+ const [farms, pools, allFees] = yield Promise.all([
37
38
  (0, multiGetObjects_1.multiGetObjects)(client, positions
38
39
  .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.pool_id; })
39
40
  .filter((s) => s !== null)),
@@ -45,14 +46,41 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
45
46
  networkId: portfolio_core_1.NetworkId.sui,
46
47
  })
47
48
  .then((res) => res.filter((p) => p !== null)),
49
+ (0, helpers_1.fetchPosFeeAmount)(positions
50
+ .map((position) => {
51
+ var _a, _b;
52
+ const clmmPosition = (_b = (_a = position.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.clmm_postion.fields;
53
+ if (!clmmPosition)
54
+ return null;
55
+ return {
56
+ poolAddress: clmmPosition.pool,
57
+ positionId: clmmPosition.id.id,
58
+ coinTypeA: clmmPosition.coin_type_a.fields.name,
59
+ coinTypeB: clmmPosition.coin_type_b.fields.name,
60
+ };
61
+ })
62
+ .filter((v) => v !== null)),
48
63
  ]);
49
- const mints = [];
50
- pools.forEach((pool) => {
51
- mints.push((0, portfolio_core_1.formatMoveTokenAddress)(pool.coinTypeA), (0, portfolio_core_1.formatMoveTokenAddress)(pool.coinTypeB));
52
- });
53
- const elements = [];
54
- const tokenPrices = yield cache.getTokenPricesAsMap(mints, portfolio_core_1.NetworkId.sui);
55
- positions.forEach((position) => {
64
+ const allRewards = yield (0, helpers_1.fetchPosRewardersAmount)(positions
65
+ .map((position) => {
66
+ var _a, _b;
67
+ const clmmPosition = (_b = (_a = position.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.clmm_postion.fields;
68
+ if (!clmmPosition)
69
+ return null;
70
+ const pool = pools.find((p) => p.poolAddress === clmmPosition.pool);
71
+ if (!pool)
72
+ return null;
73
+ return {
74
+ poolAddress: clmmPosition.pool,
75
+ positionId: clmmPosition.id.id,
76
+ coinTypeA: clmmPosition.coin_type_a.fields.name,
77
+ coinTypeB: clmmPosition.coin_type_b.fields.name,
78
+ rewarderInfo: pool.rewarder_infos,
79
+ };
80
+ })
81
+ .filter((v) => v !== null));
82
+ const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.sui, constants_1.platformId);
83
+ positions.forEach((position, i) => {
56
84
  var _a, _b, _c, _d;
57
85
  if (!((_b = (_a = position.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields))
58
86
  return;
@@ -66,6 +94,8 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
66
94
  });
67
95
  if (!pool)
68
96
  return;
97
+ const fees = allFees[i];
98
+ const rewards = allRewards[i];
69
99
  const tickLowerIndex = (0, bitsToNumber_1.bitsToNumber)(position.data.content.fields.clmm_postion.fields.tick_lower_index.fields
70
100
  .bits);
71
101
  const tickUpperIndex = (0, bitsToNumber_1.bitsToNumber)(position.data.content.fields.clmm_postion.fields.tick_upper_index.fields
@@ -75,37 +105,36 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
75
105
  const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(new bignumber_js_1.default(position.data.content.fields.clmm_postion.fields.liquidity), pool.current_tick_index, tickLowerIndex < effectiveTickLower ? effectiveTickLower : tickLowerIndex, tickUpperIndex < effectiveTickUpper ? tickUpperIndex : effectiveTickUpper, false);
76
106
  if (tokenAmountA.isZero() && tokenAmountB.isZero())
77
107
  return;
78
- const tokenPriceA = tokenPrices.get(pool.coinTypeA);
79
- const tokenPriceB = tokenPrices.get(pool.coinTypeB);
80
- const assets = [];
81
- if (tokenAmountA.isGreaterThan(0) && tokenPriceA) {
82
- assets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceA));
83
- }
84
- if (tokenAmountB.isGreaterThan(0) && tokenPriceB) {
85
- assets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, tokenAmountB.dividedBy(Math.pow(10, tokenPriceB.decimals)).toNumber(), portfolio_core_1.NetworkId.sui, tokenPriceB));
86
- }
87
- const liquidities = [
88
- {
89
- assets,
90
- assetsValue: (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value)),
91
- rewardAssets: [],
92
- rewardAssetsValue: 0,
93
- value: (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value)),
94
- yields: [],
95
- },
96
- ];
97
- elements.push({
98
- type: portfolio_core_1.PortfolioElementType.liquidity,
99
- networkId: portfolio_core_1.NetworkId.sui,
100
- platformId: constants_1.platformId,
108
+ const element = elementRegistry.addElementLiquidity({
101
109
  label: 'Farming',
102
- value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((a) => a.value)),
103
- data: {
104
- liquidities,
105
- },
106
110
  });
111
+ const liquidity = element.addLiquidity();
112
+ liquidity.addAsset({
113
+ address: pool.coinTypeA,
114
+ amount: tokenAmountA,
115
+ });
116
+ liquidity.addAsset({
117
+ address: pool.coinTypeB,
118
+ amount: tokenAmountB,
119
+ });
120
+ liquidity.addRewardAsset({
121
+ address: pool.coinTypeA,
122
+ amount: fees.feeOwedA,
123
+ });
124
+ liquidity.addRewardAsset({
125
+ address: pool.coinTypeB,
126
+ amount: fees.feeOwedB,
127
+ });
128
+ rewards.rewarderAmountOwed.forEach((rewarderAmountOwed) => {
129
+ liquidity.addRewardAsset({
130
+ address: rewarderAmountOwed.coin_address,
131
+ amount: rewarderAmountOwed.amount_owed,
132
+ });
133
+ });
134
+ if (tokenAmountA.isZero() || tokenAmountB.isZero())
135
+ element.addTag('Out Of Range');
107
136
  });
108
- return elements;
137
+ return elementRegistry.getElements(cache);
109
138
  });
110
139
  const fetcher = {
111
140
  id: `${constants_1.platformId}-farms`,
@@ -1 +1 @@
1
- {"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/cetus/farmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAGrC,2CAAuE;AACvE,iDAAmD;AAEnD,qGAA6E;AAC7E,qEAAkE;AAClE,qEAAkE;AAClE,+DAA4D;AAC5D,wFAAyF;AAEzF,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,MAAM,IAAA,iCAAe,EAAqB,MAAM,EAAE,KAAK,EAAE;QACzE,OAAO,EAAE;YACP,WAAW,EAAE,IAAI;SAClB;QACD,MAAM,EAAE;YACN,UAAU,EAAE,uBAAW;SACxB;KACF,CAAC,CAAC;IACH,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEtC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,C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AAC,SAAS;YACvB,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,YAAY;SACrB,CAAC,CAAC;QAEH,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,QAAQ;SACtB,CAAC,CAAC;QAEH,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,CAAC,QAAQ;SACtB,CAAC,CAAC;QAEH,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACxD,SAAS,CAAC,cAAc,CAAC;gBACvB,OAAO,EAAE,kBAAkB,CAAC,YAAY;gBACxC,MAAM,EAAE,kBAAkB,CAAC,WAAW;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,YAAY,CAAC,MAAM,EAAE;YAChD,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import Decimal from 'decimal.js';
2
2
  import BigNumber from 'bignumber.js';
3
- import { NFT, Pool, Position, SuiAddressType, SuiStructTag } from './types';
3
+ import { CollectFeesQuote, FetchPosFeeParams, FetchPosRewardParams, NFT, Pool, Position, PosRewarderResult, SuiAddressType, SuiStructTag } from './types';
4
4
  import { ObjectResponse } from '../../utils/sui/types';
5
5
  export declare function fromX64(num: BigNumber): Decimal;
6
6
  export declare function composeType(address: string, generics: SuiAddressType[]): SuiAddressType;
@@ -14,3 +14,5 @@ export declare function asIntN(int: bigint, bits?: number): number;
14
14
  export declare function getPoolFromObject(object: ObjectResponse<unknown>): Pool;
15
15
  export declare function buildPosition(objects: ObjectResponse<unknown>): Position;
16
16
  export declare function buildNFT(objects: ObjectResponse<unknown>): NFT;
17
+ export declare const fetchPosFeeAmount: (params: FetchPosFeeParams[]) => Promise<CollectFeesQuote[]>;
18
+ export declare const fetchPosRewardersAmount: (params: FetchPosRewardParams[]) => Promise<PosRewarderResult[]>;
@@ -1,18 +1,29 @@
1
1
  "use strict";
2
2
  /* eslint-disable no-param-reassign */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
3
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
14
  };
6
15
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.buildNFT = exports.buildPosition = exports.getPoolFromObject = exports.asIntN = exports.normalizeCoinType = exports.buildPoolName = exports.isSuiCoin = exports.extractStructTagFromType = exports.composeType = exports.fromX64 = void 0;
16
+ exports.fetchPosRewardersAmount = exports.fetchPosFeeAmount = exports.buildNFT = exports.buildPosition = exports.getPoolFromObject = exports.asIntN = exports.normalizeCoinType = exports.buildPoolName = exports.isSuiCoin = exports.extractStructTagFromType = exports.composeType = exports.fromX64 = void 0;
8
17
  const decimal_js_1 = __importDefault(require("decimal.js"));
9
18
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
10
19
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
11
20
  const utils_1 = require("@mysten/sui/utils");
21
+ const transactions_1 = require("@mysten/sui/transactions");
12
22
  const types_1 = require("./types");
13
23
  const getObjectDeletedResponse_1 = require("../../utils/sui/getObjectDeletedResponse");
14
24
  const getObjectNotExistsResponse_1 = require("../../utils/sui/getObjectNotExistsResponse");
15
25
  const bitsToNumber_1 = require("../../utils/sui/bitsToNumber");
26
+ const clients_1 = require("../../utils/clients");
16
27
  function fromX64(num) {
17
28
  return new decimal_js_1.default(num.toString()).mul(decimal_js_1.default.pow(2, -64));
18
29
  }
@@ -203,4 +214,94 @@ function buildNFT(objects) {
203
214
  return nft;
204
215
  }
205
216
  exports.buildNFT = buildNFT;
217
+ const fetchPosFeeAmount = (params) => __awaiter(void 0, void 0, void 0, function* () {
218
+ var _a, _b;
219
+ const tx = new transactions_1.Transaction();
220
+ for (const paramItem of params) {
221
+ const typeArguments = [paramItem.coinTypeA, paramItem.coinTypeB];
222
+ const args = [
223
+ tx.object('0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f'),
224
+ tx.object(paramItem.poolAddress),
225
+ tx.pure.address(paramItem.positionId),
226
+ ];
227
+ tx.moveCall({
228
+ target: `0x8faab90228e4c4df91c41626bbaefa19fc25c514405ac64de54578dec9e6f5ee::fetcher_script::fetch_position_fees`,
229
+ arguments: args,
230
+ typeArguments,
231
+ });
232
+ }
233
+ const simulateRes = yield (0, clients_1.getClientSui)().devInspectTransactionBlock({
234
+ transactionBlock: tx,
235
+ sender: simulationAccount,
236
+ });
237
+ if (simulateRes.error != null) {
238
+ throw new Error(`fetch position fee error code: ${(_a = simulateRes.error) !== null && _a !== void 0 ? _a : 'unknown error'}, please check config and postion and pool object ids`);
239
+ }
240
+ const valueData = (_b = simulateRes.events) === null || _b === void 0 ? void 0 : _b.filter((item) => extractStructTagFromType(item.type).name === `FetchPositionFeesEvent`);
241
+ if (valueData.length === 0) {
242
+ return [];
243
+ }
244
+ const result = [];
245
+ for (let i = 0; i < valueData.length; i += 1) {
246
+ const { parsedJson } = valueData[i];
247
+ const posRrewarderResult = {
248
+ feeOwedA: new bignumber_js_1.default(parsedJson.fee_owned_a),
249
+ feeOwedB: new bignumber_js_1.default(parsedJson.fee_owned_b),
250
+ position_id: parsedJson.position_id,
251
+ };
252
+ result.push(posRrewarderResult);
253
+ }
254
+ return result;
255
+ });
256
+ exports.fetchPosFeeAmount = fetchPosFeeAmount;
257
+ const simulationAccount = '0x326ce9894f08dcaa337fa232641cc34db957aec9ff6614c1186bc9a7508df0bb';
258
+ const fetchPosRewardersAmount = (params) => __awaiter(void 0, void 0, void 0, function* () {
259
+ var _c, _d;
260
+ const tx = new transactions_1.Transaction();
261
+ for (const paramItem of params) {
262
+ const typeArguments = [paramItem.coinTypeA, paramItem.coinTypeB];
263
+ const args = [
264
+ tx.object('0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f'),
265
+ tx.object(paramItem.poolAddress),
266
+ tx.pure.address(paramItem.positionId),
267
+ tx.object(portfolio_core_1.suiClockAddress),
268
+ ];
269
+ tx.moveCall({
270
+ target: `0x8faab90228e4c4df91c41626bbaefa19fc25c514405ac64de54578dec9e6f5ee::fetcher_script::fetch_position_rewards`,
271
+ arguments: args,
272
+ typeArguments,
273
+ });
274
+ }
275
+ const simulateRes = yield (0, clients_1.getClientSui)().devInspectTransactionBlock({
276
+ transactionBlock: tx,
277
+ sender: simulationAccount,
278
+ });
279
+ if (simulateRes.error != null) {
280
+ throw new Error(`fetch position rewards error code: ${(_c = simulateRes.error) !== null && _c !== void 0 ? _c : 'unknown error'}, please check config and params`);
281
+ }
282
+ const valueData = (_d = simulateRes.events) === null || _d === void 0 ? void 0 : _d.filter((item) => extractStructTagFromType(item.type).name === `FetchPositionRewardsEvent`);
283
+ if (valueData.length === 0) {
284
+ return [];
285
+ }
286
+ if (valueData.length !== params.length) {
287
+ throw new Error('valueData.length !== params.pools.length');
288
+ }
289
+ const result = [];
290
+ for (let i = 0; i < valueData.length; i += 1) {
291
+ const posRrewarderResult = {
292
+ poolAddress: params[i].poolAddress,
293
+ positionId: params[i].positionId,
294
+ rewarderAmountOwed: [],
295
+ };
296
+ for (let j = 0; j < params[i].rewarderInfo.length; j += 1) {
297
+ posRrewarderResult.rewarderAmountOwed.push({
298
+ amount_owed: new bignumber_js_1.default(valueData[i].parsedJson.data[j]),
299
+ coin_address: params[i].rewarderInfo[j].coinAddress,
300
+ });
301
+ }
302
+ result.push(posRrewarderResult);
303
+ }
304
+ return result;
305
+ });
306
+ exports.fetchPosRewardersAmount = fetchPosRewardersAmount;
206
307
  //# sourceMappingURL=helpers.js.map