@sonarwatch/portfolio-plugins 0.12.28 → 0.12.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/CHANGELOG.md +1810 -1806
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/src/plugins/balancer/helpers/pools.js +21 -21
  5. package/src/plugins/bonfida/airdropFetcher.d.ts +3 -0
  6. package/src/plugins/bonfida/airdropFetcher.js +59 -0
  7. package/src/plugins/bonfida/airdropFetcher.js.map +1 -0
  8. package/src/plugins/bonfida/constants.d.ts +4 -0
  9. package/src/plugins/bonfida/constants.js +5 -1
  10. package/src/plugins/bonfida/constants.js.map +1 -1
  11. package/src/plugins/bonfida/filters.d.ts +2 -0
  12. package/src/plugins/bonfida/filters.js +15 -0
  13. package/src/plugins/bonfida/filters.js.map +1 -0
  14. package/src/plugins/bonfida/index.js +2 -1
  15. package/src/plugins/bonfida/index.js.map +1 -1
  16. package/src/plugins/bonfida/types.d.ts +6 -0
  17. package/src/plugins/bonfida/types.js +3 -0
  18. package/src/plugins/bonfida/types.js.map +1 -0
  19. package/src/plugins/futarchy/constants.js +3 -0
  20. package/src/plugins/futarchy/constants.js.map +1 -1
  21. package/src/plugins/jupiter/exchange/filters.js +1 -6
  22. package/src/plugins/jupiter/exchange/filters.js.map +1 -1
  23. package/src/plugins/jupiter/exchange/perpetualFetcher.js +4 -3
  24. package/src/plugins/jupiter/exchange/perpetualFetcher.js.map +1 -1
  25. package/src/plugins/jupiter/exchange/structs.d.ts +1 -0
  26. package/src/plugins/jupiter/exchange/structs.js +1 -0
  27. package/src/plugins/jupiter/exchange/structs.js.map +1 -1
  28. package/src/plugins/meteora/dlmmPositionsFetcher.js +8 -9
  29. package/src/plugins/meteora/dlmmPositionsFetcher.js.map +1 -1
  30. package/src/plugins/parcl/marginFetcher.js +4 -2
  31. package/src/plugins/parcl/marginFetcher.js.map +1 -1
  32. package/src/plugins/pyth/stakingFetcher.js +4 -2
  33. package/src/plugins/pyth/stakingFetcher.js.map +1 -1
  34. package/src/plugins/raydium/clmmJob.js +114 -15
  35. package/src/plugins/raydium/clmmJob.js.map +1 -1
  36. package/src/plugins/raydium/cpmmJob.js +79 -65
  37. package/src/plugins/raydium/cpmmJob.js.map +1 -1
  38. package/src/plugins/sushiswap/helpers.js +24 -24
  39. package/src/plugins/uniswap-v2/helpers.js +22 -22
  40. package/src/plugins/whalesmarket/constants.d.ts +3 -0
  41. package/src/plugins/whalesmarket/constants.js +4 -1
  42. package/src/plugins/whalesmarket/constants.js.map +1 -1
  43. package/src/plugins/whalesmarket/depositFetcher.js +119 -26
  44. package/src/plugins/whalesmarket/depositFetcher.js.map +1 -1
  45. package/src/plugins/whalesmarket/filters.d.ts +20 -0
  46. package/src/plugins/whalesmarket/filters.js +25 -1
  47. package/src/plugins/whalesmarket/filters.js.map +1 -1
  48. package/src/plugins/whalesmarket/index.js +2 -1
  49. package/src/plugins/whalesmarket/index.js.map +1 -1
  50. package/src/plugins/whalesmarket/structs.d.ts +29 -0
  51. package/src/plugins/whalesmarket/structs.js +31 -1
  52. package/src/plugins/whalesmarket/structs.js.map +1 -1
  53. package/src/plugins/whalesmarket/tokensJob.d.ts +3 -0
  54. package/src/plugins/whalesmarket/tokensJob.js +47 -0
  55. package/src/plugins/whalesmarket/tokensJob.js.map +1 -0
  56. package/src/plugins/whalesmarket/types.d.ts +111 -0
  57. package/src/plugins/whalesmarket/types.js +48 -0
  58. package/src/plugins/whalesmarket/types.js.map +1 -0
  59. package/src/utils/misc/constants.d.ts +1 -0
  60. package/src/utils/misc/constants.js +2 -1
  61. package/src/utils/misc/constants.js.map +1 -1
  62. package/src/utils/misc/getLpUnderlyingTokenSource.js +2 -1
  63. package/src/utils/misc/getLpUnderlyingTokenSource.js.map +1 -1
  64. package/src/utils/sei/constants.js +8 -8
  65. package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -13,30 +13,129 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
16
+ const decimal_js_1 = __importDefault(require("decimal.js"));
17
17
  const constants_1 = require("./constants");
18
18
  const solana_1 = require("../../utils/solana");
19
19
  const clients_1 = require("../../utils/clients");
20
- const tokenPricesFromSqrt_1 = __importDefault(require("../../utils/clmm/tokenPricesFromSqrt"));
20
+ const tokenPricesFromSqrt_1 = require("../../utils/clmm/tokenPricesFromSqrt");
21
21
  const clmms_1 = require("./structs/clmms");
22
22
  const filters_1 = require("./filters");
23
+ const getLpUnderlyingTokenSource_1 = require("../../utils/misc/getLpUnderlyingTokenSource");
24
+ const constants_2 = require("../../utils/misc/constants");
23
25
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
24
26
  const client = (0, clients_1.getClientSolana)();
25
- const clmmPoolsInfo = yield (0, solana_1.getParsedProgramAccounts)(client, clmms_1.poolStateStruct, constants_1.raydiumProgram, filters_1.clmmPoolsStateFilter);
27
+ const allPoolsPubkeys = yield client.getProgramAccounts(constants_1.raydiumProgram, {
28
+ filters: filters_1.clmmPoolsStateFilter,
29
+ dataSlice: { offset: 0, length: 0 },
30
+ });
31
+ const acceptedPairs = getLpUnderlyingTokenSource_1.defaultAcceptedPairs.get(portfolio_core_1.NetworkId.solana);
32
+ if (!acceptedPairs)
33
+ return;
34
+ const step = 100;
35
+ const tokenPriceSources = [];
26
36
  const promises = [];
27
- for (let id = 0; id < clmmPoolsInfo.length; id++) {
28
- const poolState = clmmPoolsInfo[id];
29
- if (poolState.liquidity.isZero())
30
- continue;
31
- const reserve0 = yield client.getBalance(poolState.tokenVault0);
32
- const reserve1 = yield client.getBalance(poolState.tokenVault1);
33
- promises.push((0, tokenPricesFromSqrt_1.default)(cache, portfolio_core_1.NetworkId.solana, poolState.pubkey.toString(), new bignumber_js_1.default(reserve0), new bignumber_js_1.default(reserve1), poolState.sqrtPriceX64, poolState.tokenMint0.toString(), poolState.tokenMint1.toString()));
34
- promises.push(cache.setItem(poolState.pubkey.toString(), poolState, {
35
- prefix: constants_1.poolStatesPrefix,
36
- networkId: portfolio_core_1.NetworkId.solana,
37
- }));
37
+ let clmmPoolsInfo;
38
+ let tokenAccounts;
39
+ let tokenPriceById;
40
+ for (let offset = 0; offset < allPoolsPubkeys.length; offset += step) {
41
+ const tokenAccountsPkeys = [];
42
+ const mints = new Set();
43
+ clmmPoolsInfo = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, clmms_1.poolStateStruct, allPoolsPubkeys.slice(offset, offset + step).map((res) => res.pubkey));
44
+ clmmPoolsInfo.forEach((pI) => {
45
+ if (!pI)
46
+ return;
47
+ mints.add(pI.tokenMint0.toString());
48
+ mints.add(pI.tokenMint1.toString());
49
+ tokenAccountsPkeys.push(pI.tokenVault0, pI.tokenVault1);
50
+ });
51
+ [tokenAccounts, tokenPriceById] = yield Promise.all([
52
+ (0, solana_1.getParsedMultipleAccountsInfo)(client, solana_1.tokenAccountStruct, tokenAccountsPkeys),
53
+ cache.getTokenPricesAsMap(Array.from(mints), portfolio_core_1.NetworkId.solana),
54
+ ]);
55
+ const tokenAccountsMap = new Map();
56
+ tokenAccounts.forEach((tA) => {
57
+ if (!tA)
58
+ return;
59
+ tokenAccountsMap.set(tA.pubkey.toString(), tA);
60
+ });
61
+ let mintA;
62
+ let mintB;
63
+ let unknownPrice;
64
+ let decimalA;
65
+ let decimalB;
66
+ let poolState;
67
+ let refLiquidity;
68
+ let priceAToB;
69
+ let refTokenPrice;
70
+ let refTokenAccount;
71
+ for (let id = 0; id < clmmPoolsInfo.length; id++) {
72
+ poolState = clmmPoolsInfo[id];
73
+ if (!poolState || poolState.liquidity.isZero())
74
+ continue;
75
+ mintA = poolState.tokenMint0.toString();
76
+ mintB = poolState.tokenMint1.toString();
77
+ decimalA = poolState.mintDecimals0;
78
+ decimalB = poolState.mintDecimals1;
79
+ let refMint;
80
+ let unkMint;
81
+ let refTokenVault;
82
+ let aToB;
83
+ let refDecimal;
84
+ let unkDecimal;
85
+ if (acceptedPairs.includes(mintA)) {
86
+ refMint = mintA;
87
+ unkMint = mintB;
88
+ refTokenVault = poolState.tokenVault0.toString();
89
+ aToB = true;
90
+ refDecimal = decimalA;
91
+ unkDecimal = decimalB;
92
+ }
93
+ else if (acceptedPairs.includes(mintB)) {
94
+ refMint = mintB;
95
+ unkMint = mintA;
96
+ refTokenVault = poolState.tokenVault1.toString();
97
+ aToB = false;
98
+ refDecimal = decimalB;
99
+ unkDecimal = decimalA;
100
+ }
101
+ else {
102
+ continue;
103
+ }
104
+ refTokenPrice = tokenPriceById.get(refMint);
105
+ if (!refTokenPrice)
106
+ continue;
107
+ refTokenAccount = tokenAccountsMap.get(refTokenVault);
108
+ if (!refTokenAccount)
109
+ continue;
110
+ refLiquidity = refTokenAccount.amount
111
+ .times(refTokenPrice.price)
112
+ .dividedBy(Math.pow(10, refDecimal));
113
+ if (refLiquidity.isLessThan(constants_2.minimumReserveValue))
114
+ continue;
115
+ priceAToB = (0, tokenPricesFromSqrt_1.sqrtPriceX64ToPrice)(poolState.sqrtPriceX64, decimalA, decimalB);
116
+ unknownPrice = aToB
117
+ ? new decimal_js_1.default(refTokenPrice.price).dividedBy(priceAToB).toNumber()
118
+ : new decimal_js_1.default(refTokenPrice.price).times(priceAToB).toNumber();
119
+ tokenPriceSources.push({
120
+ address: unkMint,
121
+ decimals: unkDecimal,
122
+ id: constants_1.platformId,
123
+ networkId: portfolio_core_1.NetworkId.solana,
124
+ platformId: constants_1.platformId,
125
+ price: unknownPrice,
126
+ timestamp: Date.now(),
127
+ weight: 1,
128
+ });
129
+ promises.push(cache.setItem(poolState.pubkey.toString(), poolState, {
130
+ prefix: constants_1.poolStatesPrefix,
131
+ networkId: portfolio_core_1.NetworkId.solana,
132
+ }));
133
+ }
134
+ yield Promise.all([
135
+ ...promises,
136
+ cache.setTokenPriceSources(tokenPriceSources),
137
+ ]);
38
138
  }
39
- yield Promise.all(promises);
40
139
  });
41
140
  const job = {
42
141
  id: `${constants_1.platformId}-clmm`,
@@ -1 +1 @@
1
- {"version":3,"file":"clmmJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/clmmJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,gEAAqC;AACrC,2CAA2E;AAC3E,+CAA8D;AAC9D,iDAAsD;AAGtD,+FAA4E;AAC5E,2CAAkD;AAClD,uCAAiD;AAEjD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAwB,EAClD,MAAM,EACN,uBAAe,EACf,0BAAc,EACd,8BAAoB,CACrB,CAAC;IAEF,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;QACjD,MAAM,SAAS,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE;YAAE,SAAS;QAE3C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAChE,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAChE,QAAQ,CAAC,IAAI,CACX,IAAA,6BAAwB,EACtB,KAAK,EACL,0BAAS,CAAC,MAAM,EAChB,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,EAC3B,IAAI,sBAAS,CAAC,QAAQ,CAAC,EACvB,IAAI,sBAAS,CAAC,QAAQ,CAAC,EACvB,SAAS,CAAC,YAAY,EACtB,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,EAC/B,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAChC,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AAS,CAAC,MAAM;gBAC3B,UAAU,EAAV,sBAAU;gBACV,KAAK,EAAE,YAAY;gBACnB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,MAAM,EAAE,CAAC;aACV,CAAC,CAAC;YAEH,QAAQ,CAAC,IAAI,CACX,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE;gBACpD,MAAM,EAAE,4BAAgB;gBACxB,SAAS,EAAE,0BAAS,CAAC,MAAM;aAC5B,CAAC,CACH,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,GAAG,QAAQ;YACX,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;SAC9C,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,OAAO;IACxB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -18,74 +18,88 @@ const cpmm_1 = require("./structs/cpmm");
18
18
  const getLpTokenSourceRaw_1 = require("../../utils/misc/getLpTokenSourceRaw");
19
19
  const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
20
20
  const client = (0, clients_1.getClientSolana)();
21
- const clmmPoolsInfo = yield (0, solana_1.getParsedProgramAccounts)(client, cpmm_1.poolStateStruct, constants_1.cpmmProgramId, filters_1.cpmmPoolsStateFilter);
22
- const tokenAccountsPkeys = [];
23
- const mints = new Set();
24
- clmmPoolsInfo.forEach((pI) => {
25
- mints.add(pI.token0Mint.toString());
26
- mints.add(pI.token1Mint.toString());
27
- tokenAccountsPkeys.push(...[pI.token0Vault, pI.token1Vault]);
28
- });
29
- const [tokenAccounts, tokenPriceById] = yield Promise.all([
30
- (0, solana_1.getParsedMultipleAccountsInfo)(client, solana_1.tokenAccountStruct, tokenAccountsPkeys),
31
- cache.getTokenPricesAsMap(Array.from(mints), portfolio_core_1.NetworkId.solana),
32
- ]);
33
- const tokenAccountsMap = new Map();
34
- tokenAccounts.forEach((tA) => {
35
- if (!tA)
36
- return;
37
- tokenAccountsMap.set(tA.pubkey.toString(), tA);
21
+ const allPoolsPubkeys = yield client.getProgramAccounts(constants_1.cpmmProgramId, {
22
+ filters: filters_1.cpmmPoolsStateFilter,
23
+ dataSlice: { offset: 0, length: 0 },
38
24
  });
25
+ const step = 100;
39
26
  const tokenPriceSources = [];
40
- for (let id = 0; id < clmmPoolsInfo.length; id++) {
41
- const poolState = clmmPoolsInfo[id];
42
- const mintA = poolState.token0Mint.toString();
43
- const mintB = poolState.token1Mint.toString();
44
- const tokenAccountA = tokenAccountsMap.get(poolState.token0Vault.toString());
45
- const tokenAccountB = tokenAccountsMap.get(poolState.token1Vault.toString());
46
- if (!tokenAccountA || !tokenAccountB)
47
- continue;
48
- const decimalsA = poolState.mint0Decimals;
49
- const decimalsB = poolState.mint1Decimals;
50
- const tokenAmountARaw = tokenAccountA.amount;
51
- const tokenAmountBRaw = tokenAccountB.amount;
52
- if (tokenAmountARaw.isZero() && tokenAmountBRaw.isZero())
53
- continue;
54
- const [tokenPriceA, tokenPriceB] = [
55
- tokenPriceById.get(mintA),
56
- tokenPriceById.get(mintB),
57
- ];
58
- const { lpMint, lpMintDecimals, lpSupply } = poolState;
59
- if (lpSupply.isZero())
60
- continue;
61
- tokenPriceSources.push(...(0, getLpTokenSourceRaw_1.getLpTokenSourceRaw)({
62
- networkId: portfolio_core_1.NetworkId.solana,
63
- lpDetails: {
64
- address: lpMint.toString(),
65
- decimals: lpMintDecimals,
66
- supplyRaw: lpSupply,
67
- },
68
- poolUnderlyingsRaw: [
69
- {
70
- address: mintA,
71
- decimals: decimalsA,
72
- tokenPrice: tokenPriceA,
73
- reserveAmountRaw: tokenAmountARaw,
74
- weight: 0.5,
75
- },
76
- {
77
- address: mintB,
78
- decimals: decimalsB,
79
- tokenPrice: tokenPriceB,
80
- reserveAmountRaw: tokenAmountBRaw,
81
- weight: 0.5,
27
+ let cpmmPoolsInfo;
28
+ let tokenAccounts;
29
+ let tokenPriceById;
30
+ for (let offset = 0; offset < allPoolsPubkeys.length; offset += step) {
31
+ const tokenAccountsPkeys = [];
32
+ const mints = new Set();
33
+ cpmmPoolsInfo = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, cpmm_1.poolStateStruct, allPoolsPubkeys.slice(offset, offset + step).map((res) => res.pubkey));
34
+ cpmmPoolsInfo.forEach((pI) => {
35
+ if (!pI)
36
+ return;
37
+ mints.add(pI.token0Mint.toString());
38
+ mints.add(pI.token1Mint.toString());
39
+ tokenAccountsPkeys.push(...[pI.token0Vault, pI.token1Vault]);
40
+ });
41
+ [tokenAccounts, tokenPriceById] = yield Promise.all([
42
+ (0, solana_1.getParsedMultipleAccountsInfo)(client, solana_1.tokenAccountStruct, tokenAccountsPkeys),
43
+ cache.getTokenPricesAsMap(Array.from(mints), portfolio_core_1.NetworkId.solana),
44
+ ]);
45
+ const tokenAccountsMap = new Map();
46
+ tokenAccounts.forEach((tA) => {
47
+ if (!tA)
48
+ return;
49
+ tokenAccountsMap.set(tA.pubkey.toString(), tA);
50
+ });
51
+ for (let id = 0; id < cpmmPoolsInfo.length; id++) {
52
+ const poolState = cpmmPoolsInfo[id];
53
+ if (!poolState)
54
+ continue;
55
+ const mintA = poolState.token0Mint.toString();
56
+ const mintB = poolState.token1Mint.toString();
57
+ const tokenAccountA = tokenAccountsMap.get(poolState.token0Vault.toString());
58
+ const tokenAccountB = tokenAccountsMap.get(poolState.token1Vault.toString());
59
+ if (!tokenAccountA || !tokenAccountB)
60
+ continue;
61
+ const decimalsA = poolState.mint0Decimals;
62
+ const decimalsB = poolState.mint1Decimals;
63
+ const tokenAmountARaw = tokenAccountA.amount;
64
+ const tokenAmountBRaw = tokenAccountB.amount;
65
+ if (tokenAmountARaw.isZero() && tokenAmountBRaw.isZero())
66
+ continue;
67
+ const [tokenPriceA, tokenPriceB] = [
68
+ tokenPriceById.get(mintA),
69
+ tokenPriceById.get(mintB),
70
+ ];
71
+ const { lpMint, lpMintDecimals, lpSupply } = poolState;
72
+ if (lpSupply.isZero())
73
+ continue;
74
+ tokenPriceSources.push(...(0, getLpTokenSourceRaw_1.getLpTokenSourceRaw)({
75
+ networkId: portfolio_core_1.NetworkId.solana,
76
+ lpDetails: {
77
+ address: lpMint.toString(),
78
+ decimals: lpMintDecimals,
79
+ supplyRaw: lpSupply,
82
80
  },
83
- ],
84
- sourceId: poolState.pubkey.toString(),
85
- elementName: 'CPMM',
86
- platformId: constants_1.platformId,
87
- priceUnderlyings: true,
88
- }));
81
+ poolUnderlyingsRaw: [
82
+ {
83
+ address: mintA,
84
+ decimals: decimalsA,
85
+ tokenPrice: tokenPriceA,
86
+ reserveAmountRaw: tokenAmountARaw,
87
+ weight: 0.5,
88
+ },
89
+ {
90
+ address: mintB,
91
+ decimals: decimalsB,
92
+ tokenPrice: tokenPriceB,
93
+ reserveAmountRaw: tokenAmountBRaw,
94
+ weight: 0.5,
95
+ },
96
+ ],
97
+ sourceId: poolState.pubkey.toString(),
98
+ elementName: 'CPMM',
99
+ platformId: constants_1.platformId,
100
+ priceUnderlyings: true,
101
+ }));
102
+ }
89
103
  }
90
104
  yield cache.setTokenPriceSources(tokenPriceSources);
91
105
  });
@@ -1 +1 @@
1
- {"version":3,"file":"cpmmJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/cpmmJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAEvD,2CAAwD;AACxD,+CAK4B;AAC5B,iDAAsD;AAGtD,uCAAiD;AACjD,yCAAiD;AACjD,8EAA2E;AAE3E,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,aAAa,GAAG,MAAM,IAAA,iCAAwB,EAClD,MAAM,EACN,sBAAe,EACf,yBAAa,EACb,8B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AG,IAAA,yCAAmB,EAAC;gBACrB,SAAS,EAAE,0BAAS,CAAC,MAAM;gBAC3B,SAAS,EAAE;oBACT,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE;oBAC1B,QAAQ,EAAE,cAAc;oBACxB,SAAS,EAAE,QAAQ;iBACpB;gBACD,kBAAkB,EAAE;oBAClB;wBACE,OAAO,EAAE,KAAK;wBACd,QAAQ,EAAE,SAAS;wBACnB,UAAU,EAAE,WAAW;wBACvB,gBAAgB,EAAE,eAAe;wBACjC,MAAM,EAAE,GAAG;qBACZ;oBACD;wBACE,OAAO,EAAE,KAAK;wBACd,QAAQ,EAAE,SAAS;wBACnB,UAAU,EAAE,WAAW;wBACvB,gBAAgB,EAAE,eAAe;wBACjC,MAAM,EAAE,GAAG;qBACZ;iBACF;gBACD,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACrC,WAAW,EAAE,MAAM;gBACnB,UAAU,EAAV,sBAAU;gBACV,gBAAgB,EAAE,IAAI;aACvB,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;AACtD,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,OAAO;IACxB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
54
54
  }
55
55
  function getV3PairsAddresses(url, length = 300) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
- const query = (0, graphql_request_1.gql) `
58
- {
59
- pools(
60
- orderBy: totalValueLockedUSD
61
- first: ${length}
62
- orderDirection: desc
63
- where: { volumeUSD_not: "0", liquidity_not: "0" }
64
- ) {
65
- id
66
- token0Price
67
- token1Price
68
- liquidity
69
- token0 {
70
- id
71
- totalSupply
72
- decimals
73
- }
74
- token1 {
75
- id
76
- totalSupply
77
- decimals
78
- }
79
- }
80
- }
57
+ const query = (0, graphql_request_1.gql) `
58
+ {
59
+ pools(
60
+ orderBy: totalValueLockedUSD
61
+ first: ${length}
62
+ orderDirection: desc
63
+ where: { volumeUSD_not: "0", liquidity_not: "0" }
64
+ ) {
65
+ id
66
+ token0Price
67
+ token1Price
68
+ liquidity
69
+ token0 {
70
+ id
71
+ totalSupply
72
+ decimals
73
+ }
74
+ token1 {
75
+ id
76
+ totalSupply
77
+ decimals
78
+ }
79
+ }
80
+ }
81
81
  `;
82
82
  const res = yield (0, graphql_request_1.default)(url, query);
83
83
  const pools = res.pools;
@@ -40,28 +40,28 @@ function getPairKey(version) {
40
40
  exports.getPairKey = getPairKey;
41
41
  function getPairsV2FromTheGraph(url, length = 300) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const query = (0, graphql_request_1.gql) `
44
- {
45
- pairs(
46
- orderBy: reserveUSD
47
- first: ${length}
48
- orderDirection: desc
49
- where: { trackedReserveETH_not: "0" }
50
- ) {
51
- id
52
- reserve0
53
- reserve1
54
- totalSupply
55
- token0 {
56
- id
57
- decimals
58
- }
59
- token1 {
60
- id
61
- decimals
62
- }
63
- }
64
- }
43
+ const query = (0, graphql_request_1.gql) `
44
+ {
45
+ pairs(
46
+ orderBy: reserveUSD
47
+ first: ${length}
48
+ orderDirection: desc
49
+ where: { trackedReserveETH_not: "0" }
50
+ ) {
51
+ id
52
+ reserve0
53
+ reserve1
54
+ totalSupply
55
+ token0 {
56
+ id
57
+ decimals
58
+ }
59
+ token1 {
60
+ id
61
+ decimals
62
+ }
63
+ }
64
+ }
65
65
  `;
66
66
  const res = yield (0, graphql_request_1.default)(url, query);
67
67
  const pairs = res.pairs;
@@ -3,3 +3,6 @@ import { Platform } from '@sonarwatch/portfolio-core';
3
3
  export declare const platformId = "whalesmarket";
4
4
  export declare const platform: Platform;
5
5
  export declare const pid: PublicKey;
6
+ export declare const whalesApi = "https://api-v2.whales.market/v2/tokens/";
7
+ export declare const tokensKey = "tokens";
8
+ export declare const lastCountKey = "lastCount";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pid = exports.platform = exports.platformId = void 0;
3
+ exports.lastCountKey = exports.tokensKey = exports.whalesApi = exports.pid = exports.platform = exports.platformId = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.platformId = 'whalesmarket';
6
6
  exports.platform = {
@@ -12,4 +12,7 @@ exports.platform = {
12
12
  twitter: 'https://twitter.com/WhalesMarket',
13
13
  };
14
14
  exports.pid = new web3_js_1.PublicKey('stPdYNaJNsV3ytS9Xtx4GXXXRcVqVS6x66ZFa26K39S');
15
+ exports.whalesApi = 'https://api-v2.whales.market/v2/tokens/';
16
+ exports.tokensKey = 'tokens';
17
+ exports.lastCountKey = 'lastCount';
15
18
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/whalesmarket/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,cAAc,CAAC;AAC5B,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,oDAAoD;IAC3D,WAAW,EAAE,eAAe,EAAE,sCAAsC;IACpE,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,kCAAkC;CAC5C,CAAC;AAEW,QAAA,GAAG,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/whalesmarket/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG/B,QAAA,UAAU,GAAG,cAAc,CAAC;AAC5B,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,oDAAoD;IAC3D,WAAW,EAAE,eAAe,EAAE,sCAAsC;IACpE,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,kCAAkC;CAC5C,CAAC;AAEW,QAAA,GAAG,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC;AACnE,QAAA,SAAS,GAAG,yCAAyC,CAAC;AACtD,QAAA,SAAS,GAAG,QAAQ,CAAC;AACrB,QAAA,YAAY,GAAG,WAAW,CAAC"}