@defillama/sdk 2.3.126 → 3.0.2

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,56 +1,53 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
4
21
  };
5
22
  Object.defineProperty(exports, "__esModule", { value: true });
6
23
  var bignumber_1 = require("@ethersproject/bignumber");
7
- var lodash_1 = __importDefault(require("lodash"));
8
- function stringifyBigNumbers(result, final) {
24
+ function isNumberOrBigNumber(value) {
25
+ return bignumber_1.BigNumber.isBigNumber(value) || typeof value === "number";
26
+ }
27
+ function stringifyBigNumbers(result) {
28
+ var final = __assign({}, result);
29
+ if (Array.isArray(result))
30
+ final = __spreadArray([], result, true);
9
31
  Object.keys(result).forEach(function (key) {
10
- try {
11
- final[key] = lodash_1.default.cloneDeep(result[key]);
12
- if (bignumber_1.BigNumber.isBigNumber(result[key]) ||
13
- typeof result[key] === "number") {
14
- final[key] = result[key].toString();
15
- }
16
- if (typeof final[key] === "object") {
17
- stringifyBigNumbers(result[key], final[key]);
18
- }
19
- }
20
- catch (e) {
21
- console.log(e);
22
- }
32
+ if (isNumberOrBigNumber(result[key]))
33
+ final[key] = result[key].toString();
34
+ else if (typeof result[key] === "object")
35
+ final[key] = stringifyBigNumbers(result[key]);
36
+ else
37
+ final[key] = result[key];
23
38
  });
24
- }
25
- function containsNamedResults(obj) {
26
- return Object.keys(obj).some(function (key) { return isNaN(Number(key)); }); // Are there any non-numeric keys?
39
+ return final;
27
40
  }
28
41
  function default_1(results) {
29
- if (typeof results === "string" || typeof results === "boolean") {
42
+ var response;
43
+ if (typeof results === "string" || typeof results === "boolean")
30
44
  return results;
31
- }
32
- var convertedResults = {};
33
- if (results instanceof Array && !containsNamedResults(results)) {
34
- // Match every idiosynchrasy of the SDK
35
- convertedResults = [];
36
- }
37
- if (bignumber_1.BigNumber.isBigNumber(results) || typeof results === "number") {
38
- convertedResults = results.toString();
39
- }
40
- else {
41
- stringifyBigNumbers(results, convertedResults);
42
- }
43
- if (results instanceof Array) {
44
- if (results.length === 1) {
45
- return convertedResults[0];
46
- }
47
- else {
48
- // Some calls return the extra __length__ parameter (I think when some results are named)
49
- if (containsNamedResults(convertedResults)) {
50
- convertedResults["__length__"] = results.length;
51
- }
52
- }
53
- }
54
- return convertedResults;
45
+ if (isNumberOrBigNumber(results))
46
+ return results.toString();
47
+ response = stringifyBigNumbers(results);
48
+ if (response instanceof Array)
49
+ if (response.length === 1)
50
+ return response[0];
51
+ return response;
55
52
  }
56
53
  exports.default = default_1;
@@ -1,6 +1,6 @@
1
1
  import { Address } from "../types";
2
2
  import { Chain } from "../general";
3
- declare type CallParams = string | number | (string | number)[] | undefined;
3
+ type CallParams = string | number | (string | number)[] | undefined;
4
4
  export declare function call(params: {
5
5
  target: Address;
6
6
  abi: string | any;
@@ -13,7 +13,7 @@ export declare function call(params: {
13
13
  export declare function multiCall(params: {
14
14
  abi: string | any;
15
15
  calls: {
16
- target: Address;
16
+ target?: Address;
17
17
  params?: CallParams;
18
18
  }[];
19
19
  block?: number;
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  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;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -57,6 +57,7 @@ var general_1 = require("../general");
57
57
  var multicall_1 = __importDefault(require("./multicall"));
58
58
  var convertResults_1 = __importDefault(require("./convertResults"));
59
59
  var promise_pool_1 = require("@supercharge/promise-pool");
60
+ var debugLog_1 = require("../util/debugLog");
60
61
  function resolveABI(providedAbi) {
61
62
  var abi = providedAbi;
62
63
  if (typeof abi === "string") {
@@ -91,7 +92,7 @@ function call(params) {
91
92
  contractInterface = new ethers_1.ethers.utils.Interface([abi]);
92
93
  functionABI = ethers_1.ethers.utils.FunctionFragment.from(abi);
93
94
  callData = contractInterface.encodeFunctionData(functionABI, callParams);
94
- return [4 /*yield*/, general_1.getProvider(params.chain).call({
95
+ return [4 /*yield*/, (0, general_1.getProvider)(params.chain).call({
95
96
  to: params.target,
96
97
  data: callData,
97
98
  }, (_a = params.block) !== null && _a !== void 0 ? _a : "latest")];
@@ -99,7 +100,7 @@ function call(params) {
99
100
  result = _b.sent();
100
101
  decodedResult = contractInterface.decodeFunctionResult(functionABI, result);
101
102
  return [2 /*return*/, {
102
- output: convertResults_1.default(decodedResult),
103
+ output: (0, convertResults_1.default)(decodedResult),
103
104
  }];
104
105
  }
105
106
  });
@@ -107,14 +108,22 @@ function call(params) {
107
108
  }
108
109
  exports.call = call;
109
110
  function multiCall(params) {
111
+ var _a;
110
112
  return __awaiter(this, void 0, void 0, function () {
111
- var abi, contractCalls, chunkSize, contractChunks, i, _a, results, errors, flatResults, failedQueries, failed, newResults_1;
113
+ var abi, contractCalls, chunkSize, contractChunks, i, _b, results, errors, flatResults, failedQueries, failed, newResults_1;
112
114
  var _this = this;
113
- return __generator(this, function (_b) {
114
- switch (_b.label) {
115
+ return __generator(this, function (_c) {
116
+ switch (_c.label) {
115
117
  case 0:
118
+ if (!params.calls)
119
+ throw new Error('Missing calls parameter');
120
+ if (params.target && !params.target.startsWith('0x'))
121
+ throw new Error('Invalid target: ' + params.target);
122
+ if (!params.calls.length) {
123
+ return [2 /*return*/, { output: [] }];
124
+ }
116
125
  abi = resolveABI(params.abi);
117
- contractCalls = params.calls.map(function (call, index) {
126
+ contractCalls = (params.calls).map(function (call) {
118
127
  var _a;
119
128
  var callParams = normalizeParams(call.params);
120
129
  return {
@@ -132,11 +141,11 @@ function multiCall(params) {
132
141
  .process(function (calls, i) { return __awaiter(_this, void 0, void 0, function () {
133
142
  var _a;
134
143
  return __generator(this, function (_b) {
135
- return [2 /*return*/, multicall_1.default(abi, calls, (_a = params.chain) !== null && _a !== void 0 ? _a : "ethereum", params.block).then(function (calls) { return [calls, i]; })];
144
+ return [2 /*return*/, (0, multicall_1.default)(abi, calls, (_a = params.chain) !== null && _a !== void 0 ? _a : "ethereum", params.block).then(function (calls) { return [calls, i]; })];
136
145
  });
137
146
  }); })];
138
147
  case 1:
139
- _a = _b.sent(), results = _a.results, errors = _a.errors;
148
+ _b = _c.sent(), results = _b.results, errors = _b.errors;
140
149
  if (errors.length)
141
150
  throw errors[0];
142
151
  flatResults = [].concat.apply([], results
@@ -149,9 +158,8 @@ function multiCall(params) {
149
158
  return c;
150
159
  }));
151
160
  failedQueries = flatResults.filter(function (r) { return !r.success; });
152
- if (failedQueries.length && (process.env.SDK_DEBUG === "true" || process.env.LLAMA_DEBUG_MODE)) {
153
- console.log("Failed multicalls:", failedQueries.map(function (r) { return r.input; }));
154
- }
161
+ if (failedQueries.length)
162
+ (0, debugLog_1.debugLog)("[chain: ".concat((_a = params.chain) !== null && _a !== void 0 ? _a : "ethereum", "] Failed multicalls:"), failedQueries.map(function (r) { return r.input; }));
155
163
  if (!(params.requery === true && flatResults.some(function (r) { return !r.success; }))) return [3 /*break*/, 3];
156
164
  failed = flatResults.map(function (r, i) { return [r, i]; }).filter(function (r) { return !r[0].success; });
157
165
  return [4 /*yield*/, multiCall({
@@ -165,11 +173,11 @@ function multiCall(params) {
165
173
  return output;
166
174
  })];
167
175
  case 2:
168
- newResults_1 = _b.sent();
176
+ newResults_1 = _c.sent();
169
177
  failed.forEach(function (f, i) {
170
178
  flatResults[f[1]] = newResults_1[i];
171
179
  });
172
- _b.label = 3;
180
+ _c.label = 3;
173
181
  case 3: return [2 /*return*/, {
174
182
  output: flatResults, // flatten array
175
183
  }];
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -82,7 +82,7 @@ function makeMultiCall(functionABI, calls, chain, block) {
82
82
  return [2 /*return*/, returnValues.map(function (values, index) {
83
83
  var output;
84
84
  try {
85
- output = convertResults_1.default(contractInterface.decodeFunctionResult(fd, values));
85
+ output = (0, convertResults_1.default)(contractInterface.decodeFunctionResult(fd, values));
86
86
  }
87
87
  catch (e) {
88
88
  output = null;
@@ -131,7 +131,7 @@ function executeCalls(contractCalls, chain, block) {
131
131
  to: address,
132
132
  data: callData,
133
133
  };
134
- return [4 /*yield*/, rpcCall_1.call(general_1.getProvider(chain), tx, block !== null && block !== void 0 ? block : "latest", chain)];
134
+ return [4 /*yield*/, (0, rpcCall_1.call)((0, general_1.getProvider)(chain), tx, block !== null && block !== void 0 ? block : "latest", chain)];
135
135
  case 4:
136
136
  returnData = _b.sent();
137
137
  _a = ethers_1.ethers.utils.defaultAbiCoder.decode(["uint256", "bytes[]"], returnData), blockNumber = _a[0], returnValues = _a[1];
@@ -150,7 +150,7 @@ function executeCalls(contractCalls, chain, block) {
150
150
  switch (_b.label) {
151
151
  case 0:
152
152
  _b.trys.push([0, 2, , 3]);
153
- return [4 /*yield*/, rpcCall_1.call(general_1.getProvider(chain), { to: to, data: data }, block !== null && block !== void 0 ? block : "latest", chain)];
153
+ return [4 /*yield*/, (0, rpcCall_1.call)((0, general_1.getProvider)(chain), { to: to, data: data }, block !== null && block !== void 0 ? block : "latest", chain)];
154
154
  case 1: return [2 /*return*/, _b.sent()];
155
155
  case 2:
156
156
  e_2 = _b.sent();
@@ -172,12 +172,12 @@ function multicallAddressOrThrow(chain) {
172
172
  var network, address, msg;
173
173
  return __generator(this, function (_a) {
174
174
  switch (_a.label) {
175
- case 0: return [4 /*yield*/, general_1.getProvider(chain).getNetwork()];
175
+ case 0: return [4 /*yield*/, (0, general_1.getProvider)(chain).getNetwork()];
176
176
  case 1:
177
177
  network = _a.sent();
178
178
  address = multicallAddress(network.chainId);
179
179
  if (address === null) {
180
- msg = "multicall is not available on the network " + network.chainId;
180
+ msg = "multicall is not available on the network ".concat(network.chainId);
181
181
  console.error(msg);
182
182
  throw new Error(msg);
183
183
  }
@@ -191,7 +191,7 @@ function networkSupportsMulticall(chain) {
191
191
  var network, address;
192
192
  return __generator(this, function (_a) {
193
193
  switch (_a.label) {
194
- case 0: return [4 /*yield*/, general_1.getProvider(chain).network];
194
+ case 0: return [4 /*yield*/, (0, general_1.getProvider)(chain).network];
195
195
  case 1:
196
196
  network = _a.sent();
197
197
  address = multicallAddress(network.chainId);
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -38,7 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.call = void 0;
40
40
  var events_1 = require("events");
41
- var DEBUG_MODE_ENABLED = !!process.env.LLAMA_DEBUG_MODE;
41
+ var debugLog_1 = require("../util/debugLog");
42
42
  var maxParallelCalls = !!process.env.LLAMA_SDK_MAX_PARALLEL ? +process.env.LLAMA_SDK_MAX_PARALLEL : 100;
43
43
  var COUNTERS = {};
44
44
  var emitter = new events_1.EventEmitter();
@@ -61,20 +61,20 @@ function call(provider, data, block, chain) {
61
61
  chain = 'noChain';
62
62
  counter = getChainCounter(chain);
63
63
  currentId = counter.requestCount++;
64
- eventId = chain + "-" + currentId;
64
+ eventId = "".concat(chain, "-").concat(currentId);
65
65
  if (!(counter.activeWorkers > maxParallelCalls)) return [3 /*break*/, 2];
66
66
  counter.queue.push(eventId);
67
- return [4 /*yield*/, events_1.once(emitter, eventId)];
67
+ return [4 /*yield*/, (0, events_1.once)(emitter, eventId)];
68
68
  case 1:
69
69
  _a.sent();
70
70
  _a.label = 2;
71
71
  case 2:
72
72
  counter.activeWorkers++;
73
- if (DEBUG_MODE_ENABLED) {
73
+ if (debugLog_1.DEBUG_ENABLED) {
74
74
  showEveryX = counter.queue.length > 100 ? 50 : 10 // show log fewer times if lot more are queued up
75
75
  ;
76
76
  if (currentId % showEveryX === 0)
77
- console.log("chain: " + chain + " request #: " + currentId + " queue: " + counter.queue.length + " active requests: " + counter.activeWorkers);
77
+ console.log("chain: ".concat(chain, " request #: ").concat(currentId, " queue: ").concat(counter.queue.length, " active requests: ").concat(counter.activeWorkers));
78
78
  }
79
79
  _a.label = 3;
80
80
  case 3:
@@ -0,0 +1,25 @@
1
+ import { Address } from "./types";
2
+ import { Chain } from "./general";
3
+ type CallParams = string | number | (string | number)[] | undefined;
4
+ type CallsParams = {
5
+ target?: Address;
6
+ params?: CallParams;
7
+ };
8
+ export declare function call(params: {
9
+ target: Address;
10
+ abi: string | any;
11
+ block?: number;
12
+ params?: CallParams;
13
+ chain?: Chain;
14
+ withMetadata?: boolean;
15
+ }): Promise<any>;
16
+ export declare function multiCall(params: {
17
+ abi: string | any;
18
+ calls: CallsParams[] | (string | number)[];
19
+ block?: number;
20
+ target?: Address;
21
+ chain?: Chain;
22
+ requery?: boolean;
23
+ withMetadata?: boolean;
24
+ }): Promise<any[]>;
25
+ export {};
@@ -1,8 +1,11 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
6
9
  }) : (function(o, m, k, k2) {
7
10
  if (k2 === undefined) k2 = k;
8
11
  o[k2] = m[k];
@@ -34,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
37
  function verb(n) { return function (v) { return step([n, v]); }; }
35
38
  function step(op) {
36
39
  if (f) throw new TypeError("Generator is already executing.");
37
- while (_) try {
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
38
41
  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
42
  if (y = 0, t) op = [op[0] & 2, t.value];
40
43
  switch (op[0]) {
@@ -55,41 +58,53 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
55
58
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
56
59
  }
57
60
  };
58
- var __importDefault = (this && this.__importDefault) || function (mod) {
59
- return (mod && mod.__esModule) ? mod : { "default": mod };
60
- };
61
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);
62
+ exports.multiCall = exports.call = void 0;
63
+ var abi1 = __importStar(require("./abi"));
64
+ function call(params) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var response;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0: return [4 /*yield*/, abi1.call(params)];
70
+ case 1:
71
+ response = _a.sent();
72
+ if (!params.withMetadata)
73
+ return [2 /*return*/, response];
74
+ return [2 /*return*/, response.output];
75
+ }
76
+ });
77
+ });
69
78
  }
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
- }
79
+ exports.call = call;
80
+ function multiCall(params) {
81
+ return __awaiter(this, void 0, void 0, function () {
82
+ var output;
83
+ return __generator(this, function (_a) {
84
+ switch (_a.label) {
85
+ case 0:
86
+ params.calls = params.calls.map(function (i) {
87
+ if (typeof i === 'object')
88
+ return i;
89
+ if (typeof i === 'string') {
90
+ if (params.target)
91
+ return { params: i };
92
+ return { target: i };
93
+ }
94
+ return { params: i };
95
+ });
96
+ if (!params.target) {
97
+ if (params.calls.some(function (i) { return !i.target; }))
98
+ throw new Error('Missing target parameter');
99
+ }
100
+ return [4 /*yield*/, abi1.multiCall(params)];
101
+ case 1:
102
+ output = (_a.sent()).output;
103
+ if (!params.withMetadata)
104
+ return [2 /*return*/, output];
105
+ return [2 /*return*/, output.map(function (i) { return i.output; })];
106
+ }
107
+ });
94
108
  });
95
- }); })();
109
+ }
110
+ exports.multiCall = multiCall;
package/build/api.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export * as util from "./util";
2
2
  export * as eth from "./eth";
3
3
  export * as erc20 from "./erc20";
4
- export * as cdp from "./cdp";
5
4
  export * as abi from "./abi";
6
- import { setProvider } from "./general";
5
+ import { setProvider, getProvider } from "./general";
7
6
  declare const config: {
8
7
  setProvider: typeof setProvider;
8
+ getProvider: typeof getProvider;
9
9
  };
10
10
  export { config };
package/build/api.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -19,14 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
23
  return result;
20
24
  };
21
25
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.config = exports.abi = exports.cdp = exports.erc20 = exports.eth = exports.util = void 0;
26
+ exports.config = exports.abi = exports.erc20 = exports.eth = exports.util = void 0;
23
27
  exports.util = __importStar(require("./util"));
24
28
  exports.eth = __importStar(require("./eth"));
25
29
  exports.erc20 = __importStar(require("./erc20"));
26
- exports.cdp = __importStar(require("./cdp"));
27
30
  exports.abi = __importStar(require("./abi"));
28
31
  var general_1 = require("./general");
29
32
  var config = {
30
33
  setProvider: general_1.setProvider,
34
+ getProvider: general_1.getProvider,
31
35
  };
32
36
  exports.config = config;
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -127,7 +127,7 @@ function getBlock(chain, timestamp) {
127
127
  return __generator(this, function (_a) {
128
128
  switch (_a.label) {
129
129
  case 0:
130
- provider = general_1.getProvider("ethereum");
130
+ provider = (0, general_1.getProvider)("ethereum");
131
131
  return [4 /*yield*/, provider.getBlockNumber()];
132
132
  case 1:
133
133
  lastBlockNumber = _a.sent();
@@ -149,7 +149,7 @@ function getBlock(chain, timestamp) {
149
149
  _a.label = 2;
150
150
  case 2:
151
151
  _a.trys.push([2, 4, , 5]);
152
- return [4 /*yield*/, index_1.lookupBlock(timestamp, { chain: chain, })];
152
+ return [4 /*yield*/, (0, index_1.lookupBlock)(timestamp, { chain: chain, })];
153
153
  case 3:
154
154
  block = _a.sent();
155
155
  return [2 /*return*/, block];
@@ -10,7 +10,7 @@ function humanizeNumber(amount) {
10
10
  for (var _i = 0, quantifiers_1 = quantifiers; _i < quantifiers_1.length; _i++) {
11
11
  var _a = quantifiers_1[_i], denominator = _a[0], letter = _a[1];
12
12
  if (amount > denominator) {
13
- return (amount / denominator).toFixed(2) + " " + letter;
13
+ return "".concat((amount / denominator).toFixed(2), " ").concat(letter);
14
14
  }
15
15
  }
16
16
  return amount.toString();
@@ -3,7 +3,7 @@ export interface TokenPrices {
3
3
  usd: number;
4
4
  } | undefined;
5
5
  }
6
- export declare type GetCoingeckoLog = () => Promise<any>;
6
+ export type GetCoingeckoLog = () => Promise<any>;
7
7
  export declare function makeCoingeckoCall(url: string, coingeckoMaxRetries: number, getCoingeckoLock: GetCoingeckoLog): Promise<any>;
8
8
  export declare function getTokenPrices(originalIds: string[], url: string, knownTokenPrices: TokenPrices, getCoingeckoLock: GetCoingeckoLog, coingeckoMaxRetries: number, prefix?: string): Promise<TokenPrices>;
9
9
  export declare function getHistoricalTokenPrices(ids: string[], url: string, timestamp: number, getCoingeckoLock: GetCoingeckoLog, coingeckoMaxRetries: number): Promise<TokenPrices>;
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.getHistoricalTokenPrices = exports.getTokenPrices = exports.makeCoingeckoCall = void 0;
43
43
  var node_fetch_1 = __importDefault(require("node-fetch"));
44
44
  function fetchJson(url) {
45
- return node_fetch_1.default(url).then(function (res) { return res.json(); });
45
+ return (0, node_fetch_1.default)(url).then(function (res) { return res.json(); });
46
46
  }
47
47
  function makeCoingeckoCall(url, coingeckoMaxRetries, getCoingeckoLock) {
48
48
  return __awaiter(this, void 0, void 0, function () {
@@ -100,9 +100,9 @@ function getTokenPrices(originalIds, url, knownTokenPrices, getCoingeckoLock, co
100
100
  _a.label = 1;
101
101
  case 1:
102
102
  if (!(i < newIds.length)) return [3 /*break*/, 4];
103
- return [4 /*yield*/, makeCoingeckoCall("https://api.coingecko.com/api/" + url + "=" + newIds
103
+ return [4 /*yield*/, makeCoingeckoCall("https://api.coingecko.com/api/".concat(url, "=").concat(newIds
104
104
  .slice(i, i + 100)
105
- .join(",") + "&vs_currencies=usd", coingeckoMaxRetries, getCoingeckoLock)];
105
+ .join(","), "&vs_currencies=usd"), coingeckoMaxRetries, getCoingeckoLock)];
106
106
  case 2:
107
107
  tempTokenPrices = _a.sent();
108
108
  Object.assign(tokenPrices, tempTokenPrices);
@@ -133,7 +133,7 @@ function getHistoricalTokenPrices(ids, url, timestamp, getCoingeckoLock, coingec
133
133
  case 1:
134
134
  if (!(_i < ids_1.length)) return [3 /*break*/, 4];
135
135
  id = ids_1[_i];
136
- return [4 /*yield*/, makeCoingeckoCall(url + "/" + id.toLowerCase() + "/market_chart/range?vs_currency=usd&from=" + (timestamp - secondsPerHalfDay) + "&to=" + (timestamp + secondsPerHalfDay), coingeckoMaxRetries, getCoingeckoLock)];
136
+ return [4 /*yield*/, makeCoingeckoCall("".concat(url, "/").concat(id.toLowerCase(), "/market_chart/range?vs_currency=usd&from=").concat(timestamp - secondsPerHalfDay, "&to=").concat(timestamp + secondsPerHalfDay), coingeckoMaxRetries, getCoingeckoLock)];
137
137
  case 2:
138
138
  range = _d.sent();
139
139
  if (range.error === undefined && ((_a = range.prices) === null || _a === void 0 ? void 0 : _a.length) > 0) {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -46,7 +46,7 @@ var abi = [
46
46
  "function symbol() view returns (string)",
47
47
  ];
48
48
  function getContract(address, chain) {
49
- return new ethers_1.ethers.Contract(address, abi, general_1.getProvider(chain));
49
+ return new ethers_1.ethers.Contract(address, abi, (0, general_1.getProvider)(chain));
50
50
  }
51
51
  function info(tokenAddress, chain) {
52
52
  return __awaiter(this, void 0, void 0, function () {
@@ -116,7 +116,7 @@ function totalSupply(params) {
116
116
  case 1:
117
117
  supply = _b.sent();
118
118
  return [2 /*return*/, {
119
- output: general_1.handleDecimals(supply, params.decimals),
119
+ output: (0, general_1.handleDecimals)(supply, params.decimals),
120
120
  }];
121
121
  }
122
122
  });
@@ -135,7 +135,7 @@ function balanceOf(params) {
135
135
  case 1:
136
136
  balance = _b.sent();
137
137
  return [2 /*return*/, {
138
- output: general_1.handleDecimals(balance, params.decimals),
138
+ output: (0, general_1.handleDecimals)(balance, params.decimals),
139
139
  }];
140
140
  }
141
141
  });