@gearbox-protocol/sdk 12.3.0 → 12.3.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.
- package/dist/cjs/permissionless/bindings/governance/governor.js +3 -4
- package/dist/cjs/permissionless/utils/format.js +0 -8
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +69 -37
- package/dist/cjs/sdk/market/credit/CreditFacadeV300Contract.js +1 -1
- package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +1 -1
- package/dist/cjs/sdk/utils/formatter.js +8 -0
- package/dist/esm/permissionless/bindings/governance/governor.js +5 -2
- package/dist/esm/permissionless/utils/format.js +0 -7
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +69 -37
- package/dist/esm/sdk/market/credit/CreditFacadeV300Contract.js +6 -2
- package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +6 -2
- package/dist/esm/sdk/utils/formatter.js +7 -0
- package/dist/types/permissionless/utils/format.d.ts +0 -1
- package/dist/types/sdk/types/state-human.d.ts +1 -1
- package/dist/types/sdk/utils/formatter.d.ts +1 -0
- package/package.json +1 -1
|
@@ -25,7 +25,6 @@ var import_viem = require("viem");
|
|
|
25
25
|
var import_utils = require("viem/utils");
|
|
26
26
|
var import_governor = require("../../../abi/governance/governor.js");
|
|
27
27
|
var import_sdk = require("../../../sdk/index.js");
|
|
28
|
-
var import_utils2 = require("../../utils/index.js");
|
|
29
28
|
var import_market_configurator = require("../market-configurator.js");
|
|
30
29
|
var import_treasury_splitter = require("../treasury-splitter.js");
|
|
31
30
|
var import_batches_chain = require("./batches-chain.js");
|
|
@@ -177,7 +176,7 @@ class GovernorContract extends import_sdk.BaseContract {
|
|
|
177
176
|
case "startBatch": {
|
|
178
177
|
const [eta] = args;
|
|
179
178
|
return {
|
|
180
|
-
eta: (0,
|
|
179
|
+
eta: (0, import_sdk.formatTimestamp)(Number(eta))
|
|
181
180
|
};
|
|
182
181
|
}
|
|
183
182
|
case "queueTransaction": {
|
|
@@ -190,7 +189,7 @@ class GovernorContract extends import_sdk.BaseContract {
|
|
|
190
189
|
data: (0, import_sdk.json_stringify)(
|
|
191
190
|
this.#decodeFunctionData(target, calldata)?.args ?? calldata
|
|
192
191
|
),
|
|
193
|
-
eta: (0,
|
|
192
|
+
eta: (0, import_sdk.formatTimestamp)(Number(eta))
|
|
194
193
|
};
|
|
195
194
|
}
|
|
196
195
|
case "executeBatch": {
|
|
@@ -207,7 +206,7 @@ class GovernorContract extends import_sdk.BaseContract {
|
|
|
207
206
|
data: (0, import_sdk.json_stringify)(
|
|
208
207
|
this.#decodeFunctionData(target, calldata)?.args ?? calldata
|
|
209
208
|
),
|
|
210
|
-
eta: (0,
|
|
209
|
+
eta: (0, import_sdk.formatTimestamp)(Number(eta))
|
|
211
210
|
};
|
|
212
211
|
})
|
|
213
212
|
)
|
|
@@ -22,7 +22,6 @@ __export(format_exports, {
|
|
|
22
22
|
deepJsonParse: () => deepJsonParse,
|
|
23
23
|
formatBytecodeSize: () => formatBytecodeSize,
|
|
24
24
|
formatBytecodeVersion: () => formatBytecodeVersion,
|
|
25
|
-
formatTimestamp: () => formatTimestamp,
|
|
26
25
|
shortenHash: () => shortenHash,
|
|
27
26
|
significantTrunc: () => significantTrunc
|
|
28
27
|
});
|
|
@@ -38,12 +37,6 @@ function formatBytecodeVersion(version) {
|
|
|
38
37
|
const patch = version % 10;
|
|
39
38
|
return `v${major}.${minor}.${patch}`;
|
|
40
39
|
}
|
|
41
|
-
function formatTimestamp(timestamp) {
|
|
42
|
-
return new Date(timestamp * 1e3).toLocaleString("en-GB", {
|
|
43
|
-
dateStyle: "short",
|
|
44
|
-
timeStyle: "short"
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
40
|
function shortenHash(hash, chars = 4) {
|
|
48
41
|
if (!hash) return "";
|
|
49
42
|
const start = hash.slice(0, chars + 2);
|
|
@@ -91,7 +84,6 @@ function deepJsonParse(value) {
|
|
|
91
84
|
deepJsonParse,
|
|
92
85
|
formatBytecodeSize,
|
|
93
86
|
formatBytecodeVersion,
|
|
94
|
-
formatTimestamp,
|
|
95
87
|
shortenHash,
|
|
96
88
|
significantTrunc
|
|
97
89
|
});
|
|
@@ -212,9 +212,9 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
212
212
|
* @returns call result of getConnectedBots for each credit account
|
|
213
213
|
*/
|
|
214
214
|
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
const allResp = await this.client.multicall({
|
|
216
|
+
contracts: [
|
|
217
|
+
...accountsToCheck.map((o) => {
|
|
218
218
|
const pool = this.sdk.marketRegister.findByCreditManager(
|
|
219
219
|
o.creditManager
|
|
220
220
|
);
|
|
@@ -225,32 +225,71 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
225
225
|
args: [pool.configurator.address, o.creditAccount]
|
|
226
226
|
};
|
|
227
227
|
}),
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
]);
|
|
233
|
-
return {
|
|
234
|
-
legacy: resp,
|
|
235
|
-
additionalBots: additional,
|
|
236
|
-
legacyMigration: migration
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
async getActiveBots(accountsToCheck, bots) {
|
|
240
|
-
const result = await this.client.multicall({
|
|
241
|
-
contracts: accountsToCheck.flatMap((ca) => {
|
|
242
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
243
|
-
return bots.map((bot) => {
|
|
228
|
+
...legacyMigrationBot ? accountsToCheck.map((ca) => {
|
|
229
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
230
|
+
ca.creditManager
|
|
231
|
+
);
|
|
244
232
|
return {
|
|
245
233
|
abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
|
|
246
234
|
address: cm.creditFacade.botList,
|
|
247
235
|
functionName: "getBotStatus",
|
|
248
|
-
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [
|
|
236
|
+
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
|
|
249
237
|
};
|
|
250
|
-
})
|
|
251
|
-
|
|
238
|
+
}) : [],
|
|
239
|
+
...accountsToCheck.flatMap((ca) => {
|
|
240
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
241
|
+
ca.creditManager
|
|
242
|
+
);
|
|
243
|
+
return additionalBots.map((bot) => {
|
|
244
|
+
return {
|
|
245
|
+
abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
|
|
246
|
+
address: cm.creditFacade.botList,
|
|
247
|
+
functionName: "getBotStatus",
|
|
248
|
+
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
})
|
|
252
|
+
],
|
|
252
253
|
allowFailure: true
|
|
253
254
|
});
|
|
255
|
+
const legacyStart = 0;
|
|
256
|
+
const legacyEnd = accountsToCheck.length;
|
|
257
|
+
const legacy = allResp.slice(
|
|
258
|
+
legacyStart,
|
|
259
|
+
legacyEnd
|
|
260
|
+
);
|
|
261
|
+
const migrationStart = legacyEnd;
|
|
262
|
+
const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
|
|
263
|
+
const migrationResp = allResp.slice(
|
|
264
|
+
migrationStart,
|
|
265
|
+
migrationEnd
|
|
266
|
+
);
|
|
267
|
+
const additionalStart = migrationEnd;
|
|
268
|
+
const additionalResp = allResp.slice(
|
|
269
|
+
additionalStart
|
|
270
|
+
);
|
|
271
|
+
return {
|
|
272
|
+
legacy,
|
|
273
|
+
additionalBots: this.getActiveBots(
|
|
274
|
+
accountsToCheck,
|
|
275
|
+
additionalBots,
|
|
276
|
+
additionalResp
|
|
277
|
+
),
|
|
278
|
+
legacyMigration: this.getActiveMigrationBots(
|
|
279
|
+
accountsToCheck,
|
|
280
|
+
legacyMigrationBot,
|
|
281
|
+
migrationResp
|
|
282
|
+
)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
getActiveBots(accountsToCheck, bots, result) {
|
|
286
|
+
if (result.length !== bots.length * accountsToCheck.length) {
|
|
287
|
+
console.error(
|
|
288
|
+
"result length mismatch",
|
|
289
|
+
result.length,
|
|
290
|
+
bots.length * accountsToCheck.length
|
|
291
|
+
);
|
|
292
|
+
}
|
|
254
293
|
const botsByCAIndex = accountsToCheck.reduce((acc, _, index) => {
|
|
255
294
|
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
256
295
|
acc.push({
|
|
@@ -260,22 +299,15 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
260
299
|
}, []);
|
|
261
300
|
return botsByCAIndex;
|
|
262
301
|
}
|
|
263
|
-
|
|
302
|
+
getActiveMigrationBots(accountsToCheck, bot, result) {
|
|
264
303
|
if (bot) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
address: cm.creditFacade.botList,
|
|
273
|
-
functionName: "getBotStatus",
|
|
274
|
-
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
275
|
-
};
|
|
276
|
-
}),
|
|
277
|
-
allowFailure: true
|
|
278
|
-
});
|
|
304
|
+
if (result.length !== accountsToCheck.length) {
|
|
305
|
+
console.error(
|
|
306
|
+
"result length mismatch for migration bots",
|
|
307
|
+
result.length,
|
|
308
|
+
accountsToCheck.length
|
|
309
|
+
);
|
|
310
|
+
}
|
|
279
311
|
return { result, botAddress: bot };
|
|
280
312
|
}
|
|
281
313
|
return void 0;
|
|
@@ -50,7 +50,7 @@ class CreditFacadeV300Contract extends import_base.BaseContract {
|
|
|
50
50
|
expirable: this.expirable,
|
|
51
51
|
isDegenMode: this.degenNFT !== import_constants.ADDRESS_0X0,
|
|
52
52
|
degenNFT: this.labelAddress(this.degenNFT),
|
|
53
|
-
expirationDate: this.expirationDate,
|
|
53
|
+
expirationDate: (0, import_utils.formatTimestamp)(this.expirationDate),
|
|
54
54
|
maxDebtPerBlockMultiplier: this.maxDebtPerBlockMultiplier,
|
|
55
55
|
botList: this.labelAddress(this.botList),
|
|
56
56
|
minDebt: (0, import_utils.formatBNvalue)(this.minDebt, decimals),
|
|
@@ -50,7 +50,7 @@ class CreditFacadeV310Contract extends import_base.BaseContract {
|
|
|
50
50
|
expirable: this.expirable,
|
|
51
51
|
isDegenMode: this.degenNFT !== import_constants.ADDRESS_0X0,
|
|
52
52
|
degenNFT: this.labelAddress(this.degenNFT),
|
|
53
|
-
expirationDate: this.expirationDate,
|
|
53
|
+
expirationDate: (0, import_utils.formatTimestamp)(this.expirationDate),
|
|
54
54
|
maxDebtPerBlockMultiplier: this.maxDebtPerBlockMultiplier,
|
|
55
55
|
botList: this.labelAddress(this.botList),
|
|
56
56
|
minDebt: (0, import_utils.formatBNvalue)(this.minDebt, decimals),
|
|
@@ -23,6 +23,7 @@ __export(formatter_exports, {
|
|
|
23
23
|
formatBNvalue: () => formatBNvalue,
|
|
24
24
|
formatDuration: () => formatDuration,
|
|
25
25
|
formatNumberToString_: () => formatNumberToString_,
|
|
26
|
+
formatTimestamp: () => formatTimestamp,
|
|
26
27
|
numberWithCommas: () => numberWithCommas,
|
|
27
28
|
percentFmt: () => percentFmt,
|
|
28
29
|
toBigInt: () => toBigInt
|
|
@@ -121,6 +122,12 @@ function formatDuration(seconds, raw = true) {
|
|
|
121
122
|
function formatNumberToString_(value) {
|
|
122
123
|
return value.toLocaleString("en-US", { minimumIntegerDigits: 1, useGrouping: true }).replaceAll(",", "_");
|
|
123
124
|
}
|
|
125
|
+
function formatTimestamp(timestamp) {
|
|
126
|
+
return new Date(timestamp * 1e3).toLocaleString("en-GB", {
|
|
127
|
+
dateStyle: "short",
|
|
128
|
+
timeStyle: "short"
|
|
129
|
+
});
|
|
130
|
+
}
|
|
124
131
|
// Annotate the CommonJS export names for ESM import in node:
|
|
125
132
|
0 && (module.exports = {
|
|
126
133
|
fmtBinaryMask,
|
|
@@ -128,6 +135,7 @@ function formatNumberToString_(value) {
|
|
|
128
135
|
formatBNvalue,
|
|
129
136
|
formatDuration,
|
|
130
137
|
formatNumberToString_,
|
|
138
|
+
formatTimestamp,
|
|
131
139
|
numberWithCommas,
|
|
132
140
|
percentFmt,
|
|
133
141
|
toBigInt
|
|
@@ -6,8 +6,11 @@ import {
|
|
|
6
6
|
} from "viem";
|
|
7
7
|
import { formatAbiItem } from "viem/utils";
|
|
8
8
|
import { governorAbi } from "../../../abi/governance/governor.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
BaseContract,
|
|
11
|
+
formatTimestamp,
|
|
12
|
+
json_stringify
|
|
13
|
+
} from "../../../sdk/index.js";
|
|
11
14
|
import { MarketConfiguratorContract } from "../market-configurator.js";
|
|
12
15
|
import { TreasurySplitterContract } from "../treasury-splitter.js";
|
|
13
16
|
import { BatchesChainContract } from "./batches-chain.js";
|
|
@@ -9,12 +9,6 @@ function formatBytecodeVersion(version) {
|
|
|
9
9
|
const patch = version % 10;
|
|
10
10
|
return `v${major}.${minor}.${patch}`;
|
|
11
11
|
}
|
|
12
|
-
function formatTimestamp(timestamp) {
|
|
13
|
-
return new Date(timestamp * 1e3).toLocaleString("en-GB", {
|
|
14
|
-
dateStyle: "short",
|
|
15
|
-
timeStyle: "short"
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
12
|
function shortenHash(hash, chars = 4) {
|
|
19
13
|
if (!hash) return "";
|
|
20
14
|
const start = hash.slice(0, chars + 2);
|
|
@@ -61,7 +55,6 @@ export {
|
|
|
61
55
|
deepJsonParse,
|
|
62
56
|
formatBytecodeSize,
|
|
63
57
|
formatBytecodeVersion,
|
|
64
|
-
formatTimestamp,
|
|
65
58
|
shortenHash,
|
|
66
59
|
significantTrunc
|
|
67
60
|
};
|
|
@@ -202,9 +202,9 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
202
202
|
* @returns call result of getConnectedBots for each credit account
|
|
203
203
|
*/
|
|
204
204
|
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
const allResp = await this.client.multicall({
|
|
206
|
+
contracts: [
|
|
207
|
+
...accountsToCheck.map((o) => {
|
|
208
208
|
const pool = this.sdk.marketRegister.findByCreditManager(
|
|
209
209
|
o.creditManager
|
|
210
210
|
);
|
|
@@ -215,32 +215,71 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
215
215
|
args: [pool.configurator.address, o.creditAccount]
|
|
216
216
|
};
|
|
217
217
|
}),
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
]);
|
|
223
|
-
return {
|
|
224
|
-
legacy: resp,
|
|
225
|
-
additionalBots: additional,
|
|
226
|
-
legacyMigration: migration
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
async getActiveBots(accountsToCheck, bots) {
|
|
230
|
-
const result = await this.client.multicall({
|
|
231
|
-
contracts: accountsToCheck.flatMap((ca) => {
|
|
232
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
233
|
-
return bots.map((bot) => {
|
|
218
|
+
...legacyMigrationBot ? accountsToCheck.map((ca) => {
|
|
219
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
220
|
+
ca.creditManager
|
|
221
|
+
);
|
|
234
222
|
return {
|
|
235
223
|
abi: isV300(cm.creditFacade.version) ? iBotListV300Abi : iBotListV310Abi,
|
|
236
224
|
address: cm.creditFacade.botList,
|
|
237
225
|
functionName: "getBotStatus",
|
|
238
|
-
args: isV300(cm.creditFacade.version) ? [
|
|
226
|
+
args: isV300(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
|
|
239
227
|
};
|
|
240
|
-
})
|
|
241
|
-
|
|
228
|
+
}) : [],
|
|
229
|
+
...accountsToCheck.flatMap((ca) => {
|
|
230
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
231
|
+
ca.creditManager
|
|
232
|
+
);
|
|
233
|
+
return additionalBots.map((bot) => {
|
|
234
|
+
return {
|
|
235
|
+
abi: isV300(cm.creditFacade.version) ? iBotListV300Abi : iBotListV310Abi,
|
|
236
|
+
address: cm.creditFacade.botList,
|
|
237
|
+
functionName: "getBotStatus",
|
|
238
|
+
args: isV300(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
})
|
|
242
|
+
],
|
|
242
243
|
allowFailure: true
|
|
243
244
|
});
|
|
245
|
+
const legacyStart = 0;
|
|
246
|
+
const legacyEnd = accountsToCheck.length;
|
|
247
|
+
const legacy = allResp.slice(
|
|
248
|
+
legacyStart,
|
|
249
|
+
legacyEnd
|
|
250
|
+
);
|
|
251
|
+
const migrationStart = legacyEnd;
|
|
252
|
+
const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
|
|
253
|
+
const migrationResp = allResp.slice(
|
|
254
|
+
migrationStart,
|
|
255
|
+
migrationEnd
|
|
256
|
+
);
|
|
257
|
+
const additionalStart = migrationEnd;
|
|
258
|
+
const additionalResp = allResp.slice(
|
|
259
|
+
additionalStart
|
|
260
|
+
);
|
|
261
|
+
return {
|
|
262
|
+
legacy,
|
|
263
|
+
additionalBots: this.getActiveBots(
|
|
264
|
+
accountsToCheck,
|
|
265
|
+
additionalBots,
|
|
266
|
+
additionalResp
|
|
267
|
+
),
|
|
268
|
+
legacyMigration: this.getActiveMigrationBots(
|
|
269
|
+
accountsToCheck,
|
|
270
|
+
legacyMigrationBot,
|
|
271
|
+
migrationResp
|
|
272
|
+
)
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
getActiveBots(accountsToCheck, bots, result) {
|
|
276
|
+
if (result.length !== bots.length * accountsToCheck.length) {
|
|
277
|
+
console.error(
|
|
278
|
+
"result length mismatch",
|
|
279
|
+
result.length,
|
|
280
|
+
bots.length * accountsToCheck.length
|
|
281
|
+
);
|
|
282
|
+
}
|
|
244
283
|
const botsByCAIndex = accountsToCheck.reduce((acc, _, index) => {
|
|
245
284
|
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
246
285
|
acc.push({
|
|
@@ -250,22 +289,15 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
250
289
|
}, []);
|
|
251
290
|
return botsByCAIndex;
|
|
252
291
|
}
|
|
253
|
-
|
|
292
|
+
getActiveMigrationBots(accountsToCheck, bot, result) {
|
|
254
293
|
if (bot) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
address: cm.creditFacade.botList,
|
|
263
|
-
functionName: "getBotStatus",
|
|
264
|
-
args: isV300(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
265
|
-
};
|
|
266
|
-
}),
|
|
267
|
-
allowFailure: true
|
|
268
|
-
});
|
|
294
|
+
if (result.length !== accountsToCheck.length) {
|
|
295
|
+
console.error(
|
|
296
|
+
"result length mismatch for migration bots",
|
|
297
|
+
result.length,
|
|
298
|
+
accountsToCheck.length
|
|
299
|
+
);
|
|
300
|
+
}
|
|
269
301
|
return { result, botAddress: bot };
|
|
270
302
|
}
|
|
271
303
|
return void 0;
|
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
} from "../../../abi/v300.js";
|
|
6
6
|
import { BaseContract } from "../../base/index.js";
|
|
7
7
|
import { ADDRESS_0X0 } from "../../constants/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
fmtBinaryMask,
|
|
10
|
+
formatBNvalue,
|
|
11
|
+
formatTimestamp
|
|
12
|
+
} from "../../utils/index.js";
|
|
9
13
|
const abi = [
|
|
10
14
|
...iCreditFacadeV300Abi,
|
|
11
15
|
...iCreditFacadeV300MulticallAbi,
|
|
@@ -30,7 +34,7 @@ class CreditFacadeV300Contract extends BaseContract {
|
|
|
30
34
|
expirable: this.expirable,
|
|
31
35
|
isDegenMode: this.degenNFT !== ADDRESS_0X0,
|
|
32
36
|
degenNFT: this.labelAddress(this.degenNFT),
|
|
33
|
-
expirationDate: this.expirationDate,
|
|
37
|
+
expirationDate: formatTimestamp(this.expirationDate),
|
|
34
38
|
maxDebtPerBlockMultiplier: this.maxDebtPerBlockMultiplier,
|
|
35
39
|
botList: this.labelAddress(this.botList),
|
|
36
40
|
minDebt: formatBNvalue(this.minDebt, decimals),
|
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
6
6
|
import { BaseContract } from "../../base/index.js";
|
|
7
7
|
import { ADDRESS_0X0 } from "../../constants/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
fmtBinaryMask,
|
|
10
|
+
formatBNvalue,
|
|
11
|
+
formatTimestamp
|
|
12
|
+
} from "../../utils/index.js";
|
|
9
13
|
const abi = [
|
|
10
14
|
...iCreditFacadeV310Abi,
|
|
11
15
|
...iCreditFacadeMulticallV310Abi,
|
|
@@ -30,7 +34,7 @@ class CreditFacadeV310Contract extends BaseContract {
|
|
|
30
34
|
expirable: this.expirable,
|
|
31
35
|
isDegenMode: this.degenNFT !== ADDRESS_0X0,
|
|
32
36
|
degenNFT: this.labelAddress(this.degenNFT),
|
|
33
|
-
expirationDate: this.expirationDate,
|
|
37
|
+
expirationDate: formatTimestamp(this.expirationDate),
|
|
34
38
|
maxDebtPerBlockMultiplier: this.maxDebtPerBlockMultiplier,
|
|
35
39
|
botList: this.labelAddress(this.botList),
|
|
36
40
|
minDebt: formatBNvalue(this.minDebt, decimals),
|
|
@@ -91,12 +91,19 @@ function formatDuration(seconds, raw = true) {
|
|
|
91
91
|
function formatNumberToString_(value) {
|
|
92
92
|
return value.toLocaleString("en-US", { minimumIntegerDigits: 1, useGrouping: true }).replaceAll(",", "_");
|
|
93
93
|
}
|
|
94
|
+
function formatTimestamp(timestamp) {
|
|
95
|
+
return new Date(timestamp * 1e3).toLocaleString("en-GB", {
|
|
96
|
+
dateStyle: "short",
|
|
97
|
+
timeStyle: "short"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
94
100
|
export {
|
|
95
101
|
fmtBinaryMask,
|
|
96
102
|
formatBN,
|
|
97
103
|
formatBNvalue,
|
|
98
104
|
formatDuration,
|
|
99
105
|
formatNumberToString_,
|
|
106
|
+
formatTimestamp,
|
|
100
107
|
numberWithCommas,
|
|
101
108
|
percentFmt,
|
|
102
109
|
toBigInt
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare function formatBytecodeSize(size: number): string;
|
|
2
2
|
export declare function formatBytecodeVersion(version: number): string;
|
|
3
|
-
export declare function formatTimestamp(timestamp: number): string;
|
|
4
3
|
export declare function shortenHash(hash: string, chars?: number): string;
|
|
5
4
|
export declare function convertPercent(percent: number): number;
|
|
6
5
|
export declare function significantTrunc(x: number): string;
|
|
@@ -72,7 +72,7 @@ export interface CreditFacadeStateHuman extends BaseContractStateHuman {
|
|
|
72
72
|
expirable: boolean;
|
|
73
73
|
isDegenMode: boolean;
|
|
74
74
|
degenNFT: string;
|
|
75
|
-
expirationDate:
|
|
75
|
+
expirationDate: string;
|
|
76
76
|
maxDebtPerBlockMultiplier: number;
|
|
77
77
|
botList: string;
|
|
78
78
|
minDebt: string;
|
|
@@ -9,3 +9,4 @@ export declare function fmtBinaryMask(mask: bigint): string;
|
|
|
9
9
|
export declare function numberWithCommas(x: number | bigint): string;
|
|
10
10
|
export declare function formatDuration(seconds: number, raw?: boolean): string;
|
|
11
11
|
export declare function formatNumberToString_(value: bigint | number): string;
|
|
12
|
+
export declare function formatTimestamp(timestamp: number): string;
|