@gearbox-protocol/sdk 14.12.0-next.21 → 14.12.0-next.23

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 (53) hide show
  1. package/dist/cjs/abi/IWithdrawalCompressorV313.js +2 -1
  2. package/dist/cjs/abi/compressors/withdrawalCompressor.js +2 -1
  3. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +1 -5
  4. package/dist/cjs/preview/preview/applyInnerOperations.js +83 -58
  5. package/dist/cjs/preview/preview/applyQuotaChanges.js +43 -0
  6. package/dist/cjs/preview/preview/errors.js +0 -16
  7. package/dist/cjs/preview/preview/index.js +2 -0
  8. package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +19 -8
  9. package/dist/cjs/preview/preview/previewCloseOrRepayCreditAccount.js +18 -7
  10. package/dist/cjs/preview/preview/previewOpenCreditAccount.js +18 -6
  11. package/dist/cjs/preview/preview/types.js +30 -0
  12. package/dist/cjs/preview/preview/unwrapNativeCollateral.js +10 -4
  13. package/dist/cjs/sdk/OnchainSDK.js +3 -6
  14. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +45 -37
  15. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +14 -22
  16. package/dist/cjs/sdk/accounts/withdrawal-compressor/addresses.js +6 -18
  17. package/dist/cjs/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +3 -5
  18. package/dist/esm/abi/IWithdrawalCompressorV313.js +2 -1
  19. package/dist/esm/abi/compressors/withdrawalCompressor.js +2 -1
  20. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -9
  21. package/dist/esm/preview/preview/applyInnerOperations.js +90 -59
  22. package/dist/esm/preview/preview/applyQuotaChanges.js +19 -0
  23. package/dist/esm/preview/preview/errors.js +0 -15
  24. package/dist/esm/preview/preview/index.js +1 -0
  25. package/dist/esm/preview/preview/previewAdjustCreditAccount.js +20 -8
  26. package/dist/esm/preview/preview/previewCloseOrRepayCreditAccount.js +18 -7
  27. package/dist/esm/preview/preview/previewOpenCreditAccount.js +20 -6
  28. package/dist/esm/preview/preview/types.js +16 -0
  29. package/dist/esm/preview/preview/unwrapNativeCollateral.js +12 -4
  30. package/dist/esm/sdk/OnchainSDK.js +3 -6
  31. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +45 -37
  32. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +14 -22
  33. package/dist/esm/sdk/accounts/withdrawal-compressor/addresses.js +6 -18
  34. package/dist/esm/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +3 -5
  35. package/dist/types/abi/IWithdrawalCompressorV313.d.ts +4 -0
  36. package/dist/types/abi/compressors/withdrawalCompressor.d.ts +4 -0
  37. package/dist/types/permissionless/bindings/compressors/withdrawal-compressor.d.ts +4 -0
  38. package/dist/types/preview/preview/applyInnerOperations.d.ts +8 -33
  39. package/dist/types/preview/preview/applyQuotaChanges.d.ts +24 -0
  40. package/dist/types/preview/preview/errors.d.ts +0 -12
  41. package/dist/types/preview/preview/index.d.ts +1 -0
  42. package/dist/types/preview/preview/previewAdjustCreditAccount.d.ts +1 -1
  43. package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +1 -1
  44. package/dist/types/preview/preview/types.d.ts +81 -0
  45. package/dist/types/preview/preview/unwrapNativeCollateral.d.ts +19 -4
  46. package/dist/types/sdk/OnchainSDK.d.ts +3 -6
  47. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +5 -1
  48. package/dist/types/sdk/accounts/types.d.ts +32 -3
  49. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +4 -0
  50. package/dist/types/sdk/accounts/withdrawal-compressor/addresses.d.ts +1 -2
  51. package/dist/types/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.d.ts +2 -4
  52. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +7 -0
  53. package/package.json +1 -1
@@ -1,5 +1,16 @@
1
1
  import type { Address } from "viem";
2
2
  import { type Asset } from "../../sdk/index.js";
3
+ import { type OperationPreviewError } from "./types.js";
4
+ export interface UnwrapNativeCollateralResult {
5
+ /**
6
+ * Collateral with the native amount unwrapped from the WETH entry.
7
+ */
8
+ assets: Asset[];
9
+ /**
10
+ * Error set when the transaction value is malformed.
11
+ */
12
+ error?: OperationPreviewError;
13
+ }
3
14
  /**
4
15
  * Represents the transaction's attached native value as a `NATIVE_ADDRESS`
5
16
  * entry in the collateral list.
@@ -10,11 +21,15 @@ import { type Asset } from "../../sdk/index.js";
10
21
  * `NATIVE_ADDRESS` and the WETH entry is reduced accordingly (dropped when it
11
22
  * reaches zero). Other entries are preserved.
12
23
  *
24
+ * When `nativeAmount` is positive but the WETH collateral is missing or
25
+ * smaller than it, the transaction is malformed: the collateral is returned
26
+ * as-is (no unwrapping) together with an `ERROR_INVALID_TRANSACTION_VALUE`
27
+ * error.
28
+ *
13
29
  * @param collateral - Collateral assets as declared by the multicall.
14
30
  * @param nativeAmount - Transaction `msg.value`.
15
31
  * @param wethToken - Wrapped native token address.
16
- * @returns Collateral with the native amount unwrapped from the WETH entry.
17
- * @throws InvalidTransactionValueError when `nativeAmount` is positive but the
18
- * WETH collateral is missing or smaller than it.
32
+ * @returns Collateral with the native amount unwrapped from the WETH entry,
33
+ * plus the error on a malformed transaction value.
19
34
  */
20
- export declare function unwrapNativeCollateral(collateral: Asset[], nativeAmount: bigint, wethToken: Address): Asset[];
35
+ export declare function unwrapNativeCollateral(collateral: Asset[], nativeAmount: bigint, wethToken: Address): UnwrapNativeCollateralResult;
@@ -1,7 +1,7 @@
1
1
  import type { Address } from "viem";
2
2
  import { type PublicClient, type Transport } from "viem";
3
3
  import type { HttpRpcClientOptions } from "viem/utils";
4
- import { type ICreditAccountsService, type IWithdrawalCompressorContract, type WithdrawalCompressorVersion } from "./accounts/index.js";
4
+ import { type ICreditAccountsService, type IWithdrawalCompressorContract } from "./accounts/index.js";
5
5
  import type { BaseState, IBaseContract } from "./base/index.js";
6
6
  import { ChainContractsRegister } from "./base/index.js";
7
7
  import type { GearboxChain, NetworkType } from "./chain/chains.js";
@@ -289,10 +289,7 @@ export declare class OnchainSDK<const Plugins extends PluginsMap = {}> extends C
289
289
  /**
290
290
  * Lazily returns a withdrawal compressor contract for the current chain.
291
291
  *
292
- * @param version - Desired compressor version; when omitted, the latest
293
- * version supported on the current chain is used.
294
- * @throws If no withdrawal compressor of the given version is supported
295
- * on the current chain.
292
+ * @throws If no withdrawal compressor is supported on the current chain.
296
293
  **/
297
- withdrawalCompressor(version?: WithdrawalCompressorVersion): IWithdrawalCompressorContract;
294
+ get withdrawalCompressor(): IWithdrawalCompressorContract;
298
295
  }
@@ -6,7 +6,7 @@ import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
6
6
  import type { OnchainSDK } from "../OnchainSDK.js";
7
7
  import type { RouterCASlice } from "../router/index.js";
8
8
  import type { MultiCall, RawTx } from "../types/index.js";
9
- import type { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
9
+ import type { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
10
10
  import type { RequestableWithdrawal } from "./withdrawal-compressor/index.js";
11
11
  /**
12
12
  * Options for configuring the credit account service.
@@ -103,6 +103,10 @@ export declare class CreditAccountsServiceV310 extends SDKConstruct implements I
103
103
  * {@inheritDoc ICreditAccountsService.assembleStartDelayedWithdrawalCalls}
104
104
  **/
105
105
  assembleStartDelayedWithdrawalCalls({ creditFacade, preview, }: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
106
+ /**
107
+ * {@inheritDoc ICreditAccountsService.assembleClaimDelayedCalls}
108
+ **/
109
+ assembleClaimDelayedCalls({ creditFacade, claimableNow, }: AssembleClaimDelayedCallsProps): Array<MultiCall>;
106
110
  /**
107
111
  * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
108
112
  **/
@@ -374,6 +374,19 @@ export type AssembleStartDelayedWithdrawalCallsProps = {
374
374
  */
375
375
  preview: Pick<RequestableWithdrawal, "outputs" | "requestCalls">;
376
376
  };
377
+ /**
378
+ * Input for {@link ICreditAccountsService.assembleClaimDelayedCalls}.
379
+ */
380
+ export type AssembleClaimDelayedCallsProps = {
381
+ /**
382
+ * Credit facade that receives `storeExpectedBalances` / `compareBalances`.
383
+ */
384
+ creditFacade: Address;
385
+ /**
386
+ * Claimable withdrawal: `outputs` for expected balances, `claimCalls` for the body.
387
+ */
388
+ claimableNow: Pick<ClaimableWithdrawal, "outputs" | "claimCalls">;
389
+ };
377
390
  export interface StartDelayedWithdrawalProps extends PrepareUpdateQuotasProps {
378
391
  /**
379
392
  * Withdrawal preview
@@ -898,6 +911,21 @@ export interface ICreditAccountsService extends Construct {
898
911
  * @returns Raw facade multicall payload for the delayed-withdrawal request
899
912
  */
900
913
  assembleStartDelayedWithdrawalCalls(props: AssembleStartDelayedWithdrawalCallsProps): Array<MultiCall>;
914
+ /**
915
+ * Builds claim-delayed-withdrawal multicall calls without price feed updates
916
+ * or quota updates.
917
+ *
918
+ * Same balance bracket as {@link claimDelayed}:
919
+ * `storeExpectedBalances` → `claimableNow.claimCalls` → `compareBalances`.
920
+ *
921
+ * Does not prepend price updates, does not update quotas, and does not build
922
+ * the facade transaction. Use for resume / intent assembly where claim is
923
+ * followed by other ops and quotas/prices are applied separately.
924
+ *
925
+ * @param props - {@link AssembleClaimDelayedCallsProps}
926
+ * @returns Raw facade multicall payload for the claim
927
+ */
928
+ assembleClaimDelayedCalls(props: AssembleClaimDelayedCallsProps): Array<MultiCall>;
901
929
  /**
902
930
  * Preview delayed withdrawal for given token
903
931
  * @param props - {@link PreviewDelayedWithdrawalProps}
@@ -1004,10 +1032,11 @@ export interface ICreditAccountsService extends Construct {
1004
1032
  * Each operation must already carry concrete encoding data (e.g. swap/wrap
1005
1033
  * `calls`). Unknown operation types throw.
1006
1034
  *
1007
- * Does not handle close, repay, or start delayed withdrawal — use
1008
- * {@link ICreditAccountsService.assembleCloseCreditAccountCalls} /
1035
+ * Does not handle close, repay, start delayed withdrawal, or claim delayed
1036
+ * use {@link ICreditAccountsService.assembleCloseCreditAccountCalls} /
1009
1037
  * {@link ICreditAccountsService.assembleRepayCreditAccountCalls} /
1010
- * {@link ICreditAccountsService.assembleStartDelayedWithdrawalCalls}.
1038
+ * {@link ICreditAccountsService.assembleStartDelayedWithdrawalCalls} /
1039
+ * {@link ICreditAccountsService.assembleClaimDelayedCalls}.
1011
1040
  *
1012
1041
  * @param props - Encodable operations and account context
1013
1042
  * @returns Array of facade / adapter multicall calls (without price feed updates)
@@ -103,6 +103,10 @@ declare const abi: readonly [{
103
103
  readonly name: "claimableAt";
104
104
  readonly type: "uint256";
105
105
  readonly internalType: "uint256";
106
+ }, {
107
+ readonly name: "extraData";
108
+ readonly type: "bytes";
109
+ readonly internalType: "bytes";
106
110
  }];
107
111
  }];
108
112
  readonly stateMutability: "view";
@@ -15,7 +15,6 @@ export interface WithdrawalCompressorLocation {
15
15
  * Returns the withdrawal compressor deployment for the given network,
16
16
  * or `undefined` if none is configured.
17
17
  * @param network - Network type.
18
- * @param version - Desired compressor version; when omitted, the latest supported version is returned.
19
18
  * @returns Withdrawal compressor address and version, or `undefined`.
20
19
  **/
21
- export declare function getWithdrawalCompressorAddress(network: NetworkType, version?: WithdrawalCompressorVersion): WithdrawalCompressorLocation | undefined;
20
+ export declare function getWithdrawalCompressorAddress(network: NetworkType): WithdrawalCompressorLocation | undefined;
@@ -1,11 +1,9 @@
1
1
  import type { OnchainSDK } from "../../OnchainSDK.js";
2
- import type { WithdrawalCompressorVersion } from "./addresses.js";
3
2
  import type { IWithdrawalCompressorContract } from "./types.js";
4
3
  /**
5
4
  * Returns a withdrawal compressor contract for the current chain,
6
5
  * reusing an instance from the contracts register when available.
7
6
  * @param sdk
8
- * @param version - Desired compressor version; when omitted, the latest supported version is used.
9
- * @throws if no withdrawal compressor of given version is supported on the current chain.
7
+ * @throws if no withdrawal compressor is supported on the current chain.
10
8
  **/
11
- export declare function createWithdrawalCompressor(sdk: OnchainSDK, version?: WithdrawalCompressorVersion): IWithdrawalCompressorContract;
9
+ export declare function createWithdrawalCompressor(sdk: OnchainSDK): IWithdrawalCompressorContract;
@@ -209,6 +209,13 @@ export interface PendingWithdrawal {
209
209
  * Unix timestamp (in seconds) when the withdrawal becomes claimable
210
210
  **/
211
211
  claimableAt: bigint;
212
+ /**
213
+ * Delayed intent decoded from the withdrawal's `extraData`, enriched with
214
+ * the credit manager of the credit account. `undefined` on compressor
215
+ * versions below 313, and on v313+ when the withdrawal was requested
216
+ * without an intent (empty `extraData`).
217
+ **/
218
+ intent?: DelayedIntentExtended;
212
219
  }
213
220
  /**
214
221
  * Result of previewing a delayed withdrawal request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.21",
3
+ "version": "14.12.0-next.23",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {