@gearbox-protocol/sdk 14.12.0-next.79 → 14.12.0-next.80

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.
Files changed (45) hide show
  1. package/dist/cjs/model/filters.schema.js +2 -0
  2. package/dist/cjs/model/index.js +3 -0
  3. package/dist/cjs/model/opportunities.schema.js +45 -0
  4. package/dist/cjs/offchain/AbstractOffchainNamespace.js +132 -0
  5. package/dist/cjs/offchain/index.js +5 -0
  6. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +34 -56
  7. package/dist/cjs/offchain/positions/OffchainPositions.js +5 -24
  8. package/dist/cjs/offchain/types.js +58 -0
  9. package/dist/esm/dev/AccountOpener.js +1 -1
  10. package/dist/esm/dev/withdrawalUtils.js +1 -1
  11. package/dist/esm/model/filters.schema.js +2 -1
  12. package/dist/esm/model/index.js +3 -3
  13. package/dist/esm/model/opportunities.schema.js +45 -2
  14. package/dist/esm/offchain/AbstractOffchainNamespace.js +131 -0
  15. package/dist/esm/offchain/index.js +3 -2
  16. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +34 -56
  17. package/dist/esm/offchain/positions/OffchainPositions.js +5 -24
  18. package/dist/esm/offchain/types.js +56 -1
  19. package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
  20. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  21. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  22. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  23. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
  24. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  25. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  26. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  27. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  28. package/dist/esm/sdk/base/TokensMeta.js +2 -2
  29. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  30. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  31. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  32. package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
  33. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  34. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  35. package/dist/esm/sdk/pools/PoolService.js +1 -1
  36. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  37. package/dist/types/model/filters.schema.d.ts +5 -1
  38. package/dist/types/model/index.d.ts +3 -3
  39. package/dist/types/model/opportunities.schema.d.ts +49 -1
  40. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +87 -0
  41. package/dist/types/offchain/index.d.ts +3 -2
  42. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +3 -33
  43. package/dist/types/offchain/positions/OffchainPositions.d.ts +2 -17
  44. package/dist/types/offchain/types.d.ts +49 -1
  45. package/package.json +2 -1
@@ -0,0 +1,131 @@
1
+ import { historySeriesSchema } from "../model/history.schema.js";
2
+ import { OffchainNotConfiguredError, OffchainTransportError, OffchainValidationError } from "./types.js";
3
+ import { z } from "zod/v4";
4
+ //#region src/offchain/AbstractOffchainNamespace.ts
5
+ const DEFAULT_TIMEOUT = 3e4;
6
+ /**
7
+ * Common logic of every {@link GearboxAPI} namespace.
8
+ *
9
+ * A namespace is a set of routes: it knows which path answers which read and
10
+ * which schema describes the payload. Everything under that — where the
11
+ * backend is, how long a request may take, how a failure is reported and how a
12
+ * response becomes read model values — lives here, so a namespace holds
13
+ * nothing but its routes.
14
+ **/
15
+ var AbstractOffchainNamespace = class {
16
+ logger;
17
+ #baseUrl;
18
+ #timeout;
19
+ constructor(name, options) {
20
+ this.#baseUrl = options?.baseUrl?.replace(/\/+$/, "");
21
+ this.#timeout = options?.timeout ?? DEFAULT_TIMEOUT;
22
+ this.logger = options?.logger?.child?.({ name }) ?? options?.logger;
23
+ }
24
+ /**
25
+ * Base URL every read of this namespace is issued against.
26
+ **/
27
+ get baseUrl() {
28
+ return this.#baseUrl;
29
+ }
30
+ /**
31
+ * Reads one endpoint and decodes its payload.
32
+ *
33
+ * The envelope is built here rather than by the caller: the status is
34
+ * `"success"` whenever this returns at all, because anything else has
35
+ * already thrown.
36
+ **/
37
+ async get(request) {
38
+ const url = this.#url(request.path, request.query);
39
+ this.logger?.debug(`reading ${url}`);
40
+ const payload = await this.#fetchJson(url);
41
+ const parsed = request.schema.safeParse(payload);
42
+ if (!parsed.success) {
43
+ this.logger?.error({
44
+ url,
45
+ issues: parsed.error.issues
46
+ }, "offchain response does not match the read model");
47
+ throw new OffchainValidationError(url, parsed.error.issues);
48
+ }
49
+ return {
50
+ result: parsed.data,
51
+ meta: { status: "success" }
52
+ };
53
+ }
54
+ /**
55
+ * Reads one historical series.
56
+ *
57
+ * The requested metric is pinned in the schema, which is what upholds the
58
+ * `HistorySeries<M>` a caller gets back: a response carrying a different
59
+ * metric is version skew and fails validation like any other mismatch,
60
+ * rather than being cast into the requested shape.
61
+ **/
62
+ async readHistory(request) {
63
+ return this.get({
64
+ path: request.path,
65
+ query: { range: request.range },
66
+ schema: historySeriesSchema.extend({ metric: z.literal(request.metric) })
67
+ });
68
+ }
69
+ /**
70
+ * Full URL of a read, with the conditions that do not narrow left out.
71
+ **/
72
+ #url(path, query) {
73
+ if (!this.#baseUrl) throw new OffchainNotConfiguredError(path);
74
+ const url = new URL(`${this.#baseUrl}${path}`);
75
+ for (const [key, value] of Object.entries(query ?? {})) if (value !== void 0) url.searchParams.set(key, value);
76
+ return url.toString();
77
+ }
78
+ /**
79
+ * Body of a successful read, still undecoded.
80
+ **/
81
+ async #fetchJson(url) {
82
+ let response;
83
+ try {
84
+ response = await fetch(url, {
85
+ headers: { accept: "application/json" },
86
+ signal: AbortSignal.timeout(this.#timeout)
87
+ });
88
+ } catch (error) {
89
+ throw new OffchainTransportError(url, describe(error));
90
+ }
91
+ if (!response.ok) throw new OffchainTransportError(url, await failureReason(response), response.status);
92
+ try {
93
+ return await response.json();
94
+ } catch (error) {
95
+ throw new OffchainTransportError(url, `the body is not JSON (${describe(error)})`, response.status);
96
+ }
97
+ }
98
+ };
99
+ /**
100
+ * Why a non-2xx response failed, in the backend's own words when it said.
101
+ **/
102
+ async function failureReason(response) {
103
+ const status = `the backend answered ${response.status}`;
104
+ let body;
105
+ try {
106
+ body = await response.text();
107
+ } catch {
108
+ return status;
109
+ }
110
+ const message = backendMessage(body) ?? body.trim();
111
+ return message ? `${status}: ${truncate(message)}` : status;
112
+ }
113
+ /**
114
+ * The `message` of a Gearbox backend error body, or nothing when the body is
115
+ * not one.
116
+ **/
117
+ function backendMessage(body) {
118
+ try {
119
+ const parsed = JSON.parse(body);
120
+ if (typeof parsed === "object" && parsed !== null && "message" in parsed && typeof parsed.message === "string") return parsed.message;
121
+ } catch {}
122
+ }
123
+ function describe(error) {
124
+ if (error instanceof Error) return error.name === "TimeoutError" ? "the request timed out" : error.message;
125
+ return String(error);
126
+ }
127
+ function truncate(text) {
128
+ return text.length > 200 ? `${text.slice(0, 200)}…` : text;
129
+ }
130
+ //#endregion
131
+ export { AbstractOffchainNamespace };
@@ -1,7 +1,8 @@
1
- import { OffchainNotImplementedError } from "./types.js";
1
+ import { OffchainNotConfiguredError, OffchainNotImplementedError, OffchainTransportError, OffchainValidationError } from "./types.js";
2
+ import { AbstractOffchainNamespace } from "./AbstractOffchainNamespace.js";
2
3
  import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
3
4
  import "./opportunities/index.js";
4
5
  import { OffchainPositions } from "./positions/OffchainPositions.js";
5
6
  import "./positions/index.js";
6
7
  import { GearboxAPI } from "./GearboxAPI.js";
7
- export { GearboxAPI, OffchainNotImplementedError, OffchainOpportunities, OffchainPositions };
8
+ export { AbstractOffchainNamespace, GearboxAPI, OffchainNotConfiguredError, OffchainNotImplementedError, OffchainOpportunities, OffchainPositions, OffchainTransportError, OffchainValidationError };
@@ -1,84 +1,62 @@
1
- import { OffchainNotImplementedError } from "../types.js";
1
+ import { opportunityFilterQuerySchema, opportunitySchema, poolOpportunityDetailSchema, strategyOpportunityDetailSchema } from "../../model/opportunities.schema.js";
2
+ import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
3
+ import { z } from "zod/v4";
2
4
  //#region src/offchain/opportunities/OffchainOpportunities.ts
3
5
  /**
4
6
  * Backend counterpart of the `opportunities` namespace.
5
- *
6
- * This is a stub: the HTTP client is not written yet, so list reads answer with
7
- * an empty list and detail reads throw. Every signature is already the final
8
- * one, because the backend returns the read model types directly — there is no
9
- * wire DTO and no mapper between the two.
10
- *
11
- * When the transport lands, each method will validate the response against the
12
- * matching schema from `src/model` before returning it. A validation failure is
13
- * a version-skew error and is handled exactly like a transport error: the
14
- * combined SDK drops the backend's contribution in `both` mode and rethrows in
15
- * `offchain` mode.
16
7
  **/
17
- var OffchainOpportunities = class {
18
- #baseUrl;
19
- #logger;
8
+ var OffchainOpportunities = class extends AbstractOffchainNamespace {
9
+ #root = "/v2/opportunities";
20
10
  constructor(options) {
21
- this.#baseUrl = options?.baseUrl;
22
- this.#logger = options?.logger?.child?.({ name: "OffchainOpportunities" });
23
- }
24
- /**
25
- * Base URL the client will call once the transport is implemented.
26
- **/
27
- get baseUrl() {
28
- return this.#baseUrl;
11
+ super("OffchainOpportunities", options);
29
12
  }
30
13
  /**
31
14
  * All opportunities the backend knows about, optionally narrowed by
32
15
  * {@link OpportunityFilter}.
33
- *
34
- * @returns An empty list until the backend client is implemented.
35
16
  **/
36
17
  async list(filter) {
37
- this.#logger?.debug({ filter }, "offchain opportunities list is not implemented, serving empty list");
38
- return {
39
- result: [],
40
- meta: { status: "success" }
41
- };
18
+ return this.get({
19
+ path: this.#root,
20
+ query: filter ? z.encode(opportunityFilterQuerySchema, filter) : void 0,
21
+ schema: z.array(opportunitySchema)
22
+ });
42
23
  }
43
24
  /**
44
25
  * Detailed view of one pool opportunity.
45
- *
46
- * @throws {@link OffchainNotImplementedError} until the backend client is
47
- * implemented.
48
26
  **/
49
27
  async getPool(key) {
50
- throw new OffchainNotImplementedError("opportunities.getPool");
28
+ return this.get({
29
+ path: this.#poolPath(key),
30
+ schema: poolOpportunityDetailSchema
31
+ });
51
32
  }
52
33
  /**
53
34
  * Detailed view of one strategy opportunity.
54
- *
55
- * @throws {@link OffchainNotImplementedError} until the backend client is
56
- * implemented.
57
35
  **/
58
36
  async getStrategy(key) {
59
- throw new OffchainNotImplementedError("opportunities.getStrategy");
37
+ return this.get({
38
+ path: this.#strategyPath(key),
39
+ schema: strategyOpportunityDetailSchema
40
+ });
60
41
  }
61
42
  /**
62
- * One historical series of one opportunity. History exists only here:
63
- * rebuilding it from the chain would mean an archive read per point.
64
- *
65
- * The requested metric types the response, so a caller asking for one metric
66
- * does not have to narrow the union back down. When the transport lands,
67
- * validation is what upholds it: a response carrying a different metric than
68
- * the one asked for is a version-skew error like any other.
69
- *
70
- * @returns An empty series until the backend client is implemented.
43
+ * One historical series of one opportunity
71
44
  **/
72
45
  async getHistory(query) {
73
- this.#logger?.debug({ query }, "offchain opportunities history is not implemented, serving empty series");
74
- return {
75
- result: {
76
- metric: query.metric,
77
- points: [],
78
- metadata: {}
79
- },
80
- meta: { status: "success" }
81
- };
46
+ return this.readHistory({
47
+ path: `${this.#historyRoot(query.opportunity)}/history/${query.metric}`,
48
+ metric: query.metric,
49
+ range: query.range
50
+ });
51
+ }
52
+ #poolPath(key) {
53
+ return `${this.#root}/pools/${key.chainId}/${key.pool}`;
54
+ }
55
+ #strategyPath(key) {
56
+ return `${this.#root}/strategies/${key.chainId}/${key.creditManager}/${key.targetCollateral}`;
57
+ }
58
+ #historyRoot(key) {
59
+ return key.kind === "pool" ? this.#poolPath(key) : this.#strategyPath(key);
82
60
  }
83
61
  };
84
62
  //#endregion
@@ -1,30 +1,11 @@
1
+ import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
1
2
  //#region src/offchain/positions/OffchainPositions.ts
2
3
  /**
3
4
  * Backend counterpart of the `positions` namespace.
4
- *
5
- * This is a stub: the HTTP client is not written yet, so reads answer with an
6
- * empty payload. Every signature is already the final one, because the backend
7
- * returns the read model types directly — there is no wire DTO and no mapper
8
- * between the two.
9
- *
10
- * When the transport lands, each method will validate the response against the
11
- * matching schema from `src/model` before returning it. A validation failure is
12
- * a version-skew error and is handled exactly like a transport error: the
13
- * combined SDK drops the backend's contribution in `both` mode and rethrows in
14
- * `offchain` mode.
15
5
  **/
16
- var OffchainPositions = class {
17
- #baseUrl;
18
- #logger;
6
+ var OffchainPositions = class extends AbstractOffchainNamespace {
19
7
  constructor(options) {
20
- this.#baseUrl = options?.baseUrl;
21
- this.#logger = options?.logger?.child?.({ name: "OffchainPositions" });
22
- }
23
- /**
24
- * Base URL the client will call once the transport is implemented.
25
- **/
26
- get baseUrl() {
27
- return this.#baseUrl;
8
+ super("OffchainPositions", options);
28
9
  }
29
10
  /**
30
11
  * Everything a wallet holds, optionally narrowed by {@link PositionFilter}.
@@ -32,7 +13,7 @@ var OffchainPositions = class {
32
13
  * @returns An empty list until the backend client is implemented.
33
14
  **/
34
15
  async list(wallet, filter) {
35
- this.#logger?.debug({
16
+ this.logger?.debug({
36
17
  wallet,
37
18
  filter
38
19
  }, "offchain positions list is not implemented, serving empty list");
@@ -53,7 +34,7 @@ var OffchainPositions = class {
53
34
  * @returns An empty series until the backend client is implemented.
54
35
  **/
55
36
  async getHistory(query) {
56
- this.#logger?.debug({ query }, "offchain positions history is not implemented, serving empty series");
37
+ this.logger?.debug({ query }, "offchain positions history is not implemented, serving empty series");
57
38
  return {
58
39
  result: {
59
40
  metric: query.metric,
@@ -13,5 +13,60 @@ var OffchainNotImplementedError = class extends Error {
13
13
  this.name = "OffchainNotImplementedError";
14
14
  }
15
15
  };
16
+ /**
17
+ * Thrown when a read is issued against a client that was never told where the
18
+ * backend is.
19
+ **/
20
+ var OffchainNotConfiguredError = class extends Error {
21
+ constructor(path) {
22
+ super(`GearboxAPI: cannot read ${path}, no baseUrl was configured`);
23
+ this.name = "OffchainNotConfiguredError";
24
+ }
25
+ };
26
+ /**
27
+ * Thrown when the backend could not be reached, or answered with a status
28
+ * outside the 2xx range.
29
+ **/
30
+ var OffchainTransportError = class extends Error {
31
+ /**
32
+ * URL that was requested, query included.
33
+ **/
34
+ url;
35
+ /**
36
+ * Status the backend answered with, absent when the request never completed.
37
+ **/
38
+ status;
39
+ constructor(url, reason, status) {
40
+ super(`GearboxAPI: request to ${url} failed, ${reason}`);
41
+ this.name = "OffchainTransportError";
42
+ this.url = url;
43
+ this.status = status;
44
+ }
45
+ };
46
+ /**
47
+ * Thrown when the backend answered, but with a payload the read model does not
48
+ * describe.
49
+ *
50
+ * This is version skew rather than a bad request, and it is deliberately
51
+ * handled like a transport error: the combined SDK drops the backend's
52
+ * contribution in `both` mode and fails the read in `offchain` mode.
53
+ **/
54
+ var OffchainValidationError = class extends Error {
55
+ /**
56
+ * URL whose payload failed to validate.
57
+ **/
58
+ url;
59
+ /**
60
+ * What did not match, in the order zod reported it.
61
+ **/
62
+ issues;
63
+ constructor(url, issues) {
64
+ const summary = issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`).join("; ");
65
+ super(`GearboxAPI: response from ${url} does not match the model, ${summary}`);
66
+ this.name = "OffchainValidationError";
67
+ this.url = url;
68
+ this.issues = issues;
69
+ }
70
+ };
16
71
  //#endregion
17
- export { OffchainNotImplementedError };
72
+ export { OffchainNotConfiguredError, OffchainNotImplementedError, OffchainTransportError, OffchainValidationError };
@@ -1,5 +1,5 @@
1
- import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
2
1
  import { ierc4626AdapterAbi } from "../../../abi/ierc4626Adapter.js";
2
+ import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
3
3
  import "../../../sdk/index.js";
4
4
  import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
5
5
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
@@ -1,5 +1,5 @@
1
- import { iPoolV310Abi } from "../../abi/310/generated.js";
2
1
  import { iZapperAbi } from "../../abi/iZapper.js";
2
+ import { iPoolV310Abi } from "../../abi/310/generated.js";
3
3
  import { asPreviewSimulationError } from "./errors.js";
4
4
  //#region src/preview/simulate/simulatePoolOperation.ts
5
5
  function previewRead(operation) {
@@ -1,6 +1,6 @@
1
+ import { ierc20Abi } from "../../abi/iERC20.js";
1
2
  import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
2
3
  import { AddressMap } from "../../sdk/utils/AddressMap.js";
3
- import { ierc20Abi } from "../../abi/iERC20.js";
4
4
  import "../../sdk/index.js";
5
5
  import { UnexpectedFacadeEventOrderError } from "./errors.js";
6
6
  import { getAddress, isAddressEqual, parseEventLogs } from "viem";
@@ -1,3 +1,5 @@
1
+ import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
2
+ import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
1
3
  import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
2
4
  import { ADDRESS_0X0 } from "../constants/addresses.js";
3
5
  import { MAX_UINT256 } from "../constants/math.js";
@@ -8,8 +10,6 @@ import "../base/index.js";
8
10
  import { AccountBotsService } from "./bots/AccountBotsService.js";
9
11
  import "./bots/index.js";
10
12
  import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
11
- import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
12
- import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
13
13
  import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
14
14
  import "../market/index.js";
15
15
  import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
@@ -1,3 +1,4 @@
1
+ import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
1
2
  import { AddressSet } from "../../utils/AddressSet.js";
2
3
  import { bytes32ToString } from "../../utils/bytes32ToString.js";
3
4
  import { ADDRESS_0X0 } from "../../constants/addresses.js";
@@ -19,7 +20,6 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
19
20
  import "../../market/rwa/securitize/index.js";
20
21
  import "../../market/index.js";
21
22
  import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
22
- import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
23
23
  //#region src/sdk/accounts/liquidations/LiquidationsService.ts
24
24
  /**
25
25
  * Service for discovering liquidatable credit accounts and previewing manual
@@ -1,7 +1,7 @@
1
+ import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
4
  import { decodeDelayedIntent } from "./intent-codec.js";
4
- import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
5
5
  import { InvalidDelayedIntentError } from "./errors.js";
6
6
  //#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
7
7
  const abi = iRedemptionLoggerV310Abi;
@@ -1,5 +1,5 @@
1
- import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
1
  import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
2
+ import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
3
3
  //#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
4
4
  const abi = iWithdrawalCompressorV310Abi;
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
1
  import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
2
+ import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
3
3
  //#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
4
4
  const abi = iWithdrawalCompressorV311Abi;
5
5
  /**
@@ -1,6 +1,6 @@
1
+ import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
1
2
  import { encodeDelayedIntent } from "./intent-codec.js";
2
3
  import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
3
- import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
4
4
  import { toWithdrawalStatus } from "./types.js";
5
5
  //#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
6
6
  const abi = iWithdrawalCompressorV313Abi;
@@ -1,11 +1,11 @@
1
+ import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
2
+ import { iVersionAbi } from "../../abi/iVersion.js";
1
3
  import { AddressMap } from "../utils/AddressMap.js";
2
4
  import { AddressSet } from "../utils/AddressSet.js";
3
5
  import { bytes32ToString } from "../utils/bytes32ToString.js";
4
6
  import { getAssetType } from "../chain/chains.js";
5
7
  import { formatBN } from "../utils/formatter.js";
6
8
  import "../utils/index.js";
7
- import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
8
- import { iVersionAbi } from "../../abi/iVersion.js";
9
9
  //#region src/sdk/base/TokensMeta.ts
10
10
  /**
11
11
  * Registry of token metadata (symbol, decimals, phantom type) keyed by address.
@@ -1,5 +1,5 @@
1
- import { chains } from "./chains.js";
2
1
  import { ierc20Abi } from "../../abi/iERC20.js";
2
+ import { chains } from "./chains.js";
3
3
  //#region src/sdk/chain/detectNetwork.ts
4
4
  /**
5
5
  * Detects the network type from the given client.
@@ -1,8 +1,8 @@
1
+ import { iVersionAbi } from "../../abi/iVersion.js";
1
2
  import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
2
3
  import { isV310 } from "../constants/versions.js";
3
4
  import "../constants/index.js";
4
5
  import { hexEq } from "../utils/hex.js";
5
- import { iVersionAbi } from "../../abi/iVersion.js";
6
6
  import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
7
7
  //#region src/sdk/core/createAddressProvider.ts
8
8
  const OVERRIDE_ADDRESSES = { Mainnet: {
@@ -1,7 +1,7 @@
1
+ import { iPausableAbi } from "../../../abi/iPausable.js";
1
2
  import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
2
3
  import { BaseContract } from "../../base/BaseContract.js";
3
4
  import "../../base/index.js";
4
- import { iPausableAbi } from "../../../abi/iPausable.js";
5
5
  //#region src/sdk/market/credit/CreditFacadeV310BaseContract.ts
6
6
  const abi = [
7
7
  ...iCreditFacadeV310Abi,
@@ -1,3 +1,4 @@
1
+ import { iPausableAbi } from "../../../abi/iPausable.js";
1
2
  import { iPoolV310Abi } from "../../../abi/310/generated.js";
2
3
  import { AddressMap } from "../../utils/AddressMap.js";
3
4
  import { RAY } from "../../constants/math.js";
@@ -6,7 +7,6 @@ import { formatBN, formatBNvalue, percentFmt } from "../../utils/formatter.js";
6
7
  import "../../utils/index.js";
7
8
  import { BaseContract } from "../../base/BaseContract.js";
8
9
  import "../../base/index.js";
9
- import { iPausableAbi } from "../../../abi/iPausable.js";
10
10
  import { utilizationBps } from "../math.js";
11
11
  //#region src/sdk/market/pool/PoolV310Contract.ts
12
12
  const abi = [...iPoolV310Abi, ...iPausableAbi];
@@ -1,5 +1,5 @@
1
- import { ZapperContract } from "./ZapperContract.js";
2
1
  import { iethZapperAbi } from "../../../abi/iETHZapper.js";
2
+ import { ZapperContract } from "./ZapperContract.js";
3
3
  //#region src/sdk/market/zapper/IETHZapperContract.ts
4
4
  const abi = iethZapperAbi;
5
5
  var IETHZapperContract = class extends ZapperContract {
@@ -1,6 +1,6 @@
1
+ import { iZapperAbi } from "../../../abi/iZapper.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
- import { iZapperAbi } from "../../../abi/iZapper.js";
4
4
  import { UnsupportedZapperFunctionError } from "./errors.js";
5
5
  //#region src/sdk/market/zapper/ZapperContract.ts
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { AddressSet } from "../utils/AddressSet.js";
2
1
  import { ierc20Abi } from "../../abi/iERC20.js";
2
+ import { AddressSet } from "../utils/AddressSet.js";
3
3
  import "../constants/addresses.js";
4
4
  import { RAY } from "../constants/math.js";
5
5
  import "../constants/index.js";
@@ -1,6 +1,6 @@
1
1
  import { errorAbis } from "../../../abi/errors.js";
2
- import { generateCastTraceCall } from "./cast.js";
3
2
  import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
3
+ import { generateCastTraceCall } from "./cast.js";
4
4
  import { simulateMulticall } from "./simulateMulticall.js";
5
5
  import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
6
6
  import { getAction, parseAccount } from "viem/utils";
@@ -12,5 +12,9 @@ declare const filterAllSchema: z.ZodLiteral<"all">;
12
12
  * {@link Filterable}
13
13
  **/
14
14
  declare function filterable<T extends z.ZodType>(schema: T): z.ZodUnion<[T, typeof filterAllSchema]>;
15
+ declare const booleanParamSchema: z.ZodEnum<{
16
+ false: "false";
17
+ true: "true";
18
+ }>;
15
19
  //#endregion
16
- export { filterAllSchema, filterable };
20
+ export { booleanParamSchema, filterAllSchema, filterable };
@@ -2,14 +2,14 @@ import { Curator, CuratorName } from "./curators.js";
2
2
  import { Amount, AssetType, Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, TxCall } from "./primitives.js";
3
3
  import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
4
4
  import { FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
5
- import { filterAllSchema, filterable } from "./filters.schema.js";
5
+ import { booleanParamSchema, filterAllSchema, filterable } from "./filters.schema.js";
6
6
  import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
7
7
  import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
8
8
  import { PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, RewardsPnL, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
9
9
  import { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, OpportunityHistoryQuery, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PoolHistoryMetric, PoolPositionHistoryMetric, PositionHistoryMetric, PositionHistoryQuery, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyPositionHistoryMetric } from "./history.js";
10
10
  import { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, poolPositionHistoryMetricSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, strategyHistoryMetricSchema, strategyPositionHistoryMetricSchema } from "./history.schema.js";
11
11
  import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
12
- import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
12
+ import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
13
13
  import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
14
14
  import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
15
- export { Amount, ApyBreakdown, AssetType, Bps, ChainId, Curator, CuratorName, DelayedReceivedAsset, FILTER_ALL, FilterAll, Filterable, HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityHistoryQuery, OpportunityId, OpportunityKey, OpportunityKind, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolHistoryMetric, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionHistoryMetric, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionHistoryMetric, PositionHistoryQuery, PositionId, PositionKey, PositionKind, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, Rewards, RewardsPnL, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionHistoryMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorNameSchema, curatorSchema, delayedReceivedAssetSchema, filterAllSchema, filterable, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
15
+ export { Amount, ApyBreakdown, AssetType, Bps, ChainId, Curator, CuratorName, DelayedReceivedAsset, FILTER_ALL, FilterAll, Filterable, HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityHistoryQuery, OpportunityId, OpportunityKey, OpportunityKind, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolHistoryMetric, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionHistoryMetric, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionHistoryMetric, PositionHistoryQuery, PositionId, PositionKey, PositionKind, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, Rewards, RewardsPnL, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionHistoryMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, booleanParamSchema, bpsSchema, chainIdSchema, curatorNameSchema, curatorSchema, delayedReceivedAssetSchema, filterAllSchema, filterable, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };