Skip to content

Commit c9e18ae

Browse files
committed
fix: improve state-human
1 parent 99f8b0f commit c9e18ae

File tree

6 files changed

+360
-361
lines changed

6 files changed

+360
-361
lines changed

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
33
"extends": ["@gearbox-protocol/biome-config"],
44
"vcs": {
55
"enabled": true,

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,25 @@
6363
"date-fns": "^4.1.0",
6464
"decimal.js-light": "^2.5.1",
6565
"viem": ">=2.23.15 <3.0.0",
66-
"zod": "^4.3.5"
66+
"zod": "^4.3.6"
6767
},
6868
"devDependencies": {
69-
"@biomejs/biome": "^2.3.11",
70-
"@commitlint/cli": "^20.3.0",
71-
"@commitlint/config-conventional": "^20.3.0",
72-
"@gearbox-protocol/biome-config": "^1.0.17",
69+
"@biomejs/biome": "^2.3.13",
70+
"@commitlint/cli": "^20.3.1",
71+
"@commitlint/config-conventional": "^20.3.1",
72+
"@gearbox-protocol/biome-config": "^1.0.19",
7373
"@types/cross-spawn": "^6.0.6",
74-
"axios": "^1.13.2",
74+
"axios": "^1.13.3",
7575
"cross-spawn": "^7.0.6",
7676
"husky": "^9.1.7",
7777
"lint-staged": "^16.2.7",
78-
"pino": "^10.1.0",
78+
"pino": "^10.3.0",
7979
"pino-pretty": "^13.1.3",
8080
"tsup": "^8.5.1",
8181
"tsx": "^4.21.0",
8282
"typescript": "^5.9.3",
8383
"viem-deal": "^2.0.4",
84-
"vitest": "^4.0.16"
84+
"vitest": "^4.0.18"
8585
},
8686
"peerDependencies": {
8787
"axios": "^1.0.0",

src/sdk/GearboxSDK.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
import { createRouter, type IRouterContract } from "./router/index.js";
4444
import type { GearboxState, GearboxStateHuman } from "./types/index.js";
4545
import type { PickSomeRequired } from "./utils/index.js";
46-
import { TypedObjectUtils, toAddress } from "./utils/index.js";
46+
import { formatTimestamp, TypedObjectUtils, toAddress } from "./utils/index.js";
4747
import { Hooks } from "./utils/internal/index.js";
4848
import { getLogsSafe } from "./utils/viem/index.js";
4949

@@ -477,7 +477,7 @@ export class GearboxSDK<
477477
public stateHuman(raw = true): GearboxStateHuman {
478478
return {
479479
block: Number(this.currentBlock),
480-
timestamp: Number(this.timestamp),
480+
timestamp: formatTimestamp(Number(this.timestamp), raw),
481481
core: {
482482
addressProviderV3: this.addressProvider.stateHuman(raw),
483483
botList: this.botListContract?.stateHuman(raw),

src/sdk/types/state-human.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export interface MarketStateHuman {
240240

241241
export interface GearboxStateHuman {
242242
block: number;
243-
timestamp: number;
243+
timestamp: string;
244244
core: CoreStateHuman;
245245
markets: MarketStateHuman[];
246246
plugins: Record<string, unknown>;

src/sdk/utils/formatter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ export function formatNumberToString_(value: bigint | number): string {
127127
.replaceAll(",", "_");
128128
}
129129

130-
export function formatTimestamp(timestamp: number) {
131-
return new Date(timestamp * 1000).toLocaleString("en-GB", {
130+
export function formatTimestamp(timestamp: number, raw = true): string {
131+
const result = new Date(timestamp * 1000).toLocaleString("en-GB", {
132132
dateStyle: "short",
133133
timeStyle: "short",
134134
});
135+
return raw ? `${result} [${timestamp}]` : result;
135136
}

0 commit comments

Comments
 (0)