@sonarwatch/portfolio-plugins 0.12.162 → 0.12.164

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.12.164](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.163...plugins-0.12.164) (2024-09-10)
6
+
7
+
8
+
9
+ ## [0.12.163](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.162...plugins-0.12.163) (2024-09-09)
10
+
11
+
12
+
5
13
  ## [0.12.162](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.161...plugins-0.12.162) (2024-09-09)
6
14
 
7
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonarwatch/portfolio-plugins",
3
- "version": "0.12.162",
3
+ "version": "0.12.164",
4
4
  "type": "commonjs",
5
5
  "types": "./src/index.d.ts",
6
6
  "peerDependencies": {
@@ -20,8 +20,8 @@ const clients_1 = require("../../utils/clients");
20
20
  const solana_1 = require("../../utils/solana");
21
21
  const whirlpool_1 = require("./structs/whirlpool");
22
22
  const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
23
- const runInBatch_1 = __importDefault(require("../../utils/misc/runInBatch"));
24
23
  const tokenAmountFromLiquidity_1 = require("../../utils/clmm/tokenAmountFromLiquidity");
24
+ const helpers_fees_1 = require("./helpers_fees");
25
25
  exports.getWhirlpoolPositions = getOrcaNftFetcher(constants_1.platformId, constants_1.whirlpoolProgram);
26
26
  function getOrcaNftFetcher(platformId, programId) {
27
27
  return (cache, nfts) => __awaiter(this, void 0, void 0, function* () {
@@ -47,29 +47,34 @@ function getOrcaNftFetcher(platformId, programId) {
47
47
  prefix: constants_1.whirlpoolPrefix,
48
48
  networkId: portfolio_core_1.NetworkId.solana,
49
49
  });
50
- const tokensMints = [];
50
+ const tokensMints = new Set();
51
51
  const whirlpoolMap = new Map();
52
52
  allWhirlpoolsInfo.forEach((wInfo) => {
53
+ var _a, _b, _c;
53
54
  if (!wInfo)
54
55
  return;
55
56
  if (whirlpoolAddresses.has(wInfo.pubkey.toString())) {
56
57
  whirlpoolMap.set(wInfo.pubkey.toString(), wInfo);
57
- tokensMints.push(wInfo.tokenMintA.toString(), wInfo.tokenMintB.toString());
58
+ tokensMints.add(wInfo.tokenMintA.toString());
59
+ tokensMints.add(wInfo.tokenMintB.toString());
60
+ if (!(0, helpers_fees_1.isRewardInitialized)(wInfo.rewardInfos[0])) {
61
+ tokensMints.add((_a = wInfo.rewardInfos[0]) === null || _a === void 0 ? void 0 : _a.mint.toString());
62
+ }
63
+ if (!(0, helpers_fees_1.isRewardInitialized)(wInfo.rewardInfos[1])) {
64
+ tokensMints.add((_b = wInfo.rewardInfos[1]) === null || _b === void 0 ? void 0 : _b.mint.toString());
65
+ }
66
+ if (!(0, helpers_fees_1.isRewardInitialized)(wInfo.rewardInfos[2])) {
67
+ tokensMints.add((_c = wInfo.rewardInfos[2]) === null || _c === void 0 ? void 0 : _c.mint.toString());
68
+ }
58
69
  }
59
70
  });
60
- const tokenPriceResults = yield (0, runInBatch_1.default)(tokensMints.map((mint) => () => cache.getTokenPrice(mint, portfolio_core_1.NetworkId.solana)));
61
- const tokenPrices = new Map();
62
- tokenPriceResults.forEach((r) => {
63
- if (r.status === 'rejected')
64
- return;
65
- if (!r.value)
66
- return;
67
- tokenPrices.set(r.value.address, r.value);
68
- });
69
71
  if (whirlpoolMap.size === 0)
70
72
  return [];
71
- const assets = [];
72
- let totalLiquidityValue = 0;
73
+ const [tokenPrices, tickArrays] = yield Promise.all([
74
+ cache.getTokenPricesAsMap([...tokensMints], portfolio_core_1.NetworkId.solana),
75
+ (0, helpers_fees_1.getTickArraysAsMap)(positionsInfo, whirlpoolMap),
76
+ ]);
77
+ const elements = [];
73
78
  for (let index = 0; index < positionsInfo.length; index++) {
74
79
  const positionInfo = positionsInfo[index];
75
80
  if (!positionInfo)
@@ -82,45 +87,81 @@ function getOrcaNftFetcher(platformId, programId) {
82
87
  !whirlpoolInfo.tickCurrentIndex)
83
88
  continue;
84
89
  const { tokenAmountA, tokenAmountB } = (0, tokenAmountFromLiquidity_1.getTokenAmountsFromLiquidity)(positionInfo.liquidity, whirlpoolInfo.tickCurrentIndex, positionInfo.tickLowerIndex, positionInfo.tickUpperIndex, false);
90
+ const rewardAssets = [];
85
91
  const tokenPriceA = tokenPrices.get(whirlpoolInfo.tokenMintA.toString());
86
92
  if (!tokenPriceA)
87
93
  continue;
88
- const assetTokenA = (0, tokenPriceToAssetToken_1.default)(whirlpoolInfo.tokenMintA.toString(), tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA);
89
94
  const tokenPriceB = tokenPrices.get(whirlpoolInfo.tokenMintB.toString());
90
95
  if (!tokenPriceB)
91
96
  continue;
97
+ const assetTokenA = (0, tokenPriceToAssetToken_1.default)(whirlpoolInfo.tokenMintA.toString(), tokenAmountA.dividedBy(Math.pow(10, tokenPriceA.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA);
92
98
  const assetTokenB = (0, tokenPriceToAssetToken_1.default)(whirlpoolInfo.tokenMintB.toString(), tokenAmountB.dividedBy(Math.pow(10, tokenPriceB.decimals)).toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB);
99
+ const feesAndRewards = (0, helpers_fees_1.calcFeesAndRewards)(whirlpoolInfo, positionInfo, tickArrays);
100
+ if (feesAndRewards) {
101
+ if (feesAndRewards.feeOwedA.isGreaterThan(0)) {
102
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, feesAndRewards.feeOwedA
103
+ .dividedBy(Math.pow(10, tokenPriceA.decimals))
104
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA));
105
+ }
106
+ if (feesAndRewards.feeOwedB.isGreaterThan(0)) {
107
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, feesAndRewards.feeOwedB
108
+ .dividedBy(Math.pow(10, tokenPriceB.decimals))
109
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB));
110
+ }
111
+ if (feesAndRewards.rewardOwedA.isGreaterThan(0)) {
112
+ const tokenPriceRewardA = tokenPrices.get(whirlpoolInfo.rewardInfos[0].mint.toString());
113
+ if (tokenPriceRewardA) {
114
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardA.address, feesAndRewards.rewardOwedA
115
+ .dividedBy(Math.pow(10, tokenPriceRewardA.decimals))
116
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardA));
117
+ }
118
+ }
119
+ if (feesAndRewards.rewardOwedB.isGreaterThan(0)) {
120
+ const tokenPriceRewardB = tokenPrices.get(whirlpoolInfo.rewardInfos[1].mint.toString());
121
+ if (tokenPriceRewardB) {
122
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardB.address, feesAndRewards.rewardOwedB
123
+ .dividedBy(Math.pow(10, tokenPriceRewardB.decimals))
124
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardB));
125
+ }
126
+ }
127
+ if (feesAndRewards.rewardOwedC.isGreaterThan(0)) {
128
+ const tokenPriceRewardC = tokenPrices.get(whirlpoolInfo.rewardInfos[2].mint.toString());
129
+ if (tokenPriceRewardC) {
130
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceRewardC.address, feesAndRewards.rewardOwedC
131
+ .dividedBy(Math.pow(10, tokenPriceRewardC.decimals))
132
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceRewardC));
133
+ }
134
+ }
135
+ }
93
136
  if (!assetTokenA ||
94
137
  !assetTokenB ||
95
138
  assetTokenA.value === null ||
96
139
  assetTokenB.value === null)
97
140
  continue;
98
141
  const value = assetTokenA.value + assetTokenB.value;
99
- assets.push({
100
- assets: [assetTokenA, assetTokenB],
101
- assetsValue: value,
102
- rewardAssets: [],
103
- rewardAssetsValue: 0,
104
- value,
105
- yields: [],
106
- });
107
- totalLiquidityValue += value;
108
- }
109
- if (assets.length === 0)
110
- return [];
111
- return [
112
- {
142
+ const rewardAssetsValue = (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((a) => a.value));
143
+ elements.push({
113
144
  type: portfolio_core_1.PortfolioElementType.liquidity,
114
145
  networkId: portfolio_core_1.NetworkId.solana,
115
146
  platformId,
116
147
  label: 'LiquidityPool',
117
148
  name: 'Concentrated',
118
- value: totalLiquidityValue,
149
+ value: value + (rewardAssetsValue || 0),
119
150
  data: {
120
- liquidities: assets,
151
+ liquidities: [
152
+ {
153
+ assets: [assetTokenA, assetTokenB],
154
+ assetsValue: value,
155
+ rewardAssets,
156
+ rewardAssetsValue,
157
+ value: value + (rewardAssetsValue || 0),
158
+ yields: [],
159
+ },
160
+ ],
121
161
  },
122
- },
123
- ];
162
+ });
163
+ }
164
+ return elements;
124
165
  });
125
166
  }
126
167
  exports.getOrcaNftFetcher = getOrcaNftFetcher;
@@ -1 +1 @@
1
- {"version":3,"file":"getWhirlpoolPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/orca/getWhirlpoolPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,6CAA4C;AAC5C,2CAIqB;AACrB,iDAAsD;AACtD,+CAG4B;AAE5B,mDAAgE;AAChE,qGAA6E;AAC7E,6EAAqD;AACrD,wFAAyF;AAG5E,QAAA,qBAAqB,GAAG,iBAAiB,CACpD,sBAAc,EACd,4BAAgB,CACjB,CAAC;AAEF,SAAgB,iBAAiB,CAC/B,UAAkB,EAClB,SAAoB;IAEpB,OAAO,CACL,KAAY,EACZ,IAAiC,EACJ,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;QACjC,MAAM,uBAAuB,GAAgB,EAAE,CAAC;QAEhD,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,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AW,CAAC,KAAK,KAAK,IAAI;gBAE1B,SAAS;YAEX,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC;gBAClC,WAAW,EAAE,KAAK;gBAClB,YAAY,EAAE,EAAE;gBAChB,iBAAiB,EAAE,CAAC;gBACpB,KAAK;gBACL,MAAM,EAAE,EAAE;aACX,CAAC,CAAC;YACH,mBAAmB,IAAI,KAAK,CAAC;QAC/B,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACnC,OAAO;YACL;gBACE,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU;gBACV,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,mBAAmB;gBAC1B,IAAI,EAAE;oBACJ,WAAW,EAAE,MAAM;iBACpB;aACF;SACF,CAAC;IACJ,CAAC,CAAA,CAAC;AACJ,CAAC;AAlJD,8CAkJC"}
1
+ {"version":3,"file":"getWhirlpoolPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/orca/getWhirlpoolPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,6CAA4C;AAC5C,2CAIqB;AACrB,iDAAsD;AACtD,+CAG4B;AAE5B,mDAAgE;AAChE,qGAA6E;AAC7E,wFAAyF;AAEzF,iDAIwB;AAEX,QAAA,qBAAqB,GAAG,iBAAiB,CACpD,sBAAc,EACd,4BAAgB,CACjB,CAAC;AAEF,SAAgB,iBAAiB,CAC/B,UAAkB,EAClB,SAAoB;IAEpB,OAAO,CACL,KAAY,EACZ,IAAiC,EACJ,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;QACjC,M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lpool, WhirlpoolRewardInfo } from './structs/whirlpool';
2
+ import { ParsedAccount } from '../../utils/solana';
3
+ import BigNumber from 'bignumber.js';
4
+ export declare const getTickArraysAsMap: (positionsInfo: (ParsedAccount<Position> | null)[], whirlpoolMap: Map<string, Whirlpool>) => Promise<Map<string, TickArray>>;
5
+ export declare const calcFeesAndRewards: (whirlpool: Whirlpool, position: ParsedAccount<Position>, tickArrays: Map<string, TickArray>) => {
6
+ feeOwedA: BigNumber;
7
+ feeOwedB: BigNumber;
8
+ rewardOwedA: BigNumber;
9
+ rewardOwedB: BigNumber;
10
+ rewardOwedC: BigNumber;
11
+ } | null;
12
+ export declare function isRewardInitialized(rewardInfo: WhirlpoolRewardInfo): boolean;
13
+ export declare function getCollectRewardsQuoteInternal(param: {
14
+ whirlpool: Whirlpool;
15
+ position: Position;
16
+ tickLower: Tick;
17
+ tickUpper: Tick;
18
+ }): {
19
+ rewardOwedA: BigNumber;
20
+ rewardOwedB: BigNumber;
21
+ rewardOwedC: BigNumber;
22
+ };
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getCollectRewardsQuoteInternal = exports.isRewardInitialized = exports.calcFeesAndRewards = exports.getTickArraysAsMap = void 0;
16
+ const whirlpool_1 = require("./structs/whirlpool");
17
+ const solana_1 = require("../../utils/solana");
18
+ const constants_1 = require("./constants");
19
+ const clients_1 = require("../../utils/clients");
20
+ const web3_js_1 = require("@solana/web3.js");
21
+ const bn_js_1 = __importDefault(require("bn.js"));
22
+ const toBN_1 = require("../../utils/misc/toBN");
23
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
24
+ const TWO = new bn_js_1.default(2);
25
+ const U128 = TWO.pow(new bn_js_1.default(128));
26
+ const TICK_ARRAY_SIZE = 88;
27
+ const MAX_TICK_INDEX = 443636;
28
+ const MIN_TICK_INDEX = -443636;
29
+ const NUM_REWARDS = 3;
30
+ const getTickArraysAsMap = (positionsInfo, whirlpoolMap) => __awaiter(void 0, void 0, void 0, function* () {
31
+ const client = (0, clients_1.getClientSolana)();
32
+ const tickArrayAddresses = [];
33
+ for (let index = 0; index < positionsInfo.length; index++) {
34
+ const positionInfo = positionsInfo[index];
35
+ if (!positionInfo)
36
+ continue;
37
+ const whirlpoolInfo = whirlpoolMap.get(positionInfo.whirlpool.toString());
38
+ if (!whirlpoolInfo)
39
+ continue;
40
+ tickArrayAddresses.push(getTickArrayPda(constants_1.whirlpoolProgram, positionInfo.whirlpool, getStartTickIndex(positionInfo.tickLowerIndex, whirlpoolInfo.tickSpacing)), getTickArrayPda(constants_1.whirlpoolProgram, positionInfo.whirlpool, getStartTickIndex(positionInfo.tickUpperIndex, whirlpoolInfo.tickSpacing)));
41
+ }
42
+ const tickArrays = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, whirlpool_1.tickArrayStruct, tickArrayAddresses);
43
+ const tickArraysAsMap = new Map();
44
+ tickArrays.forEach((ta) => {
45
+ if (ta)
46
+ tickArraysAsMap.set(ta.pubkey.toString(), ta);
47
+ });
48
+ return tickArraysAsMap;
49
+ });
50
+ exports.getTickArraysAsMap = getTickArraysAsMap;
51
+ const calcFeesAndRewards = (whirlpool, position, tickArrays) => {
52
+ const tickArrayLowerAddress = getTickArrayPda(constants_1.whirlpoolProgram, position.whirlpool, getStartTickIndex(position.tickLowerIndex, whirlpool.tickSpacing));
53
+ const tickArrayUpperAddress = getTickArrayPda(constants_1.whirlpoolProgram, position.whirlpool, getStartTickIndex(position.tickUpperIndex, whirlpool.tickSpacing));
54
+ const tickArrayLower = tickArrays.get(tickArrayLowerAddress.toString());
55
+ const tickArrayUpper = tickArrays.get(tickArrayUpperAddress.toString());
56
+ if (!tickArrayLower || !tickArrayUpper) {
57
+ return null;
58
+ }
59
+ const tickLower = getTick(tickArrayLower, position.tickLowerIndex, whirlpool.tickSpacing);
60
+ const tickUpper = getTick(tickArrayUpper, position.tickUpperIndex, whirlpool.tickSpacing);
61
+ const rewards = getCollectRewardsQuoteInternal({
62
+ whirlpool,
63
+ position,
64
+ tickLower,
65
+ tickUpper,
66
+ });
67
+ const fees = getCollectFeesQuoteInternal({
68
+ whirlpool,
69
+ position,
70
+ tickUpper,
71
+ tickLower,
72
+ });
73
+ return Object.assign(Object.assign({}, rewards), fees);
74
+ };
75
+ exports.calcFeesAndRewards = calcFeesAndRewards;
76
+ function invariant(condition, message) {
77
+ if (condition) {
78
+ return;
79
+ }
80
+ const prefix = 'Invariant failed';
81
+ const provided = typeof message === 'function' ? message() : message;
82
+ const value = provided ? `${prefix}: ${provided}` : prefix;
83
+ throw new Error(value);
84
+ }
85
+ function getStartTickIndex(tickIndex, tickSpacing, offset = 0) {
86
+ const realIndex = Math.floor(tickIndex / tickSpacing / TICK_ARRAY_SIZE);
87
+ const startTickIndex = (realIndex + offset) * tickSpacing * TICK_ARRAY_SIZE;
88
+ const ticksInArray = TICK_ARRAY_SIZE * tickSpacing;
89
+ const minTickIndex = MIN_TICK_INDEX - ((MIN_TICK_INDEX % ticksInArray) + ticksInArray);
90
+ invariant(startTickIndex >= minTickIndex, 'startTickIndex is too small');
91
+ invariant(startTickIndex <= MAX_TICK_INDEX, 'startTickIndex is too large');
92
+ return startTickIndex;
93
+ }
94
+ function getTickArrayPda(programId, whirlpool, startIndex) {
95
+ return web3_js_1.PublicKey.findProgramAddressSync([
96
+ Buffer.from('tick_array', 'utf8'),
97
+ whirlpool.toBuffer(),
98
+ Buffer.from(startIndex.toString(), 'utf8'),
99
+ ], programId)[0];
100
+ }
101
+ function subUnderflowU128(n0, n1) {
102
+ return n0.add(U128).sub(n1).mod(U128);
103
+ }
104
+ function getCollectFeesQuoteInternal(param) {
105
+ const { whirlpool, position, tickLower, tickUpper } = param;
106
+ const { tickCurrentIndex, feeGrowthGlobalA: feeGrowthGlobalAX64, feeGrowthGlobalB: feeGrowthGlobalBX64, } = whirlpool;
107
+ const { tickLowerIndex, tickUpperIndex, liquidity, feeOwedA, feeOwedB, feeGrowthCheckpointA: feeGrowthCheckpointAX64, feeGrowthCheckpointB: feeGrowthCheckpointBX64, } = position;
108
+ const { feeGrowthOutsideA: tickLowerFeeGrowthOutsideAX64, feeGrowthOutsideB: tickLowerFeeGrowthOutsideBX64, } = tickLower;
109
+ const { feeGrowthOutsideA: tickUpperFeeGrowthOutsideAX64, feeGrowthOutsideB: tickUpperFeeGrowthOutsideBX64, } = tickUpper;
110
+ // Calculate the fee growths inside the position
111
+ let feeGrowthBelowAX64 = null;
112
+ let feeGrowthBelowBX64 = null;
113
+ if (tickCurrentIndex < tickLowerIndex) {
114
+ feeGrowthBelowAX64 = subUnderflowU128((0, toBN_1.toBN)(feeGrowthGlobalAX64), (0, toBN_1.toBN)(tickLowerFeeGrowthOutsideAX64));
115
+ feeGrowthBelowBX64 = subUnderflowU128((0, toBN_1.toBN)(feeGrowthGlobalBX64), (0, toBN_1.toBN)(tickLowerFeeGrowthOutsideBX64));
116
+ }
117
+ else {
118
+ feeGrowthBelowAX64 = (0, toBN_1.toBN)(tickLowerFeeGrowthOutsideAX64);
119
+ feeGrowthBelowBX64 = (0, toBN_1.toBN)(tickLowerFeeGrowthOutsideBX64);
120
+ }
121
+ let feeGrowthAboveAX64 = null;
122
+ let feeGrowthAboveBX64 = null;
123
+ if (tickCurrentIndex < tickUpperIndex) {
124
+ feeGrowthAboveAX64 = (0, toBN_1.toBN)(tickUpperFeeGrowthOutsideAX64);
125
+ feeGrowthAboveBX64 = (0, toBN_1.toBN)(tickUpperFeeGrowthOutsideBX64);
126
+ }
127
+ else {
128
+ feeGrowthAboveAX64 = subUnderflowU128((0, toBN_1.toBN)(feeGrowthGlobalAX64), (0, toBN_1.toBN)(tickUpperFeeGrowthOutsideAX64));
129
+ feeGrowthAboveBX64 = subUnderflowU128((0, toBN_1.toBN)(feeGrowthGlobalBX64), (0, toBN_1.toBN)(tickUpperFeeGrowthOutsideBX64));
130
+ }
131
+ const feeGrowthInsideAX64 = subUnderflowU128(subUnderflowU128((0, toBN_1.toBN)(feeGrowthGlobalAX64), feeGrowthBelowAX64), feeGrowthAboveAX64);
132
+ const feeGrowthInsideBX64 = subUnderflowU128(subUnderflowU128((0, toBN_1.toBN)(feeGrowthGlobalBX64), feeGrowthBelowBX64), feeGrowthAboveBX64);
133
+ // Calculate the updated fees owed
134
+ const feeOwedADelta = subUnderflowU128(feeGrowthInsideAX64, (0, toBN_1.toBN)(feeGrowthCheckpointAX64))
135
+ .mul((0, toBN_1.toBN)(liquidity))
136
+ .shrn(64);
137
+ const feeOwedBDelta = subUnderflowU128(feeGrowthInsideBX64, (0, toBN_1.toBN)(feeGrowthCheckpointBX64))
138
+ .mul((0, toBN_1.toBN)(liquidity))
139
+ .shrn(64);
140
+ const updatedFeeOwedA = feeOwedA.plus(feeOwedADelta.toString());
141
+ const updatedFeeOwedB = feeOwedB.plus(feeOwedBDelta.toString());
142
+ return {
143
+ feeOwedA: updatedFeeOwedA,
144
+ feeOwedB: updatedFeeOwedB,
145
+ };
146
+ }
147
+ function getTick(tickArray, tickIndex, tickSpacing) {
148
+ const realIndex = tickIndexToTickArrayIndex(tickArray, tickIndex, tickSpacing);
149
+ const tick = tickArray.ticks[realIndex];
150
+ invariant(!!tick, 'tick realIndex out of range');
151
+ return tick;
152
+ }
153
+ function tickIndexToTickArrayIndex({ startTickIndex }, tickIndex, tickSpacing) {
154
+ return Math.floor((tickIndex - startTickIndex) / tickSpacing);
155
+ }
156
+ function isRewardInitialized(rewardInfo) {
157
+ return (rewardInfo.mint.toString() !== '11111111111111111111111111111111' &&
158
+ rewardInfo.vault.toString() !== '11111111111111111111111111111111');
159
+ }
160
+ exports.isRewardInitialized = isRewardInitialized;
161
+ function getCollectRewardsQuoteInternal(param) {
162
+ var _a, _b, _c, _d, _e, _f;
163
+ const { whirlpool, position, tickLower, tickUpper } = param;
164
+ const { tickCurrentIndex, rewardInfos: whirlpoolRewardsInfos } = whirlpool;
165
+ const { tickLowerIndex, tickUpperIndex, liquidity, rewardInfos } = position;
166
+ // Calculate the reward growths inside the position
167
+ const range = [...Array(NUM_REWARDS).keys()];
168
+ const rewardGrowthsBelowX64 = range.map(() => new bn_js_1.default(0));
169
+ const rewardGrowthsAboveX64 = range.map(() => new bn_js_1.default(0));
170
+ const tickLowerRewardGrowthsOutside = [
171
+ tickLower.rewardGrowthsOutside1,
172
+ tickLower.rewardGrowthsOutside2,
173
+ tickLower.rewardGrowthsOutside3,
174
+ ];
175
+ const tickUpperRewardGrowthsOutside = [
176
+ tickUpper.rewardGrowthsOutside1,
177
+ tickUpper.rewardGrowthsOutside2,
178
+ tickLower.rewardGrowthsOutside3,
179
+ ];
180
+ for (const i of range) {
181
+ const rewardInfo = whirlpoolRewardsInfos[i];
182
+ invariant(!!rewardInfo, 'whirlpoolRewardsInfos cannot be undefined');
183
+ const growthGlobalX64 = rewardInfo.growthGlobalX64;
184
+ const lowerRewardGrowthsOutside = tickLowerRewardGrowthsOutside[i];
185
+ const upperRewardGrowthsOutside = tickUpperRewardGrowthsOutside[i];
186
+ invariant(!!lowerRewardGrowthsOutside, 'lowerRewardGrowthsOutside cannot be undefined');
187
+ invariant(!!upperRewardGrowthsOutside, 'upperRewardGrowthsOutside cannot be undefined');
188
+ if (tickCurrentIndex < tickLowerIndex) {
189
+ rewardGrowthsBelowX64[i] = subUnderflowU128((0, toBN_1.toBN)(growthGlobalX64), (0, toBN_1.toBN)(lowerRewardGrowthsOutside));
190
+ }
191
+ else {
192
+ rewardGrowthsBelowX64[i] = (0, toBN_1.toBN)(lowerRewardGrowthsOutside);
193
+ }
194
+ if (tickCurrentIndex < tickUpperIndex) {
195
+ rewardGrowthsAboveX64[i] = (0, toBN_1.toBN)(upperRewardGrowthsOutside);
196
+ }
197
+ else {
198
+ rewardGrowthsAboveX64[i] = subUnderflowU128((0, toBN_1.toBN)(growthGlobalX64), (0, toBN_1.toBN)(upperRewardGrowthsOutside));
199
+ }
200
+ }
201
+ const rewardGrowthsInsideX64 = range.map(() => [
202
+ new bn_js_1.default(0),
203
+ false,
204
+ ]);
205
+ for (const i of range) {
206
+ const rewardInfo = whirlpoolRewardsInfos[i];
207
+ invariant(!!rewardInfo, 'whirlpoolRewardsInfos cannot be undefined');
208
+ const rewardInitialized = isRewardInitialized(rewardInfo);
209
+ if (rewardInitialized) {
210
+ const growthBelowX64 = rewardGrowthsBelowX64[i];
211
+ const growthAboveX64 = rewardGrowthsAboveX64[i];
212
+ invariant(!!growthBelowX64, 'growthBelowX64 cannot be undefined');
213
+ invariant(!!growthAboveX64, 'growthAboveX64 cannot be undefined');
214
+ const growthInsde = subUnderflowU128(subUnderflowU128((0, toBN_1.toBN)(rewardInfo.growthGlobalX64), growthBelowX64), growthAboveX64);
215
+ rewardGrowthsInsideX64[i] = [growthInsde, true];
216
+ }
217
+ }
218
+ // Calculate the updated rewards owed
219
+ const updatedRewardInfosX64 = range.map(() => new bn_js_1.default(0));
220
+ for (const i of range) {
221
+ const growthInsideX64 = rewardGrowthsInsideX64[i];
222
+ invariant(!!growthInsideX64, 'growthInsideX64 cannot be undefined');
223
+ const [rewardGrowthInsideX64, isRewardInitialized] = growthInsideX64;
224
+ if (isRewardInitialized) {
225
+ const rewardInfo = rewardInfos[i];
226
+ invariant(!!rewardInfo, 'rewardInfo cannot be undefined');
227
+ const amountOwedX64 = (0, toBN_1.toBN)(rewardInfo.amountOwed).shln(64);
228
+ const growthInsideCheckpointX64 = rewardInfo.growthInsideCheckpoint;
229
+ updatedRewardInfosX64[i] = amountOwedX64.add(subUnderflowU128(rewardGrowthInsideX64, (0, toBN_1.toBN)(growthInsideCheckpointX64)).mul((0, toBN_1.toBN)(liquidity)));
230
+ }
231
+ }
232
+ invariant(rewardGrowthsInsideX64.length >= 3, 'rewards length is less than 3');
233
+ const rewardExistsA = (_a = rewardGrowthsInsideX64[0]) === null || _a === void 0 ? void 0 : _a[1];
234
+ const rewardExistsB = (_b = rewardGrowthsInsideX64[1]) === null || _b === void 0 ? void 0 : _b[1];
235
+ const rewardExistsC = (_c = rewardGrowthsInsideX64[2]) === null || _c === void 0 ? void 0 : _c[1];
236
+ const rewardOwedA = rewardExistsA
237
+ ? new bignumber_js_1.default((_d = updatedRewardInfosX64[0]) === null || _d === void 0 ? void 0 : _d.shrn(64).toString())
238
+ : new bignumber_js_1.default(0);
239
+ const rewardOwedB = rewardExistsB
240
+ ? new bignumber_js_1.default((_e = updatedRewardInfosX64[1]) === null || _e === void 0 ? void 0 : _e.shrn(64).toString())
241
+ : new bignumber_js_1.default(0);
242
+ const rewardOwedC = rewardExistsC
243
+ ? new bignumber_js_1.default((_f = updatedRewardInfosX64[2]) === null || _f === void 0 ? void 0 : _f.shrn(64).toString())
244
+ : new bignumber_js_1.default(0);
245
+ return { rewardOwedA, rewardOwedB, rewardOwedC };
246
+ }
247
+ exports.getCollectRewardsQuoteInternal = getCollectRewardsQuoteInternal;
248
+ //# sourceMappingURL=helpers_fees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers_fees.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/orca/helpers_fees.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAO6B;AAC7B,+CAG4B;AAC5B,2CAA+C;AAC/C,iDAAsD;AACtD,6CAA4C;AAC5C,kDAAuB;AACvB,gDAA6C;AAC7C,gEAAqC;AAErC,MAAM,GAAG,GAAG,IAAI,eAA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AsB,CAAC,CAAC,CAAC,0CAAG,CAAC,CAAC,CAAC;IACrD,MAAM,aAAa,GAAG,MAAA,sBAAsB,CAAC,CAAC,CAAC,0CAAG,CAAC,CAAC,CAAC;IAErD,MAAM,WAAW,GAAG,aAAa;QAC/B,CAAC,CAAC,IAAI,sBAAS,CAAC,MAAA,qBAAqB,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC9D,CAAC,CAAC,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,WAAW,GAAG,aAAa;QAC/B,CAAC,CAAC,IAAI,sBAAS,CAAC,MAAA,qBAAqB,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC9D,CAAC,CAAC,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,WAAW,GAAG,aAAa;QAC/B,CAAC,CAAC,IAAI,sBAAS,CAAC,MAAA,qBAAqB,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC;QAC9D,CAAC,CAAC,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;IAErB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACnD,CAAC;AAzID,wEAyIC"}
@@ -52,3 +52,21 @@ export type Whirlpool = {
52
52
  rewardInfos: WhirlpoolRewardInfo[];
53
53
  };
54
54
  export declare const whirlpoolStruct: BeetStruct<Whirlpool, Partial<Whirlpool>>;
55
+ export type Tick = {
56
+ initialized: boolean;
57
+ liquidityNet: BigNumber;
58
+ liquidityGross: BigNumber;
59
+ feeGrowthOutsideA: BigNumber;
60
+ feeGrowthOutsideB: BigNumber;
61
+ rewardGrowthsOutside1: BigNumber;
62
+ rewardGrowthsOutside2: BigNumber;
63
+ rewardGrowthsOutside3: BigNumber;
64
+ };
65
+ export declare const tickStruct: BeetStruct<Tick, Partial<Tick>>;
66
+ export type TickArray = {
67
+ padding: Buffer;
68
+ startTickIndex: number;
69
+ ticks: Tick[];
70
+ whirlpool: PublicKey;
71
+ };
72
+ export declare const tickArrayStruct: BeetStruct<TickArray, Partial<TickArray>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.whirlpoolStruct = exports.whirlpoolRewardInfoStruct = exports.positionStruct = exports.positionRewardInfoStruct = void 0;
3
+ exports.tickArrayStruct = exports.tickStruct = exports.whirlpoolStruct = exports.whirlpoolRewardInfoStruct = exports.positionStruct = 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");
@@ -50,4 +50,20 @@ exports.whirlpoolStruct = new beet_1.BeetStruct([
50
50
  ['rewardLastUpdatedTimestamp', solana_1.u64],
51
51
  ['rewardInfos', (0, beet_1.uniformFixedSizeArray)(exports.whirlpoolRewardInfoStruct, 3)],
52
52
  ], (args) => args);
53
+ exports.tickStruct = new beet_1.BeetStruct([
54
+ ['initialized', beet_1.bool],
55
+ ['liquidityNet', solana_1.i128],
56
+ ['liquidityGross', solana_1.u128],
57
+ ['feeGrowthOutsideA', solana_1.u128],
58
+ ['feeGrowthOutsideB', solana_1.u128],
59
+ ['rewardGrowthsOutside1', solana_1.u128],
60
+ ['rewardGrowthsOutside2', solana_1.u128],
61
+ ['rewardGrowthsOutside3', solana_1.u128],
62
+ ], (args) => args);
63
+ exports.tickArrayStruct = new beet_1.BeetStruct([
64
+ ['padding', (0, solana_1.blob)(8)],
65
+ ['startTickIndex', beet_1.i32],
66
+ ['ticks', (0, beet_1.uniformFixedSizeArray)(exports.tickStruct, 88)],
67
+ ['whirlpool', beet_solana_1.publicKey],
68
+ ], (args) => args);
53
69
  //# sourceMappingURL=whirlpool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"whirlpool.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CAAC,SAAS,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACpB,CAAC,kBAAkB,EAAE,uBAAS,CAAC;IAC/B,CAAC,eAAe,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC,aAAa,EAAE,UAAG,CAAC;IACpB,CAAC,iBAAiB,EAAE,IAAA,4BAAqB,EAAC,SAAE,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC,SAAS,EAAE,UAAG,CAAC;IAChB,CAAC,iBAAiB,EAAE,UAAG,CAAC;IACxB,CAAC,WAAW,EAAE,aAAI,CAAC;IACnB,CAAC,WAAW,EAAE,aAAI,CAAC;IACnB,CAAC,kBAAkB,EAAE,UAAG,CAAC;IACzB,CAAC,kBAAkB,EAAE,YAAG,CAAC;IACzB,CAAC,kBAAkB,EAAE,YAAG,CAAC;IACzB,CAAC,YAAY,EAAE,uBAAS,CAAC;IACzB,CAAC,aAAa,EAAE,uBAAS,CAAC;IAC1B,CAAC,kBAAkB,EAAE,aAAI,CAAC;IAC1B,CAAC,YAAY,EAAE,uBAAS,CAAC;IACzB,CAAC,aAAa,EAAE,uBAAS,CAAC;IAC1B,CAAC,kBAAkB,EAAE,aAAI,CAAC;IAC1B,CAAC,4BAA4B,EAAE,YAAG,CAAC;IACnC,CAAC,aAAa,EAAE,IAAA,4BAAqB,EAAC,iCAAyB,EAAE,CAAC,CAAC,CAAC;CACrE,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAiB,CAC5B,CAAC"}
1
+ {"version":3,"file":"whirlpool.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/orca/structs/whirlpool.ts"],"names":[],"mappings":";;;AAAA,oDAOmC;AACnC,kEAA6D;AAG7D,kDAA8D;AAOjD,QAAA,wBAAwB,GAAG,IAAI,iBAAU,CACpD;IACE,CAAC,wBAAwB,EAAE,aAAI,CAAC;IAChC,CAAC,YAAY,EAAE,YAAG,CAAC;CACpB,EACD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B,EAAE,UAAG,CAAC;IACvB,CAAC,OAAO,EAAE,IAAA,4BAAqB,EAAC,kBAAU,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC,WAAW,EAAE,uBAAS,CAAC;CACzB,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAiB,CAC5B,CAAC"}
@@ -99,17 +99,27 @@ function getRaydiumCLMMPositions(cache, nfts) {
99
99
  if (tokenAmountB.isZero())
100
100
  assetTokenB.attributes.tags = ['Out Of Range'];
101
101
  const rewardAssets = [];
102
- const rewardBalances = (0, helpers_1.getRewardBalance)(personalPositionInfo, poolStateInfo, tickArrays[index]);
103
- rewardBalances.forEach((rewardBalance, i) => {
104
- if (rewardBalance.isZero() ||
105
- poolStateInfo.rewardInfos[i].tokenMint.toString() ===
106
- '11111111111111111111111111111111')
107
- return;
108
- const rewardTokenPrice = tokenPrices.get(poolStateInfo.rewardInfos[i].tokenMint.toString());
109
- if (!rewardTokenPrice)
110
- return;
111
- 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));
112
- });
102
+ const feesAndRewardsBalances = (0, helpers_1.getFeesAndRewardsBalance)(personalPositionInfo, poolStateInfo, tickArrays[index]);
103
+ if (feesAndRewardsBalances) {
104
+ if (feesAndRewardsBalances.tokenFeeAmountA.isGreaterThan(0))
105
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceA.address, feesAndRewardsBalances.tokenFeeAmountA
106
+ .dividedBy(Math.pow(10, tokenPriceA.decimals))
107
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceA));
108
+ if (feesAndRewardsBalances.tokenFeeAmountB.isGreaterThan(0))
109
+ rewardAssets.push((0, tokenPriceToAssetToken_1.default)(tokenPriceB.address, feesAndRewardsBalances.tokenFeeAmountB
110
+ .dividedBy(Math.pow(10, tokenPriceB.decimals))
111
+ .toNumber(), portfolio_core_1.NetworkId.solana, tokenPriceB));
112
+ feesAndRewardsBalances.rewards.forEach((rewardBalance, i) => {
113
+ if (rewardBalance.isZero() ||
114
+ poolStateInfo.rewardInfos[i].tokenMint.toString() ===
115
+ '11111111111111111111111111111111')
116
+ return;
117
+ const rewardTokenPrice = tokenPrices.get(poolStateInfo.rewardInfos[i].tokenMint.toString());
118
+ if (!rewardTokenPrice)
119
+ return;
120
+ 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));
121
+ });
122
+ }
113
123
  const assets = [assetTokenA, assetTokenB];
114
124
  const assetsValue = (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value));
115
125
  const rewardAssetsValue = (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((a) => a.value));
@@ -1 +1 @@
1
- {"version":3,"file":"getRaydiumCLMMPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/getRaydiumCLMMPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,6CAA4C;AAC5C,2CAAyD;AACzD,qGAA6E;AAC7E,+CAAmE;AACnE,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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,GAAG,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAC/D,MAAM,iBAAiB,GAAG,IAAA,+BAAc,EAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,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,MAAM,WAAW,GAAG;gBAClB;oBACE,MAAM;oBACN,WAAW;oBACX,YAAY;oBACZ,iBAAiB;oBACjB,KAAK;oBACL,MAAM,EAAE,EAAE;iBACX;aACF,CAAC;YAEF,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU,EAAV,sBAAU;gBACV,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AApMD,0DAoMC"}
1
+ {"version":3,"file":"getRaydiumCLMMPositions.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/getRaydiumCLMMPositions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,6CAA4C;AAC5C,2CAAyD;AACzD,qGAA6E;AAC7E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c,EAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,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,MAAM,WAAW,GAAG;gBAClB;oBACE,MAAM;oBACN,WAAW;oBACX,YAAY;oBACZ,iBAAiB;oBACjB,KAAK;oBACL,MAAM,EAAE,EAAE;iBACX;aACF,CAAC;YAEF,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,UAAU,EAAV,sBAAU;gBACV,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AA9ND,0DA8NC"}
@@ -14,4 +14,8 @@ export declare function getStakePubKey(owner: string): PublicKey;
14
14
  export declare function getFarmYield(rewardToken: TokenPrice, rewardPerBlock: BigNumber, tvl: number, slotsPerSec?: number): Yield;
15
15
  export declare function getPendingAssetToken(depositBalance: BigNumber, rewardDebt: BigNumber, perShare: BigNumber, rewardToken: TokenPrice, multiplier: number | BigNumber): PortfolioAssetToken;
16
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[];
17
+ export declare const getFeesAndRewardsBalance: (personalPositionInfo: ParsedAccount<PersonalPositionState>, poolStateInfo: ParsedAccount<PoolState>, tickArrays: (ParsedAccount<TickArrayState> | null)[]) => {
18
+ tokenFeeAmountA: BigNumber;
19
+ tokenFeeAmountB: BigNumber;
20
+ rewards: BigNumber[];
21
+ } | null;
@@ -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.getRewardBalance = exports.getTickArrayAddress = exports.getPendingAssetToken = exports.getFarmYield = exports.getStakePubKey = exports.getRaydiumTokenAmountsFromLiquidity = exports.raydiumTickToPriceX64 = exports.isARaydiumPosition = void 0;
6
+ exports.getFeesAndRewardsBalance = 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 */
@@ -295,29 +295,69 @@ function getTickOffsetInArray(tickIndex, tickSpacing) {
295
295
  }
296
296
  return offsetInArray;
297
297
  }
298
- const getRewardBalance = (personalPositionInfo, poolStateInfo, tickArrays) => {
298
+ function getfeeGrowthInside(poolState, tickLowerState, tickUpperState) {
299
+ let feeGrowthBelowX64A = new bn_js_1.default(0);
300
+ let feeGrowthBelowX64B = new bn_js_1.default(0);
301
+ if (poolState.tickCurrent >= tickLowerState.tick) {
302
+ feeGrowthBelowX64A = tickLowerState.feeGrowthOutsideX64A;
303
+ feeGrowthBelowX64B = tickLowerState.feeGrowthOutsideX64B;
304
+ }
305
+ else {
306
+ feeGrowthBelowX64A = poolState.feeGrowthGlobalX64A.sub(tickLowerState.feeGrowthOutsideX64A);
307
+ feeGrowthBelowX64B = poolState.feeGrowthGlobalX64B.sub(tickLowerState.feeGrowthOutsideX64B);
308
+ }
309
+ let feeGrowthAboveX64A = new bn_js_1.default(0);
310
+ let feeGrowthAboveX64B = new bn_js_1.default(0);
311
+ if (poolState.tickCurrent < tickUpperState.tick) {
312
+ feeGrowthAboveX64A = tickUpperState.feeGrowthOutsideX64A;
313
+ feeGrowthAboveX64B = tickUpperState.feeGrowthOutsideX64B;
314
+ }
315
+ else {
316
+ feeGrowthAboveX64A = poolState.feeGrowthGlobalX64A.sub(tickUpperState.feeGrowthOutsideX64A);
317
+ feeGrowthAboveX64B = poolState.feeGrowthGlobalX64B.sub(tickUpperState.feeGrowthOutsideX64B);
318
+ }
319
+ const feeGrowthInsideX64A = wrappingSubU128(wrappingSubU128(poolState.feeGrowthGlobalX64A, feeGrowthBelowX64A), feeGrowthAboveX64A);
320
+ const feeGrowthInsideBX64 = wrappingSubU128(wrappingSubU128(poolState.feeGrowthGlobalX64B, feeGrowthBelowX64B), feeGrowthAboveX64B);
321
+ return { feeGrowthInsideX64A, feeGrowthInsideBX64 };
322
+ }
323
+ function GetPositionFeesV2(ammPool, positionState, tickLowerState, tickUpperState) {
324
+ const { feeGrowthInsideX64A, feeGrowthInsideBX64 } = getfeeGrowthInside(ammPool, tickLowerState, tickUpperState);
325
+ const feeGrowthdeltaA = mulDivFloor(wrappingSubU128(feeGrowthInsideX64A, positionState.feeGrowthInsideLastX64A), positionState.liquidity, Q64);
326
+ const tokenFeeAmountA = positionState.tokenFeesOwedA.add(feeGrowthdeltaA);
327
+ const feeGrowthdelta1 = mulDivFloor(wrappingSubU128(feeGrowthInsideBX64, positionState.feeGrowthInsideLastX64B), positionState.liquidity, Q64);
328
+ const tokenFeeAmountB = positionState.tokenFeesOwedB.add(feeGrowthdelta1);
329
+ return { tokenFeeAmountA, tokenFeeAmountB };
330
+ }
331
+ const getFeesAndRewardsBalance = (personalPositionInfo, poolStateInfo, tickArrays) => {
299
332
  const [tickArrayLower, tickArrayUpper] = tickArrays;
300
333
  if (!tickArrayLower || !tickArrayUpper)
301
- return [];
334
+ return null;
302
335
  const tickLowerState = tickArrayLower &&
303
336
  tickArrayLower.ticks[getTickOffsetInArray(personalPositionInfo.tickLowerIndex, poolStateInfo.tickSpacing)];
304
337
  const tickUpperState = tickArrayUpper &&
305
338
  tickArrayUpper.ticks[getTickOffsetInArray(personalPositionInfo.tickUpperIndex, poolStateInfo.tickSpacing)];
306
339
  if (!tickLowerState || !tickUpperState)
307
- return [];
308
- return GetPositionRewardsV2({
340
+ return null;
341
+ const ammPool = {
309
342
  tickCurrent: poolStateInfo.tickCurrent,
310
- feeGrowthGlobalX64B: (0, toBN_1.toBN)(poolStateInfo.feeGrowthGlobal0X64),
343
+ feeGrowthGlobalX64A: (0, toBN_1.toBN)(poolStateInfo.feeGrowthGlobal0X64),
344
+ feeGrowthGlobalX64B: (0, toBN_1.toBN)(poolStateInfo.feeGrowthGlobal1X64),
311
345
  rewardInfos: poolStateInfo.rewardInfos.map((ri) => ({
312
346
  rewardGrowthGlobalX64: (0, toBN_1.toBN)(ri.rewardGrowthGlobalX64),
313
347
  })),
314
- }, {
348
+ };
349
+ const positionState = {
315
350
  liquidity: (0, toBN_1.toBN)(personalPositionInfo.liquidity),
316
351
  rewardInfos: personalPositionInfo.rewardInfos.map((ri) => ({
317
352
  growthInsideLastX64: (0, toBN_1.toBN)(ri.growthInsideLastX64),
318
353
  rewardAmountOwed: (0, toBN_1.toBN)(ri.rewardAmountOwed),
319
354
  })),
320
- }, {
355
+ feeGrowthInsideLastX64A: (0, toBN_1.toBN)(personalPositionInfo.feeGrowthInside0LastX64),
356
+ feeGrowthInsideLastX64B: (0, toBN_1.toBN)(personalPositionInfo.feeGrowthInside1LastX64),
357
+ tokenFeesOwedA: (0, toBN_1.toBN)(personalPositionInfo.tokenFeesOwed0),
358
+ tokenFeesOwedB: (0, toBN_1.toBN)(personalPositionInfo.tokenFeesOwed1),
359
+ };
360
+ const tickLowerS = {
321
361
  tick: tickLowerState.tick,
322
362
  liquidityNet: (0, toBN_1.toBN)(tickLowerState.liquidityNet),
323
363
  liquidityGross: (0, toBN_1.toBN)(tickLowerState.liquidityGross),
@@ -328,7 +368,8 @@ const getRewardBalance = (personalPositionInfo, poolStateInfo, tickArrays) => {
328
368
  (0, toBN_1.toBN)(tickLowerState.rewardGrowthsOutsideX641),
329
369
  (0, toBN_1.toBN)(tickLowerState.rewardGrowthsOutsideX642),
330
370
  ],
331
- }, {
371
+ };
372
+ const tickUpperS = {
332
373
  tick: tickUpperState.tick,
333
374
  liquidityNet: (0, toBN_1.toBN)(tickUpperState.liquidityNet),
334
375
  liquidityGross: (0, toBN_1.toBN)(tickUpperState.liquidityGross),
@@ -339,7 +380,14 @@ const getRewardBalance = (personalPositionInfo, poolStateInfo, tickArrays) => {
339
380
  (0, toBN_1.toBN)(tickUpperState.rewardGrowthsOutsideX641),
340
381
  (0, toBN_1.toBN)(tickUpperState.rewardGrowthsOutsideX642),
341
382
  ],
342
- }).map((bn) => new bignumber_js_1.default(bn.toString(10)));
383
+ };
384
+ const fees = GetPositionFeesV2(ammPool, positionState, tickLowerS, tickUpperS);
385
+ const rewards = GetPositionRewardsV2(ammPool, positionState, tickLowerS, tickUpperS);
386
+ return {
387
+ tokenFeeAmountA: new bignumber_js_1.default(fees.tokenFeeAmountA.toString(10)),
388
+ tokenFeeAmountB: new bignumber_js_1.default(fees.tokenFeeAmountB.toString(10)),
389
+ rewards: rewards.map((bn) => new bignumber_js_1.default(bn.toString(10))),
390
+ };
343
391
  };
344
- exports.getRewardBalance = getRewardBalance;
392
+ exports.getFeesAndRewardsBalance = getFeesAndRewardsBalance;
345
393
  //# 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;A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