@gearbox-protocol/sdk 16.0.0-next.43 → 16.0.0-next.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/onchain/accounts/index.js +0 -2
- package/dist/cjs/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +13 -7
- package/dist/cjs/onchain/accounts/withdrawal-compressor/errors.js +0 -19
- package/dist/cjs/onchain/accounts/withdrawal-compressor/index.js +1 -2
- package/dist/cjs/onchain/index.js +0 -4
- package/dist/cjs/onchain/market/index.js +0 -2
- package/dist/cjs/onchain/market/zapper/ZapperContract.js +15 -8
- package/dist/cjs/onchain/market/zapper/errors.js +0 -18
- package/dist/cjs/onchain/market/zapper/index.js +1 -2
- package/dist/cjs/onchain/validation/checks.js +1 -1
- package/dist/cjs/preview/index.js +1 -10
- package/dist/cjs/preview/parse/errors.js +0 -35
- package/dist/cjs/preview/parse/index.js +1 -5
- package/dist/cjs/preview/parse/parseOperationCalldata.js +28 -17
- package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +17 -11
- package/dist/cjs/preview/prerequisites/checkPrerequisites.js +5 -2
- package/dist/cjs/preview/preview/detectDelayedClaim.js +9 -7
- package/dist/cjs/preview/preview/detectDelayedOperation.js +11 -4
- package/dist/cjs/preview/preview/errors.js +0 -17
- package/dist/cjs/preview/preview/index.js +1 -2
- package/dist/cjs/preview/preview/previewOperation.js +30 -42
- package/dist/cjs/preview/preview/previewPoolPositionOperation.js +7 -3
- package/dist/cjs/preview/simulate/errors.js +13 -23
- package/dist/cjs/preview/simulate/index.js +1 -1
- package/dist/cjs/preview/simulate/simulateOperation.js +6 -4
- package/dist/cjs/preview/simulate/simulatePoolOperation.js +6 -3
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/index.js +1 -2
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +14 -8
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/errors.js +1 -19
- package/dist/esm/onchain/accounts/withdrawal-compressor/index.js +2 -2
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +1 -3
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/index.js +1 -2
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +16 -9
- package/dist/esm/onchain/market/zapper/errors.js +1 -18
- package/dist/esm/onchain/market/zapper/index.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/onchain/validation/checks.js +1 -1
- package/dist/esm/preview/index.js +2 -6
- package/dist/esm/preview/parse/errors.js +1 -33
- package/dist/esm/preview/parse/index.js +2 -3
- package/dist/esm/preview/parse/parseOperationCalldata.js +28 -17
- package/dist/esm/preview/parse/parsePoolOperationCalldata.js +17 -11
- package/dist/esm/preview/prerequisites/checkPrerequisites.js +5 -2
- package/dist/esm/preview/preview/detectDelayedClaim.js +9 -7
- package/dist/esm/preview/preview/detectDelayedOperation.js +11 -4
- package/dist/esm/preview/preview/errors.js +1 -17
- package/dist/esm/preview/preview/index.js +2 -2
- package/dist/esm/preview/preview/previewOperation.js +31 -43
- package/dist/esm/preview/preview/previewPoolPositionOperation.js +7 -3
- package/dist/esm/preview/simulate/errors.js +14 -23
- package/dist/esm/preview/simulate/index.js +2 -2
- package/dist/esm/preview/simulate/simulateOperation.js +6 -4
- package/dist/esm/preview/simulate/simulatePoolOperation.js +7 -4
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/types/model/errors.d.ts +1 -1
- package/dist/types/onchain/accounts/index.d.ts +1 -1
- package/dist/types/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +6 -4
- package/dist/types/onchain/accounts/withdrawal-compressor/errors.d.ts +2 -11
- package/dist/types/onchain/accounts/withdrawal-compressor/index.d.ts +1 -1
- package/dist/types/onchain/accounts/withdrawal-compressor/types.d.ts +6 -4
- package/dist/types/onchain/index.d.ts +2 -2
- package/dist/types/onchain/market/index.d.ts +1 -1
- package/dist/types/onchain/market/zapper/ZapperContract.d.ts +7 -3
- package/dist/types/onchain/market/zapper/errors.d.ts +1 -10
- package/dist/types/onchain/market/zapper/index.d.ts +1 -1
- package/dist/types/onchain/market/zapper/types.d.ts +4 -1
- package/dist/types/onchain/validation/checks.d.ts +1 -1
- package/dist/types/preview/index.d.ts +4 -4
- package/dist/types/preview/parse/errors.d.ts +3 -21
- package/dist/types/preview/parse/index.d.ts +1 -1
- package/dist/types/preview/parse/parseOperationCalldata.d.ts +5 -1
- package/dist/types/preview/parse/parsePoolOperationCalldata.d.ts +5 -2
- package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +6 -1
- package/dist/types/preview/preview/detectDelayedClaim.d.ts +7 -6
- package/dist/types/preview/preview/detectDelayedOperation.d.ts +3 -1
- package/dist/types/preview/preview/errors.d.ts +1 -10
- package/dist/types/preview/preview/index.d.ts +2 -2
- package/dist/types/preview/preview/previewOperation.d.ts +10 -10
- package/dist/types/preview/preview/previewPoolPositionOperation.d.ts +3 -1
- package/dist/types/preview/simulate/errors.d.ts +2 -11
- package/dist/types/preview/simulate/index.d.ts +2 -2
- package/dist/types/preview/simulate/simulateOperation.d.ts +4 -1
- package/dist/types/preview/simulate/simulatePoolOperation.d.ts +4 -1
- package/dist/types/sdk/prepare/errors.d.ts +1 -1
- package/dist/types/sdk/preview/PreviewNamespace.d.ts +2 -2
- package/dist/types/sdk/preview/types.d.ts +3 -3
- package/dist/types/sdk/types.d.ts +1 -3
- package/package.json +1 -1
|
@@ -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
|
|
45
|
-
* nothing, the redemption logger is not deployed, or the log carries
|
|
46
|
-
* intent
|
|
47
|
-
*
|
|
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
|
-
*
|
|
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 {
|
|
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,
|
|
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 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OperationPreview } from "../../model/previews.js";
|
|
2
2
|
import { SDKReturn } from "../../model/result.js";
|
|
3
3
|
import "../../model/index.js";
|
|
4
|
+
import { InvalidDelayedIntentError } from "../../onchain/accounts/withdrawal-compressor/errors.js";
|
|
4
5
|
import { UnsupportedZapperFunctionError } from "../../onchain/market/zapper/errors.js";
|
|
5
6
|
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
6
|
-
import { InvalidDelayedIntentError } from "../../onchain/accounts/withdrawal-compressor/errors.js";
|
|
7
7
|
import "../../onchain/index.js";
|
|
8
8
|
import { UnsupportedPoolFunctionError, UnsupportedTargetError } from "../parse/errors.js";
|
|
9
9
|
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
@@ -12,21 +12,21 @@ import { UnsupportedOperationError } from "./errors.js";
|
|
|
12
12
|
import { PreviewSimulationError } from "../simulate/errors.js";
|
|
13
13
|
//#region src/preview/preview/previewOperation.d.ts
|
|
14
14
|
/**
|
|
15
|
-
* Everything {@link previewOperation} can refuse with: the
|
|
16
|
-
* pipeline raises, discriminated by `code`. Each is a plain object —
|
|
17
|
-
* thrown `Error` — per the SDK's refusal vocabulary.
|
|
15
|
+
* Everything {@link previewOperation} can refuse with: the refusal errors
|
|
16
|
+
* its pipeline raises, discriminated by `code`. Each is a plain object —
|
|
17
|
+
* never a thrown `Error` — per the SDK's refusal vocabulary.
|
|
18
18
|
*/
|
|
19
|
-
type
|
|
19
|
+
type PreviewOperationError = UnsupportedTargetError | UnsupportedPoolFunctionError | UnsupportedZapperFunctionError | UnsupportedOperationError | InvalidDelayedIntentError | PreviewSimulationError;
|
|
20
20
|
/**
|
|
21
21
|
* Previews a raw operation calldata: decodes it into a typed operation and
|
|
22
22
|
* assembles an operation-specific, human-displayable preview.
|
|
23
23
|
*
|
|
24
24
|
* Answers an {@link SDKReturn} envelope: the preview behind `ok: true`, or —
|
|
25
25
|
* when the transaction is one the previewer refuses to read — a
|
|
26
|
-
* {@link
|
|
27
|
-
* means the SDK could not do its job (a read failed, the targeted
|
|
28
|
-
* account could not be resolved), not a
|
|
26
|
+
* {@link PreviewOperationError} behind `ok: false`. A thrown exception
|
|
27
|
+
* still means the SDK could not do its job (a read failed, the targeted
|
|
28
|
+
* credit account could not be resolved), not a refusal of the transaction.
|
|
29
29
|
*/
|
|
30
|
-
declare function previewOperation<P extends PluginsMap = PluginsMap>(input: PreviewOperationInput<P>, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview,
|
|
30
|
+
declare function previewOperation<P extends PluginsMap = PluginsMap>(input: PreviewOperationInput<P>, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
|
|
31
31
|
//#endregion
|
|
32
|
-
export {
|
|
32
|
+
export { PreviewOperationError, previewOperation };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { PoolPositionOperationPreview } from "../../model/previews.js";
|
|
2
|
+
import { SDKReturn } from "../../model/result.js";
|
|
2
3
|
import "../../model/index.js";
|
|
3
4
|
import { PluginsMap } from "../../onchain/plugins/types.js";
|
|
4
5
|
import "../../onchain/index.js";
|
|
5
6
|
import { PoolOperation } from "../parse/types-pools.js";
|
|
6
7
|
import { PreviewOperationInput, PreviewOperationOptions } from "../types.js";
|
|
7
8
|
import "../parse/index.js";
|
|
9
|
+
import { PreviewSimulationError } from "../simulate/errors.js";
|
|
8
10
|
//#region src/preview/preview/previewPoolPositionOperation.d.ts
|
|
9
|
-
declare function previewPoolPositionOperation<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: PoolOperation, options?: PreviewOperationOptions): Promise<PoolPositionOperationPreview
|
|
11
|
+
declare function previewPoolPositionOperation<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: PoolOperation, options?: PreviewOperationOptions): Promise<SDKReturn<PoolPositionOperationPreview, PreviewSimulationError>>;
|
|
10
12
|
//#endregion
|
|
11
13
|
export { previewPoolPositionOperation };
|
|
@@ -10,26 +10,17 @@ interface SimulationFlowFailure {
|
|
|
10
10
|
detail: SimulationError;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Refusal answered when the pool simulation fails. It wraps each flow's
|
|
14
14
|
* decoded revert reason (see {@link failures}). A plain returned object per
|
|
15
15
|
* the SDK's refusal vocabulary — not a thrown `Error`.
|
|
16
16
|
*/
|
|
17
17
|
interface PreviewSimulationError extends IGearboxError {
|
|
18
18
|
code: "previewSimulationFailed";
|
|
19
|
-
/** Per-flow decoded failures behind this
|
|
19
|
+
/** Per-flow decoded failures behind this refusal. */
|
|
20
20
|
failures: SimulationFlowFailure[];
|
|
21
21
|
/** First flow failure that was itself an `Error`, kept for debugging. */
|
|
22
22
|
cause?: Error;
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Builds the verdict. Callable with or without `new`, so pre-declassing raise
|
|
26
|
-
* sites keep compiling; `instanceof` matches on the `code` discriminant, and
|
|
27
|
-
* the answer is never an `Error`.
|
|
28
|
-
*/
|
|
29
|
-
declare const PreviewSimulationError: {
|
|
30
|
-
(failures: SimulationFlowFailure[]): PreviewSimulationError;
|
|
31
|
-
new (failures: SimulationFlowFailure[]): PreviewSimulationError;
|
|
32
|
-
};
|
|
33
24
|
/**
|
|
34
25
|
* Normalises an unknown rejection reason into a {@link PreviewSimulationError}.
|
|
35
26
|
* Pass-through when it already is one; otherwise decodes it under `source`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PreviewSimulationError, SimulationError, SimulationFlowFailure, SimulationFlowSource } from "./errors.js";
|
|
1
|
+
import { PreviewSimulationError, SimulationError, SimulationFlowFailure, SimulationFlowSource, asPreviewSimulationError } from "./errors.js";
|
|
2
2
|
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
3
3
|
import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
4
4
|
import { simulateOperation } from "./simulateOperation.js";
|
|
5
5
|
import { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
6
6
|
import { simulateRWAOperation } from "./simulateRWAOperation.js";
|
|
7
|
-
export { type PoolOperationSimulationResult, PreviewSimulationError, type SimulationError, type SimulationFlowFailure, type SimulationFlowSource, type SimulationInput, simulateFacadeOperation, simulateOperation, simulatePoolOperation, simulateRWAOperation };
|
|
7
|
+
export { type PoolOperationSimulationResult, type PreviewSimulationError, type SimulationError, type SimulationFlowFailure, type SimulationFlowSource, type SimulationInput, asPreviewSimulationError, simulateFacadeOperation, simulateOperation, simulatePoolOperation, simulateRWAOperation };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { SDKReturn } from "../../model/result.js";
|
|
2
|
+
import "../../model/index.js";
|
|
1
3
|
import { PreviewOperationOptions } from "../types.js";
|
|
4
|
+
import { PreviewSimulationError } from "./errors.js";
|
|
2
5
|
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
3
6
|
//#region src/preview/simulate/simulateOperation.d.ts
|
|
4
7
|
/**
|
|
5
8
|
* Simulates a parsed pool or credit account operation
|
|
6
9
|
*/
|
|
7
|
-
declare function simulateOperation(input: SimulationInput, options?: PreviewOperationOptions): Promise<PoolOperationSimulationResult
|
|
10
|
+
declare function simulateOperation(input: SimulationInput, options?: PreviewOperationOptions): Promise<SDKReturn<PoolOperationSimulationResult, PreviewSimulationError>>;
|
|
8
11
|
//#endregion
|
|
9
12
|
export { simulateOperation };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { SDKReturn } from "../../model/result.js";
|
|
2
|
+
import "../../model/index.js";
|
|
1
3
|
import { PoolOperation } from "../parse/types-pools.js";
|
|
2
4
|
import { PreviewOperationOptions } from "../types.js";
|
|
3
5
|
import "../parse/index.js";
|
|
6
|
+
import { PreviewSimulationError } from "./errors.js";
|
|
4
7
|
import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
5
8
|
//#region src/preview/simulate/simulatePoolOperation.d.ts
|
|
6
9
|
/**
|
|
@@ -17,6 +20,6 @@ import { PoolOperationSimulationResult, SimulationInput } from "./types.js";
|
|
|
17
20
|
* It does not execute the calldata, so it ignores balance/allowance
|
|
18
21
|
* prerequisites (preview reads succeed regardless).
|
|
19
22
|
*/
|
|
20
|
-
declare function simulatePoolOperation(input: SimulationInput<PoolOperation>, options?: PreviewOperationOptions): Promise<PoolOperationSimulationResult
|
|
23
|
+
declare function simulatePoolOperation(input: SimulationInput<PoolOperation>, options?: PreviewOperationOptions): Promise<SDKReturn<PoolOperationSimulationResult, PreviewSimulationError>>;
|
|
21
24
|
//#endregion
|
|
22
25
|
export { simulatePoolOperation };
|
|
@@ -235,7 +235,7 @@ interface CreditAccountNotFoundError extends IGearboxError {
|
|
|
235
235
|
* connected to, a market or token address it knows nothing about, a contract
|
|
236
236
|
* that reverted where nothing should, a bug of ours.
|
|
237
237
|
*
|
|
238
|
-
* The one code that is not a
|
|
238
|
+
* The one code that is not a refusal of the request — everything above says
|
|
239
239
|
* "this cannot be done", this one says "we do not know". It exists so that a
|
|
240
240
|
* refusable `prepare` method always answers: the failure that used to escape
|
|
241
241
|
* as an exception arrives here instead, whole, under `cause`.
|
|
@@ -3,7 +3,7 @@ import { SDKReturn } from "../../model/result.js";
|
|
|
3
3
|
import "../../model/index.js";
|
|
4
4
|
import { MultichainSDK } from "../../onchain/MultichainSDK.js";
|
|
5
5
|
import "../../onchain/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { PreviewOperationError } from "../../preview/preview/previewOperation.js";
|
|
7
7
|
import "../../preview/index.js";
|
|
8
8
|
import { IPreview } from "./types.js";
|
|
9
9
|
import { NamespaceOptions } from "../types.js";
|
|
@@ -17,7 +17,7 @@ declare class PreviewNamespace implements IPreview {
|
|
|
17
17
|
/**
|
|
18
18
|
* {@inheritDoc IPreview.previewOperation}
|
|
19
19
|
**/
|
|
20
|
-
previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview,
|
|
20
|
+
previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { PreviewNamespace };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "../../model/previews.js";
|
|
2
2
|
import { SDKReturn } from "../../model/result.js";
|
|
3
3
|
import "../../model/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { PreviewOperationError } from "../../preview/preview/previewOperation.js";
|
|
5
5
|
import "../../preview/index.js";
|
|
6
6
|
//#region src/sdk/preview/types.d.ts
|
|
7
7
|
/**
|
|
@@ -10,11 +10,11 @@ import "../../preview/index.js";
|
|
|
10
10
|
interface IPreview {
|
|
11
11
|
/**
|
|
12
12
|
* Decodes a raw operation and assembles an operation-specific,
|
|
13
|
-
* human-displayable preview. A
|
|
13
|
+
* human-displayable preview. A refusal of the calldata — an unsupported
|
|
14
14
|
* target, function or operation, a foreign delayed intent, a failed
|
|
15
15
|
* simulation — is the `ok: false` half; genuine failures still throw.
|
|
16
16
|
**/
|
|
17
|
-
previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview,
|
|
17
|
+
previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* `sdk.preview` per mode: an on-chain read, absent when the SDK reads no chain.
|
|
@@ -114,9 +114,7 @@ interface OnchainByMode {
|
|
|
114
114
|
* The banners the backend attaches to a pool opportunity or a strategy
|
|
115
115
|
* position, see {@link Notice}.
|
|
116
116
|
**/
|
|
117
|
-
|
|
118
|
-
(subject: NoticeSubject): Promise<DataResponse<Notice[]>>;
|
|
119
|
-
}
|
|
117
|
+
type INotices = (subject: NoticeSubject) => Promise<DataResponse<Notice[]>>;
|
|
120
118
|
/**
|
|
121
119
|
* `sdk.notices` per mode: a backend read, absent when the SDK reads no backend.
|
|
122
120
|
**/
|