@defillama/sdk 5.0.170 → 5.0.173
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/build/Balances.d.ts +51 -1
- package/build/Balances.js +26 -2
- package/build/ChainApi.d.ts +11 -0
- package/build/abi/multicall3.js +8 -1
- package/build/providers.json +1 -1
- package/build/util/blocks.js +2 -1
- package/build/util/cache.js +1 -1
- package/build/util/computeTVL.d.ts +14 -1
- package/build/util/computeTVL.js +7 -2
- package/build/util/graph.js +2 -2
- package/build/util/updateProviderList.js +2 -0
- package/package.json +1 -1
package/build/Balances.d.ts
CHANGED
|
@@ -31,13 +31,52 @@ export declare class Balances {
|
|
|
31
31
|
removeTokenBalance(token: string): void;
|
|
32
32
|
getUSDValue(): Promise<number>;
|
|
33
33
|
getUSDString(): Promise<string>;
|
|
34
|
-
getUSDJSONs(
|
|
34
|
+
getUSDJSONs({ debug, debugOptions: { printTokenTable, minTokenUSDValue } }?: {
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
debugOptions?: {
|
|
37
|
+
printTokenTable?: boolean;
|
|
38
|
+
minTokenUSDValue?: number;
|
|
39
|
+
};
|
|
40
|
+
}): Promise<{
|
|
35
41
|
usdTvl: number;
|
|
36
42
|
usdTokenBalances: BalancesV1;
|
|
37
43
|
rawTokenBalances: BalancesV1;
|
|
38
44
|
labelBreakdown?: {
|
|
39
45
|
[key: string]: number;
|
|
40
46
|
};
|
|
47
|
+
debugData?: {
|
|
48
|
+
tokenData: {
|
|
49
|
+
balance: string | number;
|
|
50
|
+
price: number;
|
|
51
|
+
decimals: number;
|
|
52
|
+
value: number;
|
|
53
|
+
confidence: number;
|
|
54
|
+
token: string;
|
|
55
|
+
symbol: string;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
}>;
|
|
59
|
+
debug({ printTokenTable, minTokenUSDValue }?: {
|
|
60
|
+
printTokenTable?: boolean;
|
|
61
|
+
minTokenUSDValue?: number;
|
|
62
|
+
}): Promise<{
|
|
63
|
+
usdTvl: number;
|
|
64
|
+
usdTokenBalances: BalancesV1;
|
|
65
|
+
rawTokenBalances: BalancesV1;
|
|
66
|
+
labelBreakdown?: {
|
|
67
|
+
[key: string]: number;
|
|
68
|
+
} | undefined;
|
|
69
|
+
debugData?: {
|
|
70
|
+
tokenData: {
|
|
71
|
+
balance: string | number;
|
|
72
|
+
price: number;
|
|
73
|
+
decimals: number;
|
|
74
|
+
value: number;
|
|
75
|
+
confidence: number;
|
|
76
|
+
token: string;
|
|
77
|
+
symbol: string;
|
|
78
|
+
}[];
|
|
79
|
+
} | undefined;
|
|
41
80
|
}>;
|
|
42
81
|
resizeBy(ratio: number): this;
|
|
43
82
|
static getUSDValue(balances: BalancesV1, timestamp?: number): Promise<number>;
|
|
@@ -45,6 +84,17 @@ export declare class Balances {
|
|
|
45
84
|
static getBalanceObjects(balances: BalancesV1, timestamp?: number): Promise<{
|
|
46
85
|
usdTvl: number;
|
|
47
86
|
usdTokenBalances: BalancesV1;
|
|
87
|
+
debugData: {
|
|
88
|
+
tokenData: {
|
|
89
|
+
balance: string | number;
|
|
90
|
+
price: number;
|
|
91
|
+
decimals: number;
|
|
92
|
+
value: number;
|
|
93
|
+
confidence: number;
|
|
94
|
+
token: string;
|
|
95
|
+
symbol: string;
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
48
98
|
}>;
|
|
49
99
|
static getUSDJSONs(balances: BalancesV1, timestamp?: number): Promise<{
|
|
50
100
|
usdTvl: number;
|
package/build/Balances.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Balances = void 0;
|
|
7
7
|
const generalUtil_1 = require("./generalUtil");
|
|
8
8
|
const computeTVL_1 = __importDefault(require("./util/computeTVL"));
|
|
9
|
+
const humanizeNumber_1 = require("./computeTVL/humanizeNumber");
|
|
9
10
|
const nullAddress = '0x0000000000000000000000000000000000000000';
|
|
10
11
|
// the last parameter of add function can be either a string or an object with options (or both as last two parameters)
|
|
11
12
|
function getOptions({ optionsOrLabel = {}, options = {} } = {}) {
|
|
@@ -153,9 +154,29 @@ class Balances {
|
|
|
153
154
|
async getUSDString() {
|
|
154
155
|
return Number(await this.getUSDValue()).toFixed(0);
|
|
155
156
|
}
|
|
156
|
-
async getUSDJSONs() {
|
|
157
|
-
const { usdTvl, usdTokenBalances } = await (0, computeTVL_1.default)(this.getBalances(), this.timestamp);
|
|
157
|
+
async getUSDJSONs({ debug = false, debugOptions: { printTokenTable = true, minTokenUSDValue } = {} } = {}) {
|
|
158
|
+
const { usdTvl, usdTokenBalances, debugData } = await (0, computeTVL_1.default)(this.getBalances(), this.timestamp, { debug });
|
|
158
159
|
const response = { usdTvl, usdTokenBalances, rawTokenBalances: this.getBalances(), labelBreakdown: {} };
|
|
160
|
+
if (debug) {
|
|
161
|
+
response.debugData = debugData;
|
|
162
|
+
if (!minTokenUSDValue && minTokenUSDValue !== 0) {
|
|
163
|
+
minTokenUSDValue = usdTvl / 100; // default to 1% of total TVL
|
|
164
|
+
}
|
|
165
|
+
let tokenData = debugData.tokenData;
|
|
166
|
+
// filter out tokens with value less than minTokenUSDValue
|
|
167
|
+
if (minTokenUSDValue)
|
|
168
|
+
tokenData = tokenData.filter((i) => +i.value >= minTokenUSDValue);
|
|
169
|
+
tokenData.sort((a, b) => b.value - a.value); // sort descending by value
|
|
170
|
+
if (printTokenTable) {
|
|
171
|
+
const dataClone = tokenData.map((i) => ({ ...i, value: (0, humanizeNumber_1.humanizeNumber)(i.value), }));
|
|
172
|
+
console.log((0, generalUtil_1.tableToString)(dataClone));
|
|
173
|
+
}
|
|
174
|
+
// add a humanized value field so it's easier to read big numbers
|
|
175
|
+
tokenData.forEach((i) => {
|
|
176
|
+
i.valueHN = (0, humanizeNumber_1.humanizeNumber)(i.value);
|
|
177
|
+
});
|
|
178
|
+
debugData.tokenData = tokenData;
|
|
179
|
+
}
|
|
159
180
|
if (!this.hasBreakdownBalances())
|
|
160
181
|
return response;
|
|
161
182
|
for (const [label, breakdown] of Object.entries(this.getBreakdownBalances())) {
|
|
@@ -164,6 +185,9 @@ class Balances {
|
|
|
164
185
|
}
|
|
165
186
|
return response;
|
|
166
187
|
}
|
|
188
|
+
async debug({ printTokenTable = true, minTokenUSDValue } = {}) {
|
|
189
|
+
return this.getUSDJSONs({ debug: true, debugOptions: { printTokenTable, minTokenUSDValue } });
|
|
190
|
+
}
|
|
167
191
|
resizeBy(ratio) {
|
|
168
192
|
Object.keys(this._balances).forEach((token) => {
|
|
169
193
|
this._balances[token] = Number(this._balances[token]) * ratio;
|
package/build/ChainApi.d.ts
CHANGED
|
@@ -82,6 +82,17 @@ export declare class ChainApi {
|
|
|
82
82
|
labelBreakdown?: {
|
|
83
83
|
[key: string]: number;
|
|
84
84
|
} | undefined;
|
|
85
|
+
debugData?: {
|
|
86
|
+
tokenData: {
|
|
87
|
+
balance: string | number;
|
|
88
|
+
price: number;
|
|
89
|
+
decimals: number;
|
|
90
|
+
value: number;
|
|
91
|
+
confidence: number;
|
|
92
|
+
token: string;
|
|
93
|
+
symbol: string;
|
|
94
|
+
}[];
|
|
95
|
+
} | undefined;
|
|
85
96
|
}>;
|
|
86
97
|
getLogs(params: GetLogsOptions): Promise<any[] | import("ethers").EventLog[] | import("ethers").EventLog[][]>;
|
|
87
98
|
getBalancesV2(): Balances;
|
package/build/abi/multicall3.js
CHANGED
|
@@ -204,7 +204,7 @@ const DEPLOYMENT_BLOCK = {
|
|
|
204
204
|
xrplevm: 1,
|
|
205
205
|
katana: 1,
|
|
206
206
|
mint: 1,
|
|
207
|
-
btnx:
|
|
207
|
+
btnx: 516999,
|
|
208
208
|
vechain: 22103870,
|
|
209
209
|
tac: 1,
|
|
210
210
|
eventum: 1,
|
|
@@ -213,6 +213,12 @@ const DEPLOYMENT_BLOCK = {
|
|
|
213
213
|
bitci: 1,
|
|
214
214
|
plasma: 1,
|
|
215
215
|
eteria: 918,
|
|
216
|
+
gatelayer: 1,
|
|
217
|
+
xone: 3752043,
|
|
218
|
+
mezo: 351760,
|
|
219
|
+
edu_chain: 16410660,
|
|
220
|
+
stratis: 1420372,
|
|
221
|
+
'0g': 6546802,
|
|
216
222
|
};
|
|
217
223
|
async function makeMultiCall(functionABI, calls, chain, block) {
|
|
218
224
|
if (chain === 'tron')
|
|
@@ -316,4 +322,5 @@ const CUSTOM_MULTICALL_ADDRESSES = {
|
|
|
316
322
|
'somnia': '0x5e44F178E8cF9B2F5409B6f18ce936aB817C5a11',
|
|
317
323
|
'bitci': '0x777238B119cD07e6849b0817f284532DC0F9F8D9',
|
|
318
324
|
'eteria': '0x8cC688B1F99b651ee00bB0Cb0aae61F416F8384b',
|
|
325
|
+
'xone': '0xe39d7BCDdaBBD0526D143185Fb7b459099Fd40c9',
|
|
319
326
|
};
|