@sonarwatch/portfolio-plugins 0.11.154 → 0.11.156

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +2 -2
  3. package/src/index.js +8 -0
  4. package/src/index.js.map +1 -1
  5. package/src/plugins/meteora/index.js +2 -1
  6. package/src/plugins/meteora/index.js.map +1 -1
  7. package/src/plugins/meteora/multiTokenPools.json +139 -0
  8. package/src/plugins/meteora/multiTokenPoolsJob.d.ts +3 -0
  9. package/src/plugins/meteora/multiTokenPoolsJob.js +76 -0
  10. package/src/plugins/meteora/multiTokenPoolsJob.js.map +1 -0
  11. package/src/plugins/meteora/poolsJob.js +8 -86
  12. package/src/plugins/meteora/poolsJob.js.map +1 -1
  13. package/src/plugins/meteora/vaultsJob.js +7 -8
  14. package/src/plugins/meteora/vaultsJob.js.map +1 -1
  15. package/src/plugins/tulip/constants.d.ts +10 -0
  16. package/src/plugins/tulip/constants.js +20 -0
  17. package/src/plugins/tulip/constants.js.map +1 -0
  18. package/src/plugins/tulip/depositsFetcher.d.ts +3 -0
  19. package/src/plugins/tulip/depositsFetcher.js +73 -0
  20. package/src/plugins/tulip/depositsFetcher.js.map +1 -0
  21. package/src/plugins/tulip/filters.d.ts +13 -0
  22. package/src/plugins/tulip/filters.js +18 -0
  23. package/src/plugins/tulip/filters.js.map +1 -0
  24. package/src/plugins/tulip/index.d.ts +6 -0
  25. package/src/plugins/tulip/index.js +14 -0
  26. package/src/plugins/tulip/index.js.map +1 -0
  27. package/src/plugins/tulip/lendingTokensJob.d.ts +3 -0
  28. package/src/plugins/tulip/lendingTokensJob.js +90 -0
  29. package/src/plugins/tulip/lendingTokensJob.js.map +1 -0
  30. package/src/plugins/tulip/strategyTokensJob.d.ts +3 -0
  31. package/src/plugins/tulip/strategyTokensJob.js +75 -0
  32. package/src/plugins/tulip/strategyTokensJob.js.map +1 -0
  33. package/src/plugins/tulip/structs.d.ts +178 -0
  34. package/src/plugins/tulip/structs.js +174 -0
  35. package/src/plugins/tulip/structs.js.map +1 -0
  36. package/src/plugins/uxd/constants.d.ts +9 -0
  37. package/src/plugins/uxd/constants.js +22 -0
  38. package/src/plugins/uxd/constants.js.map +1 -0
  39. package/src/plugins/uxd/filters.d.ts +6 -0
  40. package/src/plugins/uxd/filters.js +13 -0
  41. package/src/plugins/uxd/filters.js.map +1 -0
  42. package/src/plugins/uxd/index.d.ts +6 -0
  43. package/src/plugins/uxd/index.js +12 -0
  44. package/src/plugins/uxd/index.js.map +1 -0
  45. package/src/plugins/uxd/stakingFetcher.d.ts +3 -0
  46. package/src/plugins/uxd/stakingFetcher.js +60 -0
  47. package/src/plugins/uxd/stakingFetcher.js.map +1 -0
  48. package/src/plugins/uxd/structs.d.ts +16 -0
  49. package/src/plugins/uxd/structs.js +17 -0
  50. package/src/plugins/uxd/structs.js.map +1 -0
  51. package/src/plugins/meteora/pools.d.ts +0 -5
  52. package/src/plugins/meteora/pools.js +0 -143
  53. package/src/plugins/meteora/pools.js.map +0 -1
@@ -0,0 +1,73 @@
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 constants_1 = require("./constants");
17
+ const clients_1 = require("../../utils/clients");
18
+ const solana_1 = require("../../utils/solana");
19
+ const structs_1 = require("./structs");
20
+ const filters_1 = require("./filters");
21
+ const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
22
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
23
+ const client = (0, clients_1.getClientSolana)();
24
+ const userVaultsAccounts = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.depositTrackingV1Struct, constants_1.tulipV2ProgramId, (0, filters_1.userStrategyVaultsFilters)(owner));
25
+ if (!userVaultsAccounts)
26
+ return [];
27
+ const vaults = yield cache.getItem(constants_1.vaultsKey, {
28
+ prefix: constants_1.platformId,
29
+ networkId: portfolio_core_1.NetworkId.solana,
30
+ });
31
+ if (!vaults)
32
+ return [];
33
+ const tokenPriceById = yield cache.getTokenPricesAsMap(vaults.map((vault) => vault.base.sharesMint.toString()), portfolio_core_1.NetworkId.solana);
34
+ const vaultById = new Map();
35
+ vaults.forEach((vault) => vaultById.set(vault.pubkey.toString(), vault));
36
+ const assets = [];
37
+ for (let i = 0; i < userVaultsAccounts.length; i += 1) {
38
+ const userVaultsAccount = userVaultsAccounts[i];
39
+ if (userVaultsAccount.depositedBalance.isZero())
40
+ continue;
41
+ const vault = vaultById.get(userVaultsAccount.vault.toString());
42
+ if (!vault)
43
+ continue;
44
+ const lpTokenPrice = tokenPriceById.get(vault.base.sharesMint.toString());
45
+ if (!lpTokenPrice)
46
+ continue;
47
+ const amount = userVaultsAccount.depositedBalance
48
+ .div(Math.pow(10, lpTokenPrice.decimals))
49
+ .toNumber();
50
+ assets.push(...(0, tokenPriceToAssetTokens_1.default)(lpTokenPrice.address, amount, portfolio_core_1.NetworkId.solana, lpTokenPrice));
51
+ }
52
+ if (assets.length === 0)
53
+ return [];
54
+ return [
55
+ {
56
+ platformId: constants_1.platformId,
57
+ networkId: portfolio_core_1.NetworkId.solana,
58
+ type: portfolio_core_1.PortfolioElementType.multiple,
59
+ value: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
60
+ label: 'Deposit',
61
+ data: {
62
+ assets,
63
+ },
64
+ },
65
+ ];
66
+ });
67
+ const fetcher = {
68
+ id: `${constants_1.platformId}-deposits`,
69
+ networkId: portfolio_core_1.NetworkId.solana,
70
+ executor,
71
+ };
72
+ exports.default = fetcher;
73
+ //# sourceMappingURL=depositsFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tulip/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAKoC;AAGpC,2CAAsE;AACtE,iDAAsD;AACtD,+CAA6E;AAC7E,uCAA6E;AAC7E,uCAAsD;AACtD,uGAA+E;AAE/E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,kBAAkB,GAAG,MAAM,IAAA,iCAAwB,EACvD,MAAM,EACN,iCAAuB,EACvB,4BAAgB,EAChB,IAAA,mCAAyB,EAAC,KAAK,CAAC,CACjC,CAAC;IACF,IAAI,CAAC,kBAAkB;QAAE,OAAO,EAAE,CAAC;IAEnC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAChC,qBAAS,EACT;QACE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CACF,CAAC;IACF,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEvB,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACpD,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EACvD,0BAAS,CAAC,MAAM,CACjB,CAAC;IAEF,MAAM,SAAS,GAAyC,IAAI,GAAG,EAAE,CAAC;IAClE,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE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,CAAC,KAAK,CAAC,CAAC;YACzD,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE;gBACJ,MAAM;aACP;SACF;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare const userStrategyVaultsFilters: (address: string) => ({
2
+ memcmp: {
3
+ offset: number;
4
+ bytes: string;
5
+ };
6
+ dataSize?: undefined;
7
+ } | {
8
+ dataSize: number;
9
+ memcmp?: undefined;
10
+ })[];
11
+ export declare const strategyVaultsFilters: {
12
+ dataSize: number;
13
+ }[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.strategyVaultsFilters = exports.userStrategyVaultsFilters = void 0;
4
+ const structs_1 = require("./structs");
5
+ const userStrategyVaultsFilters = (address) => [
6
+ {
7
+ memcmp: {
8
+ offset: 8,
9
+ bytes: address,
10
+ },
11
+ },
12
+ { dataSize: structs_1.depositTrackingV1Struct.byteSize },
13
+ ];
14
+ exports.userStrategyVaultsFilters = userStrategyVaultsFilters;
15
+ exports.strategyVaultsFilters = [
16
+ { dataSize: structs_1.multiDepositOptimizerV1Struct.byteSize },
17
+ ];
18
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tulip/filters.ts"],"names":[],"mappings":";;;AAAA,uCAGmB;AAEZ,MAAM,yBAAyB,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC;IAC5D;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,OAAO;SACf;KACF;IACD,EAAE,QAAQ,EAAE,iCAAuB,CAAC,QAAQ,EAAE;CAC/C,CAAC;AARW,QAAA,yBAAyB,6BAQpC;AAEW,QAAA,qBAAqB,GAAG;IACnC,EAAE,QAAQ,EAAE,uCAA6B,CAAC,QAAQ,EAAE;CACrD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Platform } from '@sonarwatch/portfolio-core';
2
+ import { Fetcher } from '../../Fetcher';
3
+ import { Job } from '../../Job';
4
+ export declare const platforms: Platform[];
5
+ export declare const jobs: Job[];
6
+ export declare const fetchers: Fetcher[];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchers = exports.jobs = exports.platforms = void 0;
7
+ const constants_1 = require("./constants");
8
+ const strategyTokensJob_1 = __importDefault(require("./strategyTokensJob"));
9
+ const lendingTokensJob_1 = __importDefault(require("./lendingTokensJob"));
10
+ const depositsFetcher_1 = __importDefault(require("./depositsFetcher"));
11
+ exports.platforms = [constants_1.platform];
12
+ exports.jobs = [strategyTokensJob_1.default, lendingTokensJob_1.default];
13
+ exports.fetchers = [depositsFetcher_1.default];
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tulip/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,4EAAoD;AACpD,0EAAkD;AAClD,wEAAgD;AAEnC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,2BAAiB,EAAE,0BAAgB,CAAC,CAAC;AACpD,QAAA,QAAQ,GAAc,CAAC,yBAAe,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Job } from '../../Job';
2
+ declare const job: Job;
3
+ export default job;
@@ -0,0 +1,90 @@
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 clients_1 = require("../../utils/clients");
17
+ const solana_1 = require("../../utils/solana");
18
+ const constants_1 = require("./constants");
19
+ const structs_1 = require("./structs");
20
+ const constants_2 = require("../solend/constants");
21
+ const getLpTokenSource_1 = __importDefault(require("../../utils/misc/getLpTokenSource"));
22
+ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
23
+ const client = (0, clients_1.getClientSolana)();
24
+ const lendingReserves = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.lendingReserveStruct, constants_1.tulipLendingProgramId, [
25
+ {
26
+ dataSize: 622,
27
+ },
28
+ ]);
29
+ const mints = new Set();
30
+ const collatMint = [];
31
+ lendingReserves.forEach((reserve) => {
32
+ if (reserve.liquidity.mintPubKey.toString() !==
33
+ '11111111111111111111111111111111') {
34
+ mints.add(reserve.liquidity.mintPubKey.toString());
35
+ }
36
+ if (reserve.liquidity.collateralMint.toString() !==
37
+ '11111111111111111111111111111111') {
38
+ collatMint.push(reserve.liquidity.collateralMint);
39
+ }
40
+ });
41
+ const tokenPriceById = yield cache.getTokenPricesAsMap(Array.from(mints), portfolio_core_1.NetworkId.solana);
42
+ const mintAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, solana_1.mintAccountStruct, collatMint);
43
+ const mintAccountById = new Map();
44
+ mintAccounts.forEach((mA) => mA ? mintAccountById.set(mA.pubkey.toString(), mA) : undefined);
45
+ const promises = [];
46
+ for (let i = 0; i < lendingReserves.length; i += 1) {
47
+ const reserve = lendingReserves[i];
48
+ if (reserve.lendingMarket.toString() === '11111111111111111111111111111111')
49
+ continue;
50
+ const mint = reserve.liquidity.mintPubKey.toString();
51
+ const lpMint = reserve.liquidity.collateralMint.toString();
52
+ const tokenPrice = tokenPriceById.get(mint);
53
+ if (!tokenPrice)
54
+ continue;
55
+ // Assets amounts
56
+ const borrowedAmount = reserve.liquidity.borrowedAmountWads
57
+ .dividedBy(Math.pow(10, constants_2.wadsDecimal))
58
+ .dividedBy(Math.pow(10, tokenPrice.decimals));
59
+ const platformAmount = reserve.liquidity.platformAmountWads
60
+ .dividedBy(Math.pow(10, constants_2.wadsDecimal))
61
+ .dividedBy(Math.pow(10, tokenPrice.decimals));
62
+ const availableAmount = reserve.liquidity.availableAmount.dividedBy(Math.pow(10, tokenPrice.decimals));
63
+ const totalSupply = availableAmount
64
+ .plus(borrowedAmount)
65
+ .minus(platformAmount)
66
+ .toNumber();
67
+ const mintAccount = mintAccountById.get(lpMint);
68
+ if (!mintAccount)
69
+ continue;
70
+ const { supply, decimals } = mintAccount;
71
+ if (supply.isZero())
72
+ continue;
73
+ const lpTokenSource = (0, getLpTokenSource_1.default)(portfolio_core_1.NetworkId.solana, lpMint, constants_1.platformId, {
74
+ address: lpMint.toString(),
75
+ decimals,
76
+ supply: supply.dividedBy(Math.pow(10, decimals)).toNumber(),
77
+ }, [
78
+ Object.assign(Object.assign({}, tokenPrice), { reserveAmount: totalSupply }),
79
+ ]);
80
+ promises.push(cache.setTokenPriceSource(lpTokenSource));
81
+ }
82
+ yield Promise.all(promises);
83
+ });
84
+ const job = {
85
+ id: `${constants_1.platformId}-lending-tokens`,
86
+ executor,
87
+ label: 'normal',
88
+ };
89
+ exports.default = job;
90
+ //# sourceMappingURL=lendingTokensJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lendingTokensJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tulip/lendingTokensJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AAIvD,iDAAsD;AACtD,+CAK4B;AAC5B,2CAAgE;AAChE,uCAAiD;AACjD,mDAAkD;AAClD,yFAAiE;AAEjE,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,eAAe,GAAG,MAAM,IAAA,iCAAwB,EACpD,MAAM,EACN,8BAAoB,EACpB,iCAAqB,EACrB;QACE;YACE,QAAQ,EAAE,GAAG;SACd;KACF,CACF,CAAC;IAEF,MAAM,KAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;IACrC,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,eAAe,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAClC,IACE,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE;YACvC,kCAAkC,EAClC,CAAC;YACD,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrD,CAAC;QACD,IACE,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE;YAC3C,kCAAkC,EAClC,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QACpD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACpD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EACjB,0BAAS,CAAC,MAAM,CACjB,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,IAAA,sCAA6B,EACtD,MAAM,EACN,0BAAiB,EACjB,UAAU,CACX,CAAC;IACF,MAAM,e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,CACjE,SAAA,EAAE,EAAI,UAAU,CAAC,QAAQ,CAAA,CAC1B,CAAC;QAEF,MAAM,WAAW,GAAG,eAAe;aAChC,IAAI,CAAC,cAAc,CAAC;aACpB,KAAK,CAAC,cAAc,CAAC;aACrB,QAAQ,EAAE,CAAC;QAEd,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,WAAW;YAAE,SAAS;QAE3B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;QACzC,IAAI,MAAM,CAAC,MAAM,EAAE;YAAE,SAAS;QAE9B,MAAM,aAAa,GAAG,IAAA,0BAAgB,EACpC,0BAAS,CAAC,MAAM,EAChB,MAAM,EACN,sBAAU,EACV;YACE,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE;YAC1B,QAAQ;YACR,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,SAAA,EAAE,EAAI,QAAQ,CAAA,CAAC,CAAC,QAAQ,EAAE;SACpD,EACD;4CAEO,UAAU,KACb,aAAa,EAAE,WAAW;SAE7B,CACF,CAAC;QAEF,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,iBAAiB;IAClC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Job } from '../../Job';
2
+ declare const job: Job;
3
+ export default job;
@@ -0,0 +1,75 @@
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 clients_1 = require("../../utils/clients");
17
+ const solana_1 = require("../../utils/solana");
18
+ const constants_1 = require("./constants");
19
+ const structs_1 = require("./structs");
20
+ const getLpTokenSource_1 = __importDefault(require("../../utils/misc/getLpTokenSource"));
21
+ const filters_1 = require("./filters");
22
+ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
23
+ const client = (0, clients_1.getClientSolana)();
24
+ const strategyVaults = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.multiDepositOptimizerV1Struct, constants_1.tulipV2ProgramId, filters_1.strategyVaultsFilters);
25
+ const promises = [];
26
+ promises.push(cache.setItem(constants_1.vaultsKey, strategyVaults, {
27
+ prefix: constants_1.platformId,
28
+ networkId: portfolio_core_1.NetworkId.solana,
29
+ }));
30
+ const mints = new Set();
31
+ const collatMint = [];
32
+ strategyVaults.forEach((sV) => {
33
+ if (sV.base.underlyingMint.toString() !== '11111111111111111111111111111111') {
34
+ mints.add(sV.base.underlyingMint.toString());
35
+ }
36
+ if (sV.base.sharesMint.toString() !== '11111111111111111111111111111111') {
37
+ collatMint.push(sV.base.sharesMint);
38
+ }
39
+ });
40
+ const tokenPriceById = yield cache.getTokenPricesAsMap(Array.from(mints), portfolio_core_1.NetworkId.solana);
41
+ const mintAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, solana_1.mintAccountStruct, collatMint);
42
+ const mintAccountById = new Map();
43
+ mintAccounts.forEach((mA) => mA ? mintAccountById.set(mA.pubkey.toString(), mA) : undefined);
44
+ for (let i = 0; i < strategyVaults.length; i += 1) {
45
+ const strategyVault = strategyVaults[i];
46
+ const mint = strategyVault.base.underlyingMint.toString();
47
+ const lpMint = strategyVault.base.sharesMint.toString();
48
+ const tokenPrice = tokenPriceById.get(mint);
49
+ if (!tokenPrice)
50
+ continue;
51
+ const stakedAmount = strategyVault.base.totalDepositedBalance.dividedBy(Math.pow(10, tokenPrice.decimals));
52
+ const mintAccount = mintAccountById.get(lpMint);
53
+ if (!mintAccount)
54
+ continue;
55
+ const { supply, decimals } = mintAccount;
56
+ if (supply.isZero())
57
+ continue;
58
+ const lpTokenSource = (0, getLpTokenSource_1.default)(portfolio_core_1.NetworkId.solana, lpMint, constants_1.platformId, {
59
+ address: lpMint.toString(),
60
+ decimals,
61
+ supply: supply.dividedBy(Math.pow(10, decimals)).toNumber(),
62
+ }, [
63
+ Object.assign(Object.assign({}, tokenPrice), { reserveAmount: stakedAmount.toNumber() }),
64
+ ]);
65
+ promises.push(cache.setTokenPriceSource(lpTokenSource));
66
+ }
67
+ yield Promise.all(promises);
68
+ });
69
+ const job = {
70
+ id: `${constants_1.platformId}-strategy-tokens`,
71
+ executor,
72
+ label: 'normal',
73
+ };
74
+ exports.default = job;
75
+ //# sourceMappingURL=strategyTokensJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategyTokensJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tulip/strategyTokensJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuD;AAIvD,iDAAsD;AACtD,+CAK4B;AAC5B,2CAAsE;AACtE,uCAA0D;AAC1D,yFAAiE;AACjE,uCAAkD;AAElD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,cAAc,GAAG,MAAM,IAA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;IAC1D,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,kBAAkB;IACnC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -0,0 +1,178 @@
1
+ /// <reference types="node" />
2
+ import { BeetStruct } from '@metaplex-foundation/beet';
3
+ import { PublicKey } from '@solana/web3.js';
4
+ import BigNumber from 'bignumber.js';
5
+ type RealizedYield = {
6
+ gainPerSecond: BigNumber;
7
+ apr: BigNumber;
8
+ buffer: Buffer[];
9
+ };
10
+ export declare const realizedYieldStruct: BeetStruct<RealizedYield, Partial<RealizedYield>>;
11
+ type FeesV1 = {
12
+ feeMultiplier: BigNumber;
13
+ controllerFee: BigNumber;
14
+ platformFee: BigNumber;
15
+ withdrawFee: BigNumber;
16
+ depositFee: BigNumber;
17
+ feeWallet: PublicKey;
18
+ totalCollectedA: BigNumber;
19
+ totalCollectedB: BigNumber;
20
+ buffer: BigNumber[];
21
+ };
22
+ export declare const feesV1Struct: BeetStruct<FeesV1, Partial<FeesV1>>;
23
+ type VaultBaseV1 = {
24
+ nonce: number;
25
+ tag: number[];
26
+ pda: PublicKey;
27
+ pdaNonce: number;
28
+ pdaAlignment: number[];
29
+ totalDepositedBalance: BigNumber;
30
+ totalShares: BigNumber;
31
+ underlyingMint: PublicKey;
32
+ underlyingWithdrawQueue: PublicKey;
33
+ underlyingDepositQueue: PublicKey;
34
+ underlyingCompoundQueue: PublicKey;
35
+ sharesMint: PublicKey;
36
+ withdrawsPaused: number;
37
+ depositsPaused: number;
38
+ compoundPaused: number;
39
+ supportsCompound: number;
40
+ rebasePaused: number;
41
+ rebalancePaused: number;
42
+ stateAlignment: number[];
43
+ precisionFactor: BigNumber;
44
+ lastCompoundTime: BigNumber;
45
+ compoundInterval: BigNumber;
46
+ slippageTolerance: number;
47
+ slipAlignment: number[];
48
+ fees: FeesV1;
49
+ farm: BigNumber[];
50
+ configured: number;
51
+ configuredAlignment: number[];
52
+ pendingFees: BigNumber;
53
+ totalDepositedBalanceCap: BigNumber;
54
+ realizedYield: RealizedYield;
55
+ buffer: BigNumber[];
56
+ };
57
+ export declare const vaultBaseV1Struct: BeetStruct<VaultBaseV1, Partial<VaultBaseV1>>;
58
+ export declare enum ProgramType {
59
+ SplUnmodified = 0,
60
+ SplModifiedSolend = 1,
61
+ MangoV3 = 2,
62
+ Unknown = 3
63
+ }
64
+ type StandaloneVaultCacheV1 = {
65
+ vaultAddress: PublicKey;
66
+ depositedBalance: BigNumber;
67
+ programType: ProgramType;
68
+ programAddress: PublicKey;
69
+ sharesMint: PublicKey;
70
+ sharesAccount: PublicKey;
71
+ alignment: number[];
72
+ buffer: BigNumber[];
73
+ };
74
+ export declare const standaloneVaultCacheV1Struct: BeetStruct<StandaloneVaultCacheV1, Partial<StandaloneVaultCacheV1>>;
75
+ export type MultiDepositOptimizerV1 = {
76
+ buffer: Buffer;
77
+ base: VaultBaseV1;
78
+ lastRebaseSlot: BigNumber;
79
+ standaloneVaults: StandaloneVaultCacheV1[];
80
+ targetVault: PublicKey;
81
+ stateTransitionAccount: PublicKey;
82
+ minimumRebalanceAmount: BigNumber;
83
+ pading: number[];
84
+ };
85
+ export declare const multiDepositOptimizerV1Struct: BeetStruct<MultiDepositOptimizerV1, Partial<MultiDepositOptimizerV1>>;
86
+ type DepositTrackingV1 = {
87
+ buffer: Buffer;
88
+ owner: PublicKey;
89
+ vault: PublicKey;
90
+ pdaNonce: number;
91
+ queueNonce: number;
92
+ alignment: number[];
93
+ shares: BigNumber;
94
+ depositedBalance: BigNumber;
95
+ lastDepositTime: BigNumber;
96
+ pendingWithdrawAmount: BigNumber;
97
+ totalDepositedUnderlying: BigNumber;
98
+ totalWithdrawnUnderlying: BigNumber;
99
+ lastPendingReward: BigNumber;
100
+ rewardPerSharePaid: BigNumber;
101
+ extraDataAccount: PublicKey;
102
+ padding: number[];
103
+ };
104
+ export declare const depositTrackingV1Struct: BeetStruct<DepositTrackingV1, Partial<DepositTrackingV1>>;
105
+ export type LastUpdateSlot = {
106
+ slot: BigNumber;
107
+ stale: number;
108
+ };
109
+ export declare const lastUpdateSlotStruct: BeetStruct<LastUpdateSlot, Partial<LastUpdateSlot>>;
110
+ export type Liquidity = {
111
+ mintPubKey: PublicKey;
112
+ mintDecimals: number;
113
+ supplyPubKey: PublicKey;
114
+ feeReceiver: PublicKey;
115
+ oraclePubKey: PublicKey;
116
+ availableAmount: BigNumber;
117
+ borrowedAmountWads: BigNumber;
118
+ cumulativeBorrowRate: BigNumber;
119
+ marketPrice: BigNumber;
120
+ platformAmountWads: BigNumber;
121
+ platformFees: number;
122
+ collateralMint: PublicKey;
123
+ };
124
+ export declare const liquidityStruct: BeetStruct<Liquidity, Partial<Liquidity>>;
125
+ export type LendingReserve = {
126
+ version: number;
127
+ lastUpdateSlot: LastUpdateSlot;
128
+ lendingMarket: PublicKey;
129
+ borrowAuthorizer: PublicKey;
130
+ liquidity: Liquidity;
131
+ };
132
+ export declare const lendingReserveStruct: BeetStruct<LendingReserve, Partial<LendingReserve>>;
133
+ export type Obligation = {
134
+ obligationAccount: PublicKey;
135
+ coinAmount: BigNumber;
136
+ pcAmount: BigNumber;
137
+ depositedLpTokens: BigNumber;
138
+ positionState: number;
139
+ };
140
+ export declare const obligationStruct: BeetStruct<Obligation, Partial<Obligation>>;
141
+ export type UserFarm = {
142
+ buffer: Buffer;
143
+ authority: PublicKey;
144
+ leveragedFarm: PublicKey;
145
+ userFarmNumber: number;
146
+ numberOfObligations: number;
147
+ numberOfUserFarms: number;
148
+ nonce: number;
149
+ obligations: Obligation[];
150
+ };
151
+ export declare const userFarmStruct: BeetStruct<UserFarm, Partial<UserFarm>>;
152
+ export type ObligationLiquity = {
153
+ borrowReserve: PublicKey;
154
+ cumulativeBorrowRateWads: BigNumber;
155
+ borrowedAmountWads: BigNumber;
156
+ marketValue: BigNumber;
157
+ };
158
+ export declare const obligationLiquityStruct: BeetStruct<ObligationLiquity, Partial<ObligationLiquity>>;
159
+ export type LendingObligation = {
160
+ version: number;
161
+ lastUpdateSlot: LastUpdateSlot;
162
+ lendingMarket: PublicKey;
163
+ owner: PublicKey;
164
+ borrowedValue: BigNumber;
165
+ vaultShares: BigNumber;
166
+ lpTokens: BigNumber;
167
+ coinDeposits: BigNumber;
168
+ pcDeposits: BigNumber;
169
+ depositsMarketValue: BigNumber;
170
+ lpDecimals: number;
171
+ coinDecimals: number;
172
+ pcDecimals: number;
173
+ depositsLen: number;
174
+ borrowsLen: number;
175
+ obligationLiquidities: ObligationLiquity[];
176
+ };
177
+ export declare const lendingObligationStruct: BeetStruct<LendingObligation, Partial<LendingObligation>>;
178
+ export {};