@sonarwatch/portfolio-plugins 0.12.156 → 0.12.158

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/CHANGELOG.md +1426 -1418
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/src/index.js +4 -0
  5. package/src/index.js.map +1 -1
  6. package/src/plugins/balancer/helpers/pools.js +21 -21
  7. package/src/plugins/kamino/constants.d.ts +1 -0
  8. package/src/plugins/kamino/constants.js +2 -1
  9. package/src/plugins/kamino/constants.js.map +1 -1
  10. package/src/plugins/kamino/lendsFetcher.js +20 -5
  11. package/src/plugins/kamino/lendsFetcher.js.map +1 -1
  12. package/src/plugins/kamino/marketsJob.js +7 -0
  13. package/src/plugins/kamino/marketsJob.js.map +1 -1
  14. package/src/plugins/meteora/dlmmPositionsFetcher.js +4 -5
  15. package/src/plugins/meteora/dlmmPositionsFetcher.js.map +1 -1
  16. package/src/plugins/raydium/getRaydiumCLMMPositions.js +66 -19
  17. package/src/plugins/raydium/getRaydiumCLMMPositions.js.map +1 -1
  18. package/src/plugins/raydium/helpers.d.ts +4 -0
  19. package/src/plugins/raydium/helpers.js +142 -1
  20. package/src/plugins/raydium/helpers.js.map +1 -1
  21. package/src/plugins/raydium/structs/clmms.d.ts +23 -2
  22. package/src/plugins/raydium/structs/clmms.js +21 -2
  23. package/src/plugins/raydium/structs/clmms.js.map +1 -1
  24. package/src/plugins/raydium/types.d.ts +125 -0
  25. package/src/plugins/raydium/types.js.map +1 -1
  26. package/src/plugins/sushiswap/helpers.js +24 -24
  27. package/src/plugins/tradeport/constants.d.ts +5 -0
  28. package/src/plugins/tradeport/constants.js +15 -0
  29. package/src/plugins/tradeport/constants.js.map +1 -0
  30. package/src/plugins/tradeport/helpers.d.ts +2 -0
  31. package/src/plugins/tradeport/helpers.js +24 -0
  32. package/src/plugins/tradeport/helpers.js.map +1 -0
  33. package/src/plugins/tradeport/index.d.ts +6 -0
  34. package/src/plugins/tradeport/index.js +13 -0
  35. package/src/plugins/tradeport/index.js.map +1 -0
  36. package/src/plugins/tradeport/locksJob.d.ts +3 -0
  37. package/src/plugins/tradeport/locksJob.js +32 -0
  38. package/src/plugins/tradeport/locksJob.js.map +1 -0
  39. package/src/plugins/tradeport/positionsFetcher.d.ts +3 -0
  40. package/src/plugins/tradeport/positionsFetcher.js +76 -0
  41. package/src/plugins/tradeport/positionsFetcher.js.map +1 -0
  42. package/src/plugins/tradeport/types.d.ts +28 -0
  43. package/src/plugins/tradeport/types.js +3 -0
  44. package/src/plugins/tradeport/types.js.map +1 -0
  45. package/src/plugins/uniswap-v2/helpers.js +22 -22
  46. package/src/plugins/zeta/airdropFetcher.js +14 -14
  47. package/src/utils/misc/toBN.d.ts +1 -1
  48. package/src/utils/misc/toBN.js +4 -1
  49. package/src/utils/misc/toBN.js.map +1 -1
  50. package/src/utils/sei/constants.js +8 -8
  51. package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
+ const constants_1 = require("./constants");
18
+ const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
19
+ const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
20
+ const helpers_1 = require("./helpers");
21
+ const locksMemo = new MemoizedCache_1.MemoizedCache(constants_1.locksCacheKey, {
22
+ prefix: constants_1.platformId,
23
+ networkId: portfolio_core_1.NetworkId.sui,
24
+ });
25
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const allLocks = yield locksMemo.getItem(cache);
27
+ if (!allLocks)
28
+ return [];
29
+ const locks = allLocks.filter((lock) => lock.fields.maker === owner);
30
+ if (!locks)
31
+ return [];
32
+ const suiTokenPrice = yield cache.getTokenPrice(portfolio_core_1.suiNetwork.native.address, portfolio_core_1.NetworkId.sui);
33
+ if (!suiTokenPrice)
34
+ return [];
35
+ const assets = [];
36
+ locks.forEach((lock) => {
37
+ var _a, _b;
38
+ const attributes = {
39
+ tags: [],
40
+ };
41
+ if (lock.fields.expire_at) {
42
+ attributes.lockedUntil = Number(lock.fields.expire_at);
43
+ }
44
+ const statusLabel = (0, helpers_1.getStatusLabel)(lock.fields.state);
45
+ if (statusLabel) {
46
+ (_a = attributes.tags) === null || _a === void 0 ? void 0 : _a.push(statusLabel);
47
+ }
48
+ const typeLabel = (0, helpers_1.getTypeLabel)(lock.fields.lock_type);
49
+ if (typeLabel) {
50
+ (_b = attributes.tags) === null || _b === void 0 ? void 0 : _b.push(typeLabel);
51
+ }
52
+ assets.push((0, tokenPriceToAssetToken_1.default)(suiTokenPrice.address, new bignumber_js_1.default(lock.fields.maker_price)
53
+ .dividedBy(Math.pow(10, suiTokenPrice.decimals))
54
+ .toNumber(), portfolio_core_1.NetworkId.sui, suiTokenPrice, undefined, attributes));
55
+ });
56
+ if (assets.length === 0)
57
+ return [];
58
+ return [
59
+ {
60
+ networkId: portfolio_core_1.NetworkId.sui,
61
+ platformId: constants_1.platformId,
62
+ type: portfolio_core_1.PortfolioElementType.multiple,
63
+ label: 'Deposit',
64
+ name: 'Locks',
65
+ data: { assets },
66
+ value: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
67
+ },
68
+ ];
69
+ });
70
+ const fetcher = {
71
+ id: `${constants_1.platformId}-positions`,
72
+ networkId: portfolio_core_1.NetworkId.sui,
73
+ executor,
74
+ };
75
+ exports.default = fetcher;
76
+ //# sourceMappingURL=positionsFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AACpC,gEAAqC;AAErC,2CAAwD;AAExD,kEAA+D;AAE/D,qGAA6E;AAC7E,uCAAyD;AAEzD,MAAM,SAAS,GAAG,IAAI,6BAAa,CAAS,yBAAa,EAAE;IACzD,MAAM,EAAE,sBAAU;IAClB,SAAS,EAAE,0BAAS,CAAC,GAAG;CACzB,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEhD,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IAEzB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IAErE,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,aAAa,CAC7C,2BAAU,CAAC,MAAM,CAAC,OAAO,EACzB,0BAAS,CAAC,GAAG,CACd,CAAC;IACF,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAE9B,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,KAAK,CAAC,OAAO,CAAC,CAA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AC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1D;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,28 @@
1
+ type ID = {
2
+ id: string;
3
+ };
4
+ export type Lock = {
5
+ fields: {
6
+ expire_at: string;
7
+ expire_in: string;
8
+ id: ID;
9
+ lock_type: string;
10
+ maker: string;
11
+ maker_price: string;
12
+ marketplace_fee: string;
13
+ nft_id: string;
14
+ premium: string;
15
+ premium_fee: string;
16
+ royalty: string;
17
+ state: string;
18
+ taker: string;
19
+ taker_price: string;
20
+ };
21
+ type: string;
22
+ };
23
+ export type LockObject = {
24
+ id: ID;
25
+ name: number[];
26
+ value: Lock;
27
+ };
28
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tradeport/types.ts"],"names":[],"mappings":""}
@@ -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;
@@ -42,20 +42,20 @@ const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/token
42
42
  const clients_1 = require("../../utils/clients");
43
43
  const getMultipleAccountsInfoSafe_1 = require("../../utils/solana/getMultipleAccountsInfoSafe");
44
44
  const helpers_1 = require("./helpers");
45
- const query = (0, graphql_request_1.gql) `
46
- query GetAirdropFinalFrontend($authority: String!) {
47
- getAirdropFinalFrontend(authority: $authority) {
48
- authority
49
- community_allocation
50
- eligibility
51
- main_allocation
52
- og_allocation
53
- s1_allocation
54
- s2_allocation
55
- total_allocation
56
- __typename
57
- }
58
- }
45
+ const query = (0, graphql_request_1.gql) `
46
+ query GetAirdropFinalFrontend($authority: String!) {
47
+ getAirdropFinalFrontend(authority: $authority) {
48
+ authority
49
+ community_allocation
50
+ eligibility
51
+ main_allocation
52
+ og_allocation
53
+ s1_allocation
54
+ s2_allocation
55
+ total_allocation
56
+ __typename
57
+ }
58
+ }
59
59
  `;
60
60
  const networkId = portfolio_core_1.NetworkId.solana;
61
61
  const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,3 +1,3 @@
1
1
  import BN from 'bn.js';
2
2
  import BigNumber from 'bignumber.js';
3
- export declare const toBN: (n: number | BN | BigNumber) => BN;
3
+ export declare const toBN: (n: number | string | BN | BigNumber) => BN;
@@ -10,13 +10,16 @@ const toBN = (n) => {
10
10
  if (typeof n === 'number') {
11
11
  return new bn_js_1.default(n);
12
12
  }
13
+ if (typeof n === 'string') {
14
+ return new bn_js_1.default(new bignumber_js_1.default(n).toFixed(0));
15
+ }
13
16
  if (n instanceof bn_js_1.default) {
14
17
  return n;
15
18
  }
16
19
  if (n instanceof bignumber_js_1.default) {
17
20
  return new bn_js_1.default(n.toFixed(0)); // Convert BigNumber to a string without decimals
18
21
  }
19
- throw new Error('Unsupported type for conversion to BN');
22
+ throw new Error(`Unsupported type for conversion to BN (${typeof n}) ${n}`);
20
23
  };
21
24
  exports.toBN = toBN;
22
25
  //# sourceMappingURL=toBN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toBN.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/toBN.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuB;AACvB,gEAAqC;AAE9B,MAAM,IAAI,GAAG,CAAC,CAA0B,EAAM,EAAE;IACrD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,YAAY,eAAE,EAAE,CAAC;QACpB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,CAAC,YAAY,sBAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,eAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iDAAiD;IAChF,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC3D,CAAC,CAAC;AAXW,QAAA,IAAI,QAWf"}
1
+ {"version":3,"file":"toBN.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/toBN.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuB;AACvB,gEAAqC;AAE9B,MAAM,IAAI,GAAG,CAAC,CAAmC,EAAM,EAAE;IAC9D,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,eAAE,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,eAAE,CAAC,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,CAAC,YAAY,eAAE,EAAE,CAAC;QACpB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,CAAC,YAAY,sBAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,eAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iDAAiD;IAChF,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,0CAA0C,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC;AAdW,QAAA,IAAI,QAcf"}
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.poolQueryMsg = exports.minterQueryMsg = exports.tokenInfoQueryMsg = exports.infoQueryMsg = void 0;
4
- exports.infoQueryMsg = JSON.parse(`{
5
- "info": {}
4
+ exports.infoQueryMsg = JSON.parse(`{
5
+ "info": {}
6
6
  }`);
7
- exports.tokenInfoQueryMsg = JSON.parse(`{
8
- "token_info": {}
7
+ exports.tokenInfoQueryMsg = JSON.parse(`{
8
+ "token_info": {}
9
9
  }`);
10
- exports.minterQueryMsg = JSON.parse(`{
11
- "minter": {}
10
+ exports.minterQueryMsg = JSON.parse(`{
11
+ "minter": {}
12
12
  }`);
13
- exports.poolQueryMsg = JSON.parse(`{
14
- "pool": {}
13
+ exports.poolQueryMsg = JSON.parse(`{
14
+ "pool": {}
15
15
  }`);
16
16
  //# sourceMappingURL=constants.js.map
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function getQueryBalanceByOwner(owner) {
4
- return JSON.parse(`{
5
- "balance": {
6
- "address": "${owner}"
7
- }
4
+ return JSON.parse(`{
5
+ "balance": {
6
+ "address": "${owner}"
7
+ }
8
8
  }`);
9
9
  }
10
10
  exports.default = getQueryBalanceByOwner;