@sonarwatch/portfolio-plugins 0.12.43 → 0.12.44
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/plugins/native-stake/index.js +7 -2
- package/src/plugins/native-stake/index.js.map +1 -1
- package/src/plugins/native-stake/solana/constants.d.ts +1 -0
- package/src/plugins/native-stake/solana/constants.js +2 -1
- package/src/plugins/native-stake/solana/constants.js.map +1 -1
- package/src/plugins/native-stake/solana/{solanaJob.js → solanaEpochJob.js} +1 -1
- package/src/plugins/native-stake/solana/solanaEpochJob.js.map +1 -0
- package/src/plugins/native-stake/solana/solanaFetcher.js +18 -8
- package/src/plugins/native-stake/solana/solanaFetcher.js.map +1 -1
- package/src/plugins/native-stake/solana/solanaValidatorsJob.d.ts +3 -0
- package/src/plugins/native-stake/solana/solanaValidatorsJob.js +66 -0
- package/src/plugins/native-stake/solana/solanaValidatorsJob.js.map +1 -0
- package/src/plugins/native-stake/solana/types.d.ts +15 -0
- package/src/plugins/native-stake/solana/types.js +3 -0
- package/src/plugins/native-stake/solana/types.js.map +1 -0
- package/src/plugins/native-stake/solana/solanaJob.js.map +0 -1
- /package/src/plugins/native-stake/solana/{solanaJob.d.ts → solanaEpochJob.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.12.44](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.43...plugins-0.12.44) (2024-07-01)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.12.43](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.42...plugins-0.12.43) (2024-07-01)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -7,12 +7,17 @@ exports.fetchers = exports.jobs = exports.platforms = void 0;
|
|
7
7
|
const suiFetcher_1 = __importDefault(require("./suiFetcher"));
|
8
8
|
const aptosFetcher_1 = __importDefault(require("./aptosFetcher"));
|
9
9
|
const solanaFetcher_1 = __importDefault(require("./solana/solanaFetcher"));
|
10
|
-
const solanaJob_1 = __importDefault(require("./solana/solanaJob"));
|
11
10
|
const seiFetcher_1 = __importDefault(require("./seiFetcher"));
|
12
11
|
const activeValidatorsJob_1 = __importDefault(require("./activeValidatorsJob"));
|
13
12
|
const constants_1 = require("./constants");
|
13
|
+
const solanaEpochJob_1 = __importDefault(require("./solana/solanaEpochJob"));
|
14
|
+
const solanaValidatorsJob_1 = __importDefault(require("./solana/solanaValidatorsJob"));
|
14
15
|
exports.platforms = [constants_1.nativeStakePlatform];
|
15
|
-
exports.jobs = [
|
16
|
+
exports.jobs = [
|
17
|
+
activeValidatorsJob_1.default,
|
18
|
+
solanaEpochJob_1.default,
|
19
|
+
solanaValidatorsJob_1.default,
|
20
|
+
];
|
16
21
|
exports.fetchers = [
|
17
22
|
suiFetcher_1.default,
|
18
23
|
aptosFetcher_1.default,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/native-stake/index.ts"],"names":[],"mappings":";;;;;;AAGA,8DAAsC;AACtC,kEAA0C;AAC1C,2EAAmD;AACnD,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/native-stake/index.ts"],"names":[],"mappings":";;;;;;AAGA,8DAAsC;AACtC,kEAA0C;AAC1C,2EAAmD;AACnD,8DAAsC;AACtC,gFAAuD;AACvD,2CAAkD;AAClD,6EAAqD;AACrD,uFAA+D;AAElD,QAAA,SAAS,GAAe,CAAC,+BAAmB,CAAC,CAAC;AAC9C,QAAA,IAAI,GAAU;IACzB,6BAAkB;IAClB,wBAAc;IACd,6BAAmB;CACpB,CAAC;AACW,QAAA,QAAQ,GAAc;IACjC,oBAAU;IACV,sBAAY;IACZ,uBAAa;IACb,oBAAU;CACX,CAAC"}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.marinadeManagerAddresses = exports.stakeProgramId = exports.epochInfoCacheKey = void 0;
|
3
|
+
exports.marinadeManagerAddresses = exports.configProgramId = exports.stakeProgramId = exports.epochInfoCacheKey = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
exports.epochInfoCacheKey = 'epoch-info';
|
6
6
|
exports.stakeProgramId = new web3_js_1.PublicKey('Stake11111111111111111111111111111111111111');
|
7
|
+
exports.configProgramId = new web3_js_1.PublicKey('Config1111111111111111111111111111111111111');
|
7
8
|
exports.marinadeManagerAddresses = [
|
8
9
|
'stWirqFCf2Uts1JBL1Jsd3r6VBWhgnpdPxCTe1MFjrq',
|
9
10
|
'noMa7dN4cHQLV4ZonXrC29HTKFpxrpFbDLK5Gub8W8t',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE/B,QAAA,iBAAiB,GAAG,YAAY,CAAC;AACjC,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,wBAAwB,GAAG;IACtC,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;CAC9C,CAAC"}
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE/B,QAAA,iBAAiB,GAAG,YAAY,CAAC;AACjC,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,eAAe,GAAG,IAAI,mBAAS,CAC1C,6CAA6C,CAC9C,CAAC;AACW,QAAA,wBAAwB,GAAG;IACtC,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;CAC9C,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"solanaEpochJob.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/solanaEpochJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAIvD,oDAAyD;AACzD,4CAA0C;AAC1C,2CAAgD;AAEhD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IACjC,MAAM,SAAS,GAAc,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IACzD,MAAM,KAAK,CAAC,OAAO,CAAC,6BAAiB,EAAE,SAAS,EAAE;QAChD,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,eAAe;IAChC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -23,17 +23,26 @@ const tokenPriceToAssetToken_1 = __importDefault(require("../../../utils/misc/to
|
|
23
23
|
const constants_2 = require("../../marinade/constants");
|
24
24
|
const constants_3 = require("../../jito/constants");
|
25
25
|
const constants_4 = require("./constants");
|
26
|
+
const MemoizedCache_1 = require("../../../utils/misc/MemoizedCache");
|
27
|
+
const arrayToMap_1 = require("../../../utils/misc/arrayToMap");
|
28
|
+
const validatorsMemo = new MemoizedCache_1.MemoizedCache(constants_1.validatorsKey, {
|
29
|
+
prefix: constants_1.platformId,
|
30
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
31
|
+
}, (arr) => (0, arrayToMap_1.arrayToMap)(arr || [], 'voter'));
|
26
32
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
27
33
|
const client = (0, clients_1.getClientSolana)();
|
28
34
|
const filters = (0, filters_1.stakeAccountsFilter)(owner.toString());
|
29
35
|
const stakeAccounts = yield (0, solana_1.getParsedProgramAccounts)(client, structs_1.stakeAccountStruct, constants_4.stakeProgramId, filters);
|
30
36
|
if (stakeAccounts.length === 0)
|
31
37
|
return [];
|
32
|
-
const solTokenPrice = yield
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
const [solTokenPrice, epochInfo, validators] = yield Promise.all([
|
39
|
+
cache.getTokenPrice(portfolio_core_1.solanaNetwork.native.address, portfolio_core_1.NetworkId.solana),
|
40
|
+
cache.getItem(constants_4.epochInfoCacheKey, {
|
41
|
+
prefix: constants_1.platformId,
|
42
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
43
|
+
}),
|
44
|
+
validatorsMemo.getItem(cache),
|
45
|
+
]);
|
37
46
|
const epoch = epochInfo === null || epochInfo === void 0 ? void 0 : epochInfo.epoch;
|
38
47
|
let marinadeSolAmount = 0;
|
39
48
|
let solAmount = 0;
|
@@ -42,6 +51,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
42
51
|
let nativeAssets = [];
|
43
52
|
for (let i = 0; i < stakeAccounts.length; i += 1) {
|
44
53
|
const stakeAccount = stakeAccounts[i];
|
54
|
+
const validator = validators.get(stakeAccount.voter.toString());
|
45
55
|
mevRewards += new bignumber_js_1.default(stakeAccount.lamports)
|
46
56
|
.minus(stakeAccount.rentExemptReserve)
|
47
57
|
.minus(stakeAccount.stake)
|
@@ -82,12 +92,12 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
82
92
|
tags.push('Active');
|
83
93
|
}
|
84
94
|
const lockedUntil = stakeAccount.lockup.unixTimestamp.times(1000).toNumber() || undefined;
|
85
|
-
nativeAssets.push(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.solanaNetwork.native.address, amount, portfolio_core_1.NetworkId.solana, solTokenPrice, undefined, {
|
95
|
+
nativeAssets.push(Object.assign(Object.assign({}, (0, tokenPriceToAssetToken_1.default)(portfolio_core_1.solanaNetwork.native.address, amount, portfolio_core_1.NetworkId.solana, solTokenPrice, undefined, {
|
86
96
|
tags,
|
87
97
|
lockedUntil,
|
88
|
-
})));
|
98
|
+
})), { name: validator === null || validator === void 0 ? void 0 : validator.name, imageUri: validator === null || validator === void 0 ? void 0 : validator.iconUrl }));
|
89
99
|
}
|
90
|
-
if (nativeAssets.length >
|
100
|
+
if (nativeAssets.length > 30) {
|
91
101
|
nativeAssets = [
|
92
102
|
(0, tokenPriceToAssetToken_1.default)(portfolio_core_1.solanaNetwork.native.address, solAmount, portfolio_core_1.NetworkId.solana, solTokenPrice),
|
93
103
|
];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaFetcher.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/solanaFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAIrC,
|
1
|
+
{"version":3,"file":"solanaFetcher.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/solanaFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAIrC,4CAA8E;AAC9E,oDAAyD;AACzD,kDAAiE;AACjE,uCAAgD;AAChD,uCAA+C;AAC/C,wGAAgF;AAChF,wDAA4E;AAC5E,oDAAoE;AACpE,2CAIqB;AACrB,qEAAkE;AAElE,+DAA4D;AAE5D,MAAM,cAAc,GAAG,IAAI,6BAAa,CACtC,yBAAa,EACb;IACE,MAAM,EAAE,sBAAU;IAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;CAC5B,EACD,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAU,EAAC,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC,CACxC,CAAC;AAEF,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAC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,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,66 @@
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const explorer_kit_idls_1 = require("@solanafm/explorer-kit-idls");
|
13
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
14
|
+
const clients_1 = require("../../../utils/clients");
|
15
|
+
const constants_1 = require("../constants");
|
16
|
+
const solana_1 = require("../../../utils/solana");
|
17
|
+
const constants_2 = require("./constants");
|
18
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const client = (0, clients_1.getClientSolana)();
|
20
|
+
const SFMIdlItem = yield (0, explorer_kit_idls_1.getProgramIdl)(constants_2.configProgramId.toString());
|
21
|
+
if (!SFMIdlItem)
|
22
|
+
return;
|
23
|
+
const [{ current, delinquent }, configs] = yield Promise.all([
|
24
|
+
client.getVoteAccounts(),
|
25
|
+
(0, solana_1.getAutoParsedProgramAccounts)(client, SFMIdlItem),
|
26
|
+
]);
|
27
|
+
const voters = [...current, ...delinquent];
|
28
|
+
const configsByVoter = new Map();
|
29
|
+
configs.forEach((c) => {
|
30
|
+
if (!c.info)
|
31
|
+
return;
|
32
|
+
try {
|
33
|
+
const info = JSON.parse(c.info);
|
34
|
+
const voter = c.configKeys.keysTuple[1][0];
|
35
|
+
configsByVoter.set(voter, {
|
36
|
+
voter,
|
37
|
+
name: info.name,
|
38
|
+
iconUrl: info.iconUrl,
|
39
|
+
});
|
40
|
+
}
|
41
|
+
catch (err) {
|
42
|
+
/* empty */
|
43
|
+
}
|
44
|
+
});
|
45
|
+
const validators = [];
|
46
|
+
voters.forEach((voteAcc) => {
|
47
|
+
const config = configsByVoter.get(voteAcc.nodePubkey.toString());
|
48
|
+
validators.push({
|
49
|
+
voter: voteAcc.votePubkey.toString(),
|
50
|
+
commission: voteAcc.commission,
|
51
|
+
name: config === null || config === void 0 ? void 0 : config.name,
|
52
|
+
iconUrl: config === null || config === void 0 ? void 0 : config.iconUrl,
|
53
|
+
});
|
54
|
+
});
|
55
|
+
yield cache.setItem(constants_1.validatorsKey, validators, {
|
56
|
+
prefix: constants_1.platformId,
|
57
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
58
|
+
});
|
59
|
+
});
|
60
|
+
const job = {
|
61
|
+
id: `${constants_1.platformId}-solana-validators`,
|
62
|
+
executor,
|
63
|
+
label: 'normal',
|
64
|
+
};
|
65
|
+
exports.default = job;
|
66
|
+
//# sourceMappingURL=solanaValidatorsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"solanaValidatorsJob.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/solanaValidatorsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mEAA4D;AAC5D,+DAAuD;AAIvD,oDAAyD;AACzD,4CAAyD;AACzD,kDAAqE;AACrE,2CAA8C;AAG9C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,UAAU,GAAG,MAAM,IAAA,iCAAa,EAAC,2BAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEnE,IAAI,CAAC,UAAU;QAAE,OA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YAClB,OAAO,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO;SACzB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,CAAC,OAAO,CAAC,yBAAa,EAAE,UAAU,EAAE;QAC7C,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,oBAAoB;IACrC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export type ConfigAccount = {
|
2
|
+
lamports: number;
|
3
|
+
configKeys: {
|
4
|
+
keysTuple: [string, boolean][];
|
5
|
+
};
|
6
|
+
info: string;
|
7
|
+
};
|
8
|
+
export type ValidatorConfig = {
|
9
|
+
voter: string;
|
10
|
+
name?: string;
|
11
|
+
iconUrl?: string;
|
12
|
+
};
|
13
|
+
export type Validator = ValidatorConfig & {
|
14
|
+
commission?: number;
|
15
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/types.ts"],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"solanaJob.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/native-stake/solana/solanaJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAIvD,oDAAyD;AACzD,4CAA0C;AAC1C,2CAAgD;AAEhD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IACjC,MAAM,SAAS,GAAc,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IACzD,MAAM,KAAK,CAAC,OAAO,CAAC,6BAAiB,EAAE,SAAS,EAAE;QAChD,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,eAAe;IAChC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
File without changes
|