@sonarwatch/portfolio-plugins 0.12.170 → 0.12.172
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/Cache.d.ts +2 -1
- package/src/Cache.js +3 -3
- package/src/Cache.js.map +1 -1
- package/src/TokenPriceMap.d.ts +8 -0
- package/src/TokenPriceMap.js +21 -0
- package/src/TokenPriceMap.js.map +1 -0
- package/src/index.js +16 -0
- package/src/index.js.map +1 -1
- package/src/plugins/adrastea/constants.d.ts +9 -0
- package/src/plugins/adrastea/constants.js +19 -0
- package/src/plugins/adrastea/constants.js.map +1 -0
- package/src/plugins/adrastea/index.d.ts +6 -0
- package/src/plugins/adrastea/index.js +13 -0
- package/src/plugins/adrastea/index.js.map +1 -0
- package/src/plugins/adrastea/positionsFetcher.js +61 -0
- package/src/plugins/adrastea/positionsFetcher.js.map +1 -0
- package/src/plugins/adrastea/positionsJob.d.ts +3 -0
- package/src/plugins/adrastea/positionsJob.js +53 -0
- package/src/plugins/adrastea/positionsJob.js.map +1 -0
- package/src/plugins/adrastea/structs.d.ts +45 -0
- package/src/plugins/adrastea/structs.js +44 -0
- package/src/plugins/adrastea/structs.js.map +1 -0
- package/src/plugins/adrastea/types.d.ts +4 -0
- package/src/plugins/adrastea/types.js +3 -0
- package/src/plugins/adrastea/types.js.map +1 -0
- package/src/plugins/banx/stakingFetcher.js +11 -15
- package/src/plugins/banx/stakingFetcher.js.map +1 -1
- package/src/plugins/bluemove/constants.d.ts +7 -0
- package/src/plugins/bluemove/constants.js +17 -0
- package/src/plugins/bluemove/constants.js.map +1 -0
- package/src/plugins/bluemove/index.d.ts +6 -0
- package/src/plugins/bluemove/index.js +12 -0
- package/src/plugins/bluemove/index.js.map +1 -0
- package/src/plugins/bluemove/poolsJob.d.ts +3 -0
- package/src/plugins/bluemove/poolsJob.js +97 -0
- package/src/plugins/bluemove/poolsJob.js.map +1 -0
- package/src/plugins/bluemove/types.d.ts +21 -0
- package/src/plugins/bluemove/types.js +3 -0
- package/src/plugins/bluemove/types.js.map +1 -0
- package/src/plugins/cetus/clmmsFetcher.js +3 -3
- package/src/plugins/cetus/clmmsFetcher.js.map +1 -1
- package/src/plugins/cetus/constants.d.ts +4 -0
- package/src/plugins/cetus/constants.js +5 -1
- package/src/plugins/cetus/constants.js.map +1 -1
- package/src/plugins/cetus/dcaFetcher.js +77 -0
- package/src/plugins/cetus/dcaFetcher.js.map +1 -0
- package/src/plugins/cetus/farmsFetcher.js +2 -4
- package/src/plugins/cetus/farmsFetcher.js.map +1 -1
- package/src/plugins/cetus/index.js +8 -1
- package/src/plugins/cetus/index.js.map +1 -1
- package/src/plugins/cetus/limitFetcher.d.ts +3 -0
- package/src/plugins/cetus/limitFetcher.js +66 -0
- package/src/plugins/cetus/limitFetcher.js.map +1 -0
- package/src/plugins/cetus/types.d.ts +32 -0
- package/src/plugins/deepbook/constants.d.ts +3 -0
- package/src/plugins/deepbook/constants.js +4 -1
- package/src/plugins/deepbook/constants.js.map +1 -1
- package/src/plugins/deepbook/helpers.d.ts +4 -0
- package/src/plugins/deepbook/helpers.js +142 -0
- package/src/plugins/deepbook/helpers.js.map +1 -0
- package/src/plugins/deepbook/index.js +7 -2
- package/src/plugins/deepbook/index.js.map +1 -1
- package/src/plugins/deepbook/ordersFetcher.d.ts +3 -0
- package/src/plugins/deepbook/ordersFetcher.js +74 -0
- package/src/plugins/deepbook/ordersFetcher.js.map +1 -0
- package/src/plugins/deepbook/poolsJob.d.ts +3 -0
- package/src/plugins/deepbook/poolsJob.js +30 -0
- package/src/plugins/deepbook/poolsJob.js.map +1 -0
- package/src/plugins/deepbook/types.d.ts +12 -0
- package/src/plugins/deepbook/types.js +3 -0
- package/src/plugins/deepbook/types.js.map +1 -0
- package/src/plugins/flowx/stakingPoolFetcher.js +1 -1
- package/src/plugins/flowx/stakingPoolFetcher.js.map +1 -1
- package/src/plugins/flowx/stakingPoolV3Fetcher.js +1 -1
- package/src/plugins/flowx/stakingPoolV3Fetcher.js.map +1 -1
- package/src/plugins/foo/constants.d.ts +1 -1
- package/src/plugins/foo/constants.js +2 -2
- package/src/plugins/foo/constants.js.map +1 -1
- package/src/plugins/foo/index.js +2 -2
- package/src/plugins/foo/index.js.map +1 -1
- package/src/plugins/foo/marketsJob.js +3 -3
- package/src/plugins/foo/marketsJob.js.map +1 -1
- package/src/plugins/foo/positionsEthereumFetcher.d.ts +3 -0
- package/src/plugins/foo/positionsEthereumFetcher.js +33 -0
- package/src/plugins/foo/positionsEthereumFetcher.js.map +1 -0
- package/src/plugins/foo/positionsSolanaFetcher.js +10 -26
- package/src/plugins/foo/positionsSolanaFetcher.js.map +1 -1
- package/src/plugins/foo/positionsSuiFetcher.d.ts +3 -0
- package/src/plugins/foo/positionsSuiFetcher.js +46 -0
- package/src/plugins/foo/positionsSuiFetcher.js.map +1 -0
- package/src/plugins/foo/types.d.ts +5 -0
- package/src/plugins/foo/types.js +3 -0
- package/src/plugins/foo/types.js.map +1 -0
- package/src/plugins/francium/constants.d.ts +19 -0
- package/src/plugins/francium/constants.js +839 -0
- package/src/plugins/francium/constants.js.map +1 -0
- package/src/plugins/francium/helpers.d.ts +14 -0
- package/src/plugins/francium/helpers.js +85 -0
- package/src/plugins/francium/helpers.js.map +1 -0
- package/src/plugins/francium/index.d.ts +6 -0
- package/src/plugins/francium/index.js +13 -0
- package/src/plugins/francium/index.js.map +1 -0
- package/src/plugins/francium/lendingFetcher.d.ts +3 -0
- package/src/plugins/francium/lendingFetcher.js +70 -0
- package/src/plugins/francium/lendingFetcher.js.map +1 -0
- package/src/plugins/francium/lendingPoolJob.d.ts +3 -0
- package/src/plugins/francium/lendingPoolJob.js +49 -0
- package/src/plugins/francium/lendingPoolJob.js.map +1 -0
- package/src/plugins/francium/structs.d.ts +59 -0
- package/src/plugins/francium/structs.js +49 -0
- package/src/plugins/francium/structs.js.map +1 -0
- package/src/plugins/francium/tokens.d.ts +9 -0
- package/src/plugins/francium/tokens.js +524 -0
- package/src/plugins/francium/tokens.js.map +1 -0
- package/src/plugins/francium/types.d.ts +16 -0
- package/src/plugins/francium/types.js +3 -0
- package/src/plugins/francium/types.js.map +1 -0
- package/src/plugins/kamino/constants.js +4 -0
- package/src/plugins/kamino/constants.js.map +1 -1
- package/src/plugins/kamino/lendsFetcher.js +64 -167
- package/src/plugins/kamino/lendsFetcher.js.map +1 -1
- package/src/plugins/kriya/farmsFetcher.js +23 -48
- package/src/plugins/kriya/farmsFetcher.js.map +1 -1
- package/src/plugins/kriya/leverageVaultsFetcher.js +5 -5
- package/src/plugins/kriya/leverageVaultsFetcher.js.map +1 -1
- package/src/plugins/meteora/farmsFetcher.js +19 -68
- package/src/plugins/meteora/farmsFetcher.js.map +1 -1
- package/src/plugins/nxfinance/positionsFetcher.js +32 -80
- package/src/plugins/nxfinance/positionsFetcher.js.map +1 -1
- package/src/plugins/quarry/positionsFetcher.js +1 -1
- package/src/plugins/quarry/positionsFetcher.js.map +1 -1
- package/src/plugins/raydium/farmsFetcher.js +30 -74
- package/src/plugins/raydium/farmsFetcher.js.map +1 -1
- package/src/plugins/raydium/helpers.d.ts +3 -2
- package/src/plugins/raydium/helpers.js +5 -7
- package/src/plugins/raydium/helpers.js.map +1 -1
- package/src/plugins/raydium/index.js +1 -2
- package/src/plugins/raydium/index.js.map +1 -1
- package/src/plugins/raydium/lpTokensJob.js +1 -1
- package/src/plugins/raydium/lpTokensJob.js.map +1 -1
- package/src/plugins/stabble/constants.d.ts +8 -0
- package/src/plugins/stabble/constants.js +27 -0
- package/src/plugins/stabble/constants.js.map +1 -0
- package/src/plugins/stabble/filters.d.ts +3 -0
- package/src/plugins/stabble/filters.js +20 -0
- package/src/plugins/stabble/filters.js.map +1 -0
- package/src/plugins/stabble/index.d.ts +6 -0
- package/src/plugins/stabble/index.js +12 -0
- package/src/plugins/stabble/index.js.map +1 -0
- package/src/plugins/stabble/poolsJob.d.ts +3 -0
- package/src/plugins/stabble/poolsJob.js +84 -0
- package/src/plugins/stabble/poolsJob.js.map +1 -0
- package/src/plugins/stabble/stableIdl.d.ts +40 -0
- package/src/plugins/stabble/stableIdl.js +104 -0
- package/src/plugins/stabble/stableIdl.js.map +1 -0
- package/src/plugins/stabble/types.d.ts +40 -0
- package/src/plugins/stabble/types.js +3 -0
- package/src/plugins/stabble/types.js.map +1 -0
- package/src/plugins/stabble/weightedIdl.d.ts +40 -0
- package/src/plugins/stabble/weightedIdl.js +96 -0
- package/src/plugins/stabble/weightedIdl.js.map +1 -0
- package/src/utils/bitcoin/getBalance.js +1 -0
- package/src/utils/bitcoin/getBalance.js.map +1 -1
- package/src/utils/elementbuilder/AssetBuilder.d.ts +11 -0
- package/src/utils/elementbuilder/AssetBuilder.js +28 -0
- package/src/utils/elementbuilder/AssetBuilder.js.map +1 -0
- package/src/utils/elementbuilder/ElementBorrowlendBuilder.d.ts +27 -0
- package/src/utils/elementbuilder/ElementBorrowlendBuilder.js +110 -0
- package/src/utils/elementbuilder/ElementBorrowlendBuilder.js.map +1 -0
- package/src/utils/elementbuilder/ElementBuilder.d.ts +12 -0
- package/src/utils/elementbuilder/ElementBuilder.js +13 -0
- package/src/utils/elementbuilder/ElementBuilder.js.map +1 -0
- package/src/utils/elementbuilder/ElementLiquidityBuilder.d.ts +12 -0
- package/src/utils/elementbuilder/ElementLiquidityBuilder.js +42 -0
- package/src/utils/elementbuilder/ElementLiquidityBuilder.js.map +1 -0
- package/src/utils/elementbuilder/ElementMultipleBuilder.d.ts +13 -0
- package/src/utils/elementbuilder/ElementMultipleBuilder.js +40 -0
- package/src/utils/elementbuilder/ElementMultipleBuilder.js.map +1 -0
- package/src/utils/elementbuilder/ElementParams.d.ts +7 -0
- package/src/utils/elementbuilder/ElementParams.js +3 -0
- package/src/utils/elementbuilder/ElementParams.js.map +1 -0
- package/src/utils/elementbuilder/ElementRegistry.d.ts +17 -0
- package/src/utils/elementbuilder/ElementRegistry.js +49 -0
- package/src/utils/elementbuilder/ElementRegistry.js.map +1 -0
- package/src/utils/elementbuilder/LiquidityBuilder.d.ts +15 -0
- package/src/utils/elementbuilder/LiquidityBuilder.js +52 -0
- package/src/utils/elementbuilder/LiquidityBuilder.js.map +1 -0
- package/src/utils/elementbuilder/PortfolioAssetParams.d.ts +7 -0
- package/src/utils/elementbuilder/PortfolioAssetParams.js +3 -0
- package/src/utils/elementbuilder/PortfolioAssetParams.js.map +1 -0
- package/src/plugins/foo/positionsFetcher.js +0 -49
- package/src/plugins/foo/positionsFetcher.js.map +0 -1
- package/src/plugins/raydium/stakingFetcher.js +0 -50
- package/src/plugins/raydium/stakingFetcher.js.map +0 -1
- /package/src/plugins/{foo → adrastea}/positionsFetcher.d.ts +0 -0
- /package/src/plugins/{raydium/stakingFetcher.d.ts → cetus/dcaFetcher.d.ts} +0 -0
@@ -8,18 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
13
|
const constants_1 = require("./constants");
|
17
14
|
const clients_1 = require("../../utils/clients");
|
18
15
|
const solana_1 = require("../../utils/solana");
|
19
16
|
const struct_1 = require("./struct");
|
20
|
-
const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
|
21
|
-
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
22
17
|
const helpers_1 = require("./helpers");
|
18
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
23
19
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
20
|
const client = (0, clients_1.getClientSolana)();
|
25
21
|
const farms = yield cache.getItem(constants_1.farmsKey, {
|
@@ -36,78 +32,33 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
36
32
|
});
|
37
33
|
const farmingAccountsAddresses = (0, helpers_1.getStakingAccounts)(owner, farmsMint);
|
38
34
|
const farmingAccounts = yield (0, solana_1.getParsedMultipleAccountsInfo)(client, struct_1.farmAccountStruct, farmingAccountsAddresses);
|
39
|
-
const
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
const farm = farms.at(i);
|
44
|
-
if (!farm)
|
45
|
-
return [];
|
46
|
-
return [farm.stakingMint, farm.rewardAMint, farm.rewardBMint];
|
47
|
-
})
|
48
|
-
.flat();
|
49
|
-
const tokenPrices = yield cache.getTokenPricesAsMap(neededMints, portfolio_core_1.NetworkId.solana);
|
50
|
-
const liquidities = [];
|
35
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
36
|
+
const element = elementRegistry.addElementLiquidity({
|
37
|
+
label: 'Farming',
|
38
|
+
});
|
51
39
|
for (const farmingAccount of farmingAccounts) {
|
52
40
|
if (!farmingAccount)
|
53
41
|
continue;
|
54
|
-
const rewardAssets = [];
|
55
|
-
const assets = [];
|
56
42
|
const { balanceStaked, rewardAPerTokenPending, rewardBPerTokenPending } = farmingAccount;
|
57
43
|
const farmInfo = farmsById.get(farmingAccount.pool.toString());
|
58
44
|
if (!farmInfo)
|
59
45
|
continue;
|
60
46
|
const { stakingMint, rewardAMint, rewardBMint } = farmInfo;
|
61
|
-
const
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(rewardAMint, rewardAmount, portfolio_core_1.NetworkId.solana, rewardATokenPrice));
|
75
|
-
}
|
76
|
-
if (rewardBPerTokenPending.isGreaterThan(0) && rewardBTokenPrice) {
|
77
|
-
const rewardAmount = rewardBPerTokenPending
|
78
|
-
.dividedBy(Math.pow(10, rewardBTokenPrice.decimals))
|
79
|
-
.toNumber();
|
80
|
-
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(rewardBMint, rewardAmount, portfolio_core_1.NetworkId.solana, rewardBTokenPrice));
|
81
|
-
}
|
82
|
-
const assetsValue = (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value));
|
83
|
-
const rewardAssetsValue = (0, portfolio_core_1.getUsdValueSum)(rewardAssets.map((r) => r.value));
|
84
|
-
const value = (0, portfolio_core_1.getUsdValueSum)([assetsValue, rewardAssetsValue]);
|
85
|
-
if (value === 0)
|
86
|
-
continue;
|
87
|
-
const liquidity = {
|
88
|
-
value,
|
89
|
-
assets,
|
90
|
-
assetsValue,
|
91
|
-
rewardAssets,
|
92
|
-
rewardAssetsValue,
|
93
|
-
yields: [],
|
94
|
-
};
|
95
|
-
liquidities.push(liquidity);
|
47
|
+
const liquidity = element.addLiquidity();
|
48
|
+
liquidity.addAsset({
|
49
|
+
address: stakingMint,
|
50
|
+
amount: balanceStaked,
|
51
|
+
});
|
52
|
+
liquidity.addRewardAsset({
|
53
|
+
address: rewardAMint,
|
54
|
+
amount: rewardAPerTokenPending,
|
55
|
+
});
|
56
|
+
liquidity.addRewardAsset({
|
57
|
+
address: rewardBMint,
|
58
|
+
amount: rewardBPerTokenPending,
|
59
|
+
});
|
96
60
|
}
|
97
|
-
|
98
|
-
return [];
|
99
|
-
return [
|
100
|
-
{
|
101
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
102
|
-
platformId: constants_1.platformId,
|
103
|
-
type: portfolio_core_1.PortfolioElementType.liquidity,
|
104
|
-
label: 'Farming',
|
105
|
-
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
106
|
-
data: {
|
107
|
-
liquidities,
|
108
|
-
},
|
109
|
-
},
|
110
|
-
];
|
61
|
+
return elementRegistry.dump(cache);
|
111
62
|
});
|
112
63
|
const fetcher = {
|
113
64
|
id: `${constants_1.platformId}-farms`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/meteora/farmsFetcher.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/meteora/farmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAmD;AACnD,iDAAsD;AACtD,+CAAmE;AACnE,qCAA6C;AAE7C,uCAA+C;AAC/C,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,OAAO,CAAkB,oBAAQ,EAAE;QAC3D,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,MAAM,SAAS,GAA+B,IAAI,GAAG,EAAE,CAAC;IACxD,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACjC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,wBAAwB,GAAG,IAAA,4BAAkB,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACtE,MAAM,eAAe,GAAG,MAAM,IAAA,sCAA6B,EACzD,MAAM,EACN,0BAAiB,EACjB,wBAAwB,CACzB,CAAC;IAEF,MAAM,eAAe,GAAG,IAAI,iCAAe,CAAC,0BAAS,CAAC,MAAM,EAAE,sBAAU,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAG,eAAe,CAAC,mBAAmB,CAAC;QAClD,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,IAAI,CAAC,cAAc;YAAE,SAAS;QAE9B,MAAM,EAAE,aAAa,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,GACrE,cAAc,CAAC;QACjB,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ;YAAE,SAAS;QAExB,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;QAE3D,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;QAEzC,SAAS,CAAC,QAAQ,CAAC;YACjB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QAEH,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,sBAAsB;SAC/B,CAAC,CAAC;QAEH,SAAS,CAAC,cAAc,CAAC;YACvB,OAAO,EAAE,WAAW;YACpB,MAAM,EAAE,sBAAsB;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -18,8 +18,8 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
18
18
|
const constants_1 = require("./constants");
|
19
19
|
const clients_1 = require("../../utils/clients");
|
20
20
|
const solana_1 = require("../../utils/solana");
|
21
|
-
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
22
21
|
const helpers_1 = require("./helpers");
|
22
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
23
23
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
24
|
const connection = (0, clients_1.getClientSolana)();
|
25
25
|
const marginAccountPublicKey = web3_js_1.PublicKey.findProgramAddressSync([
|
@@ -30,103 +30,55 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
30
30
|
const marginAccount = (yield (0, solana_1.getAutoParsedMultipleAccountsInfo)(connection, constants_1.nxfinanceLeverageIdlItem, [marginAccountPublicKey]))[0];
|
31
31
|
if (!marginAccount)
|
32
32
|
return [];
|
33
|
-
const elements = [];
|
34
33
|
const mints = new Set();
|
35
|
-
marginAccount.deposits.forEach((d) => mints.add(
|
36
|
-
marginAccount.loans.forEach((l) => mints.add(
|
34
|
+
marginAccount.deposits.forEach((d) => mints.add(d.tokenMint));
|
35
|
+
marginAccount.loans.forEach((l) => mints.add(l.tokenMint));
|
37
36
|
const marginPoolsPublicKeys = [...mints].map((mint) => web3_js_1.PublicKey.findProgramAddressSync([
|
38
37
|
web3_js_1.PublicKey.findProgramAddressSync([constants_1.ID.toBuffer()], constants_1.leverageFiProgramID)[0].toBuffer(),
|
39
38
|
new web3_js_1.PublicKey(mint).toBuffer(),
|
40
39
|
], constants_1.leverageFiProgramID)[0]);
|
41
|
-
const
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
40
|
+
const marginPools = yield (0, solana_1.getAutoParsedMultipleAccountsInfo)(connection, constants_1.nxfinanceLeverageIdlItem, marginPoolsPublicKeys);
|
41
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
42
|
+
const elementMultiple = elementRegistry.addElementMultiple({
|
43
|
+
label: 'Lending',
|
44
|
+
name: 'Fulcrum Lending Pool',
|
45
|
+
});
|
46
|
+
const elementBorrowlend = elementRegistry.addElementBorrowlend({
|
47
|
+
label: 'Leverage',
|
48
|
+
name: `JLP Leverage x${new bignumber_js_1.default(marginAccount.leverage)
|
49
|
+
.dividedBy(100)
|
50
|
+
.decimalPlaces(2)}`,
|
51
|
+
});
|
53
52
|
marginAccount.deposits.forEach((deposit) => {
|
54
|
-
const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(deposit.tokenMint, portfolio_core_1.NetworkId.solana));
|
55
|
-
if (!tokenPrice)
|
56
|
-
return;
|
57
53
|
const marginPool = marginPools.find((mp) => (mp === null || mp === void 0 ? void 0 : mp.tokenMint) === deposit.tokenMint);
|
58
54
|
if (!marginPool)
|
59
55
|
return;
|
60
56
|
const supplyNoteRate = (0, helpers_1.getSupplyNoteRate)(marginPool);
|
61
|
-
const amount = new bignumber_js_1.default(deposit.depositNote)
|
62
|
-
|
63
|
-
.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
assets.push(assetToken);
|
72
|
-
}
|
57
|
+
const amount = new bignumber_js_1.default(deposit.depositNote).multipliedBy(supplyNoteRate);
|
58
|
+
const asset = {
|
59
|
+
address: deposit.tokenMint,
|
60
|
+
amount: amount,
|
61
|
+
};
|
62
|
+
if (constants_1.leverageVaultsMints.includes(deposit.tokenMint)) {
|
63
|
+
elementBorrowlend.addSuppliedAsset(asset);
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
elementMultiple.addAsset(asset);
|
73
67
|
}
|
74
68
|
});
|
75
69
|
marginAccount.loans.forEach((loan) => {
|
76
|
-
const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(loan.tokenMint, portfolio_core_1.NetworkId.solana));
|
77
|
-
if (!tokenPrice)
|
78
|
-
return;
|
79
70
|
const marginPool = marginPools.find((mp) => (mp === null || mp === void 0 ? void 0 : mp.tokenMint) === loan.tokenMint);
|
80
71
|
if (!marginPool)
|
81
72
|
return;
|
73
|
+
if (loan.loanNote === '0')
|
74
|
+
return;
|
82
75
|
const borrowNoteRate = (0, helpers_1.getBorrowNoteRate)(marginPool);
|
83
|
-
|
84
|
-
.
|
85
|
-
.
|
86
|
-
.toNumber(), portfolio_core_1.NetworkId.solana, tokenPrice));
|
87
|
-
});
|
88
|
-
if (assets.length > 0)
|
89
|
-
elements.push({
|
90
|
-
type: portfolio_core_1.PortfolioElementType.multiple,
|
91
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
92
|
-
platformId: constants_1.platformId,
|
93
|
-
label: 'Lending',
|
94
|
-
name: 'Fulcrum Lending Pool',
|
95
|
-
value: (0, portfolio_core_1.getUsdValueSum)(assets.map((asset) => asset.value)),
|
96
|
-
data: {
|
97
|
-
assets,
|
98
|
-
},
|
99
|
-
});
|
100
|
-
if (suppliedAssets.length > 0 || borrowedAssets.length > 0) {
|
101
|
-
const { borrowedValue, suppliedValue, rewardValue } = (0, portfolio_core_1.getElementLendingValues)({
|
102
|
-
suppliedAssets,
|
103
|
-
borrowedAssets,
|
104
|
-
rewardAssets,
|
76
|
+
elementBorrowlend.addBorrowedAsset({
|
77
|
+
address: loan.tokenMint,
|
78
|
+
amount: new bignumber_js_1.default(loan.loanNote).multipliedBy(borrowNoteRate),
|
105
79
|
});
|
106
|
-
|
107
|
-
|
108
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
109
|
-
platformId: constants_1.platformId,
|
110
|
-
label: 'Leverage',
|
111
|
-
name: `JLP Leverage x${new bignumber_js_1.default(marginAccount.leverage)
|
112
|
-
.dividedBy(100)
|
113
|
-
.decimalPlaces(2)}`,
|
114
|
-
value: suppliedValue,
|
115
|
-
data: {
|
116
|
-
borrowedAssets,
|
117
|
-
borrowedValue,
|
118
|
-
borrowedYields,
|
119
|
-
suppliedAssets,
|
120
|
-
suppliedValue,
|
121
|
-
suppliedYields,
|
122
|
-
rewardAssets,
|
123
|
-
rewardValue,
|
124
|
-
healthRatio: null,
|
125
|
-
value: suppliedValue,
|
126
|
-
},
|
127
|
-
});
|
128
|
-
}
|
129
|
-
return elements;
|
80
|
+
});
|
81
|
+
return elementRegistry.dump(cache);
|
130
82
|
});
|
131
83
|
const fetcher = {
|
132
84
|
id: `${constants_1.platformId}-positions`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/nxfinance/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAErC,2CAMqB;AAErB,iDAAsD;AACtD,+CAAuE;
|
1
|
+
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/nxfinance/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAErC,2CAMqB;AAErB,iDAAsD;AACtD,+CAAuE;AAEvE,uCAAiE;AACjE,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IAErC,MAAM,sBAAsB,GAAG,mBAAS,CAAC,sBAAsB,CAC7D;QACE,mBAAS,CAAC,sBAAsB,CAC9B,CAAC,cAAE,CAAC,QAAQ,EAAE,CAAC,EACf,+BAAmB,CACpB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;QACf,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE;QAC/B,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;KACvB,EACD,+BAAmB,CACpB,CAAC,CAAC,CAAC,CAAC;IAEL,MAAM,aAAa,GAAG,CACpB,MAAM,IAAA,0CAAiC,EACrC,UAAU,EACV,oCAAwB,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U,CAAC,CAAC;QAErD,iBAAiB,CAAC,gBAAgB,CAAC;YACjC,OAAO,EAAE,IAAI,CAAC,SAAS;YACvB,MAAM,EAAE,IAAI,sBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC;SAClE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,YAAY;IAC7B,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -50,7 +50,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
50
50
|
mints.add(position.stakedTokenInfo.address);
|
51
51
|
position.rewardsTokenInfo.forEach((rewardTokenInfo) => mints.add(rewardTokenInfo.address.toString()));
|
52
52
|
});
|
53
|
-
const tokenPrices = yield cache.getTokenPricesAsMap(
|
53
|
+
const tokenPrices = yield cache.getTokenPricesAsMap(mints, portfolio_core_1.NetworkId.solana);
|
54
54
|
const elements = [];
|
55
55
|
positions.forEach((position) => {
|
56
56
|
const { rewardsTokenInfo, rewardsBalance, primaryRewarder, stakedBalance, stakedTokenInfo, } = position;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"positionsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/quarry/positionsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AACrC,6CAA4C;AAE5C,2CAOqB;AACrB,qDAAyE;AACzE,kDAAmE;AAEnE,iDAAsD;AACtD,+CAI4B;AAQ5B,kEAA+D;AAC/D,qGAA6E;AAC7E,uGAA+E;AAC/E,uCAA4D;AAC5D,6DAA0D;AAE1D,MAAM,aAAa,GAAG,IAAI,6BAAa,CAAa,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8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
13
|
const constants_1 = require("./constants");
|
@@ -18,7 +15,7 @@ const clients_1 = require("../../utils/clients");
|
|
18
15
|
const helpers_1 = require("./helpers");
|
19
16
|
const solana_1 = require("../../utils/solana");
|
20
17
|
const farmsJob_1 = require("./farmsJob");
|
21
|
-
const
|
18
|
+
const ElementRegistry_1 = require("../../utils/elementbuilder/ElementRegistry");
|
22
19
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
20
|
const client = (0, clients_1.getClientSolana)();
|
24
21
|
const userFarmAccountsPromises = farmsJob_1.userFarmConfigs.map((userFarmConfig) => (0, solana_1.getParsedProgramAccounts)(client, userFarmConfig.struct, userFarmConfig.programId, userFarmConfig.filters(owner)));
|
@@ -33,15 +30,14 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
33
30
|
farmsInfo.forEach((farmInfo) => farmInfo
|
34
31
|
? farmsInfoMap.set(farmInfo.account.pubkey.toString(), farmInfo)
|
35
32
|
: undefined);
|
33
|
+
const elementRegistry = new ElementRegistry_1.ElementRegistry(portfolio_core_1.NetworkId.solana, constants_1.platformId);
|
36
34
|
const rayStakingPubkey = (0, helpers_1.getStakePubKey)(owner).toString();
|
37
|
-
const
|
38
|
-
|
35
|
+
const uniqueElementForFarmsWithoutRewards = elementRegistry.addElementLiquidity({
|
36
|
+
label: 'Farming',
|
37
|
+
});
|
38
|
+
const liquidityOfUniqueElement = uniqueElementForFarmsWithoutRewards.addLiquidity();
|
39
39
|
for (let i = 0; i < userFarmAccounts.length; i += 1) {
|
40
|
-
const rewardAssets = [];
|
41
|
-
const assets = [];
|
42
40
|
const userFarmAccount = userFarmAccounts[i];
|
43
|
-
if (userFarmAccount.pubkey.toString() === rayStakingPubkey)
|
44
|
-
continue;
|
45
41
|
const farmInfo = farmsInfoMap.get(userFarmAccount.poolId.toString());
|
46
42
|
if (!farmInfo)
|
47
43
|
continue;
|
@@ -49,81 +45,41 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
49
45
|
if (!lpTokenPrice)
|
50
46
|
continue;
|
51
47
|
const farmAccount = farmInfo.account;
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
assets.push(...underlyingAssets);
|
59
|
-
}
|
48
|
+
const element = elementRegistry.addElementLiquidity({
|
49
|
+
label: userFarmAccount.pubkey.toString() === rayStakingPubkey
|
50
|
+
? 'Staked'
|
51
|
+
: 'Farming',
|
52
|
+
});
|
53
|
+
const liquidity = element.addLiquidity();
|
60
54
|
// Farm pending reward A
|
61
55
|
if (farmInfo.rewardTokenA) {
|
62
|
-
|
63
|
-
if (assetTokenA.data.amount > 0) {
|
64
|
-
rewardAssets.push(assetTokenA);
|
65
|
-
}
|
56
|
+
liquidity.addRewardAsset((0, helpers_1.getPendingAssetParams)(userFarmAccount.depositBalance, userFarmAccount.rewardDebt, farmAccount.perShare, farmInfo.rewardTokenA, farmInfo.d));
|
66
57
|
}
|
67
58
|
// Farm pending reward B
|
68
59
|
if (farmInfo.rewardTokenB &&
|
69
60
|
farmAccount.perShareB &&
|
70
61
|
userFarmAccount.rewardDebtB) {
|
71
|
-
|
72
|
-
if (assetTokenB.data.amount > 0) {
|
73
|
-
rewardAssets.push(assetTokenB);
|
74
|
-
}
|
62
|
+
liquidity.addRewardAsset((0, helpers_1.getPendingAssetParams)(userFarmAccount.depositBalance, userFarmAccount.rewardDebtB, farmAccount.perShareB, farmInfo.rewardTokenB, farmInfo.d));
|
75
63
|
}
|
76
|
-
|
77
|
-
const
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
64
|
+
// LP staked on Farm
|
65
|
+
const amount = userFarmAccount.depositBalance.div(Math.pow(10, farmInfo.lpToken.decimals));
|
66
|
+
if (liquidity.rewardAssets.length > 0 ||
|
67
|
+
userFarmAccount.pubkey.toString() === rayStakingPubkey) {
|
68
|
+
liquidity.addAsset({
|
69
|
+
address: lpTokenPrice.address,
|
70
|
+
amount,
|
71
|
+
alreadyShifted: true,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
liquidityOfUniqueElement.addAsset({
|
76
|
+
address: lpTokenPrice.address,
|
77
|
+
amount,
|
78
|
+
alreadyShifted: true,
|
89
79
|
});
|
90
|
-
continue;
|
91
80
|
}
|
92
|
-
const liquidityWithRewards = {
|
93
|
-
value,
|
94
|
-
assets,
|
95
|
-
assetsValue,
|
96
|
-
rewardAssets,
|
97
|
-
rewardAssetsValue,
|
98
|
-
yields: [],
|
99
|
-
};
|
100
|
-
elementsWithRewards.push({
|
101
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
102
|
-
platformId: constants_1.platformId,
|
103
|
-
type: portfolio_core_1.PortfolioElementType.liquidity,
|
104
|
-
label: 'Farming',
|
105
|
-
value: liquidityWithRewards.value,
|
106
|
-
data: {
|
107
|
-
liquidities: [liquidityWithRewards],
|
108
|
-
},
|
109
|
-
});
|
110
81
|
}
|
111
|
-
|
112
|
-
elementsWithRewards.length === 0)
|
113
|
-
return [];
|
114
|
-
return [
|
115
|
-
...elementsWithRewards,
|
116
|
-
{
|
117
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
118
|
-
platformId: constants_1.platformId,
|
119
|
-
type: portfolio_core_1.PortfolioElementType.liquidity,
|
120
|
-
label: 'Farming',
|
121
|
-
value: (0, portfolio_core_1.getUsdValueSum)(liquiditiesWithoutRewards.map((l) => l.value)),
|
122
|
-
data: {
|
123
|
-
liquidities: liquiditiesWithoutRewards,
|
124
|
-
},
|
125
|
-
},
|
126
|
-
];
|
82
|
+
return elementRegistry.dump(cache);
|
127
83
|
});
|
128
84
|
const fetcher = {
|
129
85
|
id: `${constants_1.platformId}-farms`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/farmsFetcher.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/raydium/farmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAyC;AACzC,iDAAsD;AACtD,uCAAkE;AAClE,+CAA6E;AAC7E,yCAA6C;AAG7C,gFAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,wBAAwB,GAAG,0BAAe,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CACtE,IAAA,iCAAwB,EACtB,MAAM,EACN,cAAc,CAAC,MAAM,EACrB,cAAc,CAAC,SAAS,EACxB,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAC9B,CACF,CAAC;IACF,MAAM,gBAAgB,GAAG,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;SAC1E,IAAI,CAAC,CAAC,CAAC;SACP,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACpE,IAAI,EAAE,CAAC;IAEV,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;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rB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,wBAAwB,CAAC,QAAQ,CAAC;gBAChC,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,MAAM;gBACN,cAAc,EAAE,IAAI;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
2
2
|
import BN from 'bn.js';
|
3
|
-
import { PortfolioAssetCollectible,
|
3
|
+
import { PortfolioAssetCollectible, TokenPrice, Yield } from '@sonarwatch/portfolio-core';
|
4
4
|
import { PublicKey } from '@solana/web3.js';
|
5
5
|
import { PersonalPositionState, PoolState, TickArrayState } from './structs/clmms';
|
6
6
|
import { ParsedAccount } from '../../utils/solana';
|
7
|
+
import { PortfolioAssetParams } from '../../utils/elementbuilder/PortfolioAssetParams';
|
7
8
|
export declare function isARaydiumPosition(nft: PortfolioAssetCollectible): boolean;
|
8
9
|
export declare function raydiumTickToPriceX64(tick: number): BN;
|
9
10
|
export declare function getRaydiumTokenAmountsFromLiquidity(sqrtPriceCurrentX64: BigNumber, sqrtPriceX64A: BigNumber, sqrtPriceX64B: BigNumber, liquidity: BigNumber, roundUp: boolean): {
|
@@ -12,7 +13,7 @@ export declare function getRaydiumTokenAmountsFromLiquidity(sqrtPriceCurrentX64:
|
|
12
13
|
};
|
13
14
|
export declare function getStakePubKey(owner: string): PublicKey;
|
14
15
|
export declare function getFarmYield(rewardToken: TokenPrice, rewardPerBlock: BigNumber, tvl: number, slotsPerSec?: number): Yield;
|
15
|
-
export declare function
|
16
|
+
export declare function getPendingAssetParams(depositBalance: BigNumber, rewardDebt: BigNumber, perShare: BigNumber, rewardToken: TokenPrice, multiplier: number | BigNumber): PortfolioAssetParams;
|
16
17
|
export declare const getTickArrayAddress: (programId: string, poolId: string, tickNumber: number, tickSpacing: number) => PublicKey;
|
17
18
|
export declare const getFeesAndRewardsBalance: (personalPositionInfo: ParsedAccount<PersonalPositionState>, poolStateInfo: ParsedAccount<PoolState>, tickArrays: (ParsedAccount<TickArrayState> | null)[]) => {
|
18
19
|
tokenFeeAmountA: BigNumber;
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.getFeesAndRewardsBalance = exports.getTickArrayAddress = exports.
|
6
|
+
exports.getFeesAndRewardsBalance = exports.getTickArrayAddress = exports.getPendingAssetParams = 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 */
|
@@ -14,7 +14,6 @@ const bn_js_1 = __importDefault(require("bn.js"));
|
|
14
14
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
15
15
|
const web3_js_1 = require("@solana/web3.js");
|
16
16
|
const constants_1 = require("./constants");
|
17
|
-
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
18
17
|
const toBN_1 = require("../../utils/misc/toBN");
|
19
18
|
function isARaydiumPosition(nft) {
|
20
19
|
return nft.name === constants_1.positionsIdentifier;
|
@@ -195,16 +194,15 @@ function getFarmYield(rewardToken, rewardPerBlock, tvl, slotsPerSec = 2) {
|
|
195
194
|
};
|
196
195
|
}
|
197
196
|
exports.getFarmYield = getFarmYield;
|
198
|
-
function
|
197
|
+
function getPendingAssetParams(depositBalance, rewardDebt, perShare, rewardToken, multiplier) {
|
199
198
|
const amount = depositBalance
|
200
199
|
.times(perShare)
|
201
200
|
.div(multiplier)
|
202
201
|
.minus(rewardDebt)
|
203
|
-
.div(Math.pow(10, rewardToken.decimals))
|
204
|
-
|
205
|
-
return (0, tokenPriceToAssetToken_1.default)(rewardToken.address, amount, portfolio_core_1.NetworkId.solana, rewardToken);
|
202
|
+
.div(Math.pow(10, rewardToken.decimals));
|
203
|
+
return { address: rewardToken.address, amount, alreadyShifted: true };
|
206
204
|
}
|
207
|
-
exports.
|
205
|
+
exports.getPendingAssetParams = getPendingAssetParams;
|
208
206
|
function getRewardGrowthInsideV2(tickCurrentIndex, tickLowerState, tickUpperState, rewardInfos) {
|
209
207
|
const rewardGrowthsInside = [];
|
210
208
|
for (let i = 0; i < rewardInfos.length; i++) {
|