@sonarwatch/portfolio-plugins 0.12.36 → 0.12.37
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/allbridge/constants.d.ts +0 -1
- package/src/plugins/allbridge/constants.js +1 -2
- package/src/plugins/allbridge/constants.js.map +1 -1
- package/src/plugins/allbridge/positionsFetcher.js +6 -2
- package/src/plugins/allbridge/positionsFetcher.js.map +1 -1
- package/src/plugins/banx/constants.d.ts +0 -1
- package/src/plugins/banx/constants.js +1 -2
- package/src/plugins/banx/constants.js.map +1 -1
- package/src/plugins/banx/idl.d.ts +15 -7
- package/src/plugins/banx/idl.js +199 -268
- package/src/plugins/banx/idl.js.map +1 -1
- package/src/plugins/banx/loansFetcher.js +19 -23
- package/src/plugins/banx/loansFetcher.js.map +1 -1
- package/src/plugins/banx/offersFetcher.js +10 -15
- package/src/plugins/banx/offersFetcher.js.map +1 -1
- package/src/plugins/citrus/collectionsJob.js.map +1 -1
- package/src/plugins/citrus/constants.d.ts +0 -1
- package/src/plugins/citrus/constants.js +1 -2
- package/src/plugins/citrus/constants.js.map +1 -1
- package/src/plugins/citrus/loansFetcher.js +14 -20
- package/src/plugins/citrus/loansFetcher.js.map +1 -1
- package/src/plugins/jupiter/exchange/constants.d.ts +1 -0
- package/src/plugins/jupiter/exchange/constants.js +2 -1
- package/src/plugins/jupiter/exchange/constants.js.map +1 -1
- package/src/plugins/jupiter/exchange/limitFetcher.js +9 -6
- package/src/plugins/jupiter/exchange/limitFetcher.js.map +1 -1
- package/src/plugins/jupiter/exchange/structs.d.ts +21 -0
- package/src/plugins/jupiter/exchange/structs.js +21 -1
- package/src/plugins/jupiter/exchange/structs.js.map +1 -1
- package/src/plugins/rain/collectionsJob.js +6 -10
- package/src/plugins/rain/collectionsJob.js.map +1 -1
- package/src/plugins/rain/helpers.js +3 -1
- package/src/plugins/rain/helpers.js.map +1 -1
- package/src/plugins/rain/index.js +2 -1
- package/src/plugins/rain/index.js.map +1 -1
- package/src/plugins/rain/loansFetcher.js +60 -25
- package/src/plugins/rain/loansFetcher.js.map +1 -1
- package/src/plugins/rain/types.d.ts +3 -0
- package/src/plugins/sharky/constants.d.ts +0 -1
- package/src/plugins/sharky/constants.js +3 -4
- package/src/plugins/sharky/constants.js.map +1 -1
- package/src/plugins/sharky/loansFetcher.js +17 -20
- package/src/plugins/sharky/loansFetcher.js.map +1 -1
- package/src/utils/misc/MemoizedCache.d.ts +12 -0
- package/src/utils/misc/MemoizedCache.js +35 -0
- package/src/utils/misc/MemoizedCache.js.map +1 -0
- package/src/utils/misc/arrayToMap.d.ts +1 -0
- package/src/utils/misc/arrayToMap.js +12 -0
- package/src/utils/misc/arrayToMap.js.map +1 -0
- package/src/utils/misc/pick.d.ts +2 -0
- package/src/utils/misc/pick.js +16 -0
- package/src/utils/misc/pick.js.map +1 -0
- package/src/utils/solana/getAutoParsedMultipleAccountsInfo.js +8 -3
- package/src/utils/solana/getAutoParsedMultipleAccountsInfo.js.map +1 -1
- package/src/plugins/allbridge/getPoolInfo.d.ts +0 -3
- package/src/plugins/allbridge/getPoolInfo.js +0 -28
- package/src/plugins/allbridge/getPoolInfo.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/structs.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/jupiter/exchange/structs.ts"],"names":[],"mappings":";;;AAAA,oDAQmC;AACnC,kEAA6D;AAG7D,kDAA6D;AAqBhD,QAAA,gBAAgB,GAAG,IAAI,iBAAU,CAC5C;IACE,CAAC,QAAQ,EAAE,IAAA,aAAI,EAAC,CAAC,CAAC,CAAC;IACnB,CAAC,OAAO,EAAE,uBAAS,CAAC;IACpB,CAAC,WAAW,EAAE,uBAAS,CAAC;IACxB,CAAC,YAAY,EAAE,uBAAS,CAAC;IACzB,CAAC,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ACpB,CAAC,MAAM,EAAE,uBAAS,CAAC;IACnB,CAAC,SAAS,EAAE,uBAAS,CAAC;IACtB,CAAC,mBAAmB,EAAE,uBAAS,CAAC;IAChC,CAAC,UAAU,EAAE,YAAG,CAAC;IACjB,CAAC,YAAY,EAAE,YAAG,CAAC;IACnB,CAAC,MAAM,EAAE,SAAE,CAAC;IACZ,CAAC,OAAO,EAAE,YAAG,CAAC;IACd,CAAC,SAAS,EAAE,YAAG,CAAC;IAChB,CAAC,eAAe,EAAE,YAAG,CAAC;IACtB,CAAC,gBAAgB,EAAE,YAAG,CAAC;IACvB,CAAC,4BAA4B,EAAE,aAAI,CAAC;IACpC,CAAC,cAAc,EAAE,YAAG,CAAC;IACrB,CAAC,MAAM,EAAE,SAAE,CAAC;CACb,EACD,CAAC,IAAI,EAAE,EAAE,CAAC,IAAgB,CAC3B,CAAC"}
|
@@ -12,20 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
13
|
const constants_1 = require("./constants");
|
14
14
|
const helpers_1 = require("./helpers");
|
15
|
+
const pick_1 = require("../../utils/misc/pick");
|
15
16
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
16
17
|
const collections = yield (0, helpers_1.getCollections)();
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
22
|
-
}));
|
23
|
-
}
|
24
|
-
promises.push(cache.setItem(constants_1.collectionsKey, collections, {
|
18
|
+
const filteredCollections = collections
|
19
|
+
.filter((c) => !c.isDefi)
|
20
|
+
.map((c) => (0, pick_1.pick)(c, ['collectionId', 'name', 'floorPrice']));
|
21
|
+
yield cache.setItem(constants_1.collectionsKey, filteredCollections, {
|
25
22
|
prefix: constants_1.platformId,
|
26
23
|
networkId: portfolio_core_1.NetworkId.solana,
|
27
|
-
})
|
28
|
-
yield Promise.all(promises);
|
24
|
+
});
|
29
25
|
});
|
30
26
|
const job = {
|
31
27
|
id: `${constants_1.platformId}-collections`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collectionsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/collectionsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAyD;AACzD,uCAA2C;
|
1
|
+
{"version":3,"file":"collectionsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/collectionsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAAyD;AACzD,uCAA2C;AAC3C,gDAA6C;AAG7C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAc,GAAE,CAAC;IAC3C,MAAM,mBAAmB,GAAG,WAAW;SACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;SACxB,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,CAAC,CAAqB,CAC3E,CAAC;IAEJ,MAAM,KAAK,CAAC,OAAO,CAAC,0BAAc,EAAE,mBAAmB,EAAE;QACvD,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,cAAc;IAC/B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -45,7 +45,9 @@ exports.getPoolPda = getPoolPda;
|
|
45
45
|
function getLoans(owner) {
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
47
47
|
const getLoansRes = yield axios_1.default
|
48
|
-
.get(`${constants_1.rainApi}/loans/user?pubkey=${owner}`, {
|
48
|
+
.get(`${constants_1.rainApi}/loans/user?pubkey=${owner}&status=Ongoing`, {
|
49
|
+
timeout: 1000,
|
50
|
+
})
|
49
51
|
.catch(() => null);
|
50
52
|
if (!getLoansRes || getLoansRes.data.ongoingCount === 0)
|
51
53
|
return [];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,6CAA4C;AAC5C,gEAAqC;AACrC,2CAAiD;AASjD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEnC,SAAsB,OAAO,CAAC,IAAY;;QACxC,MAAM,WAAW,GAAuC,MAAM,eAAK;aAChE,GAAG,CAAC,GAAG,mBAAO,sBAAsB,IAAI,EAAE,CAAC;aAC3C,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QACxD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;IAC/B,CAAC;CAAA;AAND,0BAMC;AAED,SAAsB,cAAc;;QAClC,MAAM,iBAAiB,GACrB,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,mBAAO,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QAC7D,OAAO,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC;IAC5C,CAAC;CAAA;AALD,wCAKC;AAED,SAAgB,UAAU,CAAC,KAAa;IACtC,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ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AsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,EACjE,qBAAS,CACV,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AALD,gCAKC;AAED,SAAsB,QAAQ,CAAC,KAAa;;QAC1C,MAAM,WAAW,GAAwC,MAAM,eAAK;aACjE,GAAG,CAAC,GAAG,mBAAO,sBAAsB,KAAK,iBAAiB,EAAE;YAC3D,OAAO,EAAE,IAAI;SACd,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACnE,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;IAChC,CAAC;CAAA;AARD,4BAQC;AAED,SAAgB,gBAAgB,CAAC,KAAW,EAAE,GAAS;IACrD,OAAO,IAAI,sBAAS,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SAChC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;SACtB,SAAS,CAAC,MAAM,CAAC;SACjB,aAAa,CAAC,CAAC,EAAE,sBAAS,CAAC,UAAU,CAAC;SACtC,QAAQ,EAAE,CAAC;AAChB,CAAC;AAND,4CAMC"}
|
@@ -7,7 +7,8 @@ exports.fetchers = exports.jobs = exports.platforms = void 0;
|
|
7
7
|
const constants_1 = require("./constants");
|
8
8
|
const poolsFetcher_1 = __importDefault(require("./poolsFetcher"));
|
9
9
|
const loansFetcher_1 = __importDefault(require("./loansFetcher"));
|
10
|
+
const collectionsJob_1 = __importDefault(require("./collectionsJob"));
|
10
11
|
exports.platforms = [constants_1.platform];
|
11
|
-
exports.jobs = [];
|
12
|
+
exports.jobs = [collectionsJob_1.default];
|
12
13
|
exports.fetchers = [poolsFetcher_1.default, loansFetcher_1.default];
|
13
14
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,kEAA0C;AAC1C,kEAA0C;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,kEAA0C;AAC1C,kEAA0C;AAC1C,sEAA8C;AAEjC,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,wBAAc,CAAC,CAAC;AAC/B,QAAA,QAAQ,GAAc,CAAC,sBAAY,EAAE,sBAAY,CAAC,CAAC"}
|
@@ -21,55 +21,90 @@ const solana_1 = require("../../utils/solana");
|
|
21
21
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
22
22
|
const pool_1 = require("./structs/pool");
|
23
23
|
const helpers_1 = require("./helpers");
|
24
|
+
const getAssetBatchDas_1 = require("../../utils/solana/das/getAssetBatchDas");
|
25
|
+
const getSolanaDasEndpoint_1 = __importDefault(require("../../utils/clients/getSolanaDasEndpoint"));
|
26
|
+
const heliusAssetToAssetCollectible_1 = require("../../utils/solana/das/heliusAssetToAssetCollectible");
|
27
|
+
const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
|
28
|
+
const collectionMemo = new MemoizedCache_1.MemoizedCache(constants_1.collectionsKey, {
|
29
|
+
prefix: constants_1.platformId,
|
30
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
31
|
+
});
|
24
32
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
25
33
|
const client = (0, clients_1.getClientSolana)();
|
26
|
-
|
27
|
-
// client,
|
28
|
-
// loanStruct,
|
29
|
-
// programId,
|
30
|
-
// loanBorrowerFilter(owner)
|
31
|
-
// );
|
32
|
-
// if (loans.length === 0) return [];
|
34
|
+
const dasUrl = (0, getSolanaDasEndpoint_1.default)();
|
33
35
|
const loans = yield (0, helpers_1.getLoans)(owner);
|
34
36
|
if (loans.length === 0)
|
35
37
|
return [];
|
36
|
-
const
|
38
|
+
const tokenMints = new Set();
|
39
|
+
const nftMints = new Set();
|
37
40
|
const pools = new Set();
|
41
|
+
tokenMints.add(portfolio_core_1.solanaNativeAddress);
|
38
42
|
loans.forEach((loan) => {
|
39
43
|
pools.add(loan.pool.toString());
|
40
|
-
|
41
|
-
|
44
|
+
tokenMints.add(loan.currency.toString());
|
45
|
+
if (loan.isDefi)
|
46
|
+
tokenMints.add(loan.mint.toString());
|
47
|
+
else
|
48
|
+
nftMints.add(loan.mint.toString());
|
42
49
|
});
|
43
|
-
const tokenPriceById = yield
|
44
|
-
|
50
|
+
const [tokenPriceById, heliusAssets, collections, poolsAccounts] = yield Promise.all([
|
51
|
+
cache.getTokenPricesAsMap(Array.from(tokenMints), portfolio_core_1.NetworkId.solana),
|
52
|
+
(0, getAssetBatchDas_1.getAssetBatchDasAsMap)(dasUrl, Array.from(nftMints)),
|
53
|
+
collectionMemo.getItem(cache),
|
54
|
+
(0, solana_1.getParsedMultipleAccountsInfo)(client, pool_1.poolStruct, Array.from(pools).map((pool) => new web3_js_1.PublicKey(pool))),
|
55
|
+
]);
|
45
56
|
const poolById = new Map();
|
46
57
|
poolsAccounts.forEach((account) => account ? poolById.set(account.pubkey.toString(), account) : undefined);
|
47
58
|
const elements = [];
|
48
59
|
for (const loan of loans) {
|
49
60
|
if (new bignumber_js_1.default(loan.amount).isZero())
|
50
61
|
continue;
|
51
|
-
|
52
|
-
continue;
|
53
|
-
if (!loan.isDefi)
|
54
|
-
continue;
|
55
|
-
const collateraMint = loan.mint.toString();
|
62
|
+
const collateralMint = loan.mint.toString();
|
56
63
|
const borrowMint = loan.currency.toString();
|
57
|
-
const collatTokenPrice = tokenPriceById.get(collateraMint);
|
58
|
-
const borrowTokenPrice = tokenPriceById.get(borrowMint);
|
59
|
-
if (!collatTokenPrice || !borrowTokenPrice)
|
60
|
-
continue;
|
61
64
|
const borrowedAssets = [];
|
62
65
|
const borrowedYields = [];
|
63
66
|
const suppliedAssets = [];
|
64
67
|
const suppliedYields = [];
|
65
68
|
const rewardAssets = [];
|
66
|
-
const amountBorrowed = new bignumber_js_1.default(loan.amount).dividedBy(Math.pow(10, borrowTokenPrice.decimals));
|
67
69
|
const daysRemaining = (0, helpers_1.daysBetweenDates)(new Date(), new Date(loan.expiredAt));
|
70
|
+
const borrowTokenPrice = tokenPriceById.get(borrowMint);
|
71
|
+
if (!borrowTokenPrice)
|
72
|
+
continue;
|
73
|
+
if (loan.isDefi) {
|
74
|
+
// mint is a token
|
75
|
+
const collatTokenPrice = tokenPriceById.get(collateralMint);
|
76
|
+
if (!collatTokenPrice)
|
77
|
+
continue;
|
78
|
+
const amountDeposited = new bignumber_js_1.default(loan.collateralAmount).dividedBy(Math.pow(10, collatTokenPrice.decimals));
|
79
|
+
if (!amountDeposited.isZero())
|
80
|
+
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(collatTokenPrice.address, amountDeposited.toNumber(), portfolio_core_1.NetworkId.solana, collatTokenPrice));
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
// mint is a nft
|
84
|
+
const heliusAsset = heliusAssets.get(loan.mint);
|
85
|
+
if (heliusAsset && collections) {
|
86
|
+
const collection = collections.find((c) => c.collectionId === loan.collectionId);
|
87
|
+
const solTokenPrice = tokenPriceById.get(portfolio_core_1.solanaNativeAddress);
|
88
|
+
const assetValue = collection && solTokenPrice
|
89
|
+
? new bignumber_js_1.default(collection.floorPrice)
|
90
|
+
.dividedBy(Math.pow(10, solTokenPrice.decimals))
|
91
|
+
.multipliedBy(solTokenPrice.price)
|
92
|
+
.toNumber()
|
93
|
+
: undefined;
|
94
|
+
const asset = (0, heliusAssetToAssetCollectible_1.heliusAssetToAssetCollectible)(heliusAsset, {
|
95
|
+
tags: [portfolio_core_1.collectibleFreezedTag],
|
96
|
+
collection: {
|
97
|
+
name: collection === null || collection === void 0 ? void 0 : collection.name,
|
98
|
+
floorPrice: assetValue,
|
99
|
+
},
|
100
|
+
});
|
101
|
+
if (asset)
|
102
|
+
suppliedAssets.push(asset);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
const amountBorrowed = new bignumber_js_1.default(loan.amount).dividedBy(Math.pow(10, borrowTokenPrice.decimals));
|
68
106
|
if (!amountBorrowed.isZero())
|
69
107
|
borrowedAssets.push((0, tokenPriceToAssetToken_1.default)(borrowTokenPrice.address, amountBorrowed.toNumber(), portfolio_core_1.NetworkId.solana, borrowTokenPrice, undefined, { tags: [`Refund in ${daysRemaining} days`] }));
|
70
|
-
const amountDeposited = new bignumber_js_1.default(loan.collateralAmount).dividedBy(Math.pow(10, collatTokenPrice.decimals));
|
71
|
-
if (!amountDeposited.isZero())
|
72
|
-
suppliedAssets.push((0, tokenPriceToAssetToken_1.default)(collatTokenPrice.address, amountDeposited.toNumber(), portfolio_core_1.NetworkId.solana, collatTokenPrice));
|
73
108
|
if (suppliedAssets.length === 0 && borrowedAssets.length === 0)
|
74
109
|
continue;
|
75
110
|
const { borrowedValue, healthRatio, suppliedValue, value, rewardValue } = (0, portfolio_core_1.getElementLendingValues)({ suppliedAssets, borrowedAssets, rewardAssets });
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/rain/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,6CAA4C;AAC5C,gEAAqC;AAGrC,2CAAyD;AACzD,iDAAsD;AACtD,+CAG4B;AAC5B,qGAA6E;AAC7E,yCAAkD;AAClD,uCAAuD;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ChB,KAAK;YACL,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,cAAc;gBACd,aAAa;gBACb,cAAc;gBACd,YAAY;gBACZ,WAAW;gBACX,WAAW;gBACX,KAAK;aACN;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,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"}
|
@@ -96,7 +96,10 @@ export type Collection = {
|
|
96
96
|
updatedAt: string;
|
97
97
|
deletedAt: string;
|
98
98
|
version: number;
|
99
|
+
mintIn: string;
|
100
|
+
isDefi: boolean;
|
99
101
|
};
|
102
|
+
export type PickedCollection = Pick<Collection, 'collectionId' | 'name' | 'floorPrice'>;
|
100
103
|
export type LoansResponse = {
|
101
104
|
user: string;
|
102
105
|
platform: string;
|
@@ -8,5 +8,4 @@ export declare const cachePrefix = "sharky";
|
|
8
8
|
export declare const sharkyProgram: PublicKey;
|
9
9
|
export declare const loanDataSize = 338;
|
10
10
|
export declare const orderBookDataSize = 10240;
|
11
|
-
export declare const collectionRefreshInterval = 3600000;
|
12
11
|
export declare const sharkyIdlItem: IdlItem;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.sharkyIdlItem = exports.
|
3
|
+
exports.sharkyIdlItem = exports.orderBookDataSize = exports.loanDataSize = exports.sharkyProgram = exports.cachePrefix = exports.collectionsCacheKey = exports.platform = exports.platformId = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
const idl_1 = require("./idl");
|
6
6
|
exports.platformId = 'sharky';
|
7
7
|
exports.platform = {
|
8
8
|
id: exports.platformId,
|
9
9
|
name: 'Sharky',
|
10
|
-
image: 'https://sonar.watch/img/platforms/
|
11
|
-
website: 'https://
|
10
|
+
image: 'https://sonar.watch/img/platforms/sharky.webp',
|
11
|
+
website: 'https://sharky.fi/',
|
12
12
|
twitter: 'https://twitter.com/SharkyFi',
|
13
13
|
defiLlamaId: 'sharky', // from https://defillama.com/docs/api
|
14
14
|
};
|
@@ -17,7 +17,6 @@ exports.cachePrefix = `${exports.platformId}`;
|
|
17
17
|
exports.sharkyProgram = new web3_js_1.PublicKey('SHARKobtfF1bHhxD2eqftjHBdVSCbKo9JtgK71FhELP');
|
18
18
|
exports.loanDataSize = 338;
|
19
19
|
exports.orderBookDataSize = 10240;
|
20
|
-
exports.collectionRefreshInterval = 3600000;
|
21
20
|
exports.sharkyIdlItem = {
|
22
21
|
programId: exports.sharkyProgram.toString(),
|
23
22
|
idl: idl_1.SharkyIDL,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/sharky/constants.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE5C,+BAAkC;AAErB,QAAA,UAAU,GAAG,QAAQ,CAAC;AACtB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,+CAA+C;IACtD,OAAO,EAAE,oBAAoB;IAC7B,OAAO,EAAE,8BAA8B;IACvC,WAAW,EAAE,QAAQ,EAAE,sCAAsC;CAC9D,CAAC;AACW,QAAA,mBAAmB,GAAG,GAAG,kBAAU,cAAc,CAAC;AAClD,QAAA,WAAW,GAAG,GAAG,kBAAU,EAAE,CAAC;AAE9B,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,6CAA6C,CAC9C,CAAC;AAEW,QAAA,YAAY,GAAG,GAAG,CAAC;AACnB,QAAA,iBAAiB,GAAG,KAAK,CAAC;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/sharky/constants.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE5C,+BAAkC;AAErB,QAAA,UAAU,GAAG,QAAQ,CAAC;AACtB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,+CAA+C;IACtD,OAAO,EAAE,oBAAoB;IAC7B,OAAO,EAAE,8BAA8B;IACvC,WAAW,EAAE,QAAQ,EAAE,sCAAsC;CAC9D,CAAC;AACW,QAAA,mBAAmB,GAAG,GAAG,kBAAU,cAAc,CAAC;AAClD,QAAA,WAAW,GAAG,GAAG,kBAAU,EAAE,CAAC;AAE9B,QAAA,aAAa,GAAG,IAAI,mBAAS,CACxC,6CAA6C,CAC9C,CAAC;AAEW,QAAA,YAAY,GAAG,GAAG,CAAC;AACnB,QAAA,iBAAiB,GAAG,KAAK,CAAC;AAE1B,QAAA,aAAa,GAAG;IAC3B,SAAS,EAAE,qBAAa,CAAC,QAAQ,EAAE;IACnC,GAAG,EAAE,eAAS;IACd,OAAO,EAAE,QAAQ;CACP,CAAC"}
|
@@ -22,8 +22,12 @@ const getAssetBatchDas_1 = require("../../utils/solana/das/getAssetBatchDas");
|
|
22
22
|
const getSolanaDasEndpoint_1 = __importDefault(require("../../utils/clients/getSolanaDasEndpoint"));
|
23
23
|
const heliusAssetToAssetCollectible_1 = require("../../utils/solana/das/heliusAssetToAssetCollectible");
|
24
24
|
const filters_1 = require("./filters");
|
25
|
-
const
|
26
|
-
|
25
|
+
const MemoizedCache_1 = require("../../utils/misc/MemoizedCache");
|
26
|
+
const arrayToMap_1 = require("../../utils/misc/arrayToMap");
|
27
|
+
const collectionsMemo = new MemoizedCache_1.MemoizedCache(constants_1.collectionsCacheKey, {
|
28
|
+
prefix: constants_1.cachePrefix,
|
29
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
30
|
+
}, (arr) => (0, arrayToMap_1.arrayToMap)(arr || [], 'orderBook'));
|
27
31
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
28
32
|
const dasUrl = (0, getSolanaDasEndpoint_1.default)();
|
29
33
|
const connection = (0, clients_1.getClientSolana)();
|
@@ -35,26 +39,15 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
35
39
|
])).flat();
|
36
40
|
if (accounts.length === 0)
|
37
41
|
return [];
|
38
|
-
const [solTokenPrice, heliusAssets] = yield Promise.all([
|
42
|
+
const [solTokenPrice, heliusAssets, collections] = yield Promise.all([
|
39
43
|
cache.getTokenPrice(portfolio_core_1.solanaNativeAddress, portfolio_core_1.NetworkId.solana),
|
40
44
|
(0, getAssetBatchDas_1.getAssetBatchDasAsMap)(dasUrl, accounts
|
41
45
|
.map((acc) => { var _a; return (_a = acc.loanState.taken) === null || _a === void 0 ? void 0 : _a.taken.nftCollateralMint; })
|
42
46
|
.filter((mint) => mint)),
|
47
|
+
collectionsMemo.getItem(cache),
|
43
48
|
]);
|
44
|
-
if (!solTokenPrice)
|
49
|
+
if (!solTokenPrice || !collections)
|
45
50
|
return [];
|
46
|
-
if (collectionLastUpdate + constants_1.collectionRefreshInterval < Date.now()) {
|
47
|
-
const collectionsArr = yield cache.getItem(constants_1.collectionsCacheKey, {
|
48
|
-
prefix: constants_1.cachePrefix,
|
49
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
50
|
-
});
|
51
|
-
if (collectionsArr) {
|
52
|
-
collectionsArr.forEach((cc) => {
|
53
|
-
collections.set(cc.orderBook, cc);
|
54
|
-
});
|
55
|
-
}
|
56
|
-
collectionLastUpdate = Date.now();
|
57
|
-
}
|
58
51
|
const elements = [];
|
59
52
|
accounts.forEach((acc) => {
|
60
53
|
var _a;
|
@@ -107,17 +100,21 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
107
100
|
}
|
108
101
|
if (suppliedAssets.length === 0)
|
109
102
|
return;
|
110
|
-
const { borrowedValue, suppliedValue,
|
103
|
+
const { borrowedValue, suppliedValue, rewardValue, value } = (0, portfolio_core_1.getElementNFTLendingValues)({
|
111
104
|
suppliedAssets,
|
112
105
|
borrowedAssets,
|
113
106
|
rewardAssets: [],
|
107
|
+
lender: acc.loanState.offer !== undefined ||
|
108
|
+
(acc.loanState.taken
|
109
|
+
? acc.loanState.taken.taken.lenderNoteMint === owner.toString()
|
110
|
+
: false),
|
114
111
|
});
|
115
112
|
elements.push({
|
116
113
|
networkId: portfolio_core_1.NetworkId.solana,
|
117
114
|
label: 'Lending',
|
118
115
|
platformId: constants_1.platformId,
|
119
116
|
type: portfolio_core_1.PortfolioElementType.borrowlend,
|
120
|
-
value
|
117
|
+
value,
|
121
118
|
name,
|
122
119
|
data: {
|
123
120
|
borrowedAssets,
|
@@ -128,8 +125,8 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
128
125
|
suppliedYields: [],
|
129
126
|
rewardAssets: [],
|
130
127
|
rewardValue,
|
131
|
-
healthRatio,
|
132
|
-
value
|
128
|
+
healthRatio: null,
|
129
|
+
value,
|
133
130
|
expireOn: acc.loanState.taken
|
134
131
|
? Number(acc.loanState.taken.taken.terms.time.start) +
|
135
132
|
Number(acc.loanState.taken.taken.terms.time.duration)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/sharky/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAUoC;AACpC,gEAAqC;AAErC,
|
1
|
+
{"version":3,"file":"loansFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/sharky/loansFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAUoC;AACpC,gEAAqC;AAErC,2CAKqB;AAErB,iDAAsD;AACtD,+CAG4B;AAE5B,qGAA6E;AAC7E,8EAAgF;AAChF,oGAA4E;AAC5E,wGAAqG;AACrG,uCAA2C;AAC3C,kEAA+D;AAC/D,4DAAyD;AAEzD,MAAM,eAAe,GAAG,IAAI,6B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,CAAC;SACb,CAAC,CAAC;QAEL,QAAQ,CAAC,IAAI,CAAC;YACZ,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,KAAK,EAAE,SAAS;YAChB,UAAU,EAAV,sBAAU;YACV,IAAI,EAAE,qCAAoB,CAAC,UAAU;YACrC,KAAK;YACL,IAAI;YACJ,IAAI,EAAE;gBACJ,cAAc;gBACd,aAAa;gBACb,cAAc,EAAE,EAAE;gBAClB,cAAc;gBACd,aAAa;gBACb,cAAc,EAAE,EAAE;gBAClB,YAAY,EAAE,EAAE;gBAChB,WAAW;gBACX,WAAW,EAAE,IAAI;gBACjB,KAAK;gBACL,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK;oBAC3B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;wBAClD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;oBACvD,CAAC,CAAC,SAAS;aACd;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,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"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { StorageValue } from 'unstorage';
|
2
|
+
import { Cache, TransactionOptions } from '../../Cache';
|
3
|
+
export declare class MemoizedCache<T extends StorageValue, K = T> {
|
4
|
+
private readonly key;
|
5
|
+
private readonly opts;
|
6
|
+
private readonly transform;
|
7
|
+
private readonly ttl;
|
8
|
+
private item;
|
9
|
+
private lastUpdate;
|
10
|
+
constructor(key: string, opts: TransactionOptions, transform?: (i: T | undefined) => K, ttl?: number);
|
11
|
+
getItem: (cache: Cache) => Promise<K>;
|
12
|
+
}
|
@@ -0,0 +1,35 @@
|
|
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
|
+
exports.MemoizedCache = void 0;
|
13
|
+
const defaultMemoizedCacheRefreshInterval = 3600000;
|
14
|
+
// T is the type of stored item in cache
|
15
|
+
// K is the type of the item after transformation
|
16
|
+
class MemoizedCache {
|
17
|
+
constructor(key, opts, transform, ttl = defaultMemoizedCacheRefreshInterval) {
|
18
|
+
this.getItem = (cache) => __awaiter(this, void 0, void 0, function* () {
|
19
|
+
const now = Date.now();
|
20
|
+
if (!this.item || this.lastUpdate + this.ttl < now) {
|
21
|
+
const rawItem = yield cache.getItem(this.key, this.opts);
|
22
|
+
this.item = this.transform ? this.transform(rawItem) : rawItem;
|
23
|
+
this.lastUpdate = now;
|
24
|
+
}
|
25
|
+
return this.item;
|
26
|
+
});
|
27
|
+
this.key = key;
|
28
|
+
this.opts = opts;
|
29
|
+
this.transform = transform;
|
30
|
+
this.ttl = ttl;
|
31
|
+
this.lastUpdate = 0;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
exports.MemoizedCache = MemoizedCache;
|
35
|
+
//# sourceMappingURL=MemoizedCache.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MemoizedCache.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/MemoizedCache.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,MAAM,mCAAmC,GAAG,OAAO,CAAC;AAEpD,wCAAwC;AACxC,iDAAiD;AACjD,MAAa,aAAa;IASxB,YACE,GAAW,EACX,IAAwB,EACxB,SAAmC,EACnC,MAAc,mCAAmC;QASnD,YAAO,GAAG,CAAO,KAAY,EAAE,EAAE;YAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAEvB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;gBACnD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,CAAI,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAAa,CAAC;gBACtE,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;YACxB,CAAC;YAED,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC,CAAA,CAAC;QAjBA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACtB,CAAC;CAaF;AAjCD,sCAiCC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const arrayToMap: <T>(array: T[], keyField: keyof T) => Map<string, T>;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.arrayToMap = void 0;
|
4
|
+
const arrayToMap = (array, keyField) => {
|
5
|
+
const map = new Map();
|
6
|
+
array.forEach((item) => {
|
7
|
+
map.set(item[keyField], item);
|
8
|
+
});
|
9
|
+
return map;
|
10
|
+
};
|
11
|
+
exports.arrayToMap = arrayToMap;
|
12
|
+
//# sourceMappingURL=arrayToMap.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"arrayToMap.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/arrayToMap.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CACxB,KAAU,EACV,QAAiB,EACD,EAAE;IAClB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAa,CAAC;IACjC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAW,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AATW,QAAA,UAAU,cASrB"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.pickFromArray = exports.pick = void 0;
|
4
|
+
const pick = (obj, keys) => {
|
5
|
+
const result = {};
|
6
|
+
keys.forEach((key) => {
|
7
|
+
if (key in obj) {
|
8
|
+
result[key] = obj[key];
|
9
|
+
}
|
10
|
+
});
|
11
|
+
return result;
|
12
|
+
};
|
13
|
+
exports.pick = pick;
|
14
|
+
const pickFromArray = (items, keys) => items.map((item) => (0, exports.pick)(item, keys));
|
15
|
+
exports.pickFromArray = pickFromArray;
|
16
|
+
//# sourceMappingURL=pick.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/pick.ts"],"names":[],"mappings":";;;AAAO,MAAM,IAAI,GAAG,CAClB,GAAM,EACN,IAAS,EACG,EAAE;IACd,MAAM,MAAM,GAAG,EAAgB,CAAC;IAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACnB,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;YACf,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAXW,QAAA,IAAI,QAWf;AAEK,MAAM,aAAa,GAAG,CAC3B,KAAU,EACV,IAAS,EACK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,YAAI,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAH5C,QAAA,aAAa,iBAG+B"}
|
@@ -22,10 +22,15 @@ function getAutoParsedMultipleAccountsInfo(connection, idlItem, publicKeys, comm
|
|
22
22
|
return accountsInfo.map((accountInfo, i) => {
|
23
23
|
if (!accountInfo)
|
24
24
|
return null;
|
25
|
-
|
26
|
-
|
25
|
+
try {
|
26
|
+
const parsedAccount = eventParser.parseAccount(accountInfo.data.toString('base64'));
|
27
|
+
if (parsedAccount === null)
|
28
|
+
return null;
|
29
|
+
return Object.assign({ pubkey: publicKeys[i], lamports: accountInfo.lamports }, parsedAccount.data);
|
30
|
+
}
|
31
|
+
catch (err) {
|
27
32
|
return null;
|
28
|
-
|
33
|
+
}
|
29
34
|
});
|
30
35
|
});
|
31
36
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getAutoParsedMultipleAccountsInfo.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getAutoParsedMultipleAccountsInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,yDAIgC;AAChC,+EAA4E;AAG5E,SAAsB,iCAAiC,CACrD,UAAsB,EACtB,OAAgB,EAChB,UAAuB,EACvB,kBAA2D;;QAE3D,MAAM,MAAM,GAAG,IAAI,6BAAc,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,yBAAU,CAAC,OAAO,CAAC,CAAC;QAE5D,IAAI,CAAC,WAAW,IAAI,CAAC,IAAA,mCAAoB,EAAC,WAAW,CAAC;YAAE,OAAO,EAAE,CAAC;QAElE,MAAM,YAAY,GAAG,MAAM,IAAA,yDAA2B,EACpD,UAAU,EACV,UAAU,EACV,kBAAkB,CACnB,CAAC;QAEF,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,CAAC,WAAW;gBAAE,OAAO,IAAI,CAAC;YAE9B,MAAM,aAAa,GAAG,WAAW,CAAC,YAAY,CAC5C,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACpC,CAAC;
|
1
|
+
{"version":3,"file":"getAutoParsedMultipleAccountsInfo.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getAutoParsedMultipleAccountsInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,yDAIgC;AAChC,+EAA4E;AAG5E,SAAsB,iCAAiC,CACrD,UAAsB,EACtB,OAAgB,EAChB,UAAuB,EACvB,kBAA2D;;QAE3D,MAAM,MAAM,GAAG,IAAI,6BAAc,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,yBAAU,CAAC,OAAO,CAAC,CAAC;QAE5D,IAAI,CAAC,WAAW,IAAI,CAAC,IAAA,mCAAoB,EAAC,WAAW,CAAC;YAAE,OAAO,EAAE,CAAC;QAElE,MAAM,YAAY,GAAG,MAAM,IAAA,yDAA2B,EACpD,UAAU,EACV,UAAU,EACV,kBAAkB,CACnB,CAAC;QAEF,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,CAAC,WAAW;gBAAE,OAAO,IAAI,CAAC;YAE9B,IAAI,CAAC;gBACH,MAAM,aAAa,GAAG,WAAW,CAAC,YAAY,CAC5C,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACpC,CAAC;gBACF,IAAI,aAAa,KAAK,IAAI;oBAAE,OAAO,IAAI,CAAC;gBAExC,uBACE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,WAAW,CAAC,QAAQ,IAC1B,aAAa,CAAC,IAAU,EAC5B;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAnCD,8EAmCC"}
|
@@ -1,28 +0,0 @@
|
|
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
|
-
exports.getPoolInfo = void 0;
|
13
|
-
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
14
|
-
const constants_1 = require("./constants");
|
15
|
-
let poolInfo;
|
16
|
-
let poolInfoLastUpdate = 0;
|
17
|
-
const getPoolInfo = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
18
|
-
if (!poolInfo || poolInfoLastUpdate + constants_1.poolInfoRefreshInterval < Date.now()) {
|
19
|
-
poolInfo = yield cache.getItem(constants_1.poolsCacheKey, {
|
20
|
-
prefix: constants_1.cachePrefix,
|
21
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
22
|
-
});
|
23
|
-
poolInfoLastUpdate = Date.now();
|
24
|
-
}
|
25
|
-
return poolInfo;
|
26
|
-
});
|
27
|
-
exports.getPoolInfo = getPoolInfo;
|
28
|
-
//# sourceMappingURL=getPoolInfo.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getPoolInfo.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/allbridge/getPoolInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAuD;AAEvD,2CAIqB;AAGrB,IAAI,QAA2B,CAAC;AAChC,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAEpB,MAAM,WAAW,GAAG,CAAO,KAAY,EAAE,EAAE;IAChD,IAAI,CAAC,QAAQ,IAAI,kBAAkB,GAAG,mCAAuB,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAC3E,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAQ,yBAAa,EAAE;YACnD,MAAM,EAAE,uBAAW;YACnB,SAAS,EAAE,0BAAS,CAAC,MAAM;SAC5B,CAAC,CAAC;QACH,kBAAkB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AATW,QAAA,WAAW,eAStB"}
|