@sonarwatch/portfolio-plugins 0.12.157 → 0.12.158

Sign up to get free protection for your applications and to get access to all the features.
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.12.157",
3
+ "version": "0.12.158",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "peerDependencies": {
@@ -36,27 +36,27 @@ exports.getBalancerPoolsV2 = 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;
@@ -120,7 +120,6 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
120
120
  const positionData = (0, dlmmHelper_1.processPosition)(constants_1.dlmmProgramId, positionVersion, lbPairAcc, account, baseTokenDecimal, quoteTokenDecimal, lowerBinArray, upperBinArray);
121
121
  const assets = [];
122
122
  const rewardAssets = [];
123
- const tags = [];
124
123
  if (positionData &&
125
124
  (!positionData.totalXAmount.isZero() ||
126
125
  !positionData.totalYAmount.isZero())) {
@@ -142,6 +141,10 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
142
141
  rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardY.address, positionData.rewardTwo
143
142
  .dividedBy(Math.pow(10, tokenPriceRewardY.decimals))
144
143
  .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardY));
144
+ if (positionData.totalXAmount.isZero())
145
+ assets[0].attributes.tags = ['Out Of Range'];
146
+ if (positionData.totalYAmount.isZero())
147
+ assets[1].attributes.tags = ['Out Of Range'];
145
148
  const liquidities = [
146
149
  {
147
150
  assets,
@@ -152,9 +155,6 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
152
155
  yields: [],
153
156
  },
154
157
  ];
155
- const activeBinInPosition = positionData.positionBinData.find((bin) => bin.binXAmount !== '0' && bin.binYAmount !== '0');
156
- if (!activeBinInPosition)
157
- tags.push('Out Of Range');
158
158
  elements.push({
159
159
  type: portfolio_core_1.PortfolioElementType.liquidity,
160
160
  label: 'LiquidityPool',
@@ -162,7 +162,6 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
162
162
  platformId: constants_1.platformId,
163
163
  value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((a) => a.value)),
164
164
  name: 'DLMM',
165
- tags,
166
165
  data: {
167
166
  liquidities,
168
167
  },
@@ -1 +1 @@
1
- {"version":3,"file":"dlmmPositionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/meteora/dlmmPositionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAGrC,2CAAwD;AACxD,iDAAsD;AACtD,+CAI4B;AAC5B,qCAOkB;AAClB,uCAGmB;AACn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AK,EAAE,IAAA,+BAAc,EACnB,CAAC,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CACzD;oBACD,MAAM,EAAE,EAAE;iBACX;aACF,CAAC;YAEF,MAAM,mBAAmB,GAAG,YAAY,CAAC,eAAe,CAAC,IAAI,CAC3D,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,KAAK,GAAG,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,CAC1D,CAAC;YACF,IAAI,CAAC,mBAAmB;gBAAE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAEpD,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,KAAK,EAAE,eAAe;gBACtB,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU,EAAV,sBAAU;gBACV,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,EAAE,MAAM;gBACZ,IAAI;gBACJ,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,iBAAiB;IAClC,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"dlmmPositionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/meteora/dlmmPositionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAGrC,2CAAwD;AAC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yB;gBACxC;oBACE,MAAM;oBACN,WAAW,EAAE,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBAC/D,YAAY;oBACZ,iBAAiB,EAAE,IAAA,+BAAc,EAC/B,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CACzC;oBACD,KAAK,EAAE,IAAA,+BAAc,EACnB,CAAC,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CACzD;oBACD,MAAM,EAAE,EAAE;iBACX;aACF,CAAC;YAEF,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,KAAK,EAAE,eAAe;gBACtB,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU,EAAV,sBAAU;gBACV,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,iBAAiB;IAClC,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -21,6 +21,7 @@ const solana_1 = require("../../utils/solana");
21
21
  const clients_1 = require("../../utils/clients");
22
22
  const clmms_1 = require("./structs/clmms");
23
23
  const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
24
+ const helpers_1 = require("./helpers");
24
25
  function getRaydiumCLMMPositions(cache, nfts) {
25
26
  return __awaiter(this, void 0, void 0, function* () {
26
27
  const client = (0, clients_1.getClientSolana)();
@@ -41,8 +42,36 @@ function getRaydiumCLMMPositions(cache, nfts) {
41
42
  prefix: constants_1.poolStatesPrefix,
42
43
  networkId: portfolio_core_1.NetworkId.solana,
43
44
  });
44
- const assets = [];
45
- let totalLiquidityValue = 0;
45
+ const mints = new Set();
46
+ personalPositionsInfo.forEach((personalPositionInfo, index) => {
47
+ if (!personalPositionInfo)
48
+ return;
49
+ const poolStateInfo = poolStatesInfo[index];
50
+ if (!poolStateInfo)
51
+ return;
52
+ mints.add(poolStateInfo.tokenMint0.toString());
53
+ mints.add(poolStateInfo.tokenMint1.toString());
54
+ poolStateInfo.rewardInfos.forEach((ri) => {
55
+ if (ri.tokenMint.toString() !== '11111111111111111111111111111111') {
56
+ mints.add(ri.tokenMint.toString());
57
+ }
58
+ });
59
+ });
60
+ const [tickArrays, tokenPrices] = yield Promise.all([
61
+ Promise.all(personalPositionsInfo.map((personalPositionInfo, index) => {
62
+ if (!personalPositionInfo)
63
+ return [];
64
+ const poolStateInfo = poolStatesInfo[index];
65
+ if (!poolStateInfo)
66
+ return [];
67
+ return (0, solana_1.getParsedMultipleAccountsInfo)(client, clmms_1.tickArrayStatetruct, [
68
+ (0, helpers_1.getTickArrayAddress)(constants_1.raydiumProgram.toString(), poolStateInfo.pubkey.toString(), personalPositionInfo.tickLowerIndex, poolStateInfo.tickSpacing),
69
+ (0, helpers_1.getTickArrayAddress)(constants_1.raydiumProgram.toString(), poolStateInfo.pubkey.toString(), personalPositionInfo.tickUpperIndex, poolStateInfo.tickSpacing),
70
+ ]);
71
+ })),
72
+ cache.getTokenPricesAsMap([...Array.from(mints)], portfolio_core_1.NetworkId.solana),
73
+ ]);
74
+ const liquidities = [];
46
75
  for (let index = 0; index < personalPositionsInfo.length; index++) {
47
76
  const poolStateInfo = poolStatesInfo[index];
48
77
  if (!poolStateInfo)
@@ -57,31 +86,49 @@ function getRaydiumCLMMPositions(cache, nfts) {
57
86
  const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(personalPositionInfo.liquidity, poolStateInfo.tickCurrent, personalPositionInfo.tickLowerIndex, personalPositionInfo.tickUpperIndex, false);
58
87
  if (!tokenAmountA || !tokenAmountB)
59
88
  continue;
60
- const tokenPriceA = yield cache.getTokenPrice(poolStateInfo.tokenMint0.toString(), portfolio_core_1.NetworkId.solana);
61
- if (!tokenPriceA)
62
- continue;
63
- const assetTokenA = (0, tokenPriceToAssetToken_1.default)(poolStateInfo.tokenMint0.toString(), tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA);
64
- const tokenPriceB = yield cache.getTokenPrice(poolStateInfo.tokenMint1.toString(), portfolio_core_1.NetworkId.solana);
65
- if (!tokenPriceB)
89
+ const tokenPriceA = tokenPrices.get(poolStateInfo.tokenMint0.toString());
90
+ const tokenPriceB = tokenPrices.get(poolStateInfo.tokenMint1.toString());
91
+ if (!tokenPriceA || !tokenPriceB)
66
92
  continue;
67
- const assetTokenB = (0, tokenPriceToAssetToken_1.default)(poolStateInfo.tokenMint1.toString(), tokenAmountB.dividedBy(Math.pow(10, tokenPriceB.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB);
93
+ const assetTokenA = (0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA);
94
+ const assetTokenB = (0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, tokenAmountB.dividedBy(Math.pow(10, tokenPriceB.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB);
68
95
  if (!assetTokenB ||
69
96
  !assetTokenA ||
70
97
  assetTokenB.value === null ||
71
98
  assetTokenA.value === null)
72
99
  continue;
73
- const value = assetTokenB.value + assetTokenA.value;
74
- assets.push({
75
- assets: [assetTokenA, assetTokenB],
76
- assetsValue: value,
77
- rewardAssets: [],
78
- rewardAssetsValue: 0,
100
+ if (tokenAmountA.isZero())
101
+ assetTokenA.attributes.tags = ['Out Of Range'];
102
+ if (tokenAmountB.isZero())
103
+ assetTokenB.attributes.tags = ['Out Of Range'];
104
+ const rewardAssets = [];
105
+ const rewardBalances = (0, helpers_1.getRewardBalance)(personalPositionInfo, poolStateInfo, tickArrays[index]);
106
+ rewardBalances.forEach((rewardBalance, i) => {
107
+ if (rewardBalance.isZero() ||
108
+ poolStateInfo.rewardInfos[i].tokenMint.toString() ===
109
+ '11111111111111111111111111111111')
110
+ return;
111
+ const rewardTokenPrice = tokenPrices.get(poolStateInfo.rewardInfos[i].tokenMint.toString());
112
+ if (!rewardTokenPrice)
113
+ return;
114
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(poolStateInfo.rewardInfos[i].tokenMint.toString(), rewardBalance.dividedBy(Math.pow(10, rewardTokenPrice.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, rewardTokenPrice));
115
+ });
116
+ const assets = [assetTokenA, assetTokenB];
117
+ const assetsValue = (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value));
118
+ const rewardAssetsValue = (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((a) => a.value));
119
+ const value = (0, portfolio_core_1.getUsdValueSum)([...assets, ...rewardAssets].map((a) => a.value));
120
+ if (!value)
121
+ continue;
122
+ liquidities.push({
123
+ assets,
124
+ assetsValue,
125
+ rewardAssets,
126
+ rewardAssetsValue,
79
127
  value,
80
128
  yields: [],
81
129
  });
82
- totalLiquidityValue += value;
83
130
  }
84
- if (assets.length === 0)
131
+ if (liquidities.length === 0)
85
132
  return [];
86
133
  const elements = [];
87
134
  elements.push({
@@ -90,9 +137,9 @@ function getRaydiumCLMMPositions(cache, nfts) {
90
137
  platformId: constants_1.platformId,
91
138
  label: 'LiquidityPool',
92
139
  name: 'Concentrated',
93
- value: totalLiquidityValue,
140
+ value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((a) => a.value)),
94
141
  data: {
95
- liquidities: assets,
142
+ liquidities,
96
143
  },
97
144
  });
98
145
  return elements;
@@ -1 +1 @@
1
- {"version":3,"file":"getRaydiumCLMMPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/getRaydiumCLMMPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,6CAA4C;AAC5C,2CAA2E;AAC3E,qGAA6E;AAC7E,+CAAmE;AACnE,iDAAsD;AACtD,2CAAyE;AAEzE,wFAAyF;AAEzF,SAAsB,uBAAuB,CAC3C,KAAY,EACZ,IAAiC;;QAEjC,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;QAEjC,MAAM,uBAAuB,GAAgB,EAAE,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,MAAM,OAAO,GAAG,IAAI,mBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEhD,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEnE,MAAM,CAAC,cAAc,CAAC,GAAG,mBAAS,CAAC,sBAAsB,CACvD,YAAY,EACZ,0BAAc,CACf,CAAC;YACF,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAEpD,MAAM,qBAAqB,GAAG,MAAM,IAAA,sCAA6B,EAC/D,MAAM,EACN,mCAA2B,EAC3B,uBAAuB,CACxB,CAAC;QACF,IAAI,CAAC,qBAAqB,IAAI,qBAAqB,CAAC,MAAM,KAAK,CAAC;YAAE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C,IAAI,CAAC;YACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;YACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,mBAAmB;YAC1B,IAAI,EAAE;gBACJ,WAAW,EAAE,MAAM;aACpB;SACF,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AArHD,0DAqHC"}
1
+ {"version":3,"file":"getRaydiumCLMMPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/getRaydiumCLMMPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DASoC;AACpC,6CAA4C;AAC5C,2CAA2E;AAC3E,qGAA6E;AAC7E,+CAG4B;AAC5B,iDAAsD;AACtD,2CAIyB;AAEzB,wFAAyF;AACzF,uCAAkE;AAElE,SAAsB,uBAAuB,CAC3C,KAAY,EACZ,IAAiC;;QAEjC,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;QAEjC,MAAM,uBAAuB,GAAgB,EAAE,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,MAAM,OAAO,GAAG,IAAI,mBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAEhD,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEnE,MAAM,CAAC,cAAc,CAAC,GAAG,mBAAS,CAAC,sBAAsB,CACvD,YAAY,EACZ,0BAAc,CACf,CAAC;YACF,uBAAuB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAEpD,MAAM,qBAAqB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K,CAAC,CAAC,CAAC;YAC3E,MAAM,KAAK,GAAG,IAAA,+BAAc,EAC1B,CAAC,GAAG,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CACjD,CAAC;YAEF,IAAI,CAAC,KAAK;gBAAE,SAAS;YAErB,WAAW,CAAC,IAAI,CAAC;gBACf,MAAM;gBACN,WAAW;gBACX,YAAY;gBACZ,iBAAiB;gBACjB,KAAK;gBACL,MAAM,EAAE,EAAE;aACX,CAAC,CAAC;QACL,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAExC,MAAM,QAAQ,GAAgC,EAAE,CAAC;QACjD,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;YACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACtD,IAAI,EAAE;gBACJ,WAAW;aACZ;SACF,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAtMD,0DAsMC"}
@@ -2,6 +2,8 @@ import BigNumber from 'bignumber.js';
2
2
  import BN from 'bn.js';
3
3
  import { PortfolioAssetCollectible, PortfolioAssetToken, TokenPrice, Yield } from '@sonarwatch/portfolio-core';
4
4
  import { PublicKey } from '@solana/web3.js';
5
+ import { PersonalPositionState, PoolState, TickArrayState } from './structs/clmms';
6
+ import { ParsedAccount } from '../../utils/solana';
5
7
  export declare function isARaydiumPosition(nft: PortfolioAssetCollectible): boolean;
6
8
  export declare function raydiumTickToPriceX64(tick: number): BN;
7
9
  export declare function getRaydiumTokenAmountsFromLiquidity(sqrtPriceCurrentX64: BigNumber, sqrtPriceX64A: BigNumber, sqrtPriceX64B: BigNumber, liquidity: BigNumber, roundUp: boolean): {
@@ -11,3 +13,5 @@ export declare function getRaydiumTokenAmountsFromLiquidity(sqrtPriceCurrentX64:
11
13
  export declare function getStakePubKey(owner: string): PublicKey;
12
14
  export declare function getFarmYield(rewardToken: TokenPrice, rewardPerBlock: BigNumber, tvl: number, slotsPerSec?: number): Yield;
13
15
  export declare function getPendingAssetToken(depositBalance: BigNumber, rewardDebt: BigNumber, perShare: BigNumber, rewardToken: TokenPrice, multiplier: number | BigNumber): PortfolioAssetToken;
16
+ export declare const getTickArrayAddress: (programId: string, poolId: string, tickNumber: number, tickSpacing: number) => PublicKey;
17
+ export declare const getRewardBalance: (personalPositionInfo: ParsedAccount<PersonalPositionState>, poolStateInfo: ParsedAccount<PoolState>, tickArrays: (ParsedAccount<TickArrayState> | null)[]) => BigNumber[];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPendingAssetToken = exports.getFarmYield = exports.getStakePubKey = exports.getRaydiumTokenAmountsFromLiquidity = exports.raydiumTickToPriceX64 = exports.isARaydiumPosition = void 0;
6
+ exports.getRewardBalance = exports.getTickArrayAddress = exports.getPendingAssetToken = exports.getFarmYield = exports.getStakePubKey = exports.getRaydiumTokenAmountsFromLiquidity = exports.raydiumTickToPriceX64 = exports.isARaydiumPosition = void 0;
7
7
  /* eslint-disable eqeqeq */
8
8
  /* eslint-disable @typescript-eslint/naming-convention */
9
9
  /* eslint-disable no-underscore-dangle */
@@ -15,6 +15,7 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
15
15
  const web3_js_1 = require("@solana/web3.js");
16
16
  const constants_1 = require("./constants");
17
17
  const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
18
+ const toBN_1 = require("../../utils/misc/toBN");
18
19
  function isARaydiumPosition(nft) {
19
20
  return nft.name === constants_1.positionsIdentifier;
20
21
  }
@@ -119,6 +120,9 @@ function mulDivFloor(a, b, denominator) {
119
120
  }
120
121
  return a.mul(b).div(denominator);
121
122
  }
123
+ function wrappingSubU128(n0, n1) {
124
+ return n0.add(Q128).sub(n1).mod(Q128);
125
+ }
122
126
  function mulDivCeil(a, b, denominator) {
123
127
  if (denominator.eq(ZERO)) {
124
128
  throw new Error('division by 0');
@@ -201,4 +205,141 @@ function getPendingAssetToken(depositBalance, rewardDebt, perShare, rewardToken,
201
205
  return (0, tokenPriceToAssetToken_1.default)(rewardToken.address, amount, portfolio_core_1.NetworkId.solana, rewardToken);
202
206
  }
203
207
  exports.getPendingAssetToken = getPendingAssetToken;
208
+ function getRewardGrowthInsideV2(tickCurrentIndex, tickLowerState, tickUpperState, rewardInfos) {
209
+ const rewardGrowthsInside = [];
210
+ for (let i = 0; i < rewardInfos.length; i++) {
211
+ let rewardGrowthsBelow = new bn_js_1.default(0);
212
+ if (tickLowerState.liquidityGross.eqn(0)) {
213
+ rewardGrowthsBelow = rewardInfos[i].rewardGrowthGlobalX64;
214
+ }
215
+ else if (tickCurrentIndex < tickLowerState.tick) {
216
+ rewardGrowthsBelow = rewardInfos[i].rewardGrowthGlobalX64.sub(tickLowerState.rewardGrowthsOutsideX64[i]);
217
+ }
218
+ else {
219
+ rewardGrowthsBelow = tickLowerState.rewardGrowthsOutsideX64[i];
220
+ }
221
+ let rewardGrowthsAbove = new bn_js_1.default(0);
222
+ if (tickUpperState.liquidityGross.eqn(0)) {
223
+ //
224
+ }
225
+ else if (tickCurrentIndex < tickUpperState.tick) {
226
+ rewardGrowthsAbove = tickUpperState.rewardGrowthsOutsideX64[i];
227
+ }
228
+ else {
229
+ rewardGrowthsAbove = rewardInfos[i].rewardGrowthGlobalX64.sub(tickUpperState.rewardGrowthsOutsideX64[i]);
230
+ }
231
+ rewardGrowthsInside.push(wrappingSubU128(wrappingSubU128(rewardInfos[i].rewardGrowthGlobalX64, rewardGrowthsBelow), rewardGrowthsAbove));
232
+ }
233
+ return rewardGrowthsInside;
234
+ }
235
+ const GetPositionRewardsV2 = (ammPool, positionState, tickLowerState, tickUpperState) => {
236
+ const rewards = [];
237
+ const rewardGrowthsInside = getRewardGrowthInsideV2(ammPool.tickCurrent, tickLowerState, tickUpperState, ammPool.rewardInfos);
238
+ for (let i = 0; i < rewardGrowthsInside.length; i++) {
239
+ const rewardGrowthInside = rewardGrowthsInside[i];
240
+ const currRewardInfo = positionState.rewardInfos[i];
241
+ const rewardGrowthDelta = wrappingSubU128(rewardGrowthInside, currRewardInfo.growthInsideLastX64);
242
+ const amountOwedDelta = mulDivFloor(rewardGrowthDelta, positionState.liquidity, Q64);
243
+ const rewardAmountOwed = currRewardInfo.rewardAmountOwed.add(amountOwedDelta);
244
+ rewards.push(rewardAmountOwed);
245
+ }
246
+ return rewards;
247
+ };
248
+ const getTickArrayAddress = (programId, poolId, tickNumber, tickSpacing) => getTickArrayAddressByTick(new web3_js_1.PublicKey(programId), new web3_js_1.PublicKey(poolId), tickNumber, tickSpacing);
249
+ exports.getTickArrayAddress = getTickArrayAddress;
250
+ const TICK_ARRAY_SIZE = 60;
251
+ function tickCount(tickSpacing) {
252
+ return TICK_ARRAY_SIZE * tickSpacing;
253
+ }
254
+ function getTickArrayBitIndex(tickIndex, tickSpacing) {
255
+ const ticksInArray = tickCount(tickSpacing);
256
+ let startIndex = tickIndex / ticksInArray;
257
+ if (tickIndex < 0 && tickIndex % ticksInArray != 0) {
258
+ startIndex = Math.ceil(startIndex) - 1;
259
+ }
260
+ else {
261
+ startIndex = Math.floor(startIndex);
262
+ }
263
+ return startIndex;
264
+ }
265
+ function getTickArrayStartIndexByTick(tickIndex, tickSpacing) {
266
+ return getTickArrayBitIndex(tickIndex, tickSpacing) * tickCount(tickSpacing);
267
+ }
268
+ const TICK_ARRAY_SEED = Buffer.from('tick_array', 'utf8');
269
+ function getPdaTickArrayAddress(programId, poolId, startIndex) {
270
+ return findProgramAddress([TICK_ARRAY_SEED, poolId.toBuffer(), i32ToBytes(startIndex)], programId);
271
+ }
272
+ function getTickArrayAddressByTick(programId, poolId, tickIndex, tickSpacing) {
273
+ const startIndex = getTickArrayStartIndexByTick(tickIndex, tickSpacing);
274
+ const { publicKey: tickArrayAddress } = getPdaTickArrayAddress(programId, poolId, startIndex);
275
+ return tickArrayAddress;
276
+ }
277
+ function i32ToBytes(num) {
278
+ const arr = new ArrayBuffer(4);
279
+ const view = new DataView(arr);
280
+ view.setInt32(0, num, false);
281
+ return new Uint8Array(arr);
282
+ }
283
+ function findProgramAddress(seeds, programId) {
284
+ const [publicKey, nonce] = web3_js_1.PublicKey.findProgramAddressSync(seeds, programId);
285
+ return { publicKey, nonce };
286
+ }
287
+ function getTickOffsetInArray(tickIndex, tickSpacing) {
288
+ if (tickIndex % tickSpacing != 0) {
289
+ throw new Error('tickIndex % tickSpacing not equal 0');
290
+ }
291
+ const startTickIndex = getTickArrayStartIndexByTick(tickIndex, tickSpacing);
292
+ const offsetInArray = Math.floor((tickIndex - startTickIndex) / tickSpacing);
293
+ if (offsetInArray < 0 || offsetInArray >= TICK_ARRAY_SIZE) {
294
+ throw new Error('tick offset in array overflow');
295
+ }
296
+ return offsetInArray;
297
+ }
298
+ const getRewardBalance = (personalPositionInfo, poolStateInfo, tickArrays) => {
299
+ const [tickArrayLower, tickArrayUpper] = tickArrays;
300
+ if (!tickArrayLower || !tickArrayUpper)
301
+ return [];
302
+ const tickLowerState = tickArrayLower &&
303
+ tickArrayLower.ticks[getTickOffsetInArray(personalPositionInfo.tickLowerIndex, poolStateInfo.tickSpacing)];
304
+ const tickUpperState = tickArrayUpper &&
305
+ tickArrayUpper.ticks[getTickOffsetInArray(personalPositionInfo.tickUpperIndex, poolStateInfo.tickSpacing)];
306
+ if (!tickLowerState || !tickUpperState)
307
+ return [];
308
+ return GetPositionRewardsV2({
309
+ tickCurrent: poolStateInfo.tickCurrent,
310
+ feeGrowthGlobalX64B: (0, toBN_1.toBN)(poolStateInfo.feeGrowthGlobal0X64),
311
+ rewardInfos: poolStateInfo.rewardInfos.map((ri) => ({
312
+ rewardGrowthGlobalX64: (0, toBN_1.toBN)(ri.rewardGrowthGlobalX64),
313
+ })),
314
+ }, {
315
+ liquidity: (0, toBN_1.toBN)(personalPositionInfo.liquidity),
316
+ rewardInfos: personalPositionInfo.rewardInfos.map((ri) => ({
317
+ growthInsideLastX64: (0, toBN_1.toBN)(ri.growthInsideLastX64),
318
+ rewardAmountOwed: (0, toBN_1.toBN)(ri.rewardAmountOwed),
319
+ })),
320
+ }, {
321
+ tick: tickLowerState.tick,
322
+ liquidityNet: (0, toBN_1.toBN)(tickLowerState.liquidityNet),
323
+ liquidityGross: (0, toBN_1.toBN)(tickLowerState.liquidityGross),
324
+ feeGrowthOutsideX64A: (0, toBN_1.toBN)(tickLowerState.feeGrowthOutsideX64A),
325
+ feeGrowthOutsideX64B: (0, toBN_1.toBN)(tickLowerState.feeGrowthOutsideX64B),
326
+ rewardGrowthsOutsideX64: [
327
+ (0, toBN_1.toBN)(tickLowerState.rewardGrowthsOutsideX640),
328
+ (0, toBN_1.toBN)(tickLowerState.rewardGrowthsOutsideX641),
329
+ (0, toBN_1.toBN)(tickLowerState.rewardGrowthsOutsideX642),
330
+ ],
331
+ }, {
332
+ tick: tickUpperState.tick,
333
+ liquidityNet: (0, toBN_1.toBN)(tickUpperState.liquidityNet),
334
+ liquidityGross: (0, toBN_1.toBN)(tickUpperState.liquidityGross),
335
+ feeGrowthOutsideX64A: (0, toBN_1.toBN)(tickUpperState.feeGrowthOutsideX64A),
336
+ feeGrowthOutsideX64B: (0, toBN_1.toBN)(tickUpperState.feeGrowthOutsideX64B),
337
+ rewardGrowthsOutsideX64: [
338
+ (0, toBN_1.toBN)(tickUpperState.rewardGrowthsOutsideX640),
339
+ (0, toBN_1.toBN)(tickUpperState.rewardGrowthsOutsideX641),
340
+ (0, toBN_1.toBN)(tickUpperState.rewardGrowthsOutsideX642),
341
+ ],
342
+ }).map((bn) => new bignumber_js_1.default(bn.toString(10)));
343
+ };
344
+ exports.getRewardBalance = getRewardBalance;
204
345
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA2B;AAC3B,yDAAyD;AACzD,yCAAyC;AACzC,sCAAsC;AACtC,+BAA+B;AAC/B,gEAAqC;AACrC,kDAAuB;AACvB,+DAOoC;AACpC,6CAA4C;AAC5C,2CAAqE;AACrE,qGAA6E;AAE7E,SAAgB,kBAAkB,CAAC,GAA8B;IAC/D,OAAO,GAAG,CAAC,IAAI,KAAK,+BAAmB,CAAC;AAC1C,CAAC;AAFD,gDAEC;AAED,MAAM,IAAI,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,GAAG,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/B,MAAM,IAAI,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjC,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChC,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC;AACzB,MAAM,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAE3B,SAAS,gBAAgB,CAAC,EAAM,EAAE,OAAe,EAAE,QAAgB;IACjE,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,KAAK,CAAC,MAAM,CA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SACR,QAAQ,EAAE,CAAC;IACd,OAAO;QACL,GAAG;QACH,GAAG,EAAE,IAAA,yBAAQ,EAAC,GAAG,CAAC;KACnB,CAAC;AACJ,CAAC;AAfD,oCAeC;AAED,SAAgB,oBAAoB,CAClC,cAAyB,EACzB,UAAqB,EACrB,QAAmB,EACnB,WAAuB,EACvB,UAA8B;IAE9B,MAAM,MAAM,GAAG,cAAc;SAC1B,KAAK,CAAC,QAAQ,CAAC;SACf,GAAG,CAAC,UAAU,CAAC;SACf,KAAK,CAAC,UAAU,CAAC;SACjB,GAAG,CAAC,SAAA,EAAE,EAAI,WAAW,CAAC,QAAQ,CAAA,CAAC;SAC/B,QAAQ,EAAE,CAAC;IACd,OAAO,IAAA,gCAAsB,EAC3B,WAAW,CAAC,OAAO,EACnB,MAAM,EACN,0BAAS,CAAC,MAAM,EAChB,WAAW,CACZ,CAAC;AACJ,CAAC;AAnBD,oDAmBC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,2BAA2B;AAC3B,yDAAyD;AACzD,yCAAyC;AACzC,sCAAsC;AACtC,+BAA+B;AAC/B,gEAAqC;AACrC,kDAAuB;AACvB,+DAOoC;AACpC,6CAA4C;AAC5C,2CAAqE;AACrE,qGAA6E;AAE7E,gDAA6C;AAQ7C,SAAgB,kBAAkB,CAAC,GAA8B;IAC/D,OAAO,GAAG,CAAC,IAAI,KAAK,+BAAmB,CAAC;AAC1C,CAAC;AAFD,gDAEC;AAED,MAAM,IAAI,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,GAAG,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,GAAG,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/B,MAAM,IAAI,GAAG,IAAI,eAAE,CAAC,CAAC,CAAC,CA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AC,cAAc,CAAC,wBAAwB,CAAC;YAC7C,IAAA,WAAI,EAAC,cAAc,CAAC,wBAAwB,CAAC;SAC9C;KACF,EACD;QACE,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,YAAY,EAAE,IAAA,WAAI,EAAC,cAAc,CAAC,YAAY,CAAC;QAC/C,cAAc,EAAE,IAAA,WAAI,EAAC,cAAc,CAAC,cAAc,CAAC;QACnD,oBAAoB,EAAE,IAAA,WAAI,EAAC,cAAc,CAAC,oBAAoB,CAAC;QAC/D,oBAAoB,EAAE,IAAA,WAAI,EAAC,cAAc,CAAC,oBAAoB,CAAC;QAC/D,uBAAuB,EAAE;YACvB,IAAA,WAAI,EAAC,cAAc,CAAC,wBAAwB,CAAC;YAC7C,IAAA,WAAI,EAAC,cAAc,CAAC,wBAAwB,CAAC;YAC7C,IAAA,WAAI,EAAC,cAAc,CAAC,wBAAwB,CAAC;SAC9C;KACF,CACF,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,sBAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC;AApEW,QAAA,gBAAgB,oBAoE3B"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { BeetStruct } from '@metaplex-foundation/beet';
2
+ import { BeetStruct, FixableBeetStruct } from '@metaplex-foundation/beet';
3
3
  import BigNumber from 'bignumber.js';
4
4
  import { PublicKey } from '@solana/web3.js';
5
5
  export type PositionRewardInfo = {
@@ -24,7 +24,7 @@ export type PersonalPositionState = {
24
24
  };
25
25
  export declare const personalPositionStateStruct: BeetStruct<PersonalPositionState, Partial<PersonalPositionState>>;
26
26
  export type RewardInfo = {
27
- rewardState: Buffer;
27
+ rewardState: number;
28
28
  openTime: BigNumber;
29
29
  endTime: BigNumber;
30
30
  lastUpdateTime: BigNumber;
@@ -78,3 +78,24 @@ export type PoolState = {
78
78
  padding2: BigNumber[];
79
79
  };
80
80
  export declare const poolStateStruct: BeetStruct<PoolState, Partial<PoolState>>;
81
+ export type TickState = {
82
+ tick: number;
83
+ liquidityNet: BigNumber;
84
+ liquidityGross: BigNumber;
85
+ feeGrowthOutsideX64A: BigNumber;
86
+ feeGrowthOutsideX64B: BigNumber;
87
+ rewardGrowthsOutsideX640: BigNumber;
88
+ rewardGrowthsOutsideX641: BigNumber;
89
+ rewardGrowthsOutsideX642: BigNumber;
90
+ padding: number[];
91
+ };
92
+ export declare const tickStatetruct: BeetStruct<TickState, Partial<TickState>>;
93
+ export type TickArrayState = {
94
+ buffer: Buffer;
95
+ poolId: PublicKey;
96
+ startTickIndex: number;
97
+ ticks: TickState[];
98
+ initializedTickCount: number;
99
+ padding: number[];
100
+ };
101
+ export declare const tickArrayStatetruct: FixableBeetStruct<TickArrayState, Partial<TickArrayState>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.poolStateStruct = exports.rewardInfoStruct = exports.personalPositionStateStruct = exports.positionRewardInfoStruct = void 0;
3
+ exports.tickArrayStatetruct = exports.tickStatetruct = exports.poolStateStruct = exports.rewardInfoStruct = exports.personalPositionStateStruct = exports.positionRewardInfoStruct = void 0;
4
4
  const beet_1 = require("@metaplex-foundation/beet");
5
5
  const beet_solana_1 = require("@metaplex-foundation/beet-solana");
6
6
  const solana_1 = require("../../../utils/solana");
@@ -24,7 +24,7 @@ exports.personalPositionStateStruct = new beet_1.BeetStruct([
24
24
  ['padding', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 8)],
25
25
  ], (args) => args);
26
26
  exports.rewardInfoStruct = new beet_1.BeetStruct([
27
- ['rewardState', (0, solana_1.blob)(8)],
27
+ ['rewardState', beet_1.u8],
28
28
  ['openTime', solana_1.u64],
29
29
  ['endTime', solana_1.u64],
30
30
  ['lastUpdateTime', solana_1.u64],
@@ -76,4 +76,23 @@ exports.poolStateStruct = new beet_1.BeetStruct([
76
76
  ['padding1', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 26)],
77
77
  ['padding2', (0, beet_1.uniformFixedSizeArray)(solana_1.u64, 32)],
78
78
  ], (args) => args);
79
+ exports.tickStatetruct = new beet_1.BeetStruct([
80
+ ['tick', beet_1.i32],
81
+ ['liquidityNet', solana_1.i128],
82
+ ['liquidityGross', solana_1.u128],
83
+ ['feeGrowthOutsideX64A', solana_1.u128],
84
+ ['feeGrowthOutsideX64B', solana_1.u128],
85
+ ['rewardGrowthsOutsideX640', solana_1.u128],
86
+ ['rewardGrowthsOutsideX641', solana_1.u128],
87
+ ['rewardGrowthsOutsideX642', solana_1.u128],
88
+ ['padding', (0, beet_1.uniformFixedSizeArray)(beet_1.u32, 13)],
89
+ ], (args) => args);
90
+ exports.tickArrayStatetruct = new beet_1.FixableBeetStruct([
91
+ ['buffer', (0, solana_1.blob)(8)],
92
+ ['poolId', beet_solana_1.publicKey],
93
+ ['startTickIndex', beet_1.i32],
94
+ ['ticks', (0, beet_1.uniformFixedSizeArray)(exports.tickStatetruct, 60)],
95
+ ['initializedTickCount', beet_1.u8],
96
+ ['padding', (0, beet_1.uniformFixedSizeArray)(beet_1.u8, 115)],
97
+ ], (args) => args);
79
98
  //# sourceMappingURL=clmms.js.map