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

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 +229 -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 +205 -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,229 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var AbstractWithdrawalCompressorContract_exports = {};
20
+ __export(AbstractWithdrawalCompressorContract_exports, {
21
+ AbstractWithdrawalCompressorContract: () => AbstractWithdrawalCompressorContract
22
+ });
23
+ module.exports = __toCommonJS(AbstractWithdrawalCompressorContract_exports);
24
+ var import_viem = require("viem");
25
+ var import_base = require("../../base/index.js");
26
+ var import_intent = require("./intent.js");
27
+ const iCreditAccountAbi = [
28
+ {
29
+ type: "function",
30
+ name: "creditManager",
31
+ inputs: [],
32
+ outputs: [{ name: "", type: "address", internalType: "address" }],
33
+ stateMutability: "view"
34
+ }
35
+ ];
36
+ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
37
+ #sdk;
38
+ constructor(sdk, args) {
39
+ super(sdk, args);
40
+ this.#sdk = sdk;
41
+ }
42
+ /**
43
+ * The contract is instantiated with the actual versioned ABI,
44
+ * this cast is type-level only (see {@link CommonAbi}).
45
+ **/
46
+ get common() {
47
+ return this.contract;
48
+ }
49
+ /**
50
+ * {@inheritDoc IWithdrawalCompressorContract.getWithdrawableAssets}
51
+ **/
52
+ async getWithdrawableAssets(creditManager) {
53
+ const resp = await this.common.read.getWithdrawableAssets([creditManager]);
54
+ return resp.map((a) => toWithdrawableAsset(a, creditManager));
55
+ }
56
+ /**
57
+ * {@inheritDoc IWithdrawalCompressorContract.getWithdrawableAssetsBatch}
58
+ **/
59
+ async getWithdrawableAssetsBatch(creditManagers) {
60
+ const cms = creditManagers ?? this.#sdk.marketRegister.creditManagers.map(
61
+ (cm) => cm.creditManager.address
62
+ );
63
+ const resp = await this.client.multicall({
64
+ contracts: cms.map(
65
+ (cm) => ({
66
+ address: this.address,
67
+ abi: this.abi,
68
+ functionName: "getWithdrawableAssets",
69
+ args: [cm]
70
+ })
71
+ ),
72
+ allowFailure: true,
73
+ batchSize: 0
74
+ });
75
+ return resp.flatMap((r, i) => {
76
+ if (r.status !== "success") {
77
+ this.logger?.warn(
78
+ `failed to get withdrawable assets of credit manager ${cms[i]}: ${r.error}`
79
+ );
80
+ return [];
81
+ }
82
+ return r.result.map((a) => toWithdrawableAsset(a, cms[i]));
83
+ });
84
+ }
85
+ /**
86
+ * {@inheritDoc IWithdrawalCompressorContract.getCurrentWithdrawals}
87
+ **/
88
+ async getCurrentWithdrawals(creditAccount) {
89
+ const [[claimable, pending], creditManager] = await this.client.multicall({
90
+ contracts: [
91
+ {
92
+ address: this.address,
93
+ abi: this.abi,
94
+ functionName: "getCurrentWithdrawals",
95
+ args: [creditAccount]
96
+ },
97
+ {
98
+ address: creditAccount,
99
+ abi: iCreditAccountAbi,
100
+ functionName: "creditManager"
101
+ }
102
+ ],
103
+ allowFailure: false,
104
+ batchSize: 0
105
+ });
106
+ return {
107
+ claimable: claimable.map(
108
+ (w) => toClaimableWithdrawal(w, creditManager, this.version >= 313)
109
+ ),
110
+ pending: pending.map(toPendingWithdrawal).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
111
+ };
112
+ }
113
+ /**
114
+ * {@inheritDoc IWithdrawalCompressorContract.getWithdrawalRequestResult}
115
+ **/
116
+ async getWithdrawalRequestResult(creditAccount, token, amount, intent) {
117
+ const resp = intent ? await this.#getWithdrawalRequestResultWithIntent(
118
+ creditAccount,
119
+ token,
120
+ amount,
121
+ intent
122
+ ) : await this.common.read.getWithdrawalRequestResult([
123
+ creditAccount,
124
+ token,
125
+ amount
126
+ ]);
127
+ return {
128
+ token: resp.token,
129
+ amountIn: resp.amountIn,
130
+ outputs: resp.outputs.map(toWithdrawalOutput),
131
+ requestCalls: resp.requestCalls.map(toMultiCall),
132
+ claimableAt: resp.claimableAt
133
+ };
134
+ }
135
+ /**
136
+ * Previews a delayed withdrawal request with an intent attached as
137
+ * `extraData`. Only supported on v313+ compressors; on older versions,
138
+ * throws if `sdk.strictContractTypes` is `true`, otherwise logs a warning
139
+ * and previews the request without the intent.
140
+ *
141
+ * The contract overload accepting `extraData` also requires the withdrawal
142
+ * phantom token, which is resolved here the same way the 3-arg overload
143
+ * does it internally: via `getWithdrawableAssets` of the account's credit
144
+ * manager.
145
+ **/
146
+ async #getWithdrawalRequestResultWithIntent(creditAccount, token, amount, intent) {
147
+ if (this.version < 313) {
148
+ const message = `withdrawal intents are not supported by ${this.name} v${this.version}`;
149
+ if (this.#sdk.strictContractTypes) {
150
+ throw new Error(message);
151
+ }
152
+ this.logger?.warn(`${message}, requesting withdrawal without intent`);
153
+ return this.common.read.getWithdrawalRequestResult([
154
+ creditAccount,
155
+ token,
156
+ amount
157
+ ]);
158
+ }
159
+ const extraData = (0, import_intent.encodeDelayedIntent)(intent);
160
+ const creditManager = await this.client.readContract({
161
+ address: creditAccount,
162
+ abi: iCreditAccountAbi,
163
+ functionName: "creditManager"
164
+ });
165
+ const assets = await this.common.read.getWithdrawableAssets([
166
+ creditManager
167
+ ]);
168
+ const asset = assets.find((a) => (0, import_viem.isAddressEqual)(a.token, token));
169
+ if (!asset) {
170
+ throw new Error(
171
+ `token ${token} is not withdrawable from credit manager ${creditManager}`
172
+ );
173
+ }
174
+ return this.common.read.getWithdrawalRequestResult([
175
+ creditAccount,
176
+ token,
177
+ asset.withdrawalPhantomToken,
178
+ amount,
179
+ extraData
180
+ ]);
181
+ }
182
+ }
183
+ function toWithdrawalOutput(o) {
184
+ return { token: o.token, isDelayed: o.isDelayed, amount: o.amount };
185
+ }
186
+ function toMultiCall(c) {
187
+ return { target: c.target, callData: c.callData };
188
+ }
189
+ function toWithdrawableAsset(a, creditManager) {
190
+ return {
191
+ creditManager,
192
+ token: a.token,
193
+ withdrawalPhantomToken: a.withdrawalPhantomToken,
194
+ underlying: a.underlying,
195
+ withdrawalLength: a.withdrawalLength,
196
+ maxWithdrawals: a.maxWithdrawals
197
+ };
198
+ }
199
+ function toClaimableWithdrawal(w, creditManager, decodeIntent) {
200
+ let intent;
201
+ if (decodeIntent) {
202
+ if (!w.extraData || w.extraData === "0x") {
203
+ throw new Error(
204
+ `claimable withdrawal of ${w.token} has no delayed intent in extraData`
205
+ );
206
+ }
207
+ intent = { ...(0, import_intent.decodeDelayedIntent)(w.extraData), creditManager };
208
+ }
209
+ return {
210
+ token: w.token,
211
+ withdrawalPhantomToken: w.withdrawalPhantomToken,
212
+ withdrawalTokenSpent: w.withdrawalTokenSpent,
213
+ outputs: w.outputs.map(toWithdrawalOutput),
214
+ claimCalls: w.claimCalls.map(toMultiCall),
215
+ intent
216
+ };
217
+ }
218
+ function toPendingWithdrawal(w) {
219
+ return {
220
+ token: w.token,
221
+ withdrawalPhantomToken: w.withdrawalPhantomToken,
222
+ expectedOutputs: w.expectedOutputs.map(toWithdrawalOutput),
223
+ claimableAt: w.claimableAt
224
+ };
225
+ }
226
+ // Annotate the CommonJS export names for ESM import in node:
227
+ 0 && (module.exports = {
228
+ AbstractWithdrawalCompressorContract
229
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var WithdrawalCompressorV310Contract_exports = {};
20
+ __export(WithdrawalCompressorV310Contract_exports, {
21
+ WithdrawalCompressorV310Contract: () => WithdrawalCompressorV310Contract
22
+ });
23
+ module.exports = __toCommonJS(WithdrawalCompressorV310Contract_exports);
24
+ var import_IWithdrawalCompressorV310 = require("../../../abi/IWithdrawalCompressorV310.js");
25
+ var import_AbstractWithdrawalCompressorContract = require("./AbstractWithdrawalCompressorContract.js");
26
+ const abi = import_IWithdrawalCompressorV310.iWithdrawalCompressorV310Abi;
27
+ class WithdrawalCompressorV310Contract extends import_AbstractWithdrawalCompressorContract.AbstractWithdrawalCompressorContract {
28
+ constructor(sdk, address) {
29
+ super(sdk, {
30
+ addr: address,
31
+ name: "WithdrawalCompressorV310",
32
+ abi,
33
+ version: 310
34
+ });
35
+ }
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ WithdrawalCompressorV310Contract
40
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var WithdrawalCompressorV311Contract_exports = {};
20
+ __export(WithdrawalCompressorV311Contract_exports, {
21
+ WithdrawalCompressorV311Contract: () => WithdrawalCompressorV311Contract
22
+ });
23
+ module.exports = __toCommonJS(WithdrawalCompressorV311Contract_exports);
24
+ var import_IWithdrawalCompressorV311 = require("../../../abi/IWithdrawalCompressorV311.js");
25
+ var import_AbstractWithdrawalCompressorContract = require("./AbstractWithdrawalCompressorContract.js");
26
+ const abi = import_IWithdrawalCompressorV311.iWithdrawalCompressorV311Abi;
27
+ class WithdrawalCompressorV311Contract extends import_AbstractWithdrawalCompressorContract.AbstractWithdrawalCompressorContract {
28
+ constructor(sdk, address) {
29
+ super(sdk, {
30
+ addr: address,
31
+ name: "WithdrawalCompressorV311",
32
+ abi,
33
+ version: 311
34
+ });
35
+ }
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ WithdrawalCompressorV311Contract
40
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var WithdrawalCompressorV313Contract_exports = {};
20
+ __export(WithdrawalCompressorV313Contract_exports, {
21
+ WithdrawalCompressorV313Contract: () => WithdrawalCompressorV313Contract
22
+ });
23
+ module.exports = __toCommonJS(WithdrawalCompressorV313Contract_exports);
24
+ var import_IWithdrawalCompressorV313 = require("../../../abi/IWithdrawalCompressorV313.js");
25
+ var import_AbstractWithdrawalCompressorContract = require("./AbstractWithdrawalCompressorContract.js");
26
+ const abi = import_IWithdrawalCompressorV313.iWithdrawalCompressorV313Abi;
27
+ class WithdrawalCompressorV313Contract extends import_AbstractWithdrawalCompressorContract.AbstractWithdrawalCompressorContract {
28
+ constructor(sdk, address) {
29
+ super(sdk, {
30
+ addr: address,
31
+ name: "WithdrawalCompressorV313",
32
+ abi,
33
+ version: 313
34
+ });
35
+ }
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ WithdrawalCompressorV313Contract
40
+ });
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var addresses_exports = {};
20
+ __export(addresses_exports, {
21
+ getWithdrawalCompressorAddress: () => getWithdrawalCompressorAddress
22
+ });
23
+ module.exports = __toCommonJS(addresses_exports);
24
+ const WITHDRAWAL_COMPRESSORS = {
25
+ Mainnet: {
26
+ 310: "0x36F3d0Bb73CBC2E94fE24dF0f26a689409cF9023",
27
+ 313: "0x9605D59E40963ADce8a6895Aa3Fa497320Ef3F3b"
28
+ },
29
+ Monad: {
30
+ 310: "0x36F3d0Bb73CBC2E94fE24dF0f26a689409cF9023"
31
+ }
32
+ };
33
+ function getWithdrawalCompressorAddress(network, version) {
34
+ const deployments = WITHDRAWAL_COMPRESSORS[network];
35
+ if (!deployments) {
36
+ return void 0;
37
+ }
38
+ if (version !== void 0) {
39
+ const address2 = deployments[version];
40
+ return address2 ? { address: address2, version } : void 0;
41
+ }
42
+ const latest = Object.keys(deployments).map(Number).sort((a, b) => b - a)[0];
43
+ if (latest === void 0) {
44
+ return void 0;
45
+ }
46
+ const address = deployments[latest];
47
+ return address ? { address, version: latest } : void 0;
48
+ }
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ getWithdrawalCompressorAddress
52
+ });
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createWithdrawalCompressor_exports = {};
20
+ __export(createWithdrawalCompressor_exports, {
21
+ createWithdrawalCompressor: () => createWithdrawalCompressor
22
+ });
23
+ module.exports = __toCommonJS(createWithdrawalCompressor_exports);
24
+ var import_addresses = require("./addresses.js");
25
+ var import_WithdrawalCompressorV310Contract = require("./WithdrawalCompressorV310Contract.js");
26
+ var import_WithdrawalCompressorV311Contract = require("./WithdrawalCompressorV311Contract.js");
27
+ var import_WithdrawalCompressorV313Contract = require("./WithdrawalCompressorV313Contract.js");
28
+ function createWithdrawalCompressor(sdk, version) {
29
+ const location = (0, import_addresses.getWithdrawalCompressorAddress)(sdk.networkType, version);
30
+ if (!location) {
31
+ throw new Error(
32
+ `no withdrawal compressor${version ? ` v${version}` : ""} on ${sdk.networkType}`
33
+ );
34
+ }
35
+ const cached = sdk.getContract(
36
+ location.address
37
+ );
38
+ if (cached) {
39
+ return cached;
40
+ }
41
+ switch (location.version) {
42
+ case 310:
43
+ return new import_WithdrawalCompressorV310Contract.WithdrawalCompressorV310Contract(sdk, location.address);
44
+ case 311:
45
+ return new import_WithdrawalCompressorV311Contract.WithdrawalCompressorV311Contract(sdk, location.address);
46
+ case 313:
47
+ return new import_WithdrawalCompressorV313Contract.WithdrawalCompressorV313Contract(sdk, location.address);
48
+ }
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ createWithdrawalCompressor
53
+ });
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var withdrawal_compressor_exports = {};
17
+ module.exports = __toCommonJS(withdrawal_compressor_exports);
18
+ __reExport(withdrawal_compressor_exports, require("./AbstractWithdrawalCompressorContract.js"), module.exports);
19
+ __reExport(withdrawal_compressor_exports, require("./addresses.js"), module.exports);
20
+ __reExport(withdrawal_compressor_exports, require("./createWithdrawalCompressor.js"), module.exports);
21
+ __reExport(withdrawal_compressor_exports, require("./intent.js"), module.exports);
22
+ __reExport(withdrawal_compressor_exports, require("./types.js"), module.exports);
23
+ __reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV310Contract.js"), module.exports);
24
+ __reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV311Contract.js"), module.exports);
25
+ __reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV313Contract.js"), module.exports);
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ ...require("./AbstractWithdrawalCompressorContract.js"),
29
+ ...require("./addresses.js"),
30
+ ...require("./createWithdrawalCompressor.js"),
31
+ ...require("./intent.js"),
32
+ ...require("./types.js"),
33
+ ...require("./WithdrawalCompressorV310Contract.js"),
34
+ ...require("./WithdrawalCompressorV311Contract.js"),
35
+ ...require("./WithdrawalCompressorV313Contract.js")
36
+ });
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var intent_exports = {};
20
+ __export(intent_exports, {
21
+ DELAYED_INTENT_TYPES: () => DELAYED_INTENT_TYPES,
22
+ DELAYED_INTENT_VERSION: () => DELAYED_INTENT_VERSION,
23
+ decodeDelayedIntent: () => decodeDelayedIntent,
24
+ delayedAddCollateralIntentSchema: () => delayedAddCollateralIntentSchema,
25
+ delayedCloseAccountIntentSchema: () => delayedCloseAccountIntentSchema,
26
+ delayedDecreaseLeverageIntentSchema: () => delayedDecreaseLeverageIntentSchema,
27
+ delayedDepositAndIncreaseLeverageIntentSchema: () => delayedDepositAndIncreaseLeverageIntentSchema,
28
+ delayedDepositIntentSchema: () => delayedDepositIntentSchema,
29
+ delayedIncreaseLeverageIntentSchema: () => delayedIncreaseLeverageIntentSchema,
30
+ delayedIntentSchema: () => delayedIntentSchema,
31
+ delayedWithdrawCollateralIntentSchema: () => delayedWithdrawCollateralIntentSchema,
32
+ encodeDelayedIntent: () => encodeDelayedIntent
33
+ });
34
+ module.exports = __toCommonJS(intent_exports);
35
+ var import_viem = require("viem");
36
+ var import_v4 = require("zod/v4");
37
+ var import_utils = require("../../utils/index.js");
38
+ const delayedIncreaseLeverageIntentSchema = import_v4.z.object({
39
+ type: import_v4.z.literal("INCREASE_LEVERAGE"),
40
+ to: (0, import_utils.ZodAddress)()
41
+ });
42
+ const delayedDepositIntentSchema = import_v4.z.object({
43
+ type: import_v4.z.literal("DEPOSIT")
44
+ });
45
+ const delayedDepositAndIncreaseLeverageIntentSchema = import_v4.z.object({
46
+ type: import_v4.z.literal("DEPOSIT_AND_INCREASE_LEVERAGE")
47
+ });
48
+ const delayedWithdrawCollateralIntentSchema = import_v4.z.object({
49
+ type: import_v4.z.literal("WITHDRAW_COLLATERAL"),
50
+ to: (0, import_utils.ZodAddress)(),
51
+ withdrawToken: (0, import_utils.ZodAddress)(),
52
+ withdrawAmount: import_v4.z.bigint()
53
+ });
54
+ const delayedCloseAccountIntentSchema = import_v4.z.object({
55
+ type: import_v4.z.literal("CLOSE_ACCOUNT"),
56
+ to: (0, import_utils.ZodAddress)()
57
+ });
58
+ const delayedAddCollateralIntentSchema = import_v4.z.object({
59
+ type: import_v4.z.literal("ADD_COLLATERAL")
60
+ });
61
+ const delayedDecreaseLeverageIntentSchema = import_v4.z.object({
62
+ type: import_v4.z.literal("DECREASE_LEVERAGE")
63
+ });
64
+ const delayedIntentSchema = import_v4.z.discriminatedUnion("type", [
65
+ delayedIncreaseLeverageIntentSchema,
66
+ delayedDepositIntentSchema,
67
+ delayedDepositAndIncreaseLeverageIntentSchema,
68
+ delayedWithdrawCollateralIntentSchema,
69
+ delayedCloseAccountIntentSchema,
70
+ delayedAddCollateralIntentSchema,
71
+ delayedDecreaseLeverageIntentSchema
72
+ ]);
73
+ const DELAYED_INTENT_VERSION = 1;
74
+ const DELAYED_INTENT_TYPES = {
75
+ INCREASE_LEVERAGE: 1,
76
+ DEPOSIT: 2,
77
+ DEPOSIT_AND_INCREASE_LEVERAGE: 3,
78
+ WITHDRAW_COLLATERAL: 4,
79
+ CLOSE_ACCOUNT: 5,
80
+ ADD_COLLATERAL: 6,
81
+ DECREASE_LEVERAGE: 7
82
+ };
83
+ const HEADER_PARAMS = [
84
+ { type: "uint8", name: "version" },
85
+ { type: "uint8", name: "intentType" }
86
+ ];
87
+ const TO_PARAMS = [...HEADER_PARAMS, { type: "address", name: "to" }];
88
+ const WITHDRAW_COLLATERAL_PARAMS = [
89
+ ...TO_PARAMS,
90
+ { type: "address", name: "withdrawToken" },
91
+ { type: "uint256", name: "withdrawAmount" }
92
+ ];
93
+ function encodeDelayedIntent(intent) {
94
+ const parsed = delayedIntentSchema.parse(intent);
95
+ const version = DELAYED_INTENT_VERSION;
96
+ const intentType = DELAYED_INTENT_TYPES[parsed.type];
97
+ switch (parsed.type) {
98
+ case "INCREASE_LEVERAGE":
99
+ case "CLOSE_ACCOUNT":
100
+ return (0, import_viem.encodeAbiParameters)(TO_PARAMS, [version, intentType, parsed.to]);
101
+ case "WITHDRAW_COLLATERAL":
102
+ return (0, import_viem.encodeAbiParameters)(WITHDRAW_COLLATERAL_PARAMS, [
103
+ version,
104
+ intentType,
105
+ parsed.to,
106
+ parsed.withdrawToken,
107
+ parsed.withdrawAmount
108
+ ]);
109
+ case "DEPOSIT":
110
+ case "DEPOSIT_AND_INCREASE_LEVERAGE":
111
+ case "ADD_COLLATERAL":
112
+ case "DECREASE_LEVERAGE":
113
+ return (0, import_viem.encodeAbiParameters)(HEADER_PARAMS, [version, intentType]);
114
+ default: {
115
+ const t = parsed;
116
+ throw new Error(`unknown delayed intent: ${JSON.stringify(t)}`);
117
+ }
118
+ }
119
+ }
120
+ function decodeDelayedIntent(data) {
121
+ const [version, intentType] = (0, import_viem.decodeAbiParameters)(HEADER_PARAMS, data);
122
+ if (version !== DELAYED_INTENT_VERSION) {
123
+ throw new Error(`unsupported delayed intent version: ${version}`);
124
+ }
125
+ switch (intentType) {
126
+ case DELAYED_INTENT_TYPES.INCREASE_LEVERAGE: {
127
+ const [, , to] = (0, import_viem.decodeAbiParameters)(TO_PARAMS, data);
128
+ return delayedIntentSchema.parse({ type: "INCREASE_LEVERAGE", to });
129
+ }
130
+ case DELAYED_INTENT_TYPES.DEPOSIT:
131
+ return { type: "DEPOSIT" };
132
+ case DELAYED_INTENT_TYPES.DEPOSIT_AND_INCREASE_LEVERAGE:
133
+ return { type: "DEPOSIT_AND_INCREASE_LEVERAGE" };
134
+ case DELAYED_INTENT_TYPES.WITHDRAW_COLLATERAL: {
135
+ const [, , to, withdrawToken, withdrawAmount] = (0, import_viem.decodeAbiParameters)(
136
+ WITHDRAW_COLLATERAL_PARAMS,
137
+ data
138
+ );
139
+ return delayedIntentSchema.parse({
140
+ type: "WITHDRAW_COLLATERAL",
141
+ to,
142
+ withdrawToken,
143
+ withdrawAmount
144
+ });
145
+ }
146
+ case DELAYED_INTENT_TYPES.CLOSE_ACCOUNT: {
147
+ const [, , to] = (0, import_viem.decodeAbiParameters)(TO_PARAMS, data);
148
+ return delayedIntentSchema.parse({ type: "CLOSE_ACCOUNT", to });
149
+ }
150
+ case DELAYED_INTENT_TYPES.ADD_COLLATERAL:
151
+ return { type: "ADD_COLLATERAL" };
152
+ case DELAYED_INTENT_TYPES.DECREASE_LEVERAGE:
153
+ return { type: "DECREASE_LEVERAGE" };
154
+ default:
155
+ throw new Error(`unknown delayed intent type: ${intentType}`);
156
+ }
157
+ }
158
+ // Annotate the CommonJS export names for ESM import in node:
159
+ 0 && (module.exports = {
160
+ DELAYED_INTENT_TYPES,
161
+ DELAYED_INTENT_VERSION,
162
+ decodeDelayedIntent,
163
+ delayedAddCollateralIntentSchema,
164
+ delayedCloseAccountIntentSchema,
165
+ delayedDecreaseLeverageIntentSchema,
166
+ delayedDepositAndIncreaseLeverageIntentSchema,
167
+ delayedDepositIntentSchema,
168
+ delayedIncreaseLeverageIntentSchema,
169
+ delayedIntentSchema,
170
+ delayedWithdrawCollateralIntentSchema,
171
+ encodeDelayedIntent
172
+ });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);