@defillama/sdk 2.3.126 → 3.0.1

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.
@@ -1,29 +0,0 @@
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 +0,0 @@
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
- */
package/build/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/build/cli.js DELETED
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6
- }) : (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- o[k2] = m[k];
9
- }));
10
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
11
- Object.defineProperty(o, "default", { enumerable: true, value: v });
12
- }) : function(o, v) {
13
- o["default"] = v;
14
- });
15
- var __importStar = (this && this.__importStar) || function (mod) {
16
- if (mod && mod.__esModule) return mod;
17
- var result = {};
18
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
19
- __setModuleDefault(result, mod);
20
- return result;
21
- };
22
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
23
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24
- return new (P || (P = Promise))(function (resolve, reject) {
25
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
26
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
27
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
28
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29
- });
30
- };
31
- var __generator = (this && this.__generator) || function (thisArg, body) {
32
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
33
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
34
- function verb(n) { return function (v) { return step([n, v]); }; }
35
- function step(op) {
36
- if (f) throw new TypeError("Generator is already executing.");
37
- while (_) try {
38
- 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;
39
- if (y = 0, t) op = [op[0] & 2, t.value];
40
- switch (op[0]) {
41
- case 0: case 1: t = op; break;
42
- case 4: _.label++; return { value: op[1], done: false };
43
- case 5: _.label++; y = op[1]; op = [0]; continue;
44
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
45
- default:
46
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
47
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
48
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
49
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
50
- if (t[2]) _.ops.pop();
51
- _.trys.pop(); continue;
52
- }
53
- op = body.call(thisArg, _);
54
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
55
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
56
- }
57
- };
58
- var __importDefault = (this && this.__importDefault) || function (mod) {
59
- return (mod && mod.__esModule) ? mod : { "default": mod };
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- var path_1 = __importDefault(require("path"));
63
- var computeTVL_1 = __importDefault(require("./computeTVL"));
64
- var blocks_1 = require("./computeTVL/blocks");
65
- var humanizeNumber_1 = require("./computeTVL/humanizeNumber");
66
- if (process.argv.length < 3) {
67
- console.error("Missing argument, you need to provide the filename of the adapter to test.\n Eg: npx @defillama/sdk projects/myadapter.js");
68
- process.exit(1);
69
- }
70
- var passedFile = path_1.default.resolve(process.cwd(), process.argv[2]);
71
- (function () { return __awaiter(void 0, void 0, void 0, function () {
72
- var moduleToTest, _a, timestamp, ethereumBlock, chainBlocks, tvl, usdTvl;
73
- return __generator(this, function (_b) {
74
- switch (_b.label) {
75
- case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require(passedFile)); })];
76
- case 1:
77
- moduleToTest = _b.sent();
78
- return [4 /*yield*/, blocks_1.getCurrentBlocks()];
79
- case 2:
80
- _a = _b.sent(), timestamp = _a.timestamp, ethereumBlock = _a.ethereumBlock, chainBlocks = _a.chainBlocks;
81
- return [4 /*yield*/, moduleToTest.tvl(timestamp, ethereumBlock, chainBlocks)];
82
- case 3:
83
- tvl = _b.sent();
84
- if (typeof tvl !== "object") {
85
- throw new Error("TVL returned is not a balances object");
86
- }
87
- return [4 /*yield*/, computeTVL_1.default(tvl, "now", true)];
88
- case 4:
89
- usdTvl = (_b.sent()).usdTvl;
90
- console.log("Total:", humanizeNumber_1.humanizeNumber(usdTvl));
91
- process.exit(0);
92
- return [2 /*return*/];
93
- }
94
- });
95
- }); })();
@@ -1,59 +0,0 @@
1
- import { StringNumber } from "../types";
2
- import { TokenPrices, GetCoingeckoLog } from "./prices";
3
- declare type Balances = {
4
- [tokenAddressOrName: string]: StringNumber | Object;
5
- };
6
- declare type ReturnedTokenBalances = {
7
- [tokenSymbolOrName: string]: number;
8
- };
9
- export declare const chainToCoingeckoId: {
10
- bsc: string;
11
- ethereum: string;
12
- polygon: string;
13
- avax: string;
14
- fantom: string;
15
- xdai: string;
16
- heco: string;
17
- okexchain: string;
18
- harmony: string;
19
- kcc: string;
20
- celo: string;
21
- arbitrum: string;
22
- iotex: string;
23
- moonriver: string;
24
- solana: string;
25
- terra: string;
26
- tron: string;
27
- waves: string;
28
- klaytn: string;
29
- osmosis: string;
30
- kava: string;
31
- icon: string;
32
- optimism: string;
33
- eos: string;
34
- secret: string;
35
- rsk: string;
36
- neo: string;
37
- tezos: string;
38
- wan: string;
39
- ontology: string;
40
- algorand: string;
41
- zilliqa: string;
42
- kardia: string;
43
- cronos: string;
44
- aurora: string;
45
- boba: string;
46
- metis: string;
47
- telos: string;
48
- moonbeam: string;
49
- meter: string;
50
- sx: string;
51
- velas: string;
52
- milkomeda: string;
53
- };
54
- export default function (rawBalances: Balances, timestamp: number | "now", verbose?: boolean, knownTokenPrices?: TokenPrices, getCoingeckoLock?: GetCoingeckoLog, coingeckoMaxRetries?: number): Promise<{
55
- usdTvl: number;
56
- usdTokenBalances: ReturnedTokenBalances;
57
- tokenBalances: ReturnedTokenBalances;
58
- }>;
59
- export {};