@defillama/sdk 2.3.34 → 2.3.35

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.
Files changed (64) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +16 -16
  3. package/build/abi/cachedABIs.d.ts +4 -4
  4. package/build/abi/cachedABIs.js +70 -70
  5. package/build/abi/convertResults.d.ts +2 -2
  6. package/build/abi/convertResults.js +56 -56
  7. package/build/abi/index.d.ts +26 -26
  8. package/build/abi/index.js +185 -185
  9. package/build/abi/index.test.d.ts +1 -1
  10. package/build/abi/index.test.js +651 -651
  11. package/build/abi/multicall.d.ts +13 -13
  12. package/build/abi/multicall.js +210 -210
  13. package/build/api.d.ts +10 -10
  14. package/build/api.js +32 -32
  15. package/build/cdp/compoundTokens.d.ts +68 -68
  16. package/build/cdp/compoundTokens.js +69 -69
  17. package/build/cdp/index.d.ts +29 -29
  18. package/build/cdp/index.js +124 -124
  19. package/build/cdp/index.test.d.ts +1 -1
  20. package/build/cdp/index.test.js +82 -82
  21. package/build/cdp/makerTokens.d.ts +10 -10
  22. package/build/cdp/makerTokens.js +244 -244
  23. package/build/cli.d.ts +2 -2
  24. package/build/cli.js +95 -95
  25. package/build/computeTVL/blocks.d.ts +18 -15
  26. package/build/computeTVL/blocks.js +138 -136
  27. package/build/computeTVL/blocks.test.d.ts +1 -1
  28. package/build/computeTVL/blocks.test.js +56 -56
  29. package/build/computeTVL/humanizeNumber.d.ts +1 -1
  30. package/build/computeTVL/humanizeNumber.js +18 -18
  31. package/build/computeTVL/index.d.ts +52 -52
  32. package/build/computeTVL/index.js +373 -373
  33. package/build/computeTVL/index.test.d.ts +1 -1
  34. package/build/computeTVL/index.test.js +107 -107
  35. package/build/computeTVL/prices.d.ts +9 -9
  36. package/build/computeTVL/prices.js +163 -163
  37. package/build/erc20/index.d.ts +31 -31
  38. package/build/erc20/index.js +144 -144
  39. package/build/erc20/index.test.d.ts +1 -1
  40. package/build/erc20/index.test.js +124 -124
  41. package/build/eth/index.d.ts +21 -21
  42. package/build/eth/index.js +90 -90
  43. package/build/eth/index.test.d.ts +1 -1
  44. package/build/eth/index.test.js +122 -122
  45. package/build/general.d.ts +7 -7
  46. package/build/general.js +94 -94
  47. package/build/general.test.d.ts +1 -1
  48. package/build/general.test.js +73 -73
  49. package/build/generalUtil.d.ts +19 -19
  50. package/build/generalUtil.js +117 -117
  51. package/build/generalUtil.test.d.ts +1 -1
  52. package/build/generalUtil.test.js +59 -59
  53. package/build/index.d.ts +2 -2
  54. package/build/index.js +24 -24
  55. package/build/index.test.js +69 -69
  56. package/build/types.d.ts +5 -5
  57. package/build/types.js +2 -2
  58. package/build/util/index.d.ts +57 -57
  59. package/build/util/index.js +351 -351
  60. package/build/util/index.test.d.ts +1 -1
  61. package/build/util/index.test.js +314 -314
  62. package/build/util/tokenList.d.ts +14 -14
  63. package/build/util/tokenList.js +3631 -3631
  64. package/package.json +41 -41
@@ -1,68 +1,68 @@
1
- declare const _default: {
2
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
3
- cToken: string;
4
- symbol: string;
5
- rate: string;
6
- };
7
- "0x6B175474E89094C44Da98b954EedeAC495271d0F": {
8
- cToken: string;
9
- symbol: string;
10
- decimals: number;
11
- rate: string;
12
- };
13
- "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359": {
14
- cToken: string;
15
- symbol: string;
16
- decimals: number;
17
- rate: string;
18
- };
19
- "0x0D8775F648430679A709E98d2b0Cb6250d2887EF": {
20
- cToken: string;
21
- symbol: string;
22
- decimals: number;
23
- rate: string;
24
- };
25
- "0xE41d2489571d322189246DaFA5ebDe1F4699F498": {
26
- cToken: string;
27
- symbol: string;
28
- decimals: number;
29
- rate: string;
30
- };
31
- "0x1985365e9f78359a9B6AD760e32412f4a445E862": {
32
- cToken: string;
33
- symbol: string;
34
- decimals: number;
35
- rate: string;
36
- };
37
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
38
- cToken: string;
39
- symbol: string;
40
- decimals: number;
41
- rate: string;
42
- };
43
- "0xdAC17F958D2ee523a2206206994597C13D831ec7": {
44
- cToken: string;
45
- symbol: string;
46
- decimals: number;
47
- rate: string;
48
- };
49
- "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
50
- cToken: string;
51
- symbol: string;
52
- decimals: number;
53
- rate: string;
54
- };
55
- "0xc00e94Cb662C3520282E6f5717214004A7f26888": {
56
- cToken: string;
57
- symbol: string;
58
- decimals: number;
59
- rate: string;
60
- };
61
- "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": {
62
- cToken: string;
63
- symbol: string;
64
- decimals: number;
65
- rate: string;
66
- };
67
- };
68
- export default _default;
1
+ declare const _default: {
2
+ "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
3
+ cToken: string;
4
+ symbol: string;
5
+ rate: string;
6
+ };
7
+ "0x6B175474E89094C44Da98b954EedeAC495271d0F": {
8
+ cToken: string;
9
+ symbol: string;
10
+ decimals: number;
11
+ rate: string;
12
+ };
13
+ "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359": {
14
+ cToken: string;
15
+ symbol: string;
16
+ decimals: number;
17
+ rate: string;
18
+ };
19
+ "0x0D8775F648430679A709E98d2b0Cb6250d2887EF": {
20
+ cToken: string;
21
+ symbol: string;
22
+ decimals: number;
23
+ rate: string;
24
+ };
25
+ "0xE41d2489571d322189246DaFA5ebDe1F4699F498": {
26
+ cToken: string;
27
+ symbol: string;
28
+ decimals: number;
29
+ rate: string;
30
+ };
31
+ "0x1985365e9f78359a9B6AD760e32412f4a445E862": {
32
+ cToken: string;
33
+ symbol: string;
34
+ decimals: number;
35
+ rate: string;
36
+ };
37
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
38
+ cToken: string;
39
+ symbol: string;
40
+ decimals: number;
41
+ rate: string;
42
+ };
43
+ "0xdAC17F958D2ee523a2206206994597C13D831ec7": {
44
+ cToken: string;
45
+ symbol: string;
46
+ decimals: number;
47
+ rate: string;
48
+ };
49
+ "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
50
+ cToken: string;
51
+ symbol: string;
52
+ decimals: number;
53
+ rate: string;
54
+ };
55
+ "0xc00e94Cb662C3520282E6f5717214004A7f26888": {
56
+ cToken: string;
57
+ symbol: string;
58
+ decimals: number;
59
+ rate: string;
60
+ };
61
+ "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": {
62
+ cToken: string;
63
+ symbol: string;
64
+ decimals: number;
65
+ rate: string;
66
+ };
67
+ };
68
+ export default _default;
@@ -1,69 +1,69 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
5
- cToken: "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5",
6
- symbol: "WETH",
7
- rate: "200377690135395607208362598",
8
- },
9
- "0x6B175474E89094C44Da98b954EedeAC495271d0F": {
10
- cToken: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
11
- symbol: "DAI",
12
- decimals: 18,
13
- rate: "212176850022160122160642922",
14
- },
15
- "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359": {
16
- cToken: "0xF5DCe57282A584D2746FaF1593d3121Fcac444dC",
17
- symbol: "SAI",
18
- decimals: 18,
19
- rate: "214497546666952197312205662",
20
- },
21
- "0x0D8775F648430679A709E98d2b0Cb6250d2887EF": {
22
- cToken: "0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E",
23
- symbol: "BAT",
24
- decimals: 18,
25
- rate: "205532215868122759704768656",
26
- },
27
- "0xE41d2489571d322189246DaFA5ebDe1F4699F498": {
28
- cToken: "0xB3319f5D18Bc0D84dD1b4825Dcde5d5f7266d407",
29
- symbol: "ZRX",
30
- decimals: 18,
31
- rate: "204349036883537619880706814",
32
- },
33
- "0x1985365e9f78359a9B6AD760e32412f4a445E862": {
34
- cToken: "0x158079Ee67Fce2f58472A96584A73C7Ab9AC95c1",
35
- symbol: "REP",
36
- decimals: 18,
37
- rate: "200406592366310639162442485",
38
- },
39
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
40
- cToken: "0x39AA39c021dfbaE8faC545936693aC917d5E7563",
41
- symbol: "USDC",
42
- decimals: 6,
43
- rate: "217402430918649",
44
- },
45
- "0xdAC17F958D2ee523a2206206994597C13D831ec7": {
46
- cToken: "0xf650C3d88D12dB855b8bf7D11Be6C55A4e07dCC9",
47
- symbol: "USDT",
48
- decimals: 6,
49
- rate: "209119328756589",
50
- },
51
- "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
52
- cToken: "0xC11b1268C1A384e55C48c2391d8d480264A3A7F4",
53
- symbol: "WBTC",
54
- decimals: 8,
55
- rate: "20203489110711171",
56
- },
57
- "0xc00e94Cb662C3520282E6f5717214004A7f26888": {
58
- cToken: "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
59
- symbol: "COMP",
60
- decimals: 18,
61
- rate: "202419276787404650738565343",
62
- },
63
- "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": {
64
- cToken: "0x35a18000230da775cac24873d00ff85bccded550",
65
- symbol: "UNI",
66
- decimals: 18,
67
- rate: "201939636954953140035470410",
68
- },
69
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
5
+ cToken: "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5",
6
+ symbol: "WETH",
7
+ rate: "200377690135395607208362598",
8
+ },
9
+ "0x6B175474E89094C44Da98b954EedeAC495271d0F": {
10
+ cToken: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
11
+ symbol: "DAI",
12
+ decimals: 18,
13
+ rate: "212176850022160122160642922",
14
+ },
15
+ "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359": {
16
+ cToken: "0xF5DCe57282A584D2746FaF1593d3121Fcac444dC",
17
+ symbol: "SAI",
18
+ decimals: 18,
19
+ rate: "214497546666952197312205662",
20
+ },
21
+ "0x0D8775F648430679A709E98d2b0Cb6250d2887EF": {
22
+ cToken: "0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E",
23
+ symbol: "BAT",
24
+ decimals: 18,
25
+ rate: "205532215868122759704768656",
26
+ },
27
+ "0xE41d2489571d322189246DaFA5ebDe1F4699F498": {
28
+ cToken: "0xB3319f5D18Bc0D84dD1b4825Dcde5d5f7266d407",
29
+ symbol: "ZRX",
30
+ decimals: 18,
31
+ rate: "204349036883537619880706814",
32
+ },
33
+ "0x1985365e9f78359a9B6AD760e32412f4a445E862": {
34
+ cToken: "0x158079Ee67Fce2f58472A96584A73C7Ab9AC95c1",
35
+ symbol: "REP",
36
+ decimals: 18,
37
+ rate: "200406592366310639162442485",
38
+ },
39
+ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
40
+ cToken: "0x39AA39c021dfbaE8faC545936693aC917d5E7563",
41
+ symbol: "USDC",
42
+ decimals: 6,
43
+ rate: "217402430918649",
44
+ },
45
+ "0xdAC17F958D2ee523a2206206994597C13D831ec7": {
46
+ cToken: "0xf650C3d88D12dB855b8bf7D11Be6C55A4e07dCC9",
47
+ symbol: "USDT",
48
+ decimals: 6,
49
+ rate: "209119328756589",
50
+ },
51
+ "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599": {
52
+ cToken: "0xC11b1268C1A384e55C48c2391d8d480264A3A7F4",
53
+ symbol: "WBTC",
54
+ decimals: 8,
55
+ rate: "20203489110711171",
56
+ },
57
+ "0xc00e94Cb662C3520282E6f5717214004A7f26888": {
58
+ cToken: "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
59
+ symbol: "COMP",
60
+ decimals: 18,
61
+ rate: "202419276787404650738565343",
62
+ },
63
+ "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": {
64
+ cToken: "0x35a18000230da775cac24873d00ff85bccded550",
65
+ symbol: "UNI",
66
+ decimals: 18,
67
+ rate: "201939636954953140035470410",
68
+ },
69
+ };
@@ -1,29 +1,29 @@
1
- import { Address } from "../types";
2
- declare function getCompoundAssets(params: {
3
- targets: Address[];
4
- block?: number;
5
- }): Promise<{
6
- "0x0000000000000000000000000000000000000000": string;
7
- }>;
8
- declare function getAllAssetsLocked(params: {
9
- targets: Address[];
10
- block?: number;
11
- }): Promise<void>;
12
- declare function getMakerAssets(params: {
13
- targets: Address[];
14
- block?: number;
15
- }): Promise<void>;
16
- declare function getAaveAssets(params: {
17
- targets: Address[];
18
- block?: number;
19
- }): Promise<void>;
20
- declare const compound: {
21
- getAssetsLocked: typeof getCompoundAssets;
22
- };
23
- declare const aave: {
24
- getAssetsLocked: typeof getAaveAssets;
25
- };
26
- declare const maker: {
27
- getAssetsLocked: typeof getMakerAssets;
28
- };
29
- export { getAllAssetsLocked as getAssetsLocked, compound, aave, maker };
1
+ import { Address } from "../types";
2
+ declare function getCompoundAssets(params: {
3
+ targets: Address[];
4
+ block?: number;
5
+ }): Promise<{
6
+ "0x0000000000000000000000000000000000000000": string;
7
+ }>;
8
+ declare function getAllAssetsLocked(params: {
9
+ targets: Address[];
10
+ block?: number;
11
+ }): Promise<void>;
12
+ declare function getMakerAssets(params: {
13
+ targets: Address[];
14
+ block?: number;
15
+ }): Promise<void>;
16
+ declare function getAaveAssets(params: {
17
+ targets: Address[];
18
+ block?: number;
19
+ }): Promise<void>;
20
+ declare const compound: {
21
+ getAssetsLocked: typeof getCompoundAssets;
22
+ };
23
+ declare const aave: {
24
+ getAssetsLocked: typeof getAaveAssets;
25
+ };
26
+ declare const maker: {
27
+ getAssetsLocked: typeof getMakerAssets;
28
+ };
29
+ export { getAllAssetsLocked as getAssetsLocked, compound, aave, maker };
@@ -1,124 +1,124 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
- return new (P || (P = Promise))(function (resolve, reject) {
9
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
- step((generator = generator.apply(thisArg, _arguments || [])).next());
13
- });
14
- };
15
- var __generator = (this && this.__generator) || function (thisArg, body) {
16
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
18
- function verb(n) { return function (v) { return step([n, v]); }; }
19
- function step(op) {
20
- if (f) throw new TypeError("Generator is already executing.");
21
- while (_) try {
22
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
23
- if (y = 0, t) op = [op[0] & 2, t.value];
24
- switch (op[0]) {
25
- case 0: case 1: t = op; break;
26
- case 4: _.label++; return { value: op[1], done: false };
27
- case 5: _.label++; y = op[1]; op = [0]; continue;
28
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
29
- default:
30
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
31
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
32
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
33
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
34
- if (t[2]) _.ops.pop();
35
- _.trys.pop(); continue;
36
- }
37
- op = body.call(thisArg, _);
38
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
39
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
40
- }
41
- };
42
- Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.maker = exports.aave = exports.compound = exports.getAssetsLocked = void 0;
44
- var graphql_request_1 = require("graphql-request");
45
- var general_1 = require("../general");
46
- function getCompoundAssets(params) {
47
- return __awaiter(this, void 0, void 0, function () {
48
- var totalCollateralValueInEth, queries, i, addresses, query, req;
49
- var _a;
50
- return __generator(this, function (_b) {
51
- switch (_b.label) {
52
- case 0:
53
- totalCollateralValueInEth = 0;
54
- queries = [];
55
- i = 0;
56
- _b.label = 1;
57
- case 1:
58
- if (!(i < params.targets.length)) return [3 /*break*/, 4];
59
- addresses = params.targets.slice(i, i + 1000);
60
- query = graphql_request_1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n {\n accounts(where:{\n id_in:[", "]\n }) {\n id\n totalCollateralValueInEth\n tokens{\n symbol\n supplyBalanceUnderlying\n }\n }\n }\n "], ["\n {\n accounts(where:{\n id_in:[", "]\n }) {\n id\n totalCollateralValueInEth\n tokens{\n symbol\n supplyBalanceUnderlying\n }\n }\n }\n "])), addresses.map(function (addr) { return "\"" + addr.toLowerCase() + "\""; }).join(","));
61
- return [4 /*yield*/, graphql_request_1.request("https://api.thegraph.com/subgraphs/name/graphprotocol/compound-v2", query).then(function (data) {
62
- return data.accounts.forEach(function (account) {
63
- totalCollateralValueInEth += Number(account.totalCollateralValueInEth);
64
- });
65
- })];
66
- case 2:
67
- req = _b.sent();
68
- queries.push(req);
69
- _b.label = 3;
70
- case 3:
71
- i += 1000;
72
- return [3 /*break*/, 1];
73
- case 4: return [4 /*yield*/, Promise.all(queries)];
74
- case 5:
75
- _b.sent();
76
- return [2 /*return*/, (_a = {},
77
- _a[general_1.ETHER_ADDRESS] = Math.floor(totalCollateralValueInEth * Math.pow(10, 18)).toString(),
78
- _a)];
79
- }
80
- });
81
- });
82
- }
83
- function getAllAssetsLocked(params) {
84
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
85
- return [2 /*return*/];
86
- }); });
87
- }
88
- exports.getAssetsLocked = getAllAssetsLocked;
89
- function getMakerAssets(params) {
90
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
91
- return [2 /*return*/];
92
- }); });
93
- }
94
- function getAaveAssets(params) {
95
- return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
96
- return [2 /*return*/];
97
- }); });
98
- }
99
- var compound = {
100
- getAssetsLocked: getCompoundAssets,
101
- };
102
- exports.compound = compound;
103
- var aave = {
104
- getAssetsLocked: getAaveAssets,
105
- };
106
- exports.aave = aave;
107
- var maker = {
108
- getAssetsLocked: getMakerAssets,
109
- };
110
- exports.maker = maker;
111
- var templateObject_1;
112
- /*
113
- cdp: {
114
- getAssetsLocked: (options) => cdp('getAssetsLocked', { ...options, chunk: {param: 'targets', length: 1000, combine: 'balances'} }),
115
- maker: {
116
- tokens: (options) => maker('tokens', { ...options }),
117
- getAssetsLocked: (options) => maker('getAssetsLocked', { ...options, chunk: {param: 'targets', length: 3000, combine: 'balances'} })
118
- },
119
- compound: {
120
- tokens: (options) => compound('tokens', { ...options }),
121
- getAssetsLocked: (options) => compound('getAssetsLocked', { ...options, chunk: {param: 'targets', length: 1000, combine: 'balances'} })
122
- }
123
- },
124
- */
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __generator = (this && this.__generator) || function (thisArg, body) {
16
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
18
+ function verb(n) { return function (v) { return step([n, v]); }; }
19
+ function step(op) {
20
+ if (f) throw new TypeError("Generator is already executing.");
21
+ while (_) try {
22
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
23
+ if (y = 0, t) op = [op[0] & 2, t.value];
24
+ switch (op[0]) {
25
+ case 0: case 1: t = op; break;
26
+ case 4: _.label++; return { value: op[1], done: false };
27
+ case 5: _.label++; y = op[1]; op = [0]; continue;
28
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
29
+ default:
30
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
31
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
32
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
33
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
34
+ if (t[2]) _.ops.pop();
35
+ _.trys.pop(); continue;
36
+ }
37
+ op = body.call(thisArg, _);
38
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
39
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
40
+ }
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.maker = exports.aave = exports.compound = exports.getAssetsLocked = void 0;
44
+ var graphql_request_1 = require("graphql-request");
45
+ var general_1 = require("../general");
46
+ function getCompoundAssets(params) {
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ var totalCollateralValueInEth, queries, i, addresses, query, req;
49
+ var _a;
50
+ return __generator(this, function (_b) {
51
+ switch (_b.label) {
52
+ case 0:
53
+ totalCollateralValueInEth = 0;
54
+ queries = [];
55
+ i = 0;
56
+ _b.label = 1;
57
+ case 1:
58
+ if (!(i < params.targets.length)) return [3 /*break*/, 4];
59
+ addresses = params.targets.slice(i, i + 1000);
60
+ query = graphql_request_1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n {\n accounts(where:{\n id_in:[", "]\n }) {\n id\n totalCollateralValueInEth\n tokens{\n symbol\n supplyBalanceUnderlying\n }\n }\n }\n "], ["\n {\n accounts(where:{\n id_in:[", "]\n }) {\n id\n totalCollateralValueInEth\n tokens{\n symbol\n supplyBalanceUnderlying\n }\n }\n }\n "])), addresses.map(function (addr) { return "\"" + addr.toLowerCase() + "\""; }).join(","));
61
+ return [4 /*yield*/, graphql_request_1.request("https://api.thegraph.com/subgraphs/name/graphprotocol/compound-v2", query).then(function (data) {
62
+ return data.accounts.forEach(function (account) {
63
+ totalCollateralValueInEth += Number(account.totalCollateralValueInEth);
64
+ });
65
+ })];
66
+ case 2:
67
+ req = _b.sent();
68
+ queries.push(req);
69
+ _b.label = 3;
70
+ case 3:
71
+ i += 1000;
72
+ return [3 /*break*/, 1];
73
+ case 4: return [4 /*yield*/, Promise.all(queries)];
74
+ case 5:
75
+ _b.sent();
76
+ return [2 /*return*/, (_a = {},
77
+ _a[general_1.ETHER_ADDRESS] = Math.floor(totalCollateralValueInEth * Math.pow(10, 18)).toString(),
78
+ _a)];
79
+ }
80
+ });
81
+ });
82
+ }
83
+ function getAllAssetsLocked(params) {
84
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
85
+ return [2 /*return*/];
86
+ }); });
87
+ }
88
+ exports.getAssetsLocked = getAllAssetsLocked;
89
+ function getMakerAssets(params) {
90
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
91
+ return [2 /*return*/];
92
+ }); });
93
+ }
94
+ function getAaveAssets(params) {
95
+ return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
96
+ return [2 /*return*/];
97
+ }); });
98
+ }
99
+ var compound = {
100
+ getAssetsLocked: getCompoundAssets,
101
+ };
102
+ exports.compound = compound;
103
+ var aave = {
104
+ getAssetsLocked: getAaveAssets,
105
+ };
106
+ exports.aave = aave;
107
+ var maker = {
108
+ getAssetsLocked: getMakerAssets,
109
+ };
110
+ exports.maker = maker;
111
+ var templateObject_1;
112
+ /*
113
+ cdp: {
114
+ getAssetsLocked: (options) => cdp('getAssetsLocked', { ...options, chunk: {param: 'targets', length: 1000, combine: 'balances'} }),
115
+ maker: {
116
+ tokens: (options) => maker('tokens', { ...options }),
117
+ getAssetsLocked: (options) => maker('getAssetsLocked', { ...options, chunk: {param: 'targets', length: 3000, combine: 'balances'} })
118
+ },
119
+ compound: {
120
+ tokens: (options) => compound('tokens', { ...options }),
121
+ getAssetsLocked: (options) => compound('getAssetsLocked', { ...options, chunk: {param: 'targets', length: 1000, combine: 'balances'} })
122
+ }
123
+ },
124
+ */
@@ -1 +1 @@
1
- export {};
1
+ export {};