@sonarwatch/portfolio-plugins 0.5.6 → 0.5.8
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 +10 -2
- package/package.json +2 -2
- package/src/plugins/tokens/constants.d.ts +1 -0
- package/src/plugins/tokens/constants.js +2 -1
- package/src/plugins/tokens/constants.js.map +1 -1
- package/src/plugins/tokens/fetchers/evms/evmExecutorGenerator.d.ts +3 -0
- package/src/plugins/tokens/fetchers/evms/evmExecutorGenerator.js +84 -0
- package/src/plugins/tokens/fetchers/evms/evmExecutorGenerator.js.map +1 -0
- package/src/plugins/tokens/fetchers/evms/index.d.ts +2 -0
- package/src/plugins/tokens/fetchers/evms/index.js +30 -0
- package/src/plugins/tokens/fetchers/evms/index.js.map +1 -0
- package/src/plugins/tokens/index.js +4 -0
- package/src/plugins/tokens/index.js.map +1 -1
- package/src/plugins/tokens/tokenListsJob.d.ts +3 -0
- package/src/plugins/tokens/tokenListsJob.js +35 -0
- package/src/plugins/tokens/tokenListsJob.js.map +1 -0
- package/src/plugins/tokens/types.d.ts +25 -0
- package/src/plugins/top-tokens/constants.d.ts +1 -0
- package/src/plugins/top-tokens/constants.js +5 -0
- package/src/plugins/top-tokens/constants.js.map +1 -0
- package/src/plugins/top-tokens/index.d.ts +4 -0
- package/src/plugins/top-tokens/index.js +10 -0
- package/src/plugins/top-tokens/index.js.map +1 -0
- package/src/plugins/top-tokens/topTokensJob.d.ts +3 -0
- package/src/plugins/top-tokens/topTokensJob.js +41 -0
- package/src/plugins/top-tokens/topTokensJob.js.map +1 -0
- package/src/plugins/top-tokens/types.d.ts +28 -0
- package/src/plugins/top-tokens/types.js +3 -0
- package/src/plugins/top-tokens/types.js.map +1 -0
- package/src/utils/evm/erc20Abi.d.ts +13 -0
- package/src/utils/evm/erc20Abi.js +23 -0
- package/src/utils/evm/erc20Abi.js.map +1 -0
package/CHANGELOG.md
CHANGED
@@ -2,14 +2,22 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
-
## [0.5.
|
5
|
+
## [0.5.8](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.7...plugins-0.5.8) (2023-07-27)
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
## [0.5.
|
9
|
+
## [0.5.7](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.6...plugins-0.5.7) (2023-07-27)
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
## [0.5.6](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.5...plugins-0.5.6) (2023-07-24)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [0.5.5](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.4...plugins-0.5.5) (2023-07-21)
|
18
|
+
|
19
|
+
|
20
|
+
|
13
21
|
## [0.5.4](https://github.com/sonarwatch/portfolio/compare/plugins-0.5.3...plugins-0.5.4) (2023-07-21)
|
14
22
|
|
15
23
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.8",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"viem": "^1.2.9"
|
23
23
|
},
|
24
24
|
"peerDependencies": {
|
25
|
-
"@sonarwatch/portfolio-core": "0.5.
|
25
|
+
"@sonarwatch/portfolio-core": "0.5.8"
|
26
26
|
},
|
27
27
|
"main": "./src/index.js",
|
28
28
|
"types": "./src/index.d.ts"
|
@@ -1,7 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.coingeckoCoinsPriceUrl = exports.coingeckoCoinsMarketsUrl = exports.coingeckoCoinsListUrl = exports.platformId = exports.nIdsToFetch = void 0;
|
3
|
+
exports.coingeckoCoinsPriceUrl = exports.coingeckoCoinsMarketsUrl = exports.coingeckoCoinsListUrl = exports.platformId = exports.nIdsToFetch = exports.tokenListsPrefix = void 0;
|
4
4
|
const platforms_1 = require("../../platforms");
|
5
|
+
exports.tokenListsPrefix = 'tokenlists';
|
5
6
|
exports.nIdsToFetch = 50;
|
6
7
|
exports.platformId = platforms_1.walletTokensPlatform.id;
|
7
8
|
// Coingecko URLs
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/constants.ts"],"names":[],"mappings":";;;AAAA,+CAAuD;AAE1C,QAAA,WAAW,GAAG,EAAE,CAAC;AAEjB,QAAA,UAAU,GAAG,gCAAoB,CAAC,EAAE,CAAC;AAClD,iBAAiB;AACJ,QAAA,qBAAqB,GAChC,6CAA6C,CAAC;AACnC,QAAA,wBAAwB,GACnC,gDAAgD,CAAC;AACtC,QAAA,sBAAsB,GACjC,+CAA+C,CAAC"}
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/constants.ts"],"names":[],"mappings":";;;AAAA,+CAAuD;AAE1C,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAChC,QAAA,WAAW,GAAG,EAAE,CAAC;AAEjB,QAAA,UAAU,GAAG,gCAAoB,CAAC,EAAE,CAAC;AAClD,iBAAiB;AACJ,QAAA,qBAAqB,GAChC,6CAA6C,CAAC;AACnC,QAAA,wBAAwB,GACnC,gDAAgD,CAAC;AACtC,QAAA,sBAAsB,GACjC,+CAA+C,CAAC"}
|
@@ -0,0 +1,84 @@
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = require("bignumber.js");
|
17
|
+
const viem_1 = require("viem");
|
18
|
+
const platforms_1 = require("../../../../platforms");
|
19
|
+
const clients_1 = require("../../../../utils/clients");
|
20
|
+
const runInBatch_1 = __importDefault(require("../../../../utils/misc/runInBatch"));
|
21
|
+
const erc20Abi_1 = require("../../../../utils/evm/erc20Abi");
|
22
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../../../utils/misc/tokenPriceToAssetToken"));
|
23
|
+
const constants_1 = require("../../constants");
|
24
|
+
function getEvmFetcherExecutor(networkId, topTokens) {
|
25
|
+
return (owner, cache) => __awaiter(this, void 0, void 0, function* () {
|
26
|
+
if (topTokens)
|
27
|
+
return [];
|
28
|
+
const client = (0, clients_1.getEvmClient)(networkId);
|
29
|
+
const tokenList = yield cache.getItem(networkId, {
|
30
|
+
prefix: constants_1.tokenListsPrefix,
|
31
|
+
});
|
32
|
+
if (!tokenList || tokenList.tokens.length === 0)
|
33
|
+
return [];
|
34
|
+
const tokensAddresses = tokenList.tokens.map((token) => token.address);
|
35
|
+
const results = yield (0, runInBatch_1.default)(tokensAddresses.map((contract) => () => cache.getTokenPrice(contract, networkId)));
|
36
|
+
const tokenPrices = [];
|
37
|
+
results.forEach((r) => {
|
38
|
+
if (r.status === 'rejected')
|
39
|
+
return;
|
40
|
+
if (!r.value)
|
41
|
+
return;
|
42
|
+
tokenPrices.push(r.value);
|
43
|
+
});
|
44
|
+
const commonProps = {
|
45
|
+
abi: erc20Abi_1.erc20ABI,
|
46
|
+
functionName: 'balanceOf',
|
47
|
+
args: [(0, viem_1.getAddress)(owner)],
|
48
|
+
};
|
49
|
+
const contracts = tokenPrices.map((tp) => (Object.assign({ address: (0, viem_1.getAddress)(tp.address) }, commonProps)));
|
50
|
+
const contractsRes = yield client.multicall({ contracts });
|
51
|
+
const walletTokensAssets = [];
|
52
|
+
for (let i = 0; i < contractsRes.length; i += 1) {
|
53
|
+
const contractRes = contractsRes[i];
|
54
|
+
if (contractRes.status === 'failure')
|
55
|
+
continue;
|
56
|
+
if (!contractRes.result)
|
57
|
+
continue;
|
58
|
+
const tokenPrice = tokenPrices[i];
|
59
|
+
const { address } = tokenPrice;
|
60
|
+
const amount = new bignumber_js_1.BigNumber(contractRes.result.toString())
|
61
|
+
.div(Math.pow(10, tokenPrice.decimals))
|
62
|
+
.toNumber();
|
63
|
+
if (amount === 0)
|
64
|
+
continue;
|
65
|
+
const asset = (0, tokenPriceToAssetToken_1.default)(address, amount, networkId, tokenPrice);
|
66
|
+
walletTokensAssets.push(asset);
|
67
|
+
}
|
68
|
+
if (walletTokensAssets.length === 0)
|
69
|
+
return [];
|
70
|
+
const element = {
|
71
|
+
type: portfolio_core_1.PortfolioElementType.multiple,
|
72
|
+
networkId,
|
73
|
+
platformId: platforms_1.walletTokensPlatform.id,
|
74
|
+
label: 'Wallet',
|
75
|
+
value: (0, portfolio_core_1.getUsdValueSum)(walletTokensAssets.map((a) => a.value)),
|
76
|
+
data: {
|
77
|
+
assets: walletTokensAssets,
|
78
|
+
},
|
79
|
+
};
|
80
|
+
return [element];
|
81
|
+
});
|
82
|
+
}
|
83
|
+
exports.default = getEvmFetcherExecutor;
|
84
|
+
//# sourceMappingURL=evmExecutorGenerator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"evmExecutorGenerator.js","sourceRoot":"","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,CAAC;YAAE,OAAO,EAAE,CAAC;QAE/C,MAAM,OAAO,GAA6B;YACxC,IAAI,EAAE,qCAAoB,CAAC,QAAQ;YACnC,SAAS;YACT,UAAU,EAAE,gCAAoB,CAAC,EAAE;YACnC,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,IAAA,+BAAc,EAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC7D,IAAI,EAAE;gBACJ,MAAM,EAAE,kBAAkB;aAC3B;SACF,CAAC;QACF,OAAO,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC,CAAA,CAAC;AACJ,CAAC;AA7ED,wCA6EC"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.fetchers = void 0;
|
7
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
8
|
+
const platforms_1 = require("../../../../platforms");
|
9
|
+
const evmExecutorGenerator_1 = __importDefault(require("./evmExecutorGenerator"));
|
10
|
+
const evmNetworksIds = [
|
11
|
+
portfolio_core_1.NetworkId.ethereum,
|
12
|
+
portfolio_core_1.NetworkId.avalanche,
|
13
|
+
];
|
14
|
+
exports.fetchers = [
|
15
|
+
...evmNetworksIds
|
16
|
+
.map((networkId) => [
|
17
|
+
{
|
18
|
+
id: `${platforms_1.walletTokensPlatform.id}-${networkId}`,
|
19
|
+
networkId,
|
20
|
+
executor: (0, evmExecutorGenerator_1.default)(networkId, false),
|
21
|
+
},
|
22
|
+
// {
|
23
|
+
// id: `${walletTokensPlatform.id}-${networkId}`,
|
24
|
+
// networkId,
|
25
|
+
// executor: getEvmFetcherNativeExecutor(networkId, false),
|
26
|
+
// },
|
27
|
+
])
|
28
|
+
.flat(),
|
29
|
+
];
|
30
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/plugins/src/plugins/tokens/fetchers/evms/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAyE;AAEzE,qDAA6D;AAC7D,kFAA2D;AAE3D,MAAM,cAAc,GAAuB;IACzC,0BAAS,CAAC,QAAQ;IAClB,0BAAS,CAAC,SAAS;CACpB,CAAC;AAEW,QAAA,QAAQ,GAAc;IACjC,GAAG,cAAc;SACd,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;QAClB;YACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,SAAS,EAAE;YAC7C,SAAS;YACT,QAAQ,EAAE,IAAA,8BAAqB,EAAC,SAAS,EAAE,KAAK,CAAC;SAClD;QACD,IAAI;QACJ,mDAAmD;QACnD,eAAe;QACf,6DAA6D;QAC7D,KAAK;KACN,CAAC;SACD,IAAI,EAAE;CACV,CAAC"}
|
@@ -11,6 +11,8 @@ const aptos_1 = __importDefault(require("./fetchers/aptos"));
|
|
11
11
|
const solana_1 = __importDefault(require("./fetchers/solana"));
|
12
12
|
const sui_1 = __importDefault(require("./fetchers/sui"));
|
13
13
|
const solana_native_1 = __importDefault(require("./fetchers/solana-native"));
|
14
|
+
const tokenListsJob_1 = __importDefault(require("./tokenListsJob"));
|
15
|
+
const evms_1 = require("./fetchers/evms");
|
14
16
|
exports.jobs = [
|
15
17
|
{
|
16
18
|
id: `${platforms_1.walletTokensPlatform.id}-${portfolio_core_1.NetworkId.aptos}`,
|
@@ -32,11 +34,13 @@ exports.jobs = [
|
|
32
34
|
id: `${platforms_1.walletTokensPlatform.id}-${portfolio_core_1.NetworkId.sui}`,
|
33
35
|
executor: (0, jobExecutorGenerator_1.default)(portfolio_core_1.NetworkId.sui),
|
34
36
|
},
|
37
|
+
tokenListsJob_1.default,
|
35
38
|
];
|
36
39
|
exports.fetchers = [
|
37
40
|
aptos_1.default,
|
38
41
|
solana_1.default,
|
39
42
|
solana_native_1.default,
|
40
43
|
sui_1.default,
|
44
|
+
...evms_1.fetchers,
|
41
45
|
];
|
42
46
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAuD;AACvD,+CAAuD;AACvD,kFAA0D;AAC1D,6DAA4C;AAC5C,+DAA8C;AAC9C,yDAAwC;AACxC,6EAA2D;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAuD;AACvD,+CAAuD;AACvD,kFAA0D;AAC1D,6DAA4C;AAC5C,+DAA8C;AAC9C,yDAAwC;AACxC,6EAA2D;AAE3D,oEAA4C;AAE5C,0CAA0D;AAE7C,QAAA,IAAI,GAAU;IACzB;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,KAAK,EAAE;QACnD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,KAAK,CAAC;KAChD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,MAAM,EAAE;QACpD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,MAAM,CAAC;KACjD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,QAAQ,EAAE;QACtD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,QAAQ,CAAC;KACnD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,SAAS,EAAE;QACvD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,SAAS,CAAC;KACpD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,GAAG,EAAE;QACjD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,GAAG,CAAC;KAC9C;IACD,uBAAa;CACd,CAAC;AAEW,QAAA,QAAQ,GAAc;IACjC,eAAY;IACZ,gBAAa;IACb,uBAAmB;IACnB,aAAU;IACV,GAAG,eAAW;CACf,CAAC"}
|
@@ -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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
for (const network in portfolio_core_1.networks) {
|
20
|
+
if ((0, portfolio_core_1.assertNetworkId)(network)) {
|
21
|
+
const networkId = (0, portfolio_core_1.assertNetworkId)(network);
|
22
|
+
const { tokenListUrl } = portfolio_core_1.networks[networkId];
|
23
|
+
const tokenList = yield axios_1.default.get(tokenListUrl);
|
24
|
+
yield cache.setItem(networkId, tokenList.data, {
|
25
|
+
prefix: constants_1.tokenListsPrefix,
|
26
|
+
});
|
27
|
+
}
|
28
|
+
}
|
29
|
+
});
|
30
|
+
const job = {
|
31
|
+
id: 'token-lists',
|
32
|
+
executor,
|
33
|
+
};
|
34
|
+
exports.default = job;
|
35
|
+
//# sourceMappingURL=tokenListsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tokenListsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/tokenListsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAAuE;AACvE,kDAA0B;AAG1B,2CAA+C;AAE/C,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,KAAK,MAAM,OAAO,IAAI,yBAAQ,EAAE;QAC9B,IAAI,IAAA,gCAAe,EAAC,OAAO,CAAC,EAAE;YAC5B,MAAM,SAAS,GAAG,IAAA,gCAAe,EAAC,OAAO,CAAC,CAAC;YAC3C,MAAM,EAAE,YAAY,EAAE,GAAG,yBAAQ,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,SAAS,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAChD,MAAM,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,EAAE;gBAC7C,MAAM,EAAE,4BAAgB;aACzB,CAAC,CAAC;SACJ;KACF;AACH,CAAC,CAAA,CAAC;AACF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,aAAa;IACjB,QAAQ;CACT,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -7,3 +7,28 @@ export type TokenData = {
|
|
7
7
|
export type CoingeckoSimpleRes = Record<string, {
|
8
8
|
usd?: number;
|
9
9
|
}>;
|
10
|
+
export type TokenList = {
|
11
|
+
name: string;
|
12
|
+
timestamp: string;
|
13
|
+
version: {
|
14
|
+
major: number;
|
15
|
+
minor: number;
|
16
|
+
patch: number;
|
17
|
+
};
|
18
|
+
tags: object;
|
19
|
+
logoURI: string;
|
20
|
+
keywords: string[];
|
21
|
+
tokens: Token[];
|
22
|
+
};
|
23
|
+
export type Token = {
|
24
|
+
chainId: number;
|
25
|
+
address: string;
|
26
|
+
decimals: number;
|
27
|
+
name: string;
|
28
|
+
symbol: string;
|
29
|
+
logoURI: string;
|
30
|
+
tags?: string[];
|
31
|
+
extensions?: {
|
32
|
+
coingeckoId: string;
|
33
|
+
};
|
34
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const coingeckoMarketsUrl = "https://api.coingecko.com/api/v3/coins/markets";
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/top-tokens/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAC9B,gDAAgD,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.fetchers = exports.jobs = void 0;
|
7
|
+
const topTokensJob_1 = __importDefault(require("./topTokensJob"));
|
8
|
+
exports.jobs = [topTokensJob_1.default];
|
9
|
+
exports.fetchers = [];
|
10
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/top-tokens/index.ts"],"names":[],"mappings":";;;;;;AAEA,kEAA0C;AAE7B,QAAA,IAAI,GAAU,CAAC,sBAAY,CAAC,CAAC;AAC7B,QAAA,QAAQ,GAAc,EAAE,CAAC"}
|
@@ -0,0 +1,41 @@
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
+
const constants_1 = require("./constants");
|
18
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
19
|
+
const coingeckoRes = yield axios_1.default
|
20
|
+
.get(constants_1.coingeckoMarketsUrl, {
|
21
|
+
params: {
|
22
|
+
vs_currency: 'usd',
|
23
|
+
order: 'market_cap_desc',
|
24
|
+
per_page: '100',
|
25
|
+
page: '1',
|
26
|
+
},
|
27
|
+
})
|
28
|
+
.catch(() => null);
|
29
|
+
if (!coingeckoRes)
|
30
|
+
return;
|
31
|
+
if (coingeckoRes.status !== 200)
|
32
|
+
return;
|
33
|
+
const tokens = coingeckoRes.data;
|
34
|
+
yield cache.setItem(portfolio_core_1.NetworkId.ethereum, tokens.map((token) => token.id), { prefix: 'topTokens' });
|
35
|
+
});
|
36
|
+
const job = {
|
37
|
+
id: `topTokens`,
|
38
|
+
executor,
|
39
|
+
};
|
40
|
+
exports.default = job;
|
41
|
+
//# sourceMappingURL=topTokensJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"topTokensJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/top-tokens/topTokensJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA6C;AAC7C,+DAAuD;AAGvD,2CAAkD;AAGlD,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,YAAY,GAAgD,MAAM,eAAK;SAC1E,GAAG,CAAC,+BAAmB,EAAE;QACxB,MAAM,EAAE;YACN,WAAW,EAAE,KAAK;YAClB,KAAK,EAAE,iBAAiB;YACxB,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,GAAG;SACV;KACF,CAAC;SACD,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAErB,IAAI,CAAC,YAAY;QAAE,OAAO;IAC1B,IAAI,YAAY,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO;IACxC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC;IAEjC,MAAM,KAAK,CAAC,OAAO,CACjB,0BAAS,CAAC,QAAQ,EAClB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAC/B,EAAE,MAAM,EAAE,WAAW,EAAE,CACxB,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,WAAW;IACf,QAAQ;CACT,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
export type CoingeckoMarketsRes = {
|
2
|
+
id: string;
|
3
|
+
symbol: string;
|
4
|
+
name: string;
|
5
|
+
image: string;
|
6
|
+
current_price: number;
|
7
|
+
market_cap: number;
|
8
|
+
market_cap_rank: number;
|
9
|
+
fully_diluted_valuation: number;
|
10
|
+
total_volume: number;
|
11
|
+
high_24h: number;
|
12
|
+
low_24h: number;
|
13
|
+
price_change_24h: number;
|
14
|
+
price_change_percentage_24h: number;
|
15
|
+
market_cap_change_24h: number;
|
16
|
+
market_cap_change_percentage_24h: number;
|
17
|
+
circulating_supply: number;
|
18
|
+
total_supply: number;
|
19
|
+
max_supply: number;
|
20
|
+
ath: number;
|
21
|
+
ath_change_percentage: number;
|
22
|
+
ath_date: string;
|
23
|
+
atl: number;
|
24
|
+
atl_change_percentage: number;
|
25
|
+
atl_date: string;
|
26
|
+
roi: number;
|
27
|
+
last_updated: string;
|
28
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/top-tokens/types.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export declare const erc20ABI: readonly [{
|
2
|
+
readonly type: "function";
|
3
|
+
readonly name: "balanceOf";
|
4
|
+
readonly stateMutability: "view";
|
5
|
+
readonly inputs: readonly [{
|
6
|
+
readonly name: "account";
|
7
|
+
readonly type: "address";
|
8
|
+
}];
|
9
|
+
readonly outputs: readonly [{
|
10
|
+
readonly name: "";
|
11
|
+
readonly type: "uint256";
|
12
|
+
}];
|
13
|
+
}];
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.erc20ABI = void 0;
|
4
|
+
exports.erc20ABI = [
|
5
|
+
{
|
6
|
+
type: 'function',
|
7
|
+
name: 'balanceOf',
|
8
|
+
stateMutability: 'view',
|
9
|
+
inputs: [
|
10
|
+
{
|
11
|
+
name: 'account',
|
12
|
+
type: 'address',
|
13
|
+
},
|
14
|
+
],
|
15
|
+
outputs: [
|
16
|
+
{
|
17
|
+
name: '',
|
18
|
+
type: 'uint256',
|
19
|
+
},
|
20
|
+
],
|
21
|
+
},
|
22
|
+
];
|
23
|
+
//# sourceMappingURL=erc20Abi.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"erc20Abi.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/evm/erc20Abi.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACtB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,SAAS;aAChB;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;KACF;CACO,CAAC"}
|