@sonarwatch/portfolio-plugins 0.12.90 → 0.12.92
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/AirdropFetcher.d.ts +2 -2
- package/src/AirdropFetcher.js +23 -21
- package/src/AirdropFetcher.js.map +1 -1
- package/src/plugins/flash/poolJob.js +0 -1
- package/src/plugins/flash/poolJob.js.map +1 -1
- package/src/utils/misc/runInParallel.d.ts +11 -0
- package/src/utils/misc/runInParallel.js +42 -0
- package/src/utils/misc/runInParallel.js.map +1 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.12.92](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.91...plugins-0.12.92) (2024-07-25)
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
## [0.12.91](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.90...plugins-0.12.91) (2024-07-25)
|
10
|
+
|
11
|
+
|
12
|
+
|
5
13
|
## [0.12.90](https://github.com/sonarwatch/portfolio/compare/plugins-0.12.89...plugins-0.12.90) (2024-07-25)
|
6
14
|
|
7
15
|
|
package/package.json
CHANGED
package/src/AirdropFetcher.d.ts
CHANGED
@@ -12,7 +12,7 @@ export declare function setAirdropItemPrices(params: {
|
|
12
12
|
label: string;
|
13
13
|
price: number;
|
14
14
|
}[], networkId: NetworkIdType, cache: Cache): Promise<void>;
|
15
|
-
export declare function runAirdropFetchersByNetworkId(owner: string, networkId: NetworkIdType, fetchers: AirdropFetcher[], cache: Cache): Promise<AirdropFetchersResult>;
|
15
|
+
export declare function runAirdropFetchersByNetworkId(owner: string, networkId: NetworkIdType, fetchers: AirdropFetcher[], cache: Cache, useCache?: boolean): Promise<AirdropFetchersResult>;
|
16
16
|
export type AirdropStatics = Omit<AirdropRaw, 'status' | 'items'>;
|
17
17
|
export declare function getAirdropRaw(params: {
|
18
18
|
statics: AirdropStatics;
|
@@ -24,6 +24,6 @@ export declare function getAirdropRaw(params: {
|
|
24
24
|
isClaimed: IsClaimed;
|
25
25
|
}[];
|
26
26
|
}): AirdropRaw;
|
27
|
-
export declare function runAirdropFetchers(owner: string, addressSystem: AddressSystemType, fetchers: AirdropFetcher[], cache: Cache): Promise<AirdropFetchersResult>;
|
27
|
+
export declare function runAirdropFetchers(owner: string, addressSystem: AddressSystemType, fetchers: AirdropFetcher[], cache: Cache, useCache?: boolean): Promise<AirdropFetchersResult>;
|
28
28
|
export declare function runAirdropFetcher(owner: string, fetcher: AirdropFetcher, cache: Cache, useCache?: boolean): Promise<AirdropFetcherResult>;
|
29
29
|
export declare function airdropFetcherToFetcher(airdropFetcher: AirdropFetcher, platformId: string, id: string, claimEnd?: number): Fetcher;
|
package/src/AirdropFetcher.js
CHANGED
@@ -16,6 +16,7 @@ exports.airdropFetcherToFetcher = exports.runAirdropFetcher = exports.runAirdrop
|
|
16
16
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
17
|
const promiseTimeout_1 = __importDefault(require("./utils/misc/promiseTimeout"));
|
18
18
|
const tokenPriceToAssetToken_1 = __importDefault(require("./utils/misc/tokenPriceToAssetToken"));
|
19
|
+
const runInParallel_1 = __importDefault(require("./utils/misc/runInParallel"));
|
19
20
|
exports.airdropItemPriceCachePrefix = 'airdropitemprice';
|
20
21
|
function setAirdropItemPrices(params, networkId, cache) {
|
21
22
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -84,13 +85,13 @@ function enhanceAirdropItem(airdropItem, airdropId, airdropStatus, price, owner)
|
|
84
85
|
price, status: (0, portfolio_core_1.getAirdropItemStatus)(airdropStatus, airdropItem.amount, airdropItem.isClaimed), value: price ? price * airdropItem.amount : null, owner });
|
85
86
|
}
|
86
87
|
const runAirdropFetcherTimeout = 10000;
|
87
|
-
function runAirdropFetchersByNetworkId(owner, networkId, fetchers, cache) {
|
88
|
+
function runAirdropFetchersByNetworkId(owner, networkId, fetchers, cache, useCache = true) {
|
88
89
|
return __awaiter(this, void 0, void 0, function* () {
|
89
90
|
const isFetchersValids = fetchers.every((f) => f.networkId === networkId);
|
90
91
|
if (!isFetchersValids)
|
91
92
|
throw new Error(`Not all airdrop fetchers have the right network id: ${networkId}`);
|
92
93
|
const { addressSystem } = portfolio_core_1.networks[networkId];
|
93
|
-
return runAirdropFetchers(owner, addressSystem, fetchers, cache);
|
94
|
+
return runAirdropFetchers(owner, addressSystem, fetchers, cache, useCache);
|
94
95
|
});
|
95
96
|
}
|
96
97
|
exports.runAirdropFetchersByNetworkId = runAirdropFetchersByNetworkId;
|
@@ -111,14 +112,13 @@ function getAirdropItems(items) {
|
|
111
112
|
};
|
112
113
|
});
|
113
114
|
}
|
114
|
-
function runAirdropFetchers(owner, addressSystem, fetchers, cache) {
|
115
|
+
function runAirdropFetchers(owner, addressSystem, fetchers, cache, useCache = true) {
|
115
116
|
return __awaiter(this, void 0, void 0, function* () {
|
116
117
|
const fOwner = (0, portfolio_core_1.formatAddress)(owner, addressSystem);
|
117
118
|
const isFetchersValids = fetchers.every((f) => portfolio_core_1.networks[f.networkId].addressSystem === addressSystem);
|
118
119
|
if (!isFetchersValids)
|
119
120
|
throw new Error(`Not all fetchers have the right address system: ${addressSystem}`);
|
120
|
-
const
|
121
|
-
const result = yield Promise.allSettled(promises);
|
121
|
+
const result = yield (0, runInParallel_1.default)(fetchers.map((f) => () => runAirdropFetcher(fOwner, f, cache, useCache)), 5);
|
122
122
|
const fReports = [];
|
123
123
|
const airdrops = result.flatMap((r, index) => {
|
124
124
|
let fReport;
|
@@ -165,23 +165,25 @@ function internalRunAirdropFetcher(owner, fetcher, cache, useCache = true) {
|
|
165
165
|
return enhanceAirdrop(cAirdropRaw, owner, fetcher.networkId, cache);
|
166
166
|
}
|
167
167
|
const airdrop = yield fetcher.executor(owner, cache);
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
168
|
+
if (useCache) {
|
169
|
+
// TTL is 120000 ms (2min)
|
170
|
+
// If ineligible or claimed 240000 ms (4min)
|
171
|
+
// If not claimable yet 240000 ms (4min) or until claim start
|
172
|
+
let ttl = 120000;
|
173
|
+
const now = Date.now();
|
174
|
+
if (airdrop.items.every((i) => !(0, portfolio_core_1.isEligibleAmount)(i.amount)))
|
175
|
+
ttl = 240000;
|
176
|
+
else if (airdrop.items.every((i) => i.isClaimed === true))
|
177
|
+
ttl = 240000;
|
178
|
+
else if (airdrop.claimStart && airdrop.claimStart > now) {
|
179
|
+
ttl = Math.min(240000, airdrop.claimStart - now);
|
180
|
+
}
|
181
|
+
yield cache.setItem(`${fetcher.id}_${owner}`, airdrop, {
|
182
|
+
ttl,
|
183
|
+
prefix: airdropCachePrefix,
|
184
|
+
networkId: fetcher.networkId,
|
185
|
+
});
|
179
186
|
}
|
180
|
-
yield cache.setItem(`${fetcher.id}_${owner}`, airdrop, {
|
181
|
-
ttl,
|
182
|
-
prefix: airdropCachePrefix,
|
183
|
-
networkId: fetcher.networkId,
|
184
|
-
});
|
185
187
|
return enhanceAirdrop(airdrop, owner, fetcher.networkId, cache);
|
186
188
|
});
|
187
189
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AirdropFetcher.js","sourceRoot":"","sources":["../../../../packages/plugins/src/AirdropFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DA2BoC;AAEpC,iFAAyD;AAEzD,iGAAyE;
|
1
|
+
{"version":3,"file":"AirdropFetcher.js","sourceRoot":"","sources":["../../../../packages/plugins/src/AirdropFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DA2BoC;AAEpC,iFAAyD;AAEzD,iGAAyE;AACzE,+EAAuD;AAa1C,QAAA,2BAA2B,GAAG,kBAAkB,CAAC;AAC9D,SAAsB,oBAAoB,CACxC,MAGG,EACH,SAAwB,EACxB,KAAY;;QAEZ,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DAoEC"}
|
@@ -36,7 +36,6 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
const lpPrice = yield (0, helpers_1.getLpTokenPrice)(client, pool, pool.custodies.map((c) => { var _a; return ((_a = custodyAccounts.get(c.toString())) === null || _a === void 0 ? void 0 : _a.oracle.oracleAccount) || ''; }));
|
37
37
|
const decimals = yield (0, getDecimals_1.getDecimals)(client, pool.flpMint);
|
38
38
|
if (decimals && lpPrice) {
|
39
|
-
console.log('lpPrice:', lpPrice);
|
40
39
|
yield cache.setTokenPriceSource({
|
41
40
|
address: pool.flpMint.toString(),
|
42
41
|
decimals,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"poolJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/flash/poolJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,iDAAsD;AACtD,2CAA6E;AAC7E,uCAAyC;AACzC,+CAI4B;AAC5B,mDAA2D;AAE3D,uCAA4C;AAC5C,gEAA6D;AAE7D,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,yBAAe,GAAE,CAAC;IAEjC,MAAM,aAAa,GAAG,MAAM,IAAA,sCAA6B,EACvD,MAAM,EACN,sBAAY,EACZ,sBAAU,CACX,CAAC;IACF,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,OAAO,CAAgB,wBAAY,EAAE;QACrE,MAAM,EAAE,sBAAU;QAClB,SAAS,EAAE,0BAAS,CAAC,MAAM;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,aAAa;QAAE,OAAO;IAE3B,MAAM,eAAe,GAA6B,IAAI,GAAG,EAAE,CAAC;IAC5D,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAChC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7C,CAAC;IAEF,MAAM,SAAS,GA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AAC,IAAI,CAAC;aACxC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,WAA+B,CAAC;QACpC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC5D,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,uBAAc;gBAClC,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW;YAAE,SAAS;QAE3B,SAAS,CAAC,IAAI,CAAC;YACb,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAChC,IAAI,EAAE,sBAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;YAC9B,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,CAAC,OAAO,CAAC,oBAAQ,EAAE,SAAS,EAAE;QACvC,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,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* Runs an array of asynchronous functions in parallel with a specified concurrency limit.
|
3
|
+
* @template T The type of the resolved value of the promises returned by the functions.
|
4
|
+
*
|
5
|
+
* @param {(() => Promise<T>)[]} functionsToRun - An array of functions that return promises.
|
6
|
+
* Each function is expected to return a promise when called.
|
7
|
+
*
|
8
|
+
* @param {number} [limit=100] - The maximum number of promises that can be executed concurrently.
|
9
|
+
* If the limit is set to 0 or less, all functions will run concurrently without any limit.
|
10
|
+
*/
|
11
|
+
export default function runInParallel<T>(functionsToRun: (() => Promise<T>)[], limit?: number): Promise<PromiseSettledResult<T>[]>;
|
@@ -0,0 +1,42 @@
|
|
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
|
+
/**
|
13
|
+
* Runs an array of asynchronous functions in parallel with a specified concurrency limit.
|
14
|
+
* @template T The type of the resolved value of the promises returned by the functions.
|
15
|
+
*
|
16
|
+
* @param {(() => Promise<T>)[]} functionsToRun - An array of functions that return promises.
|
17
|
+
* Each function is expected to return a promise when called.
|
18
|
+
*
|
19
|
+
* @param {number} [limit=100] - The maximum number of promises that can be executed concurrently.
|
20
|
+
* If the limit is set to 0 or less, all functions will run concurrently without any limit.
|
21
|
+
*/
|
22
|
+
function runInParallel(functionsToRun, limit = 100) {
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
24
|
+
const results = [];
|
25
|
+
const executing = [];
|
26
|
+
for (const func of functionsToRun) {
|
27
|
+
const p = func().then((value) => ({ status: 'fulfilled', value }), (reason) => ({ status: 'rejected', reason }));
|
28
|
+
results.push(p);
|
29
|
+
const e = p.then(() => {
|
30
|
+
executing.splice(executing.indexOf(e), 1);
|
31
|
+
});
|
32
|
+
executing.push(e);
|
33
|
+
if (executing.length >= limit && limit > 0) {
|
34
|
+
yield Promise.race(executing);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
yield Promise.all(executing);
|
38
|
+
return Promise.all(results);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
exports.default = runInParallel;
|
42
|
+
//# sourceMappingURL=runInParallel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"runInParallel.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/runInParallel.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,SAA8B,aAAa,CACzC,cAAoC,EACpC,KAAK,GAAG,GAAG;;QAEX,MAAM,OAAO,GAAuC,EAAE,CAAC;QACvD,MAAM,SAAS,GAAoB,EAAE,CAAC;QAEtC,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;YAClC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,CACnB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAY,CAAA,EACpD,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAY,CAAA,CACtD,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAEhB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACpB,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAElB,IAAI,SAAS,CAAC,MAAM,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBAC3C,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CAAA;AA3BD,gCA2BC"}
|