@gearbox-protocol/sdk 14.12.0-next.17 → 14.12.0-next.19

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 (104) hide show
  1. package/dist/cjs/abi/{IWithdrawalCompressorV312.js → IWithdrawalCompressorV313.js} +49 -6
  2. package/dist/cjs/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.js +45 -1
  3. package/dist/cjs/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +45 -1
  4. package/dist/cjs/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +45 -1
  5. package/dist/cjs/abi/compressors/withdrawalCompressor.js +45 -1
  6. package/dist/cjs/dev/index.js +3 -1
  7. package/dist/cjs/dev/withdrawalAbi.js +2105 -0
  8. package/dist/cjs/dev/withdrawalUtils.js +271 -0
  9. package/dist/cjs/permissionless/bindings/factory/rate-keeper-factory.js +35 -0
  10. package/dist/cjs/permissionless/bindings/market-configurator.js +11 -0
  11. package/dist/cjs/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +1015 -0
  12. package/dist/cjs/plugins/adapters/abi/adapters/{iMidasIssuanceVaultAdapter.js → iMidasIssuanceVaultAdapterV310.js} +6 -6
  13. package/dist/cjs/plugins/adapters/abi/adapters/{iMidasRedemptionVault.js → iMidasRedemptionVaultAdapterV310.js} +9 -9
  14. package/dist/cjs/plugins/adapters/abi/adapters/index.js +6 -4
  15. package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +3 -0
  16. package/dist/cjs/plugins/adapters/abi/targetContractAbi.js +3 -3
  17. package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +121 -0
  18. package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +2 -2
  19. package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +2 -2
  20. package/dist/cjs/plugins/adapters/contracts/index.js +2 -0
  21. package/dist/cjs/plugins/adapters/createAdapter.js +2 -0
  22. package/dist/cjs/plugins/adapters/types.js +1 -0
  23. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +20 -37
  24. package/dist/cjs/sdk/OnchainSDK.js +11 -0
  25. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +9 -55
  26. package/dist/cjs/sdk/accounts/index.js +3 -1
  27. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +224 -0
  28. package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +40 -0
  29. package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +40 -0
  30. package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +40 -0
  31. package/dist/cjs/sdk/accounts/withdrawal-compressor/addresses.js +52 -0
  32. package/dist/cjs/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +53 -0
  33. package/dist/cjs/sdk/accounts/withdrawal-compressor/index.js +36 -0
  34. package/dist/cjs/sdk/accounts/withdrawal-compressor/intent.js +172 -0
  35. package/dist/cjs/sdk/accounts/withdrawal-compressor/types.js +16 -0
  36. package/dist/esm/abi/{IWithdrawalCompressorV312.js → IWithdrawalCompressorV313.js} +45 -2
  37. package/dist/esm/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.js +45 -1
  38. package/dist/esm/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.js +45 -1
  39. package/dist/esm/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.js +45 -1
  40. package/dist/esm/abi/compressors/withdrawalCompressor.js +45 -1
  41. package/dist/esm/dev/index.js +1 -0
  42. package/dist/esm/dev/withdrawalAbi.js +2074 -0
  43. package/dist/esm/dev/withdrawalUtils.js +259 -0
  44. package/dist/esm/permissionless/bindings/factory/rate-keeper-factory.js +11 -0
  45. package/dist/esm/permissionless/bindings/market-configurator.js +11 -0
  46. package/dist/esm/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.js +990 -0
  47. package/dist/esm/plugins/adapters/abi/adapters/{iMidasIssuanceVaultAdapter.js → iMidasIssuanceVaultAdapterV310.js} +2 -2
  48. package/dist/esm/plugins/adapters/abi/adapters/{iMidasRedemptionVault.js → iMidasRedemptionVaultAdapterV310.js} +4 -4
  49. package/dist/esm/plugins/adapters/abi/adapters/index.js +3 -2
  50. package/dist/esm/plugins/adapters/abi/conctructorAbi.js +3 -0
  51. package/dist/esm/plugins/adapters/abi/targetContractAbi.js +2 -2
  52. package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +104 -0
  53. package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +4 -4
  54. package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +4 -4
  55. package/dist/esm/plugins/adapters/contracts/index.js +1 -0
  56. package/dist/esm/plugins/adapters/createAdapter.js +3 -0
  57. package/dist/esm/plugins/adapters/types.js +1 -0
  58. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +21 -39
  59. package/dist/esm/sdk/OnchainSDK.js +13 -1
  60. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +8 -53
  61. package/dist/esm/sdk/accounts/index.js +1 -0
  62. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +200 -0
  63. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +16 -0
  64. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +16 -0
  65. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +16 -0
  66. package/dist/esm/sdk/accounts/withdrawal-compressor/addresses.js +28 -0
  67. package/dist/esm/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.js +29 -0
  68. package/dist/esm/sdk/accounts/withdrawal-compressor/index.js +8 -0
  69. package/dist/esm/sdk/accounts/withdrawal-compressor/intent.js +137 -0
  70. package/dist/esm/sdk/accounts/withdrawal-compressor/types.js +0 -0
  71. package/dist/types/abi/{IWithdrawalCompressorV312.d.ts → IWithdrawalCompressorV313.d.ts} +74 -1
  72. package/dist/types/abi/compressors/subcompressors/withdrawal/mellowWithdrawalSubcompressor.d.ts +77 -0
  73. package/dist/types/abi/compressors/subcompressors/withdrawal/midasWithdrawalSubcompressor.d.ts +77 -0
  74. package/dist/types/abi/compressors/subcompressors/withdrawal/securitizeRedemptionSubcompressor.d.ts +77 -0
  75. package/dist/types/abi/compressors/withdrawalCompressor.d.ts +77 -0
  76. package/dist/types/dev/index.d.ts +1 -0
  77. package/dist/types/dev/withdrawalAbi.d.ts +1584 -0
  78. package/dist/types/dev/withdrawalUtils.d.ts +19 -0
  79. package/dist/types/permissionless/bindings/compressors/withdrawal-compressor.d.ts +77 -0
  80. package/dist/types/permissionless/bindings/factory/rate-keeper-factory.d.ts +179 -0
  81. package/dist/types/permissionless/bindings/market-configurator.d.ts +2 -0
  82. package/dist/types/plugins/adapters/abi/adapters/iMidasGatewayAdapterV311.d.ts +754 -0
  83. package/dist/types/plugins/adapters/abi/adapters/{iMidasIssuanceVaultAdapter.d.ts → iMidasIssuanceVaultAdapterV310.d.ts} +1 -1
  84. package/dist/types/plugins/adapters/abi/adapters/{iMidasRedemptionVault.d.ts → iMidasRedemptionVaultAdapterV310.d.ts} +2 -2
  85. package/dist/types/plugins/adapters/abi/adapters/index.d.ts +3 -2
  86. package/dist/types/plugins/adapters/abi/targetContractAbi.d.ts +1 -1
  87. package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +790 -0
  88. package/dist/types/plugins/adapters/contracts/index.d.ts +1 -0
  89. package/dist/types/plugins/adapters/types.d.ts +2 -1
  90. package/dist/types/plugins/delayed-withdrawal/types.d.ts +4 -17
  91. package/dist/types/sdk/OnchainSDK.d.ts +10 -1
  92. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +3 -11
  93. package/dist/types/sdk/accounts/index.d.ts +1 -0
  94. package/dist/types/sdk/accounts/types.d.ts +4 -18
  95. package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +35 -0
  96. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.d.ts +334 -0
  97. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.d.ts +338 -0
  98. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +300 -0
  99. package/dist/types/sdk/accounts/withdrawal-compressor/addresses.d.ts +21 -0
  100. package/dist/types/sdk/accounts/withdrawal-compressor/createWithdrawalCompressor.d.ts +11 -0
  101. package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +8 -0
  102. package/dist/types/sdk/accounts/withdrawal-compressor/intent.d.ts +106 -0
  103. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +122 -0
  104. package/package.json +1 -1
@@ -0,0 +1,106 @@
1
+ import type { Hex } from "viem";
2
+ import { z } from "zod/v4";
3
+ /**
4
+ * App: 1.1 Deposit and 4.1 Adjust leverage — raise leverage at fixed TVL.
5
+ * Borrow `underlying` -> swap `underlying` into `targetToken` -> [withdraw to wallet].
6
+ **/
7
+ export declare const delayedIncreaseLeverageIntentSchema: z.ZodObject<{
8
+ type: z.ZodLiteral<"INCREASE_LEVERAGE">;
9
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
10
+ }, z.core.$strip>;
11
+ export type DelayedIncreaseLeverageIntent = z.infer<typeof delayedIncreaseLeverageIntentSchema>;
12
+ /**
13
+ * App: 1.2 Deposit — `amount > 0`, leverage = current (grow net value at same L).
14
+ **/
15
+ export declare const delayedDepositIntentSchema: z.ZodObject<{
16
+ type: z.ZodLiteral<"DEPOSIT">;
17
+ }, z.core.$strip>;
18
+ export type DelayedDepositIntent = z.infer<typeof delayedDepositIntentSchema>;
19
+ /**
20
+ * App: 1.3 Deposit and Adjust leverage — `amount > 0`, leverage > current.
21
+ **/
22
+ export declare const delayedDepositAndIncreaseLeverageIntentSchema: z.ZodObject<{
23
+ type: z.ZodLiteral<"DEPOSIT_AND_INCREASE_LEVERAGE">;
24
+ }, z.core.$strip>;
25
+ export type DelayedDepositAndIncreaseLeverageIntent = z.infer<typeof delayedDepositAndIncreaseLeverageIntentSchema>;
26
+ /**
27
+ * App: 2.1 Withdraw — withdraw selected token at fixed leverage.
28
+ **/
29
+ export declare const delayedWithdrawCollateralIntentSchema: z.ZodObject<{
30
+ type: z.ZodLiteral<"WITHDRAW_COLLATERAL">;
31
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
32
+ withdrawToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
33
+ withdrawAmount: z.ZodBigInt;
34
+ }, z.core.$strip>;
35
+ export type DelayedWithdrawCollateralIntent = z.infer<typeof delayedWithdrawCollateralIntentSchema>;
36
+ /**
37
+ * App: 2.2 Withdraw — close account (receive leftover to wallet).
38
+ **/
39
+ export declare const delayedCloseAccountIntentSchema: z.ZodObject<{
40
+ type: z.ZodLiteral<"CLOSE_ACCOUNT">;
41
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
42
+ }, z.core.$strip>;
43
+ export type DelayedCloseAccountIntent = z.infer<typeof delayedCloseAccountIntentSchema>;
44
+ /**
45
+ * App: 3.1 Add collateral — fixed debt.
46
+ **/
47
+ export declare const delayedAddCollateralIntentSchema: z.ZodObject<{
48
+ type: z.ZodLiteral<"ADD_COLLATERAL">;
49
+ }, z.core.$strip>;
50
+ export type DelayedAddCollateralIntent = z.infer<typeof delayedAddCollateralIntentSchema>;
51
+ /**
52
+ * App: 4.2 Adjust leverage — lower leverage at fixed TVL.
53
+ **/
54
+ export declare const delayedDecreaseLeverageIntentSchema: z.ZodObject<{
55
+ type: z.ZodLiteral<"DECREASE_LEVERAGE">;
56
+ }, z.core.$strip>;
57
+ export type DelayedDecreaseLeverageIntent = z.infer<typeof delayedDecreaseLeverageIntentSchema>;
58
+ /**
59
+ * Lean intent that is abi-encoded into `extraData` of a delayed withdrawal
60
+ * request and decoded back when reading claimable withdrawals.
61
+ **/
62
+ export declare const delayedIntentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
63
+ type: z.ZodLiteral<"INCREASE_LEVERAGE">;
64
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ type: z.ZodLiteral<"DEPOSIT">;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ type: z.ZodLiteral<"DEPOSIT_AND_INCREASE_LEVERAGE">;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ type: z.ZodLiteral<"WITHDRAW_COLLATERAL">;
71
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
72
+ withdrawToken: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
73
+ withdrawAmount: z.ZodBigInt;
74
+ }, z.core.$strip>, z.ZodObject<{
75
+ type: z.ZodLiteral<"CLOSE_ACCOUNT">;
76
+ to: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
77
+ }, z.core.$strip>, z.ZodObject<{
78
+ type: z.ZodLiteral<"ADD_COLLATERAL">;
79
+ }, z.core.$strip>, z.ZodObject<{
80
+ type: z.ZodLiteral<"DECREASE_LEVERAGE">;
81
+ }, z.core.$strip>], "type">;
82
+ export type DelayedIntent = z.infer<typeof delayedIntentSchema>;
83
+ /**
84
+ * Current version of the delayed intent encoding schema.
85
+ * Bump when the layout of any intent type changes.
86
+ **/
87
+ export declare const DELAYED_INTENT_VERSION = 1;
88
+ /**
89
+ * Stable uint8 discriminants for intent types.
90
+ * Starts at 1 so that all-zero data cannot decode as a valid intent.
91
+ * Never reuse or renumber existing values.
92
+ **/
93
+ export declare const DELAYED_INTENT_TYPES: Record<DelayedIntent["type"], number>;
94
+ /**
95
+ * ABI-encodes a delayed intent as
96
+ * `(uint8 version, uint8 intentType, ...intent-specific fields)`.
97
+ * @throws if the intent does not match {@link delayedIntentSchema}
98
+ **/
99
+ export declare function encodeDelayedIntent(intent: DelayedIntent): Hex;
100
+ /**
101
+ * Decodes a delayed intent from abi-encoded `extraData` and validates it
102
+ * against {@link delayedIntentSchema}.
103
+ * @throws if data is empty, has an unsupported version, an unknown intent
104
+ * type, or does not match the schema
105
+ **/
106
+ export declare function decodeDelayedIntent(data: Hex): DelayedIntent;
@@ -0,0 +1,122 @@
1
+ import type { Address } from "viem";
2
+ import type { IBaseContract } from "../../base/index.js";
3
+ import type { MultiCall } from "../../types/index.js";
4
+ import type { DelayedIntent } from "./intent.js";
5
+ /**
6
+ * Delayed intent decoded from `extraData`, enriched with data known at read time.
7
+ **/
8
+ export type DelayedIntentExtended = DelayedIntent & {
9
+ /**
10
+ * Credit manager of the credit account the withdrawal belongs to
11
+ **/
12
+ creditManager: Address;
13
+ };
14
+ /**
15
+ * A single output of a (delayed) withdrawal.
16
+ **/
17
+ export interface WithdrawalOutput {
18
+ token: Address;
19
+ isDelayed: boolean;
20
+ amount: bigint;
21
+ }
22
+ /**
23
+ * An asset that can be withdrawn from a credit manager via delayed withdrawal.
24
+ **/
25
+ export interface WithdrawableAsset {
26
+ /**
27
+ * Credit manager the asset is withdrawable from
28
+ **/
29
+ creditManager: Address;
30
+ /**
31
+ * Source token (e.g. rstETH)
32
+ **/
33
+ token: Address;
34
+ /**
35
+ * Withdrawal phantom token (e.g. wdwstETH)
36
+ **/
37
+ withdrawalPhantomToken: Address;
38
+ /**
39
+ * Target token (e.g. wstETH)
40
+ **/
41
+ underlying: Address;
42
+ withdrawalLength: bigint;
43
+ /**
44
+ * Not available on v310 compressors
45
+ **/
46
+ maxWithdrawals?: bigint;
47
+ }
48
+ /**
49
+ * A single delayed withdrawal that is ready to be claimed.
50
+ **/
51
+ export interface ClaimableWithdrawal {
52
+ token: Address;
53
+ withdrawalPhantomToken: Address;
54
+ withdrawalTokenSpent: bigint;
55
+ outputs: WithdrawalOutput[];
56
+ claimCalls: MultiCall[];
57
+ /**
58
+ * Delayed intent decoded from the withdrawal's `extraData`, enriched with
59
+ * the credit manager of the credit account. `undefined` on compressor
60
+ * versions below 313, and on v313+ when the withdrawal was requested
61
+ * without an intent (empty `extraData`).
62
+ **/
63
+ intent?: DelayedIntentExtended;
64
+ }
65
+ /**
66
+ * A single pending delayed withdrawal that is not yet claimable.
67
+ **/
68
+ export interface PendingWithdrawal {
69
+ token: Address;
70
+ withdrawalPhantomToken: Address;
71
+ expectedOutputs: WithdrawalOutput[];
72
+ claimableAt: bigint;
73
+ }
74
+ /**
75
+ * Result of previewing a delayed withdrawal request.
76
+ **/
77
+ export interface RequestableWithdrawal {
78
+ token: Address;
79
+ amountIn: bigint;
80
+ outputs: WithdrawalOutput[];
81
+ requestCalls: MultiCall[];
82
+ claimableAt: bigint;
83
+ }
84
+ /**
85
+ * Delayed withdrawals of a credit account, split into immediately claimable
86
+ * and still-pending entries.
87
+ **/
88
+ export interface CurrentWithdrawals {
89
+ claimable: ClaimableWithdrawal[];
90
+ /**
91
+ * Sorted by claimableAt in ascending order
92
+ **/
93
+ pending: PendingWithdrawal[];
94
+ }
95
+ /**
96
+ * Version-agnostic interface of the WithdrawalCompressor contract.
97
+ **/
98
+ export interface IWithdrawalCompressorContract extends IBaseContract {
99
+ /**
100
+ * Returns assets that can be withdrawn from the given credit manager via delayed withdrawal.
101
+ **/
102
+ getWithdrawableAssets(creditManager: Address): Promise<WithdrawableAsset[]>;
103
+ /**
104
+ * Same as {@link getWithdrawableAssets}, but for multiple credit managers in a single multicall.
105
+ * Defaults to all credit managers known to the SDK's market register.
106
+ * Failed per-manager calls are logged and skipped.
107
+ **/
108
+ getWithdrawableAssetsBatch(creditManagers?: Address[]): Promise<WithdrawableAsset[]>;
109
+ /**
110
+ * Returns claimable and pending delayed withdrawals of the given credit account.
111
+ **/
112
+ getCurrentWithdrawals(creditAccount: Address): Promise<CurrentWithdrawals>;
113
+ /**
114
+ * Previews a delayed withdrawal request.
115
+ *
116
+ * When `intent` is provided, it is abi-encoded and passed as `extraData` to
117
+ * the contract on v313+ compressors. On older versions, passing an intent
118
+ * throws if `sdk.strictContractTypes` is `true`, otherwise a warning is
119
+ * logged and the intent is ignored.
120
+ **/
121
+ getWithdrawalRequestResult(creditAccount: Address, token: Address, amount: bigint, intent?: DelayedIntent): Promise<RequestableWithdrawal>;
122
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.17",
3
+ "version": "14.12.0-next.19",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {