@gearbox-protocol/sdk 12.2.0 → 12.3.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.
@@ -19,10 +19,59 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var RevolverTransport_exports = {};
20
20
  __export(RevolverTransport_exports, {
21
21
  NoAvailableTransportsError: () => NoAvailableTransportsError,
22
- RevolverTransport: () => RevolverTransport
22
+ RevolverTransport: () => RevolverTransport,
23
+ SelectionStrategy: () => SelectionStrategy,
24
+ providerConfigSchema: () => providerConfigSchema,
25
+ revolverTransportConfigSchema: () => revolverTransportConfigSchema
23
26
  });
24
27
  module.exports = __toCommonJS(RevolverTransport_exports);
25
28
  var import_viem = require("viem");
29
+ var import_v4 = require("zod/v4");
30
+ var import_sdk = require("../sdk/index.js");
31
+ var import_transports = require("./transports.js");
32
+ const providerConfigSchema = import_v4.z.object({
33
+ /**
34
+ * Provider name for display purposes
35
+ */
36
+ name: import_v4.z.string(),
37
+ /**
38
+ * Provider URL
39
+ */
40
+ url: import_v4.z.url(),
41
+ /**
42
+ * How long, in milliseconds, to wait before try this provider again
43
+ */
44
+ cooldown: import_v4.z.number().optional(),
45
+ /**
46
+ * HTTP transport options to use for this provider
47
+ */
48
+ httpClientOptions: import_transports.httpTransportConfigSchema.optional()
49
+ });
50
+ const SelectionStrategy = import_v4.z.enum(["simple", "ordered"]);
51
+ const revolverTransportConfigSchema = import_v4.z.object({
52
+ network: import_sdk.NetworkType,
53
+ /**
54
+ * Providers to use
55
+ */
56
+ providers: import_v4.z.array(providerConfigSchema),
57
+ /**
58
+ * How to select the next transport
59
+ * Defaults to "simple"
60
+ */
61
+ selectionStrategy: SelectionStrategy.optional(),
62
+ /** The key of the transport. */
63
+ key: import_v4.z.string().optional(),
64
+ /** The name of the transport. */
65
+ name: import_v4.z.string().optional(),
66
+ /**
67
+ * Default HTTP options to use for all providers, can be overridden by provider config
68
+ */
69
+ defaultHTTPOptions: import_transports.httpTransportConfigSchema.optional(),
70
+ /**
71
+ * Default cooldown, in milliseconds, to wait before try this transport again
72
+ */
73
+ defaultCooldown: import_v4.z.number().optional()
74
+ });
26
75
  class NoAvailableTransportsError extends import_viem.BaseError {
27
76
  constructor(cause) {
28
77
  super("no available transports", { cause });
@@ -61,11 +110,8 @@ class RevolverTransport {
61
110
  ({ url, name, cooldown, httpClientOptions }) => ({
62
111
  name,
63
112
  transport: (0, import_viem.http)(url, {
113
+ ...config.defaultHTTPOptions,
64
114
  ...httpClientOptions,
65
- retryCount: config.retryCount,
66
- retryDelay: config.retryDelay,
67
- timeout: config.timeout,
68
- batch: !!config.batch,
69
115
  key: name,
70
116
  name,
71
117
  onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(name, ...args) : void 0,
@@ -79,7 +125,7 @@ class RevolverTransport {
79
125
  }
80
126
  this.#isSingle = transports.length === 1;
81
127
  const selectionStrategy = config.selectionStrategy ?? "simple";
82
- this.#selector = selectionStrategy === "simple" ? new SimpleTransportSelector(transports, config.cooldown) : new OrderedTransportSelector(transports, config.cooldown);
128
+ this.#selector = selectionStrategy === "simple" ? new SimpleTransportSelector(transports, config.defaultCooldown) : new OrderedTransportSelector(transports, config.defaultCooldown);
83
129
  }
84
130
  get value() {
85
131
  return {
@@ -102,8 +148,8 @@ class RevolverTransport {
102
148
  ...this.overrides
103
149
  });
104
150
  const resp = await (0, import_viem.withRetry)(() => transport.request(r), {
105
- delay: this.#config.retryDelay,
106
- retryCount: this.#config.retryCount,
151
+ delay: this.#config.defaultHTTPOptions?.retryDelay,
152
+ retryCount: this.#config.defaultHTTPOptions?.retryCount,
107
153
  shouldRetry: this.#config.shouldRetry
108
154
  });
109
155
  this.#requests.delete(r);
@@ -134,10 +180,10 @@ class RevolverTransport {
134
180
  name: "revolver",
135
181
  type: "revolver",
136
182
  request: this.request,
137
- retryCount: this.#config.retryCount,
138
- methods: void 0,
139
- retryDelay: this.#config.retryDelay,
140
- timeout: this.#config.timeout
183
+ retryCount: this.#config.defaultHTTPOptions?.retryCount,
184
+ methods: this.#config.defaultHTTPOptions?.methods,
185
+ retryDelay: this.#config.defaultHTTPOptions?.retryDelay,
186
+ timeout: this.#config.defaultHTTPOptions?.timeout
141
187
  };
142
188
  }
143
189
  /**
@@ -283,5 +329,8 @@ class OrderedTransportSelector extends AbstractTransportSelector {
283
329
  // Annotate the CommonJS export names for ESM import in node:
284
330
  0 && (module.exports = {
285
331
  NoAvailableTransportsError,
286
- RevolverTransport
332
+ RevolverTransport,
333
+ SelectionStrategy,
334
+ providerConfigSchema,
335
+ revolverTransportConfigSchema
287
336
  });
@@ -29,6 +29,7 @@ __reExport(dev_exports, require("./mint/index.js"), module.exports);
29
29
  __reExport(dev_exports, require("./providers.js"), module.exports);
30
30
  __reExport(dev_exports, require("./RevolverTransport.js"), module.exports);
31
31
  __reExport(dev_exports, require("./replaceStorage.js"), module.exports);
32
+ __reExport(dev_exports, require("./transports.js"), module.exports);
32
33
  __reExport(dev_exports, require("./types.js"), module.exports);
33
34
  // Annotate the CommonJS export names for ESM import in node:
34
35
  0 && (module.exports = {
@@ -46,5 +47,6 @@ __reExport(dev_exports, require("./types.js"), module.exports);
46
47
  ...require("./providers.js"),
47
48
  ...require("./RevolverTransport.js"),
48
49
  ...require("./replaceStorage.js"),
50
+ ...require("./transports.js"),
49
51
  ...require("./types.js")
50
52
  });
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var transports_exports = {};
20
+ __export(transports_exports, {
21
+ httpTransportConfigSchema: () => httpTransportConfigSchema
22
+ });
23
+ module.exports = __toCommonJS(transports_exports);
24
+ var import_v4 = require("zod/v4");
25
+ const httpTransportConfigSchema = import_v4.z.object({
26
+ /**
27
+ * Whether to enable Batch JSON-RPC.
28
+ * @link https://www.jsonrpc.org/specification#batch
29
+ */
30
+ batch: import_v4.z.union([
31
+ import_v4.z.boolean(),
32
+ import_v4.z.object({
33
+ /** The maximum number of JSON-RPC requests to send in a batch. @default 1_000 */
34
+ batchSize: import_v4.z.number().optional(),
35
+ /** The maximum number of milliseconds to wait before sending a batch. @default 0 */
36
+ wait: import_v4.z.number().optional()
37
+ })
38
+ ]).optional(),
39
+ /**
40
+ * Request configuration to pass to `fetch`.
41
+ * @link https://developer.mozilla.org/en-US/docs/Web/API/fetch
42
+ */
43
+ fetchOptions: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
44
+ /**
45
+ * Methods to include or exclude from executing RPC requests.
46
+ **/
47
+ methods: import_v4.z.union([
48
+ import_v4.z.object({
49
+ include: import_v4.z.array(import_v4.z.string()).optional()
50
+ }),
51
+ import_v4.z.object({
52
+ exclude: import_v4.z.array(import_v4.z.string()).optional()
53
+ })
54
+ ]).optional(),
55
+ /**
56
+ * The max number of times to retry.
57
+ **/
58
+ retryCount: import_v4.z.number().optional(),
59
+ /**
60
+ * The base delay (in ms) between retries.
61
+ **/
62
+ retryDelay: import_v4.z.number().optional(),
63
+ /**
64
+ * The timeout (in ms) for the HTTP request. Default: 10_000
65
+ **/
66
+ timeout: import_v4.z.number().optional()
67
+ });
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ httpTransportConfigSchema
71
+ });
@@ -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, import_utils2.formatTimestamp)(Number(eta))
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, import_utils2.formatTimestamp)(Number(eta))
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, import_utils2.formatTimestamp)(Number(eta))
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
  });
@@ -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
@@ -10,6 +10,52 @@ import {
10
10
  RpcError,
11
11
  withRetry
12
12
  } from "viem";
13
+ import { z } from "zod/v4";
14
+ import { NetworkType } from "../sdk/index.js";
15
+ import { httpTransportConfigSchema } from "./transports.js";
16
+ const providerConfigSchema = z.object({
17
+ /**
18
+ * Provider name for display purposes
19
+ */
20
+ name: z.string(),
21
+ /**
22
+ * Provider URL
23
+ */
24
+ url: z.url(),
25
+ /**
26
+ * How long, in milliseconds, to wait before try this provider again
27
+ */
28
+ cooldown: z.number().optional(),
29
+ /**
30
+ * HTTP transport options to use for this provider
31
+ */
32
+ httpClientOptions: httpTransportConfigSchema.optional()
33
+ });
34
+ const SelectionStrategy = z.enum(["simple", "ordered"]);
35
+ const revolverTransportConfigSchema = z.object({
36
+ network: NetworkType,
37
+ /**
38
+ * Providers to use
39
+ */
40
+ providers: z.array(providerConfigSchema),
41
+ /**
42
+ * How to select the next transport
43
+ * Defaults to "simple"
44
+ */
45
+ selectionStrategy: SelectionStrategy.optional(),
46
+ /** The key of the transport. */
47
+ key: z.string().optional(),
48
+ /** The name of the transport. */
49
+ name: z.string().optional(),
50
+ /**
51
+ * Default HTTP options to use for all providers, can be overridden by provider config
52
+ */
53
+ defaultHTTPOptions: httpTransportConfigSchema.optional(),
54
+ /**
55
+ * Default cooldown, in milliseconds, to wait before try this transport again
56
+ */
57
+ defaultCooldown: z.number().optional()
58
+ });
13
59
  class NoAvailableTransportsError extends BaseError {
14
60
  constructor(cause) {
15
61
  super("no available transports", { cause });
@@ -48,11 +94,8 @@ class RevolverTransport {
48
94
  ({ url, name, cooldown, httpClientOptions }) => ({
49
95
  name,
50
96
  transport: http(url, {
97
+ ...config.defaultHTTPOptions,
51
98
  ...httpClientOptions,
52
- retryCount: config.retryCount,
53
- retryDelay: config.retryDelay,
54
- timeout: config.timeout,
55
- batch: !!config.batch,
56
99
  key: name,
57
100
  name,
58
101
  onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(name, ...args) : void 0,
@@ -66,7 +109,7 @@ class RevolverTransport {
66
109
  }
67
110
  this.#isSingle = transports.length === 1;
68
111
  const selectionStrategy = config.selectionStrategy ?? "simple";
69
- this.#selector = selectionStrategy === "simple" ? new SimpleTransportSelector(transports, config.cooldown) : new OrderedTransportSelector(transports, config.cooldown);
112
+ this.#selector = selectionStrategy === "simple" ? new SimpleTransportSelector(transports, config.defaultCooldown) : new OrderedTransportSelector(transports, config.defaultCooldown);
70
113
  }
71
114
  get value() {
72
115
  return {
@@ -89,8 +132,8 @@ class RevolverTransport {
89
132
  ...this.overrides
90
133
  });
91
134
  const resp = await withRetry(() => transport.request(r), {
92
- delay: this.#config.retryDelay,
93
- retryCount: this.#config.retryCount,
135
+ delay: this.#config.defaultHTTPOptions?.retryDelay,
136
+ retryCount: this.#config.defaultHTTPOptions?.retryCount,
94
137
  shouldRetry: this.#config.shouldRetry
95
138
  });
96
139
  this.#requests.delete(r);
@@ -121,10 +164,10 @@ class RevolverTransport {
121
164
  name: "revolver",
122
165
  type: "revolver",
123
166
  request: this.request,
124
- retryCount: this.#config.retryCount,
125
- methods: void 0,
126
- retryDelay: this.#config.retryDelay,
127
- timeout: this.#config.timeout
167
+ retryCount: this.#config.defaultHTTPOptions?.retryCount,
168
+ methods: this.#config.defaultHTTPOptions?.methods,
169
+ retryDelay: this.#config.defaultHTTPOptions?.retryDelay,
170
+ timeout: this.#config.defaultHTTPOptions?.timeout
128
171
  };
129
172
  }
130
173
  /**
@@ -269,5 +312,8 @@ class OrderedTransportSelector extends AbstractTransportSelector {
269
312
  }
270
313
  export {
271
314
  NoAvailableTransportsError,
272
- RevolverTransport
315
+ RevolverTransport,
316
+ SelectionStrategy,
317
+ providerConfigSchema,
318
+ revolverTransportConfigSchema
273
319
  };
@@ -12,4 +12,5 @@ export * from "./mint/index.js";
12
12
  export * from "./providers.js";
13
13
  export * from "./RevolverTransport.js";
14
14
  export * from "./replaceStorage.js";
15
+ export * from "./transports.js";
15
16
  export * from "./types.js";
@@ -0,0 +1,47 @@
1
+ import { z } from "zod/v4";
2
+ const httpTransportConfigSchema = z.object({
3
+ /**
4
+ * Whether to enable Batch JSON-RPC.
5
+ * @link https://www.jsonrpc.org/specification#batch
6
+ */
7
+ batch: z.union([
8
+ z.boolean(),
9
+ z.object({
10
+ /** The maximum number of JSON-RPC requests to send in a batch. @default 1_000 */
11
+ batchSize: z.number().optional(),
12
+ /** The maximum number of milliseconds to wait before sending a batch. @default 0 */
13
+ wait: z.number().optional()
14
+ })
15
+ ]).optional(),
16
+ /**
17
+ * Request configuration to pass to `fetch`.
18
+ * @link https://developer.mozilla.org/en-US/docs/Web/API/fetch
19
+ */
20
+ fetchOptions: z.record(z.string(), z.any()).optional(),
21
+ /**
22
+ * Methods to include or exclude from executing RPC requests.
23
+ **/
24
+ methods: z.union([
25
+ z.object({
26
+ include: z.array(z.string()).optional()
27
+ }),
28
+ z.object({
29
+ exclude: z.array(z.string()).optional()
30
+ })
31
+ ]).optional(),
32
+ /**
33
+ * The max number of times to retry.
34
+ **/
35
+ retryCount: z.number().optional(),
36
+ /**
37
+ * The base delay (in ms) between retries.
38
+ **/
39
+ retryDelay: z.number().optional(),
40
+ /**
41
+ * The timeout (in ms) for the HTTP request. Default: 10_000
42
+ **/
43
+ timeout: z.number().optional()
44
+ });
45
+ export {
46
+ httpTransportConfigSchema
47
+ };
@@ -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 { BaseContract, json_stringify } from "../../../sdk/index.js";
10
- import { formatTimestamp } from "../../utils/index.js";
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
  };
@@ -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 { fmtBinaryMask, formatBNvalue } from "../../utils/index.js";
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 { fmtBinaryMask, formatBNvalue } from "../../utils/index.js";
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,34 +1,108 @@
1
- import { BaseError, type ClientConfig, type EIP1193RequestFn, type Transport, type TransportConfig } from "viem";
1
+ import { BaseError, type EIP1193RequestFn, type Transport, type TransportConfig } from "viem";
2
2
  import type { HttpRpcClientOptions } from "viem/utils";
3
- import type { ILogger, NetworkType } from "../sdk/index.js";
4
- export interface ProviderConfig {
5
- name: string;
6
- url: string;
7
- cooldown?: number;
8
- httpClientOptions?: HttpRpcClientOptions | undefined;
9
- }
3
+ import { z } from "zod/v4";
4
+ import { type ILogger } from "../sdk/index.js";
5
+ export declare const providerConfigSchema: z.ZodObject<{
6
+ name: z.ZodString;
7
+ url: z.ZodURL;
8
+ cooldown: z.ZodOptional<z.ZodNumber>;
9
+ httpClientOptions: z.ZodOptional<z.ZodObject<{
10
+ batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
11
+ batchSize: z.ZodOptional<z.ZodNumber>;
12
+ wait: z.ZodOptional<z.ZodNumber>;
13
+ }, z.core.$strip>]>>;
14
+ fetchOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
15
+ methods: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
16
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
17
+ }, z.core.$strip>, z.ZodObject<{
18
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
+ }, z.core.$strip>]>>;
20
+ retryCount: z.ZodOptional<z.ZodNumber>;
21
+ retryDelay: z.ZodOptional<z.ZodNumber>;
22
+ timeout: z.ZodOptional<z.ZodNumber>;
23
+ }, z.core.$strip>>;
24
+ }, z.core.$strip>;
25
+ export type ProviderConfig = z.infer<typeof providerConfigSchema>;
10
26
  export interface ProviderStatus {
11
27
  id: string;
12
28
  status: "active" | "cooldown" | "standby";
13
29
  }
14
30
  type OnRequestFn = (providerName: string, ...args: Parameters<Required<HttpRpcClientOptions>["onRequest"]>) => ReturnType<Required<HttpRpcClientOptions>["onRequest"]>;
15
31
  type OnResponseFn = (providerName: string, ...args: Parameters<Required<HttpRpcClientOptions>["onResponse"]>) => ReturnType<Required<HttpRpcClientOptions>["onResponse"]>;
32
+ export declare const SelectionStrategy: z.ZodEnum<{
33
+ simple: "simple";
34
+ ordered: "ordered";
35
+ }>;
16
36
  /**
17
37
  * How to select the next transport
18
38
  * - simple: selects next transport after current that is not in cooldown by checking all transports in cyclic order
19
39
  * - ordered: will select first available transport that is not in cooldown
20
40
  */
21
- export type SelectionStrategy = "simple" | "ordered";
22
- export interface RevolverTransportConfig {
23
- network: NetworkType;
24
- providers: ProviderConfig[];
41
+ export type SelectionStrategy = z.infer<typeof SelectionStrategy>;
42
+ export declare const revolverTransportConfigSchema: z.ZodObject<{
43
+ network: z.ZodEnum<{
44
+ Mainnet: "Mainnet";
45
+ Arbitrum: "Arbitrum";
46
+ Optimism: "Optimism";
47
+ Base: "Base";
48
+ Sonic: "Sonic";
49
+ MegaETH: "MegaETH";
50
+ Monad: "Monad";
51
+ Berachain: "Berachain";
52
+ Avalanche: "Avalanche";
53
+ BNB: "BNB";
54
+ WorldChain: "WorldChain";
55
+ Etherlink: "Etherlink";
56
+ Hemi: "Hemi";
57
+ Lisk: "Lisk";
58
+ Plasma: "Plasma";
59
+ Somnia: "Somnia";
60
+ }>;
61
+ providers: z.ZodArray<z.ZodObject<{
62
+ name: z.ZodString;
63
+ url: z.ZodURL;
64
+ cooldown: z.ZodOptional<z.ZodNumber>;
65
+ httpClientOptions: z.ZodOptional<z.ZodObject<{
66
+ batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
67
+ batchSize: z.ZodOptional<z.ZodNumber>;
68
+ wait: z.ZodOptional<z.ZodNumber>;
69
+ }, z.core.$strip>]>>;
70
+ fetchOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
71
+ methods: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
72
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ }, z.core.$strip>, z.ZodObject<{
74
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
+ }, z.core.$strip>]>>;
76
+ retryCount: z.ZodOptional<z.ZodNumber>;
77
+ retryDelay: z.ZodOptional<z.ZodNumber>;
78
+ timeout: z.ZodOptional<z.ZodNumber>;
79
+ }, z.core.$strip>>;
80
+ }, z.core.$strip>>;
81
+ selectionStrategy: z.ZodOptional<z.ZodEnum<{
82
+ simple: "simple";
83
+ ordered: "ordered";
84
+ }>>;
85
+ key: z.ZodOptional<z.ZodString>;
86
+ name: z.ZodOptional<z.ZodString>;
87
+ defaultHTTPOptions: z.ZodOptional<z.ZodObject<{
88
+ batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
89
+ batchSize: z.ZodOptional<z.ZodNumber>;
90
+ wait: z.ZodOptional<z.ZodNumber>;
91
+ }, z.core.$strip>]>>;
92
+ fetchOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
93
+ methods: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
94
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
95
+ }, z.core.$strip>, z.ZodObject<{
96
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
97
+ }, z.core.$strip>]>>;
98
+ retryCount: z.ZodOptional<z.ZodNumber>;
99
+ retryDelay: z.ZodOptional<z.ZodNumber>;
100
+ timeout: z.ZodOptional<z.ZodNumber>;
101
+ }, z.core.$strip>>;
102
+ defaultCooldown: z.ZodOptional<z.ZodNumber>;
103
+ }, z.core.$strip>;
104
+ export type RevolverTransportConfig = {
25
105
  logger?: ILogger;
26
- key?: TransportConfig["key"] | undefined;
27
- name?: TransportConfig["name"] | undefined;
28
- pollingInterval?: ClientConfig["pollingInterval"] | undefined;
29
- retryCount?: TransportConfig["retryCount"] | undefined;
30
- retryDelay?: TransportConfig["retryDelay"] | undefined;
31
- timeout?: TransportConfig["timeout"] | undefined;
32
106
  /**
33
107
  * When single http transport should retry?
34
108
  * Defaults to some less strict criteria, so it'll retry "blockNumber from the future" errors
@@ -42,10 +116,6 @@ export interface RevolverTransportConfig {
42
116
  count: number;
43
117
  error: Error;
44
118
  }) => Promise<boolean> | boolean) | undefined;
45
- /**
46
- * Allow batching of json-rpc requests
47
- */
48
- batch?: boolean | undefined;
49
119
  /**
50
120
  * Spying function that also returns provider name in additional to the request
51
121
  */
@@ -62,16 +132,7 @@ export interface RevolverTransportConfig {
62
132
  * Callback that is called when the transport cannot be rotated
63
133
  */
64
134
  onRotateFailed?: (oldTransportName: string, reason?: BaseError) => void | Promise<void>;
65
- /**
66
- * How long, in milliseconds, to wait before try this transport again
67
- */
68
- cooldown?: number | undefined;
69
- /**
70
- * How to select the next transport
71
- * Defaults to "simple"
72
- */
73
- selectionStrategy?: SelectionStrategy;
74
- }
135
+ } & z.infer<typeof revolverTransportConfigSchema>;
75
136
  export declare class NoAvailableTransportsError extends BaseError {
76
137
  constructor(cause?: Error);
77
138
  }
@@ -12,4 +12,5 @@ export * from "./mint/index.js";
12
12
  export * from "./providers.js";
13
13
  export * from "./RevolverTransport.js";
14
14
  export * from "./replaceStorage.js";
15
+ export * from "./transports.js";
15
16
  export * from "./types.js";
@@ -0,0 +1,16 @@
1
+ import { z } from "zod/v4";
2
+ export declare const httpTransportConfigSchema: z.ZodObject<{
3
+ batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
4
+ batchSize: z.ZodOptional<z.ZodNumber>;
5
+ wait: z.ZodOptional<z.ZodNumber>;
6
+ }, z.core.$strip>]>>;
7
+ fetchOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
8
+ methods: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
9
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
12
+ }, z.core.$strip>]>>;
13
+ retryCount: z.ZodOptional<z.ZodNumber>;
14
+ retryDelay: z.ZodOptional<z.ZodNumber>;
15
+ timeout: z.ZodOptional<z.ZodNumber>;
16
+ }, z.core.$strip>;
@@ -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: number;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "12.2.0",
3
+ "version": "12.3.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",