@sonarwatch/portfolio-plugins 0.14.115 → 0.14.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/plugins/drift-market-maker-vault/constants.d.ts +4 -1
- package/src/plugins/drift-market-maker-vault/constants.js +8 -2
- package/src/plugins/drift-market-maker-vault/constants.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/depositsFetcher.js +30 -15
- package/src/plugins/drift-market-maker-vault/depositsFetcher.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/filters.js +6 -1
- package/src/plugins/drift-market-maker-vault/filters.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/helpers.d.ts +2 -1
- package/src/plugins/drift-market-maker-vault/helpers.js +20 -2
- package/src/plugins/drift-market-maker-vault/helpers.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/vaultsJob.js +28 -23
- package/src/plugins/drift-market-maker-vault/vaultsJob.js.map +1 -1
- package/src/plugins/drift-market-maker-vault/vectis_insurance_drift_vaults.d.ts +2910 -0
- package/src/plugins/drift-market-maker-vault/vectis_insurance_drift_vaults.js +2913 -0
- package/src/plugins/drift-market-maker-vault/vectis_insurance_drift_vaults.js.map +1 -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.14.116](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.115...plugins-0.14.116) (2025-02-19)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.14.115](https://github.com/sonarwatch/portfolio/compare/plugins-0.14.114...plugins-0.14.115) (2025-02-17)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -20,6 +20,9 @@ export declare const knightradePlatformId = "knightrade";
|
|
20
20
|
export declare const knightradePlatform: Platform;
|
21
21
|
export declare const luckyperpPlatformId = "luckyperp";
|
22
22
|
export declare const luckyperpPlatform: Platform;
|
23
|
-
export declare const
|
23
|
+
export declare const vaultsProgramIds: PublicKey[];
|
24
|
+
export declare const vaultIdls: {
|
25
|
+
EDnxACbdY1GeXnadh5gRuCJnivP7oQSAHGGAHCma4VzG: import("./vectis_insurance_drift_vaults").VectisInsuranceDriftVaults;
|
26
|
+
};
|
24
27
|
export declare const prefixVaults = "circuitVaults";
|
25
28
|
export declare const platformIdByVaultManager: Map<string, string>;
|
@@ -1,8 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.platformIdByVaultManager = exports.prefixVaults = exports.
|
3
|
+
exports.platformIdByVaultManager = exports.prefixVaults = exports.vaultIdls = exports.vaultsProgramIds = exports.luckyperpPlatform = exports.luckyperpPlatformId = exports.knightradePlatform = exports.knightradePlatformId = exports.m1CapitalPlatform = exports.m1CapitalPlatformId = exports.hedgyPlatform = exports.hedgyPlatformId = exports.vectisPlatform = exports.vectisPlatformId = exports.gauntletPlatform = exports.gauntletPlatformId = exports.neutralPlatform = exports.neutralPlatformId = exports.moosePlatform = exports.moosePlatformId = exports.circuitPlatform = exports.circuitPlatformId = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
const constants_1 = require("../nxfinance/constants");
|
6
|
+
const vectis_insurance_drift_vaults_1 = require("./vectis_insurance_drift_vaults");
|
6
7
|
exports.circuitPlatformId = 'circuit';
|
7
8
|
exports.circuitPlatform = {
|
8
9
|
id: exports.circuitPlatformId,
|
@@ -74,13 +75,18 @@ exports.luckyperpPlatform = {
|
|
74
75
|
image: 'https://sonar.watch/img/platforms/luckyperp.webp',
|
75
76
|
twitter: 'https://x.com/LuckyPerp_com',
|
76
77
|
};
|
77
|
-
exports.
|
78
|
+
exports.vaultsProgramIds = [
|
78
79
|
new web3_js_1.PublicKey('vAuLTsyrvSfZRuRB3XgvkPwNGgYSs9YRYymVebLKoxR'), // from Drift
|
79
80
|
new web3_js_1.PublicKey('9Fcn3Fd4d5ocrb12xCUtEvezxcjFEAyHBPfrZDiPt9Qj'), // from Neutral
|
80
81
|
new web3_js_1.PublicKey('EuSLjg23BrtwYAk1t4TFe5ArYSXCVXLBqrHRBfWQiTeJ'), // from Neutral
|
81
82
|
new web3_js_1.PublicKey('BVddkVtFJLCihbVrtLo8e3iEd9NftuLunaznAxFFW8vf'), // from Neutral
|
82
83
|
new web3_js_1.PublicKey('HYHnL9BB3tqSPxkVbdcAn9CAa4hyqNYUh1FwDc4he7aD'), // from NXFinance
|
84
|
+
new web3_js_1.PublicKey('EDnxACbdY1GeXnadh5gRuCJnivP7oQSAHGGAHCma4VzG'), // from Vectis
|
83
85
|
];
|
86
|
+
// when we need to pass a specific IDL for a vault
|
87
|
+
exports.vaultIdls = {
|
88
|
+
EDnxACbdY1GeXnadh5gRuCJnivP7oQSAHGGAHCma4VzG: vectis_insurance_drift_vaults_1.VectisInsuranceIDL,
|
89
|
+
};
|
84
90
|
exports.prefixVaults = 'circuitVaults';
|
85
91
|
// For each vault, find the Manager of the vault and put the pubkey here along with it's platform.
|
86
92
|
exports.platformIdByVaultManager = new Map([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,sDAA2E;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,sDAA2E;AAC3E,mFAAqE;AAExD,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAC9B,QAAA,eAAe,GAAa;IACvC,EAAE,EAAE,yBAAiB;IACrB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,gDAAgD;IACvD,OAAO,EAAE,4BAA4B;IACrC,OAAO,EAAE,qCAAqC;CAC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AA8C,EAAE,0BAAkB,CAAC;IACpE,CAAC,8CAA8C,EAAE,wBAAgB,CAAC;IAClE,CAAC,8CAA8C,EAAE,2BAAmB,CAAC;IACrE,CAAC,8CAA8C,EAAE,4BAAoB,CAAC;IACtE,CAAC,8CAA8C,EAAE,2BAAmB,CAAC;IACrE,CAAC,8CAA8C,EAAE,sBAAmB,CAAC;CACtE,CAAC,CAAC"}
|
@@ -28,7 +28,7 @@ exports.sevenDays = 7 * exports.oneDay;
|
|
28
28
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
29
29
|
var _a, _b;
|
30
30
|
const client = (0, clients_1.getClientSolana)();
|
31
|
-
const depositAccounts = (yield Promise.all(constants_2.
|
31
|
+
const depositAccounts = (yield Promise.all(constants_2.vaultsProgramIds.map((vaultsPid) => (0, solana_1.getParsedProgramAccounts)(client, structs_1.vaultDepositorStruct, vaultsPid, (0, filters_1.vaultDepositorFilter)(owner))))).flat();
|
32
32
|
if (depositAccounts.length === 0)
|
33
33
|
return [];
|
34
34
|
const vaultsInfo = yield cache.getItems(depositAccounts.map((deposit) => deposit.vault.toString()), { prefix: constants_2.prefixVaults, networkId: portfolio_core_1.NetworkId.solana });
|
@@ -57,9 +57,35 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
57
57
|
});
|
58
58
|
const pricePerShare = new bignumber_js_1.default(vaultInfo.totalTokens).dividedBy(vaultInfo.totalShares);
|
59
59
|
const userSharesValue = depositAccount.vaultShares.multipliedBy(pricePerShare);
|
60
|
-
const netDeposits =
|
61
|
-
const
|
62
|
-
|
60
|
+
const { netDeposits } = depositAccount;
|
61
|
+
const performanceFee = new bignumber_js_1.default(vaultInfo.profitShare).shiftedBy(-6);
|
62
|
+
const PnL = userSharesValue.minus(netDeposits);
|
63
|
+
element.addAsset({
|
64
|
+
address: mint,
|
65
|
+
amount: netDeposits.minus(((_a = depositAccount.lastWithdrawRequest) === null || _a === void 0 ? void 0 : _a.value) || 0),
|
66
|
+
});
|
67
|
+
let hasPendingFees = false;
|
68
|
+
if (PnL.isPositive()) {
|
69
|
+
const profitShareFees = PnL.multipliedBy(performanceFee).minus(depositAccount.profitShareFeePaid);
|
70
|
+
if (profitShareFees.isPositive()) {
|
71
|
+
hasPendingFees = true;
|
72
|
+
element.addAsset({
|
73
|
+
address: mint,
|
74
|
+
amount: profitShareFees.negated(),
|
75
|
+
attributes: {
|
76
|
+
tags: [`Pending ${performanceFee.shiftedBy(2)}% Performance Fee`],
|
77
|
+
},
|
78
|
+
});
|
79
|
+
}
|
80
|
+
}
|
81
|
+
element.addAsset({
|
82
|
+
address: mint,
|
83
|
+
amount: PnL,
|
84
|
+
attributes: {
|
85
|
+
tags: [hasPendingFees ? 'PnL before Fees' : 'PnL'],
|
86
|
+
},
|
87
|
+
});
|
88
|
+
if (!((_b = depositAccount.lastWithdrawRequest) === null || _b === void 0 ? void 0 : _b.value.isZero())) {
|
63
89
|
const withdrawCooldown = [
|
64
90
|
constants_2.neutralPlatformId,
|
65
91
|
constants_2.hedgyPlatformId,
|
@@ -78,17 +104,6 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
78
104
|
},
|
79
105
|
});
|
80
106
|
}
|
81
|
-
element.addAsset({
|
82
|
-
address: mint,
|
83
|
-
amount: netDeposits.minus(((_b = depositAccount.lastWithdrawRequest) === null || _b === void 0 ? void 0 : _b.value) || 0),
|
84
|
-
});
|
85
|
-
element.addAsset({
|
86
|
-
address: mint,
|
87
|
-
amount: userPnL.minus(depositAccount.profitShareFeePaid),
|
88
|
-
attributes: {
|
89
|
-
tags: ['PnL'],
|
90
|
-
},
|
91
|
-
});
|
92
107
|
}
|
93
108
|
return elementRegistry.getElements(cache);
|
94
109
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,gEAAqC;AAGrC,kDAAmE;AACnE,2CAMqB;AACrB,iDAAsD;AACtD,+CAA8D;AAC9D,uCAAiD;AACjD,uCAAiD;AAEjD,gFAA6E;AAC7E,4DAAyD;AAE5C,QAAA,MAAM,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC7B,QAAA,SAAS,GAAG,CAAC,GAAG,cAAM,CAAC;AAEpC,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,eAAe,GAAG,CACtB,MAAM,OAAO,CAAC,GAAG,CACf,
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAAuD;AACvD,gEAAqC;AAGrC,kDAAmE;AACnE,2CAMqB;AACrB,iDAAsD;AACtD,+CAA8D;AAC9D,uCAAiD;AACjD,uCAAiD;AAEjD,gFAA6E;AAC7E,4DAAyD;AAE5C,QAAA,MAAM,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC7B,QAAA,SAAS,GAAG,CAAC,GAAG,cAAM,CAAC;AAEpC,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,eAAe,GAAG,CACtB,MAAM,OAAO,CAAC,GAAG,CACf,4BAAgB,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACjC,IAAA,iCAAwB,EACtB,MAAM,EACN,8BAAoB,EACpB,SAAS,EACT,IAAA,8BAAoB,EAAC,KAAK,CAAC,CAC5B,CACF,CACF,CACF,CAAC,IAAI,EAAE,CAAC;IAET,IAAI,eAA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,CAAC,CAAC,CAAC,KAAK,CAAC;aACnD;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,CAAA,MAAA,cAAc,CAAC,mBAAmB,0CAAE,KAAK,CAAC,MAAM,EAAE,CAAA,EAAE,CAAC;YACxD,MAAM,gBAAgB,GAAG;gBACvB,6BAAiB;gBACjB,2BAAe;gBACf,4BAAgB;aACjB,CAAC,QAAQ,CAAC,UAAU,CAAC;gBACpB,CAAC,CAAC,cAAM;gBACR,CAAC,CAAC,iBAAS,CAAC;YAEd,OAAO,CAAC,QAAQ,CAAC;gBACf,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,cAAc,CAAC,mBAAmB,CAAC,KAAK;gBAChD,UAAU,EAAE;oBACV,WAAW,EAAE,cAAc,CAAC,mBAAmB,CAAC,EAAE;yBAC/C,KAAK,CAAC,IAAI,CAAC;yBACX,IAAI,CAAC,gBAAgB,CAAC;yBACtB,QAAQ,EAAE;iBACd;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAe,qBAAqB;IAC3C,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -13,6 +13,11 @@ const vaultDepositorFilter = (owner) => [
|
|
13
13
|
];
|
14
14
|
exports.vaultDepositorFilter = vaultDepositorFilter;
|
15
15
|
exports.vaultFilter = [
|
16
|
-
{
|
16
|
+
{
|
17
|
+
memcmp: {
|
18
|
+
offset: 0,
|
19
|
+
bytes: 'cJJWPqNMczr',
|
20
|
+
},
|
21
|
+
},
|
17
22
|
];
|
18
23
|
//# sourceMappingURL=filters.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/filters.ts"],"names":[],"mappings":";;;AACA,
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/filters.ts"],"names":[],"mappings":";;;AACA,uCAAiD;AAE1C,MAAM,oBAAoB,GAAG,CAClC,KAAa,EACe,EAAE,CAAC;IAC/B,EAAE,QAAQ,EAAE,8BAAoB,CAAC,QAAQ,EAAE;IAC3C;QACE,MAAM,EAAE;YACN,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,KAAK;SACb;KACF;CACF,CAAC;AAVW,QAAA,oBAAoB,wBAU/B;AAEW,QAAA,WAAW,GAA+B;IACrD;QACE,MAAM,EAAE;YACN,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,aAAa;SACrB;KACF;CACF,CAAC"}
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import { VaultClient } from '@drift-labs/vaults-sdk';
|
2
|
+
export declare const getVaultClient: (programId?: string) => Promise<VaultClient>;
|
@@ -12,10 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getVaultClient = void 0;
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
14
14
|
const sdk_1 = require("@drift-labs/sdk");
|
15
|
-
const anchor_1 = require("@project-serum/anchor");
|
16
15
|
const vaults_sdk_1 = require("@drift-labs/vaults-sdk");
|
16
|
+
const anchor_1 = require("@project-serum/anchor");
|
17
|
+
const constants_1 = require("./constants");
|
17
18
|
const clients_1 = require("../../utils/clients");
|
18
|
-
const getVaultClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const getVaultClient = (programId) => __awaiter(void 0, void 0, void 0, function* () {
|
19
20
|
const connection = (0, clients_1.getClientSolana)();
|
20
21
|
const sdkConfig = (0, sdk_1.initialize)({ env: 'mainnet-beta' });
|
21
22
|
const driftPublicKey = new web3_js_1.PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
|
@@ -32,6 +33,23 @@ const getVaultClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
33
|
},
|
33
34
|
});
|
34
35
|
yield driftClient.subscribe();
|
36
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
37
|
+
// @ts-ignore
|
38
|
+
if (programId && constants_1.vaultIdls[programId]) {
|
39
|
+
const provider = new anchor_1.AnchorProvider(connection, wallet, {});
|
40
|
+
(0, anchor_1.setProvider)(provider);
|
41
|
+
const vaultProgram = new anchor_1.Program(
|
42
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
43
|
+
// @ts-ignore
|
44
|
+
constants_1.vaultIdls[programId], new web3_js_1.PublicKey(programId), provider);
|
45
|
+
return new vaults_sdk_1.VaultClient({
|
46
|
+
driftClient,
|
47
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
48
|
+
// @ts-ignore
|
49
|
+
program: vaultProgram,
|
50
|
+
cliMode: false,
|
51
|
+
});
|
52
|
+
}
|
35
53
|
return (0, vaults_sdk_1.getVaultClient)(connection, wallet, driftClient);
|
36
54
|
});
|
37
55
|
exports.getVaultClient = getVaultClient;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAqD;AACrD,yCAA6E;AAC7E,
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAqD;AACrD,yCAA6E;AAC7E,uDAGgC;AAChC,kDAK+B;AAC/B,2CAAwC;AACxC,iDAAsD;AAE/C,MAAM,cAAc,GAAG,CAAO,SAAkB,EAAE,EAAE;IACzD,MAAM,UAAU,GAAG,IAAA,yBAAe,GAAE,CAAC;IACrC,MAAM,SAAS,GAAG,IAAA,gBAAU,EAAC,EAAE,GAAG,EAAE,cAA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ache) => __awaiter(void 0, void 0, void 0, function* () {
|
20
20
|
const client = (0, clients_1.getClientSolana)();
|
21
|
-
const [
|
22
|
-
|
21
|
+
const [vaultIdsByProgram, spotMarkets] = yield Promise.all([
|
22
|
+
Promise.all(constants_2.vaultsProgramIds.map((vaultsPid) => client.getProgramAccounts(vaultsPid, {
|
23
23
|
filters: filters_1.vaultFilter,
|
24
24
|
dataSlice: { offset: 0, length: 0 },
|
25
|
-
})))
|
25
|
+
}))),
|
26
26
|
cache.getItem(constants_1.keySpotMarkets, {
|
27
27
|
prefix: constants_1.platformId,
|
28
28
|
networkId: portfolio_core_1.NetworkId.solana,
|
@@ -30,24 +30,25 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
30
|
]);
|
31
31
|
if (!spotMarkets)
|
32
32
|
return;
|
33
|
-
const vaultClient = yield (0, helpers_1.getVaultClient)();
|
34
|
-
const vaults = yield Promise.all(vaultIds.map((vaultId) => vaultClient.getVault(vaultId.pubkey)));
|
35
33
|
const cachedItems = [];
|
36
|
-
for (const
|
37
|
-
const
|
38
|
-
|
39
|
-
|
40
|
-
const
|
41
|
-
const
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
vault
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
34
|
+
for (const vaultIds of vaultIdsByProgram) {
|
35
|
+
const i = vaultIdsByProgram.indexOf(vaultIds);
|
36
|
+
const programId = constants_2.vaultsProgramIds[i];
|
37
|
+
const vaultClient = yield (0, helpers_1.getVaultClient)(programId.toString());
|
38
|
+
const vaults = yield Promise.all(vaultIds.map((vaultId) => vaultClient.getVault(vaultId.pubkey)));
|
39
|
+
for (const vault of vaults) {
|
40
|
+
const spotMarket = spotMarkets.find((sm) => sm.marketIndex === vault.spotMarketIndex);
|
41
|
+
if (!spotMarket)
|
42
|
+
continue;
|
43
|
+
const pubkey = vault.pubkey.toString();
|
44
|
+
const vaultPlatformId = constants_2.platformIdByVaultManager.get(vault.manager.toString());
|
45
|
+
if (!vaultPlatformId)
|
46
|
+
continue;
|
47
|
+
const totalTokens = yield vaultClient.calculateVaultEquityInDepositAsset({
|
48
|
+
vault,
|
49
|
+
factorUnrealizedPNL: true,
|
50
|
+
});
|
51
|
+
const vaultInfo = {
|
51
52
|
pubkey,
|
52
53
|
platformId: vaultPlatformId,
|
53
54
|
name: (0, solana_1.u8ArrayToString)(vault.name),
|
@@ -57,14 +58,18 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
58
|
totalTokens: totalTokens.toString(),
|
58
59
|
user: vault.user.toString(),
|
59
60
|
profitShare: vault.profitShare,
|
60
|
-
}
|
61
|
-
|
61
|
+
};
|
62
|
+
cachedItems.push({
|
63
|
+
key: pubkey,
|
64
|
+
value: vaultInfo,
|
65
|
+
});
|
66
|
+
}
|
67
|
+
yield vaultClient.driftClient.unsubscribe();
|
62
68
|
}
|
63
69
|
yield cache.setItems(cachedItems, {
|
64
70
|
prefix: constants_2.prefixVaults,
|
65
71
|
networkId: portfolio_core_1.NetworkId.solana,
|
66
72
|
});
|
67
|
-
yield vaultClient.driftClient.unsubscribe();
|
68
73
|
});
|
69
74
|
const job = {
|
70
75
|
id: `${constants_1.platformId}-market-maker-vaults`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/vaultsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,iDAAsD;AACtD,+CAAqD;AACrD,kDAAgE;AAChE,2CAIqB;AACrB,uCAAwC;AAExC,uCAA2C;AAG3C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"vaultsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/drift-market-maker-vault/vaultsJ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