@gearbox-protocol/sdk 16.0.0-next.43 → 16.0.0-next.45

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 (88) hide show
  1. package/dist/cjs/onchain/accounts/index.js +0 -2
  2. package/dist/cjs/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +13 -7
  3. package/dist/cjs/onchain/accounts/withdrawal-compressor/errors.js +0 -19
  4. package/dist/cjs/onchain/accounts/withdrawal-compressor/index.js +1 -2
  5. package/dist/cjs/onchain/index.js +0 -4
  6. package/dist/cjs/onchain/market/adapters/contracts/BalancerV3RouterAdapterContract.js +33 -1
  7. package/dist/cjs/onchain/market/index.js +0 -2
  8. package/dist/cjs/onchain/market/zapper/ZapperContract.js +15 -8
  9. package/dist/cjs/onchain/market/zapper/errors.js +0 -18
  10. package/dist/cjs/onchain/market/zapper/index.js +1 -2
  11. package/dist/cjs/onchain/validation/checks.js +1 -1
  12. package/dist/cjs/preview/index.js +1 -10
  13. package/dist/cjs/preview/parse/errors.js +0 -35
  14. package/dist/cjs/preview/parse/index.js +1 -5
  15. package/dist/cjs/preview/parse/parseOperationCalldata.js +28 -17
  16. package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +17 -11
  17. package/dist/cjs/preview/prerequisites/checkPrerequisites.js +5 -2
  18. package/dist/cjs/preview/preview/detectDelayedClaim.js +9 -7
  19. package/dist/cjs/preview/preview/detectDelayedOperation.js +11 -4
  20. package/dist/cjs/preview/preview/errors.js +0 -17
  21. package/dist/cjs/preview/preview/index.js +1 -2
  22. package/dist/cjs/preview/preview/previewOperation.js +30 -42
  23. package/dist/cjs/preview/preview/previewPoolPositionOperation.js +7 -3
  24. package/dist/cjs/preview/simulate/errors.js +13 -23
  25. package/dist/cjs/preview/simulate/index.js +1 -1
  26. package/dist/cjs/preview/simulate/simulateOperation.js +6 -4
  27. package/dist/cjs/preview/simulate/simulatePoolOperation.js +6 -3
  28. package/dist/esm/onchain/accounts/index.js +1 -2
  29. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +13 -7
  30. package/dist/esm/onchain/accounts/withdrawal-compressor/errors.js +1 -19
  31. package/dist/esm/onchain/accounts/withdrawal-compressor/index.js +2 -2
  32. package/dist/esm/onchain/index.js +1 -3
  33. package/dist/esm/onchain/market/adapters/contracts/BalancerV3RouterAdapterContract.js +33 -1
  34. package/dist/esm/onchain/market/index.js +1 -2
  35. package/dist/esm/onchain/market/zapper/ZapperContract.js +15 -8
  36. package/dist/esm/onchain/market/zapper/errors.js +1 -18
  37. package/dist/esm/onchain/market/zapper/index.js +2 -2
  38. package/dist/esm/onchain/validation/checks.js +1 -1
  39. package/dist/esm/preview/index.js +2 -6
  40. package/dist/esm/preview/parse/errors.js +1 -33
  41. package/dist/esm/preview/parse/index.js +2 -3
  42. package/dist/esm/preview/parse/parseOperationCalldata.js +28 -17
  43. package/dist/esm/preview/parse/parsePoolOperationCalldata.js +17 -11
  44. package/dist/esm/preview/prerequisites/checkPrerequisites.js +5 -2
  45. package/dist/esm/preview/preview/detectDelayedClaim.js +9 -7
  46. package/dist/esm/preview/preview/detectDelayedOperation.js +11 -4
  47. package/dist/esm/preview/preview/errors.js +1 -17
  48. package/dist/esm/preview/preview/index.js +2 -2
  49. package/dist/esm/preview/preview/previewOperation.js +31 -43
  50. package/dist/esm/preview/preview/previewPoolPositionOperation.js +7 -3
  51. package/dist/esm/preview/simulate/errors.js +14 -23
  52. package/dist/esm/preview/simulate/index.js +2 -2
  53. package/dist/esm/preview/simulate/simulateOperation.js +6 -4
  54. package/dist/esm/preview/simulate/simulatePoolOperation.js +6 -3
  55. package/dist/types/model/errors.d.ts +1 -1
  56. package/dist/types/onchain/accounts/index.d.ts +1 -1
  57. package/dist/types/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +6 -4
  58. package/dist/types/onchain/accounts/withdrawal-compressor/errors.d.ts +2 -11
  59. package/dist/types/onchain/accounts/withdrawal-compressor/index.d.ts +1 -1
  60. package/dist/types/onchain/accounts/withdrawal-compressor/types.d.ts +6 -4
  61. package/dist/types/onchain/index.d.ts +2 -2
  62. package/dist/types/onchain/market/index.d.ts +1 -1
  63. package/dist/types/onchain/market/zapper/ZapperContract.d.ts +7 -3
  64. package/dist/types/onchain/market/zapper/errors.d.ts +1 -10
  65. package/dist/types/onchain/market/zapper/index.d.ts +1 -1
  66. package/dist/types/onchain/market/zapper/types.d.ts +4 -1
  67. package/dist/types/onchain/validation/checks.d.ts +1 -1
  68. package/dist/types/preview/index.d.ts +4 -4
  69. package/dist/types/preview/parse/errors.d.ts +3 -21
  70. package/dist/types/preview/parse/index.d.ts +1 -1
  71. package/dist/types/preview/parse/parseOperationCalldata.d.ts +5 -1
  72. package/dist/types/preview/parse/parsePoolOperationCalldata.d.ts +5 -2
  73. package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +6 -1
  74. package/dist/types/preview/preview/detectDelayedClaim.d.ts +7 -6
  75. package/dist/types/preview/preview/detectDelayedOperation.d.ts +3 -1
  76. package/dist/types/preview/preview/errors.d.ts +1 -10
  77. package/dist/types/preview/preview/index.d.ts +2 -2
  78. package/dist/types/preview/preview/previewOperation.d.ts +10 -10
  79. package/dist/types/preview/preview/previewPoolPositionOperation.d.ts +3 -1
  80. package/dist/types/preview/simulate/errors.d.ts +2 -11
  81. package/dist/types/preview/simulate/index.d.ts +2 -2
  82. package/dist/types/preview/simulate/simulateOperation.d.ts +4 -1
  83. package/dist/types/preview/simulate/simulatePoolOperation.d.ts +4 -1
  84. package/dist/types/sdk/prepare/errors.d.ts +1 -1
  85. package/dist/types/sdk/preview/PreviewNamespace.d.ts +2 -2
  86. package/dist/types/sdk/preview/types.d.ts +3 -3
  87. package/dist/types/sdk/types.d.ts +1 -3
  88. package/package.json +1 -1
@@ -1,35 +1,26 @@
1
1
  import { errorAbis } from "../../abi/errors.js";
2
2
  import { BaseError, ContractFunctionRevertedError, decodeErrorResult } from "viem";
3
3
  //#region src/preview/simulate/errors.ts
4
- function previewSimulationFailed(failures) {
5
- const message = failures.length <= 1 ? failures[0]?.detail.reason ?? "simulation failed" : "all simulation flows failed";
6
- const cause = failures.find((f) => f.detail.cause instanceof Error)?.detail.cause;
7
- const verdict = {
8
- code: "previewSimulationFailed",
9
- message,
10
- failures
11
- };
12
- if (cause) verdict.cause = cause;
13
- return verdict;
4
+ function isPreviewSimulationError(value) {
5
+ return typeof value === "object" && value !== null && !(value instanceof Error) && value.code === "previewSimulationFailed";
14
6
  }
15
- Object.defineProperty(previewSimulationFailed, Symbol.hasInstance, { value: (value) => typeof value === "object" && value !== null && value.code === "previewSimulationFailed" });
16
- /**
17
- * Builds the verdict. Callable with or without `new`, so pre-declassing raise
18
- * sites keep compiling; `instanceof` matches on the `code` discriminant, and
19
- * the answer is never an `Error`.
20
- */
21
- const PreviewSimulationError = previewSimulationFailed;
22
7
  /**
23
8
  * Normalises an unknown rejection reason into a {@link PreviewSimulationError}.
24
9
  * Pass-through when it already is one; otherwise decodes it under `source`.
25
10
  */
26
11
  function asPreviewSimulationError(reason, source) {
27
- if (reason instanceof PreviewSimulationError) return reason;
12
+ if (isPreviewSimulationError(reason)) return reason;
28
13
  const error = reason instanceof Error ? reason : new Error(String(reason));
29
- return new PreviewSimulationError([{
30
- source,
31
- detail: decodeSimulationError({ error })
32
- }]);
14
+ const detail = decodeSimulationError({ error });
15
+ return {
16
+ code: "previewSimulationFailed",
17
+ message: detail.reason,
18
+ failures: [{
19
+ source,
20
+ detail
21
+ }],
22
+ cause: error
23
+ };
33
24
  }
34
25
  /**
35
26
  * Decodes a simulated call revert into a {@link SimulationError}.
@@ -77,4 +68,4 @@ function formatDecodedError(errorName, args) {
77
68
  return `${errorName}(${args.map((arg) => String(arg)).join(", ")})`;
78
69
  }
79
70
  //#endregion
80
- export { PreviewSimulationError, asPreviewSimulationError, decodeSimulationError };
71
+ export { asPreviewSimulationError, decodeSimulationError };
@@ -1,6 +1,6 @@
1
- import { PreviewSimulationError } from "./errors.js";
1
+ import { asPreviewSimulationError } from "./errors.js";
2
2
  import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
3
3
  import { simulatePoolOperation } from "./simulatePoolOperation.js";
4
4
  import { simulateRWAOperation } from "./simulateRWAOperation.js";
5
5
  import { simulateOperation } from "./simulateOperation.js";
6
- export { PreviewSimulationError, simulateFacadeOperation, simulateOperation, simulatePoolOperation, simulateRWAOperation };
6
+ export { asPreviewSimulationError, simulateFacadeOperation, simulateOperation, simulatePoolOperation, simulateRWAOperation };
@@ -1,3 +1,5 @@
1
+ import { sdkOk } from "../../model/result.js";
2
+ import "../../model/index.js";
1
3
  import { isPoolOperation, isRWAOperation } from "../parse/types.js";
2
4
  import "../parse/index.js";
3
5
  import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
@@ -13,14 +15,14 @@ async function simulateOperation(input, options) {
13
15
  ...input,
14
16
  operation
15
17
  }, options);
16
- if (isRWAOperation(operation)) return simulateRWAOperation({
18
+ if (isRWAOperation(operation)) return sdkOk(await simulateRWAOperation({
17
19
  ...input,
18
20
  operation
19
- }, options);
20
- return simulateFacadeOperation({
21
+ }, options));
22
+ return sdkOk(await simulateFacadeOperation({
21
23
  ...input,
22
24
  operation
23
- }, options);
25
+ }, options));
24
26
  }
25
27
  //#endregion
26
28
  export { simulateOperation };
@@ -1,5 +1,7 @@
1
1
  import { iZapperAbi } from "../../abi/iZapper.js";
2
2
  import { iPoolV310Abi } from "../../abi/310/generated.js";
3
+ import { sdkErr, sdkOk } from "../../model/result.js";
4
+ import "../../model/index.js";
3
5
  import { asPreviewSimulationError } from "./errors.js";
4
6
  //#region src/preview/simulate/simulatePoolOperation.ts
5
7
  function previewRead(operation) {
@@ -89,14 +91,15 @@ async function simulatePoolOperation(input, options = {}) {
89
91
  const { sdk, operation } = input;
90
92
  const { blockNumber, logger } = options;
91
93
  try {
92
- return amountsInOut(operation, await sdk.client.readContract({
94
+ const previewAmount = await sdk.client.readContract({
93
95
  blockNumber,
94
96
  ...previewContract(operation)
95
- }));
97
+ });
98
+ return sdkOk(amountsInOut(operation, previewAmount));
96
99
  } catch (cause) {
97
100
  const error = asPreviewSimulationError(cause, "multicall");
98
101
  logger?.error(error, "pool operation simulation failed");
99
- throw error;
102
+ return sdkErr(error);
100
103
  }
101
104
  }
102
105
  //#endregion
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * A thrown exception still means what it always did: the SDK could not do its
12
12
  * job (a read failed, a contract reverted unexpectedly, an argument is wrong).
13
- * Those are bugs and outages, not verdicts on the request.
13
+ * Those are bugs and outages, not refusals of the request.
14
14
  **/
15
15
  /**
16
16
  * What every error the SDK reports has.
@@ -1,3 +1,4 @@
1
+ import { InvalidDelayedIntentError } from "./withdrawal-compressor/errors.js";
1
2
  import { ClaimableWithdrawal, CurrentWithdrawals, DelayedIntentExtended, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./withdrawal-compressor/types.js";
2
3
  import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions } from "./credit-account-compressor/types.js";
3
4
  import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
@@ -7,7 +8,6 @@ import { AbstractWithdrawalCompressorContract, OnchainRequestableWithdrawal, iCr
7
8
  import { WithdrawalCompressorLocation, WithdrawalCompressorVersion, getWithdrawalCompressorAddress } from "./withdrawal-compressor/addresses.js";
8
9
  import { createRedemptionLogger } from "./withdrawal-compressor/createRedemptionLogger.js";
9
10
  import { createWithdrawalCompressor } from "./withdrawal-compressor/createWithdrawalCompressor.js";
10
- import { InvalidDelayedIntentError } from "./withdrawal-compressor/errors.js";
11
11
  import { DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, decodeDelayedIntent, encodeDelayedIntent } from "./withdrawal-compressor/intent-codec.js";
12
12
  import { RedemptionLoggerV310Contract } from "./withdrawal-compressor/RedemptionLoggerV310Contract.js";
13
13
  import { WithdrawalCompressorV310Contract } from "./withdrawal-compressor/WithdrawalCompressorV310Contract.js";
@@ -1,5 +1,7 @@
1
1
  import { DelayedIntent } from "../../../model/delayed-intents.js";
2
+ import { SDKReturn } from "../../../model/result.js";
2
3
  import "../../../model/index.js";
4
+ import { InvalidDelayedIntentError } from "./errors.js";
3
5
  import { IRedemptionLoggerContract, RedemptionLog } from "./types.js";
4
6
  import { OnchainSDK } from "../../OnchainSDK.js";
5
7
  import { BaseContract } from "../../base/BaseContract.js";
@@ -143,12 +145,12 @@ declare class RedemptionLoggerV310Contract extends BaseContract<abi> implements
143
145
  *
144
146
  * @param redeemer - Redeemer contract the withdrawal is claimed from.
145
147
  * @param blockNumber - Optional block number to read the log at.
146
- * @returns The decoded intent, or `undefined` when the log carries none
147
- * (including when nothing was logged for the redeemer).
148
- * @throws InvalidDelayedIntentError when the logged `extraData` is
148
+ * @returns The decoded intent behind `ok` (`undefined` when the log
149
+ * carries none, including when nothing was logged for the redeemer), or
150
+ * the `invalidDelayedIntent` refusal when the logged `extraData` is
149
151
  * non-empty but cannot be decoded as a `DelayedIntent`.
150
152
  **/
151
- getDelayedIntent(redeemer: Address, blockNumber?: bigint): Promise<DelayedIntent | undefined>;
153
+ getDelayedIntent(redeemer: Address, blockNumber?: bigint): Promise<SDKReturn<DelayedIntent | undefined, InvalidDelayedIntentError>>;
152
154
  }
153
155
  //#endregion
154
156
  export { RedemptionLoggerV310Contract };
@@ -3,7 +3,7 @@ import "../../../model/index.js";
3
3
  import { Hex } from "viem";
4
4
  //#region src/onchain/accounts/withdrawal-compressor/errors.d.ts
5
5
  /**
6
- * Verdict answered when a delayed-withdrawal request or redemption log carries
6
+ * Refusal answered when a delayed-withdrawal request or redemption log carries
7
7
  * non-empty `extraData` that cannot be decoded as a `DelayedIntent`.
8
8
  * Requests produced by our stack always encode a valid intent, so garbage
9
9
  * here means a malformed/foreign transaction that must not be previewed as
@@ -13,17 +13,8 @@ interface InvalidDelayedIntentError extends IGearboxError {
13
13
  code: "invalidDelayedIntent";
14
14
  /** Raw `extraData` that failed to decode. */
15
15
  extraData: Hex;
16
- /** The decoding failure this verdict stands in front of. */
16
+ /** The decoding failure this refusal stands in front of. */
17
17
  cause?: Error;
18
18
  }
19
- /**
20
- * Builds the verdict. Callable with or without `new`, so pre-declassing raise
21
- * sites keep compiling; `instanceof` matches on the `code` discriminant, and
22
- * the answer is never an `Error`.
23
- */
24
- declare const InvalidDelayedIntentError: {
25
- (extraData: Hex, cause?: unknown): InvalidDelayedIntentError;
26
- new (extraData: Hex, cause?: unknown): InvalidDelayedIntentError;
27
- };
28
19
  //#endregion
29
20
  export { InvalidDelayedIntentError };
@@ -1,9 +1,9 @@
1
+ import { InvalidDelayedIntentError } from "./errors.js";
1
2
  import { ClaimableWithdrawal, CurrentWithdrawals, DelayedIntentExtended, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./types.js";
2
3
  import { AbstractWithdrawalCompressorContract, OnchainRequestableWithdrawal, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
3
4
  import { WithdrawalCompressorLocation, WithdrawalCompressorVersion, getWithdrawalCompressorAddress } from "./addresses.js";
4
5
  import { createRedemptionLogger } from "./createRedemptionLogger.js";
5
6
  import { createWithdrawalCompressor } from "./createWithdrawalCompressor.js";
6
- import { InvalidDelayedIntentError } from "./errors.js";
7
7
  import { DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, decodeDelayedIntent, encodeDelayedIntent } from "./intent-codec.js";
8
8
  import { RedemptionLoggerV310Contract } from "./RedemptionLoggerV310Contract.js";
9
9
  import { WithdrawalCompressorV310Contract } from "./WithdrawalCompressorV310Contract.js";
@@ -1,7 +1,9 @@
1
1
  import { DelayedIntent } from "../../../model/delayed-intents.js";
2
+ import { SDKReturn } from "../../../model/result.js";
2
3
  import "../../../model/index.js";
3
4
  import { MulticallBatch } from "../../utils/viem/executeMulticallBatches.js";
4
5
  import "../../utils/viem/index.js";
6
+ import { InvalidDelayedIntentError } from "./errors.js";
5
7
  import { IBaseContract } from "../../base/types.js";
6
8
  import { MultiCall } from "../../types/transactions.js";
7
9
  import "../../types/index.js";
@@ -400,11 +402,11 @@ interface IRedemptionLoggerContract extends IBaseContract {
400
402
  * @param redeemer - Redeemer contract the withdrawal is claimed from.
401
403
  * @param blockNumber - Optional block number to read the log at.
402
404
  * @returns The decoded intent, or `undefined` when the log carries none
403
- * (including when nothing was logged for the redeemer).
404
- * @throws InvalidDelayedIntentError when the logged `extraData` is
405
- * non-empty but cannot be decoded as a `DelayedIntent`.
405
+ * (including when nothing was logged for the redeemer), behind `ok`; the
406
+ * `invalidDelayedIntent` refusal when the logged `extraData` is non-empty
407
+ * but cannot be decoded as a `DelayedIntent`.
406
408
  **/
407
- getDelayedIntent(redeemer: Address, blockNumber?: bigint): Promise<DelayedIntent | undefined>;
409
+ getDelayedIntent(redeemer: Address, blockNumber?: bigint): Promise<SDKReturn<DelayedIntent | undefined, InvalidDelayedIntentError>>;
408
410
  }
409
411
  //#endregion
410
412
  export { ClaimableWithdrawal, CurrentWithdrawals, DelayedIntentExtended, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus };
@@ -12,6 +12,7 @@ import { SimulateMulticallParameters, SimulateMulticallReturnType, simulateMulti
12
12
  import { SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, getSimulateWithPriceUpdatesError, simulateWithPriceUpdates } from "./utils/viem/simulateWithPriceUpdates.js";
13
13
  import { WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, watchBlocksAsync } from "./utils/viem/watchBlocksAsync.js";
14
14
  import "./utils/viem/index.js";
15
+ import { InvalidDelayedIntentError } from "./accounts/withdrawal-compressor/errors.js";
15
16
  import { ClaimableWithdrawal, CurrentWithdrawals, DelayedIntentExtended, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./accounts/withdrawal-compressor/types.js";
16
17
  import { detectNetwork } from "./chain/detectNetwork.js";
17
18
  import "./chain/index.js";
@@ -176,9 +177,9 @@ import { CreditSuite } from "./market/credit/CreditSuite.js";
176
177
  import { StrategyCollateralProps, dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./market/credit/collateralUtils.js";
177
178
  import { ExpectedBalanceDeltasProps, ExpectedOutput, expectedBalanceDeltas } from "./market/credit/expectedBalanceDeltas.js";
178
179
  import { CompressorZapperData, ZapperData } from "./market/types.js";
180
+ import { UnsupportedZapperFunctionError } from "./market/zapper/errors.js";
179
181
  import { IZapperContract, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem } from "./market/zapper/types.js";
180
182
  import { createZapper } from "./market/zapper/createZapper.js";
181
- import { UnsupportedZapperFunctionError } from "./market/zapper/errors.js";
182
183
  import { ZapperContract } from "./market/zapper/ZapperContract.js";
183
184
  import { IERC20ZapperContract } from "./market/zapper/IERC20ZapperContract.js";
184
185
  import { IETHZapperContract } from "./market/zapper/IETHZapperContract.js";
@@ -243,7 +244,6 @@ import { AbstractWithdrawalCompressorContract, OnchainRequestableWithdrawal, iCr
243
244
  import { WithdrawalCompressorLocation, WithdrawalCompressorVersion, getWithdrawalCompressorAddress } from "./accounts/withdrawal-compressor/addresses.js";
244
245
  import { createRedemptionLogger } from "./accounts/withdrawal-compressor/createRedemptionLogger.js";
245
246
  import { createWithdrawalCompressor } from "./accounts/withdrawal-compressor/createWithdrawalCompressor.js";
246
- import { InvalidDelayedIntentError } from "./accounts/withdrawal-compressor/errors.js";
247
247
  import { DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, decodeDelayedIntent, encodeDelayedIntent } from "./accounts/withdrawal-compressor/intent-codec.js";
248
248
  import { RedemptionLoggerV310Contract } from "./accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js";
249
249
  import { WithdrawalCompressorV310Contract } from "./accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js";
@@ -142,9 +142,9 @@ import { StrategyCollateralProps, dominantCollateral, isStrategyCollateral, pick
142
142
  import { ExpectedBalanceDeltasProps, ExpectedOutput, expectedBalanceDeltas } from "./credit/expectedBalanceDeltas.js";
143
143
  import "./credit/index.js";
144
144
  import { CompressorZapperData, ZapperData } from "./types.js";
145
+ import { UnsupportedZapperFunctionError } from "./zapper/errors.js";
145
146
  import { IZapperContract, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem } from "./zapper/types.js";
146
147
  import { createZapper } from "./zapper/createZapper.js";
147
- import { UnsupportedZapperFunctionError } from "./zapper/errors.js";
148
148
  import { ZapperContract } from "./zapper/ZapperContract.js";
149
149
  import { IERC20ZapperContract } from "./zapper/IERC20ZapperContract.js";
150
150
  import { IETHZapperContract } from "./zapper/IETHZapperContract.js";
@@ -1,4 +1,7 @@
1
+ import { SDKReturn } from "../../../model/result.js";
2
+ import "../../../model/index.js";
1
3
  import { ZapperData } from "../types.js";
4
+ import { UnsupportedZapperFunctionError } from "./errors.js";
2
5
  import { IZapperContract, ParsedZapperOperation } from "./types.js";
3
6
  import { RawTx } from "../../types/transactions.js";
4
7
  import { OnchainSDK } from "../../OnchainSDK.js";
@@ -22,10 +25,11 @@ declare class ZapperContract<A extends Abi = Abi> extends BaseContract<A> implem
22
25
  readonly tokenOut: ZapperData["tokenOut"];
23
26
  constructor(sdk: OnchainSDK, data: ZapperData, abi?: A, namePrefix?: string);
24
27
  /**
25
- * Decodes zapper calldata into {@link ParsedZapperOperation}.
26
- * Throws {@link UnsupportedZapperFunctionError} for unknown selectors.
28
+ * Decodes zapper calldata into {@link ParsedZapperOperation} behind `ok`,
29
+ * or refuses with {@link UnsupportedZapperFunctionError} for unknown
30
+ * selectors.
27
31
  */
28
- parseOperation(calldata: Hex, value?: bigint): ParsedZapperOperation;
32
+ parseOperation(calldata: Hex, value?: bigint): SDKReturn<ParsedZapperOperation, UnsupportedZapperFunctionError>;
29
33
  /**
30
34
  * Redeems pool shares (diesel tokens) for the underlying asset via this zapper.
31
35
  */
@@ -3,7 +3,7 @@ import "../../../model/index.js";
3
3
  import { Address } from "viem";
4
4
  //#region src/onchain/market/zapper/errors.d.ts
5
5
  /**
6
- * Verdict answered when a zapper call uses a function other than a known
6
+ * Refusal answered when a zapper call uses a function other than a known
7
7
  * `deposit`/`redeem` variant. A plain returned object per the SDK's refusal
8
8
  * vocabulary — not a thrown `Error`.
9
9
  */
@@ -14,14 +14,5 @@ interface UnsupportedZapperFunctionError extends IGearboxError {
14
14
  /** Decoded function name the SDK cannot preview. */
15
15
  functionName: string;
16
16
  }
17
- /**
18
- * Builds the verdict. Callable with or without `new`, so pre-declassing raise
19
- * sites keep compiling; `instanceof` matches on the `code` discriminant, and
20
- * the answer is never an `Error`.
21
- */
22
- declare const UnsupportedZapperFunctionError: {
23
- (zapper: Address, functionName: string): UnsupportedZapperFunctionError;
24
- new (zapper: Address, functionName: string): UnsupportedZapperFunctionError;
25
- };
26
17
  //#endregion
27
18
  export { UnsupportedZapperFunctionError };
@@ -1,6 +1,6 @@
1
+ import { UnsupportedZapperFunctionError } from "./errors.js";
1
2
  import { IZapperContract, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem } from "./types.js";
2
3
  import { createZapper } from "./createZapper.js";
3
- import { UnsupportedZapperFunctionError } from "./errors.js";
4
4
  import { ZapperContract } from "./ZapperContract.js";
5
5
  import { IERC20ZapperContract } from "./IERC20ZapperContract.js";
6
6
  import { IETHZapperContract } from "./IETHZapperContract.js";
@@ -1,5 +1,8 @@
1
+ import { SDKReturn } from "../../../model/result.js";
2
+ import "../../../model/index.js";
1
3
  import { IBaseContract } from "../../base/types.js";
2
4
  import { ZapperData } from "../types.js";
5
+ import { UnsupportedZapperFunctionError } from "./errors.js";
3
6
  import { RawTx } from "../../types/transactions.js";
4
7
  import "../../types/index.js";
5
8
  import "../../base/index.js";
@@ -54,7 +57,7 @@ interface IZapperContract extends IBaseContract, ZapperData {
54
57
  * @param calldata - Raw ABI-encoded calldata sent to the zapper.
55
58
  * @param value - Transaction `msg.value`, used for native-token deposits.
56
59
  */
57
- parseOperation(calldata: Hex, value?: bigint): ParsedZapperOperation;
60
+ parseOperation(calldata: Hex, value?: bigint): SDKReturn<ParsedZapperOperation, UnsupportedZapperFunctionError>;
58
61
  /**
59
62
  * Redeems pool shares (diesel tokens) for the underlying asset via this zapper.
60
63
  */
@@ -4,7 +4,7 @@ import { BorrowLimitBinding, PreviewIssue } from "./refusal.js";
4
4
  import { Address } from "viem";
5
5
  //#region src/onchain/validation/checks.d.ts
6
6
  /**
7
- * Every verdict the protocol can pass on an operation, as values.
7
+ * Every refusal the protocol can pass on an operation, as values.
8
8
  *
9
9
  * Each check is handed the numbers it compares — never a suite, a market or an
10
10
  * SDK — so the engine, `checkOperation` and the strategy lists share one
@@ -1,5 +1,5 @@
1
- import { UnsupportedZapperFunctionError } from "../onchain/market/zapper/errors.js";
2
1
  import { InvalidDelayedIntentError } from "../onchain/accounts/withdrawal-compressor/errors.js";
2
+ import { UnsupportedZapperFunctionError } from "../onchain/market/zapper/errors.js";
3
3
  import { BorrowLimitBinding, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, raise, refuse } from "../onchain/validation/refusal.js";
4
4
  import { AdapterOperation, AdapterOperationBase, TokenTransfer, TraceAdapterExt } from "./parse/types-adapters.js";
5
5
  import { AddCollateralOp, CloseCreditAccountOperation, CompareBalancesOp, CreditAccountOperation, DecreaseDebtOp, DirectTokenTransferOperation, FacadeOperationMetadata, IncreaseDebtOp, InnerFacadeOperation, InnerOperation, LiquidateCreditAccountOperation, MulticallOperation, OpenCreditAccountOperation, OperationMetadata, OuterFacadeOperation, PartialLiquidationOperation, StoreExpectedBalancesOp, UpdateQuotaOp, WithdrawCollateralOp } from "./parse/types-facades.js";
@@ -36,12 +36,12 @@ import { UnsupportedOperationError } from "./preview/errors.js";
36
36
  import { estimateClaimableAt } from "./preview/estimateClaimableAt.js";
37
37
  import { previewAdjustStrategyPosition } from "./preview/previewAdjustStrategyPosition.js";
38
38
  import { CloseOrRepayOperation, previewExitOrRepayStrategyPosition } from "./preview/previewExitOrRepayStrategyPosition.js";
39
- import { PreviewSimulationError, SimulationError, SimulationFlowFailure, SimulationFlowSource } from "./simulate/errors.js";
40
- import { PreviewVerdictError, previewOperation } from "./preview/previewOperation.js";
39
+ import { PreviewSimulationError, SimulationError, SimulationFlowFailure, SimulationFlowSource, asPreviewSimulationError } from "./simulate/errors.js";
40
+ import { PreviewOperationError, previewOperation } from "./preview/previewOperation.js";
41
41
  import { ReplayState, makeReplayState, replayInnerOperations } from "./preview/replayInnerOperations.js";
42
42
  import { ReplayMulticallResult, ReplayableOperation, replayMulticall } from "./preview/replayMulticall.js";
43
43
  import "./preview/index.js";
44
44
  import { CheckOperationOptions, WeighedFactors, checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./validate/checkOperation.js";
45
45
  import { checkSimulation } from "./validate/checkSimulation.js";
46
46
  import "./validate/index.js";
47
- export { AdapterOperation, AdapterOperationBase, AddCollateralOp, AllowanceDetail, AllowancePrerequisite, AllowanceResult, BalanceDetail, BalancePrerequisite, BalanceResult, type BorrowLimitBinding, CheckOperationOptions, ClassifyInnerOperationsProps, CloseCreditAccountOperation, CloseOrRepayOperation, CompareBalancesOp, CreditAccountOperation, CreditAccountState, CreditAccountStateProps, DecreaseDebtOp, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ExtractTransfersResult, FacadeCallType, FacadeOperationMetadata, FacadeParsedCall, IncreaseDebtOp, InnerFacadeOperation, InnerOperation, InvalidDelayedIntentError, LiquidateCreditAccountOperation, MulticallOperation, OpenCreditAccountOperation, Operation, OperationMetadata, OuterFacadeOperation, PartialLiquidationOperation, PoolDepositOperation, PoolMintOperation, PoolOperation, PoolRedeemOperation, PoolWithdrawOperation, Prerequisite, PrerequisiteContext, PrerequisiteError, PrerequisiteKind, PrerequisiteOutcome, PrerequisiteResult, type PreviewErrorDetails, type PreviewErrorReason, type PreviewIssue, PreviewOperationInput, PreviewOperationOptions, type PreviewRefusal, PreviewSimulationError, PreviewVerdictError, RWAMulticallOperation, RWAOpenCreditAccountOperation, RWAOpenRequirementsDetail, RWAOpenRequirementsPrerequisite, RWAOpenRequirementsResult, RWAOperation, RWAOperationMetadata, ReplayMulticallResult, ReplayState, ReplayableOperation, type SimulationError, type SimulationFlowFailure, type SimulationFlowSource, StoreExpectedBalancesOp, TokenTransfer, TraceAdapterExt, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, UpdateQuotaOp, WeighedFactors, WithdrawCollateralAlignmentError, WithdrawCollateralEventInfo, WithdrawCollateralOp, buildDelayedStrategyPositionOperationPreview, checkOperation, checkPrerequisites, checkSimulation, classifyCloseOrRepay, classifyInnerOperations, collateralIssue, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, extractAdapterCallTraces, extractTransfers, findFacadeCalls, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, marketIssues, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, quotaCountIssue, raise, refuse, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
47
+ export { AdapterOperation, AdapterOperationBase, AddCollateralOp, AllowanceDetail, AllowancePrerequisite, AllowanceResult, BalanceDetail, BalancePrerequisite, BalanceResult, type BorrowLimitBinding, CheckOperationOptions, ClassifyInnerOperationsProps, CloseCreditAccountOperation, CloseOrRepayOperation, CompareBalancesOp, CreditAccountOperation, CreditAccountState, CreditAccountStateProps, DecreaseDebtOp, DetectedDelayedClaim, DetectedDelayedOperation, DirectTokenTransferOperation, ExtractTransfersResult, FacadeCallType, FacadeOperationMetadata, FacadeParsedCall, IncreaseDebtOp, InnerFacadeOperation, InnerOperation, type InvalidDelayedIntentError, LiquidateCreditAccountOperation, MulticallOperation, OpenCreditAccountOperation, Operation, OperationMetadata, OuterFacadeOperation, PartialLiquidationOperation, PoolDepositOperation, PoolMintOperation, PoolOperation, PoolRedeemOperation, PoolWithdrawOperation, Prerequisite, PrerequisiteContext, PrerequisiteError, PrerequisiteKind, PrerequisiteOutcome, PrerequisiteResult, type PreviewErrorDetails, type PreviewErrorReason, type PreviewIssue, PreviewOperationError, PreviewOperationInput, PreviewOperationOptions, type PreviewRefusal, type PreviewSimulationError, RWAMulticallOperation, RWAOpenCreditAccountOperation, RWAOpenRequirementsDetail, RWAOpenRequirementsPrerequisite, RWAOpenRequirementsResult, RWAOperation, RWAOperationMetadata, ReplayMulticallResult, ReplayState, ReplayableOperation, type SimulationError, type SimulationFlowFailure, type SimulationFlowSource, StoreExpectedBalancesOp, TokenTransfer, TraceAdapterExt, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, type UnsupportedZapperFunctionError, UpdateQuotaOp, WeighedFactors, WithdrawCollateralAlignmentError, WithdrawCollateralEventInfo, WithdrawCollateralOp, asPreviewSimulationError, buildDelayedStrategyPositionOperationPreview, checkOperation, checkPrerequisites, checkSimulation, classifyCloseOrRepay, classifyInnerOperations, collateralIssue, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, extractAdapterCallTraces, extractTransfers, findFacadeCalls, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, marketIssues, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, quotaCountIssue, raise, refuse, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
@@ -4,7 +4,7 @@ import { UnsupportedZapperFunctionError } from "../../onchain/market/zapper/erro
4
4
  import { Address } from "viem";
5
5
  //#region src/preview/parse/errors.d.ts
6
6
  /**
7
- * Verdict answered when the target of a transaction is neither a known
7
+ * Refusal answered when the target of a transaction is neither a known
8
8
  * Gearbox pool nor a credit facade. A plain returned object per the SDK's
9
9
  * refusal vocabulary — not a thrown `Error`.
10
10
  */
@@ -14,16 +14,7 @@ interface UnsupportedTargetError extends IGearboxError {
14
14
  target: Address;
15
15
  }
16
16
  /**
17
- * Builds the verdict. Callable with or without `new`, so pre-declassing raise
18
- * sites keep compiling; `instanceof` matches on the `code` discriminant, and
19
- * the answer is never an `Error`.
20
- */
21
- declare const UnsupportedTargetError: {
22
- (target: Address): UnsupportedTargetError;
23
- new (target: Address): UnsupportedTargetError;
24
- };
25
- /**
26
- * Verdict answered when a pool call uses a function other than ERC4626
17
+ * Refusal answered when a pool call uses a function other than ERC4626
27
18
  * `deposit`/`redeem`. A plain returned object per the SDK's refusal
28
19
  * vocabulary — not a thrown `Error`.
29
20
  */
@@ -34,14 +25,5 @@ interface UnsupportedPoolFunctionError extends IGearboxError {
34
25
  /** Decoded function name the SDK cannot preview. */
35
26
  functionName: string;
36
27
  }
37
- /**
38
- * Builds the verdict. Callable with or without `new`, so pre-declassing raise
39
- * sites keep compiling; `instanceof` matches on the `code` discriminant, and
40
- * the answer is never an `Error`.
41
- */
42
- declare const UnsupportedPoolFunctionError: {
43
- (pool: Address, functionName: string): UnsupportedPoolFunctionError;
44
- new (pool: Address, functionName: string): UnsupportedPoolFunctionError;
45
- };
46
28
  //#endregion
47
- export { UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError };
29
+ export { UnsupportedPoolFunctionError, UnsupportedTargetError, type UnsupportedZapperFunctionError };
@@ -10,4 +10,4 @@ import { parseFacadeOperationCalldata } from "./parseFacadeOperationCalldata.js"
10
10
  import { parseOperationCalldata } from "./parseOperationCalldata.js";
11
11
  import { parsePoolOperationCalldata } from "./parsePoolOperationCalldata.js";
12
12
  import { parseRWAFactoryOperationCalldata } from "./parseRWAFactoryOperationCalldata.js";
13
- export { AdapterOperation, AdapterOperationBase, AddCollateralOp, ClassifyInnerOperationsProps, CloseCreditAccountOperation, CompareBalancesOp, CreditAccountOperation, DecreaseDebtOp, DirectTokenTransferOperation, FacadeOperationMetadata, IncreaseDebtOp, InnerFacadeOperation, InnerOperation, LiquidateCreditAccountOperation, MulticallOperation, OpenCreditAccountOperation, Operation, OperationMetadata, OuterFacadeOperation, PartialLiquidationOperation, PoolDepositOperation, PoolMintOperation, PoolOperation, PoolRedeemOperation, PoolWithdrawOperation, RWAMulticallOperation, RWAOpenCreditAccountOperation, RWAOperation, RWAOperationMetadata, StoreExpectedBalancesOp, TokenTransfer, TraceAdapterExt, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, UpdateQuotaOp, WithdrawCollateralOp, classifyInnerOperations, isPoolOperation, isRWAOperation, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata };
13
+ export { AdapterOperation, AdapterOperationBase, AddCollateralOp, ClassifyInnerOperationsProps, CloseCreditAccountOperation, CompareBalancesOp, CreditAccountOperation, DecreaseDebtOp, DirectTokenTransferOperation, FacadeOperationMetadata, IncreaseDebtOp, InnerFacadeOperation, InnerOperation, LiquidateCreditAccountOperation, MulticallOperation, OpenCreditAccountOperation, Operation, OperationMetadata, OuterFacadeOperation, PartialLiquidationOperation, PoolDepositOperation, PoolMintOperation, PoolOperation, PoolRedeemOperation, PoolWithdrawOperation, RWAMulticallOperation, RWAOpenCreditAccountOperation, RWAOperation, RWAOperationMetadata, StoreExpectedBalancesOp, TokenTransfer, TraceAdapterExt, UnsupportedPoolFunctionError, UnsupportedTargetError, type UnsupportedZapperFunctionError, UpdateQuotaOp, WithdrawCollateralOp, classifyInnerOperations, isPoolOperation, isRWAOperation, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata };
@@ -1,6 +1,10 @@
1
+ import { SDKReturn } from "../../model/result.js";
2
+ import "../../model/index.js";
3
+ import { UnsupportedZapperFunctionError } from "../../onchain/market/zapper/errors.js";
1
4
  import { PluginsMap } from "../../onchain/plugins/types.js";
2
5
  import "../../onchain/index.js";
3
6
  import { Operation } from "./types.js";
7
+ import { UnsupportedPoolFunctionError, UnsupportedTargetError } from "./errors.js";
4
8
  import { PreviewOperationInput } from "../types.js";
5
9
  //#region src/preview/parse/parseOperationCalldata.d.ts
6
10
  /**
@@ -9,6 +13,6 @@ import { PreviewOperationInput } from "../types.js";
9
13
  * Support parsing of pool operations (including via zappers),
10
14
  * credit facade operations and RWA factory operations.
11
15
  */
12
- declare function parseOperationCalldata<P extends PluginsMap>(input: PreviewOperationInput<P>): Operation;
16
+ declare function parseOperationCalldata<P extends PluginsMap>(input: PreviewOperationInput<P>): SDKReturn<Operation, UnsupportedTargetError | UnsupportedPoolFunctionError | UnsupportedZapperFunctionError>;
13
17
  //#endregion
14
18
  export { parseOperationCalldata };
@@ -1,8 +1,11 @@
1
+ import { SDKReturn } from "../../model/result.js";
2
+ import "../../model/index.js";
1
3
  import { PoolV310Contract } from "../../onchain/market/pool/PoolV310Contract.js";
2
4
  import { OnchainSDK } from "../../onchain/OnchainSDK.js";
3
5
  import "../../onchain/index.js";
4
6
  import { PoolOperation } from "./types-pools.js";
5
7
  import "./types.js";
8
+ import { UnsupportedPoolFunctionError } from "./errors.js";
6
9
  import { Hex } from "viem";
7
10
  //#region src/preview/parse/parsePoolOperationCalldata.d.ts
8
11
  /**
@@ -11,8 +14,8 @@ import { Hex } from "viem";
11
14
  * @param sdk - The SDK instance.
12
15
  * @param pool - The pool contract.
13
16
  * @param calldata - The calldata to parse.
14
- * @returns The parsed operation.
17
+ * @returns The parsed operation behind `ok`, or the refusal.
15
18
  */
16
- declare function parsePoolOperationCalldata(sdk: OnchainSDK, pool: PoolV310Contract, calldata: Hex): PoolOperation;
19
+ declare function parsePoolOperationCalldata(sdk: OnchainSDK, pool: PoolV310Contract, calldata: Hex): SDKReturn<PoolOperation, UnsupportedPoolFunctionError>;
17
20
  //#endregion
18
21
  export { parsePoolOperationCalldata };
@@ -1,6 +1,11 @@
1
+ import { SDKReturn } from "../../model/result.js";
2
+ import "../../model/index.js";
3
+ import { UnsupportedZapperFunctionError } from "../../onchain/market/zapper/errors.js";
1
4
  import { PluginsMap } from "../../onchain/plugins/types.js";
2
5
  import "../../onchain/index.js";
6
+ import { UnsupportedPoolFunctionError, UnsupportedTargetError } from "../parse/errors.js";
3
7
  import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
8
+ import "../parse/index.js";
4
9
  import { PrerequisiteResult } from "./types.js";
5
10
  //#region src/preview/prerequisites/checkPrerequisites.d.ts
6
11
  /**
@@ -18,6 +23,6 @@ import { PrerequisiteResult } from "./types.js";
18
23
  * (e.g. pool is paused) is intentionally out of scope, since the user cannot
19
24
  * resolve it.
20
25
  */
21
- declare function checkPrerequisites<P extends PluginsMap>(input: PreviewOperationInput<P>, options?: PreviewOperationOptions): Promise<PrerequisiteResult[]>;
26
+ declare function checkPrerequisites<P extends PluginsMap>(input: PreviewOperationInput<P>, options?: PreviewOperationOptions): Promise<SDKReturn<PrerequisiteResult[], UnsupportedTargetError | UnsupportedPoolFunctionError | UnsupportedZapperFunctionError>>;
22
27
  //#endregion
23
28
  export { checkPrerequisites };
@@ -1,5 +1,7 @@
1
1
  import { DelayedIntent } from "../../model/delayed-intents.js";
2
+ import { SDKReturn } from "../../model/result.js";
2
3
  import "../../model/index.js";
4
+ import { InvalidDelayedIntentError } from "../../onchain/accounts/withdrawal-compressor/errors.js";
3
5
  import { PluginsMap } from "../../onchain/plugins/types.js";
4
6
  import { OnchainSDK } from "../../onchain/OnchainSDK.js";
5
7
  import "../../onchain/index.js";
@@ -41,12 +43,11 @@ declare function detectDelayedClaim<P extends PluginsMap>(sdk: OnchainSDK<P>, mu
41
43
  * @param sdk - Attached SDK.
42
44
  * @param multicall - Parsed inner operations of the multicall.
43
45
  * @param blockNumber - Optional block number to read the log at.
44
- * @returns The decoded intent, or `undefined` when the multicall claims
45
- * nothing, the redemption logger is not deployed, or the log carries no
46
- * intent.
47
- * @throws InvalidDelayedIntentError when the logged `extraData` is non-empty
48
- * but cannot be decoded as a `DelayedIntent`.
46
+ * @returns The decoded intent behind `ok` (`undefined` when the multicall
47
+ * claims nothing, the redemption logger is not deployed, or the log carries
48
+ * no intent), or the `invalidDelayedIntent` refusal when the logged
49
+ * `extraData` is non-empty but cannot be decoded as a `DelayedIntent`.
49
50
  */
50
- declare function resolveDelayedClaimIntent<P extends PluginsMap>(sdk: OnchainSDK<P>, multicall: InnerOperation[], blockNumber?: bigint): Promise<DelayedIntent | undefined>;
51
+ declare function resolveDelayedClaimIntent<P extends PluginsMap>(sdk: OnchainSDK<P>, multicall: InnerOperation[], blockNumber?: bigint): Promise<SDKReturn<DelayedIntent | undefined, InvalidDelayedIntentError>>;
51
52
  //#endregion
52
53
  export { DetectedDelayedClaim, detectDelayedClaim, resolveDelayedClaimIntent };
@@ -1,5 +1,7 @@
1
1
  import { DelayedIntent } from "../../model/delayed-intents.js";
2
+ import { SDKReturn } from "../../model/result.js";
2
3
  import "../../model/index.js";
4
+ import { InvalidDelayedIntentError } from "../../onchain/accounts/withdrawal-compressor/errors.js";
3
5
  import { DelayedWithdrawalRequest } from "../../onchain/market/adapters/types.js";
4
6
  import { PluginsMap } from "../../onchain/plugins/types.js";
5
7
  import { OnchainSDK } from "../../onchain/OnchainSDK.js";
@@ -32,6 +34,6 @@ interface DetectedDelayedOperation {
32
34
  * @throws InvalidDelayedIntentError when a request carries non-empty
33
35
  * `extraData` that cannot be decoded as a `DelayedIntent`.
34
36
  */
35
- declare function detectDelayedOperation<P extends PluginsMap>(sdk: OnchainSDK<P>, multicall: InnerOperation[]): DetectedDelayedOperation | undefined;
37
+ declare function detectDelayedOperation<P extends PluginsMap>(sdk: OnchainSDK<P>, multicall: InnerOperation[]): SDKReturn<DetectedDelayedOperation | undefined, InvalidDelayedIntentError>;
36
38
  //#endregion
37
39
  export { DetectedDelayedOperation, detectDelayedOperation };
@@ -2,7 +2,7 @@ import { IGearboxError } from "../../model/errors.js";
2
2
  import "../../model/index.js";
3
3
  //#region src/preview/preview/errors.d.ts
4
4
  /**
5
- * Verdict answered by `previewOperation` for parsed operations it cannot
5
+ * Refusal answered by `previewOperation` for parsed operations it cannot
6
6
  * preview yet. A plain returned object per the SDK's refusal vocabulary —
7
7
  * not a thrown `Error`.
8
8
  */
@@ -11,14 +11,5 @@ interface UnsupportedOperationError extends IGearboxError {
11
11
  /** The parsed operation kind (the `operation` discriminant). */
12
12
  operation: string;
13
13
  }
14
- /**
15
- * Builds the verdict. Callable with or without `new`, so pre-declassing raise
16
- * sites keep compiling; `instanceof` matches on the `code` discriminant, and
17
- * the answer is never an `Error`.
18
- */
19
- declare const UnsupportedOperationError: {
20
- (operation: string): UnsupportedOperationError;
21
- new (operation: string): UnsupportedOperationError;
22
- };
23
14
  //#endregion
24
15
  export { UnsupportedOperationError };
@@ -7,7 +7,7 @@ import { UnsupportedOperationError } from "./errors.js";
7
7
  import { estimateClaimableAt } from "./estimateClaimableAt.js";
8
8
  import { previewAdjustStrategyPosition } from "./previewAdjustStrategyPosition.js";
9
9
  import { CloseOrRepayOperation, previewExitOrRepayStrategyPosition } from "./previewExitOrRepayStrategyPosition.js";
10
- import { PreviewVerdictError, previewOperation } from "./previewOperation.js";
10
+ import { PreviewOperationError, previewOperation } from "./previewOperation.js";
11
11
  import { ReplayState, makeReplayState, replayInnerOperations } from "./replayInnerOperations.js";
12
12
  import { ReplayMulticallResult, ReplayableOperation, replayMulticall } from "./replayMulticall.js";
13
- export { CloseOrRepayOperation, CreditAccountState, CreditAccountStateProps, DetectedDelayedClaim, DetectedDelayedOperation, PreviewVerdictError, ReplayMulticallResult, ReplayState, ReplayableOperation, UnsupportedOperationError, buildDelayedStrategyPositionOperationPreview, classifyCloseOrRepay, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, isCloseOrRepay, makeReplayState, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
13
+ export { CloseOrRepayOperation, CreditAccountState, CreditAccountStateProps, DetectedDelayedClaim, DetectedDelayedOperation, PreviewOperationError, ReplayMulticallResult, ReplayState, ReplayableOperation, UnsupportedOperationError, buildDelayedStrategyPositionOperationPreview, classifyCloseOrRepay, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, isCloseOrRepay, makeReplayState, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };