@morpho-org/bundler-sdk-viem 3.0.0 → 3.0.1

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/lib/actions.js CHANGED
@@ -1,28 +1,32 @@
1
- import { encodeFunctionData, erc20Abi, maxUint256, verifyTypedData, zeroAddress, } from "viem";
2
- import { ChainId, DEFAULT_SLIPPAGE_TOLERANCE, MathLib, NATIVE_ADDRESS, convexWrapperTokens, erc20WrapperTokens, getChainAddresses, getUnwrappedToken, } from "@morpho-org/blue-sdk";
3
- import { Time, getValue } from "@morpho-org/morpho-ts";
4
- import { getCurrent, simulateOperation, } from "@morpho-org/simulation-sdk";
5
- import { blueAbi, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermitTypedData, } from "@morpho-org/blue-sdk-viem";
6
- import { signTypedData } from "viem/actions";
7
- import { ActionBundle, ActionBundleRequirements } from "./ActionBundle.js";
8
- import { BundlerErrors } from "./errors.js";
9
- export const APPROVE_ONLY_ONCE_TOKENS = {
10
- [ChainId.EthMainnet]: [
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeOperation = exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = void 0;
4
+ exports.encodeBundle = encodeBundle;
5
+ const viem_1 = require("viem");
6
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
7
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
8
+ const simulation_sdk_1 = require("@morpho-org/simulation-sdk");
9
+ const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
10
+ const actions_1 = require("viem/actions");
11
+ const ActionBundle_js_1 = require("./ActionBundle.js");
12
+ const errors_js_1 = require("./errors.js");
13
+ exports.APPROVE_ONLY_ONCE_TOKENS = {
14
+ [blue_sdk_1.ChainId.EthMainnet]: [
11
15
  "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT
12
16
  "0xD533a949740bb3306d119CC777fa900bA034cd52", // CRV
13
17
  ],
14
18
  };
15
- export const MAX_TOKEN_APPROVALS = {
16
- [ChainId.EthMainnet]: {
17
- "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": MathLib.maxUint(96), // UNI --> see https://github.com/Uniswap/governance/blob/eabd8c71ad01f61fb54ed6945162021ee419998e/contracts/Uni.sol#L154
19
+ exports.MAX_TOKEN_APPROVALS = {
20
+ [blue_sdk_1.ChainId.EthMainnet]: {
21
+ "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984": blue_sdk_1.MathLib.maxUint(96), // UNI --> see https://github.com/Uniswap/governance/blob/eabd8c71ad01f61fb54ed6945162021ee419998e/contracts/Uni.sol#L154
18
22
  },
19
23
  };
20
24
  const encodeErc20Approval = (token, sender, spender, amount, data) => {
21
25
  const { chainId } = data;
22
- const { morpho, bundler3: { generalAdapter1 }, permit2, } = getChainAddresses(chainId);
23
- amount = MathLib.min(amount, MAX_TOKEN_APPROVALS[chainId]?.[token] ?? maxUint256);
26
+ const { morpho, bundler3: { generalAdapter1 }, permit2, } = (0, blue_sdk_1.getChainAddresses)(chainId);
27
+ amount = blue_sdk_1.MathLib.min(amount, exports.MAX_TOKEN_APPROVALS[chainId]?.[token] ?? viem_1.maxUint256);
24
28
  const txRequirements = [];
25
- if (APPROVE_ONLY_ONCE_TOKENS[chainId]?.includes(token)) {
29
+ if (exports.APPROVE_ONLY_ONCE_TOKENS[chainId]?.includes(token)) {
26
30
  const contract = spender === morpho
27
31
  ? "morpho"
28
32
  : spender === generalAdapter1
@@ -41,8 +45,8 @@ const encodeErc20Approval = (token, sender, spender, amount, data) => {
41
45
  args: [token, spender, 0n],
42
46
  tx: {
43
47
  to: token,
44
- data: encodeFunctionData({
45
- abi: erc20Abi,
48
+ data: (0, viem_1.encodeFunctionData)({
49
+ abi: viem_1.erc20Abi,
46
50
  functionName: "approve",
47
51
  args: [spender, 0n],
48
52
  }),
@@ -54,8 +58,8 @@ const encodeErc20Approval = (token, sender, spender, amount, data) => {
54
58
  args: [token, spender, amount],
55
59
  tx: {
56
60
  to: token,
57
- data: encodeFunctionData({
58
- abi: erc20Abi,
61
+ data: (0, viem_1.encodeFunctionData)({
62
+ abi: viem_1.erc20Abi,
59
63
  functionName: "approve",
60
64
  args: [spender, amount],
61
65
  }),
@@ -63,28 +67,28 @@ const encodeErc20Approval = (token, sender, spender, amount, data) => {
63
67
  });
64
68
  return txRequirements;
65
69
  };
66
- export const encodeOperation = (operation, dataBefore, supportsSignature = true, index = 0) => {
70
+ const encodeOperation = (operation, dataBefore, supportsSignature = true, index = 0) => {
67
71
  const { chainId } = dataBefore;
68
- const deadline = Time.timestamp() + Time.s.from.h(24n);
69
- const { morpho, bundler3: { bundler3, generalAdapter1 }, permit2, wNative, dai, wstEth, stEth, } = getChainAddresses(chainId);
72
+ const deadline = morpho_ts_1.Time.timestamp() + morpho_ts_1.Time.s.from.h(24n);
73
+ const { morpho, bundler3: { bundler3, generalAdapter1 }, permit2, wNative, dai, wstEth, stEth, } = (0, blue_sdk_1.getChainAddresses)(chainId);
70
74
  const actions = [];
71
- const requirements = new ActionBundleRequirements();
75
+ const requirements = new ActionBundle_js_1.ActionBundleRequirements();
72
76
  let callbackBundle;
73
- const callback = getValue(operation.args, "callback");
77
+ const callback = (0, morpho_ts_1.getValue)(operation.args, "callback");
74
78
  const simulatedOperation = {
75
79
  ...operation,
76
80
  args: {
77
81
  ...operation.args,
78
82
  ...(callback && {
79
83
  callback: (dataBefore) => {
80
- callbackBundle = encodeBundle(callback, getCurrent(dataBefore), supportsSignature);
84
+ callbackBundle = encodeBundle(callback, (0, simulation_sdk_1.getCurrent)(dataBefore), supportsSignature);
81
85
  return callback;
82
86
  },
83
87
  }),
84
88
  },
85
89
  };
86
90
  // Operations with callbacks are encoded recursively as a side-effect of the simulation, within the callback itself.
87
- const dataAfter = simulateOperation(simulatedOperation, dataBefore, index);
91
+ const dataAfter = (0, simulation_sdk_1.simulateOperation)(simulatedOperation, dataBefore, index);
88
92
  if (callbackBundle) {
89
93
  requirements.txs.push(...callbackBundle.requirements.txs);
90
94
  requirements.signatures.push(...callbackBundle.requirements.signatures);
@@ -95,7 +99,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
95
99
  const { owner, isAuthorized, authorized } = operation.args;
96
100
  // Never authorize bundler3 otherwise the signature can be used independently.
97
101
  if (authorized === bundler3)
98
- throw new BundlerErrors.UnexpectedSignature(authorized);
102
+ throw new errors_js_1.BundlerErrors.UnexpectedSignature(authorized);
99
103
  if (supportsSignature) {
100
104
  const ownerData = dataBefore.getUser(owner);
101
105
  const authorization = {
@@ -116,12 +120,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
116
120
  let signature = action.args[1];
117
121
  if (signature != null)
118
122
  return signature;
119
- const typedData = getAuthorizationTypedData(authorization, chainId);
120
- signature = await signTypedData(client, {
123
+ const typedData = (0, blue_sdk_viem_1.getAuthorizationTypedData)(authorization, chainId);
124
+ signature = await (0, actions_1.signTypedData)(client, {
121
125
  ...typedData,
122
126
  account,
123
127
  });
124
- await verifyTypedData({
128
+ await (0, viem_1.verifyTypedData)({
125
129
  ...typedData,
126
130
  address: sender, // Verify against the authorization's owner.
127
131
  signature,
@@ -137,8 +141,8 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
137
141
  args: [authorized, isAuthorized],
138
142
  tx: {
139
143
  to: morpho,
140
- data: encodeFunctionData({
141
- abi: blueAbi,
144
+ data: (0, viem_1.encodeFunctionData)({
145
+ abi: blue_sdk_viem_1.blueAbi,
142
146
  functionName: "setAuthorization",
143
147
  args: [authorized, isAuthorized],
144
148
  }),
@@ -148,7 +152,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
148
152
  }
149
153
  case "Erc20_Approve": {
150
154
  // Native token cannot be approved.
151
- if (address === NATIVE_ADDRESS)
155
+ if (address === blue_sdk_1.NATIVE_ADDRESS)
152
156
  break;
153
157
  const { amount, spender } = operation.args;
154
158
  // Signatures are not supported, skip Permit2 approval.
@@ -159,13 +163,13 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
159
163
  }
160
164
  case "Erc20_Permit": {
161
165
  // Native token cannot be permitted.
162
- if (address === NATIVE_ADDRESS)
166
+ if (address === blue_sdk_1.NATIVE_ADDRESS)
163
167
  break;
164
168
  const { amount, spender, nonce } = operation.args;
165
169
  // Never permit any other address than the GeneralAdapter1 otherwise
166
170
  // the signature can be used independently.
167
171
  if (spender !== generalAdapter1)
168
- throw new BundlerErrors.UnexpectedSignature(spender);
172
+ throw new errors_js_1.BundlerErrors.UnexpectedSignature(spender);
169
173
  if (supportsSignature) {
170
174
  const action = address === dai
171
175
  ? {
@@ -199,25 +203,25 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
199
203
  if (signature != null)
200
204
  return signature; // action is already signed
201
205
  if (address === dai) {
202
- const typedData = getDaiPermitTypedData({
206
+ const typedData = (0, blue_sdk_viem_1.getDaiPermitTypedData)({
203
207
  owner: sender,
204
208
  spender,
205
209
  allowance: amount,
206
210
  nonce,
207
211
  deadline,
208
212
  }, chainId);
209
- signature = await signTypedData(client, {
213
+ signature = await (0, actions_1.signTypedData)(client, {
210
214
  ...typedData,
211
215
  account,
212
216
  });
213
- await verifyTypedData({
217
+ await (0, viem_1.verifyTypedData)({
214
218
  ...typedData,
215
219
  address: account.address,
216
220
  signature,
217
221
  });
218
222
  }
219
223
  else {
220
- const typedData = getPermitTypedData({
224
+ const typedData = (0, blue_sdk_viem_1.getPermitTypedData)({
221
225
  erc20: tokenData,
222
226
  owner: sender,
223
227
  spender,
@@ -225,11 +229,11 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
225
229
  nonce,
226
230
  deadline,
227
231
  }, chainId);
228
- signature = await signTypedData(client, {
232
+ signature = await (0, actions_1.signTypedData)(client, {
229
233
  ...typedData,
230
234
  account,
231
235
  });
232
- await verifyTypedData({
236
+ await (0, viem_1.verifyTypedData)({
233
237
  ...typedData,
234
238
  address: sender, // Verify against the permit's owner.
235
239
  signature,
@@ -246,7 +250,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
246
250
  }
247
251
  case "Erc20_Permit2": {
248
252
  // Native token cannot be permitted.
249
- if (address === NATIVE_ADDRESS)
253
+ if (address === blue_sdk_1.NATIVE_ADDRESS)
250
254
  break;
251
255
  const { amount, expiration, nonce } = operation.args;
252
256
  if (supportsSignature) {
@@ -275,7 +279,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
275
279
  let signature = action.args[2];
276
280
  if (signature != null)
277
281
  return signature; // action is already signed
278
- const typedData = getPermit2PermitTypedData({
282
+ const typedData = (0, blue_sdk_viem_1.getPermit2PermitTypedData)({
279
283
  // Never permit any other address than the GeneralAdapter1 otherwise
280
284
  // the signature can be used independently.
281
285
  spender: generalAdapter1,
@@ -285,11 +289,11 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
285
289
  deadline: sigDeadline,
286
290
  expiration: details.expiration,
287
291
  }, chainId);
288
- signature = await signTypedData(client, {
292
+ signature = await (0, actions_1.signTypedData)(client, {
289
293
  ...typedData,
290
294
  account,
291
295
  });
292
- await verifyTypedData({
296
+ await (0, viem_1.verifyTypedData)({
293
297
  ...typedData,
294
298
  address: sender, // Verify against the permit's owner.
295
299
  signature,
@@ -305,7 +309,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
305
309
  }
306
310
  case "Erc20_Transfer": {
307
311
  const { amount, from, to } = operation.args;
308
- if (address === NATIVE_ADDRESS) {
312
+ if (address === blue_sdk_1.NATIVE_ADDRESS) {
309
313
  actions.push({
310
314
  type: "nativeTransfer",
311
315
  args: [from, to, amount, operation.skipRevert],
@@ -364,8 +368,8 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
364
368
  type: "stakeEth",
365
369
  args: [
366
370
  amount,
367
- MathLib.MAX_UINT_256,
368
- zeroAddress,
371
+ blue_sdk_1.MathLib.MAX_UINT_256,
372
+ viem_1.zeroAddress,
369
373
  generalAdapter1,
370
374
  operation.skipRevert,
371
375
  ],
@@ -373,8 +377,8 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
373
377
  break;
374
378
  }
375
379
  default: {
376
- if (erc20WrapperTokens[chainId]?.has(address)) {
377
- const underlying = getUnwrappedToken(address, chainId);
380
+ if (blue_sdk_1.erc20WrapperTokens[chainId]?.has(address)) {
381
+ const underlying = (0, blue_sdk_1.getUnwrappedToken)(address, chainId);
378
382
  if (underlying == null)
379
383
  throw Error(`unknown wrapped token: ${address}`);
380
384
  actions.push({
@@ -384,7 +388,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
384
388
  break;
385
389
  }
386
390
  // Convex token wrapping is executed onchain along with supplyCollateral, via depositFor.
387
- if (!convexWrapperTokens[chainId]?.has(address))
391
+ if (!blue_sdk_1.convexWrapperTokens[chainId]?.has(address))
388
392
  throw Error(`unexpected token wrap: ${address}`);
389
393
  }
390
394
  }
@@ -408,7 +412,7 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
408
412
  break;
409
413
  }
410
414
  default: {
411
- if (!erc20WrapperTokens[chainId]?.has(address))
415
+ if (!blue_sdk_1.erc20WrapperTokens[chainId]?.has(address))
412
416
  throw Error(`unexpected token unwrap: ${address}`);
413
417
  actions.push({
414
418
  type: "erc20WrapperWithdrawTo",
@@ -419,12 +423,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
419
423
  break;
420
424
  }
421
425
  case "Blue_Supply": {
422
- const { id, assets = 0n, shares = 0n, onBehalf, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
426
+ const { id, assets = 0n, shares = 0n, onBehalf, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
423
427
  // Accrue interest to calculate the expected share price.
424
428
  const market = dataBefore
425
429
  .getMarket(id)
426
430
  .accrueInterest(dataBefore.block.timestamp);
427
- const maxSharePrice = market.toSupplyAssets(MathLib.wToRay(MathLib.WAD + slippage));
431
+ const maxSharePrice = market.toSupplyAssets(blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage));
428
432
  actions.push({
429
433
  type: "morphoSupply",
430
434
  args: [
@@ -440,12 +444,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
440
444
  break;
441
445
  }
442
446
  case "Blue_Withdraw": {
443
- const { id, assets = 0n, shares = 0n, receiver, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
447
+ const { id, assets = 0n, shares = 0n, receiver, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
444
448
  // Accrue interest to calculate the expected share price.
445
449
  const market = dataBefore
446
450
  .getMarket(id)
447
451
  .accrueInterest(dataBefore.block.timestamp);
448
- const minSharePrice = market.toSupplyAssets(MathLib.wToRay(MathLib.WAD - slippage));
452
+ const minSharePrice = market.toSupplyAssets(blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage));
449
453
  actions.push({
450
454
  type: "morphoWithdraw",
451
455
  args: [
@@ -460,12 +464,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
460
464
  break;
461
465
  }
462
466
  case "Blue_Borrow": {
463
- const { id, assets = 0n, shares = 0n, receiver, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
467
+ const { id, assets = 0n, shares = 0n, receiver, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
464
468
  // Accrue interest to calculate the expected share price.
465
469
  const market = dataBefore
466
470
  .getMarket(id)
467
471
  .accrueInterest(dataBefore.block.timestamp);
468
- const minSharePrice = market.toBorrowAssets(MathLib.wToRay(MathLib.WAD - slippage));
472
+ const minSharePrice = market.toBorrowAssets(blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage));
469
473
  actions.push({
470
474
  type: "morphoBorrow",
471
475
  args: [
@@ -480,12 +484,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
480
484
  break;
481
485
  }
482
486
  case "Blue_Repay": {
483
- const { id, assets = 0n, shares = 0n, onBehalf, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
487
+ const { id, assets = 0n, shares = 0n, onBehalf, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
484
488
  // Accrue interest to calculate the expected share price.
485
489
  const market = dataBefore
486
490
  .getMarket(id)
487
491
  .accrueInterest(dataBefore.block.timestamp);
488
- const maxSharePrice = market.toBorrowAssets(MathLib.wToRay(MathLib.WAD + slippage));
492
+ const maxSharePrice = market.toBorrowAssets(blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage));
489
493
  actions.push({
490
494
  type: "morphoRepay",
491
495
  args: [
@@ -503,8 +507,8 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
503
507
  case "Blue_SupplyCollateral": {
504
508
  const { id, assets, onBehalf } = operation.args;
505
509
  const { params } = dataBefore.getMarket(id);
506
- if (convexWrapperTokens[chainId]?.has(params.collateralToken)) {
507
- const underlying = getUnwrappedToken(address, chainId);
510
+ if (blue_sdk_1.convexWrapperTokens[chainId]?.has(params.collateralToken)) {
511
+ const underlying = (0, blue_sdk_1.getUnwrappedToken)(address, chainId);
508
512
  if (underlying == null)
509
513
  throw Error(`unknown wrapped token: ${address}`);
510
514
  actions.push({
@@ -540,12 +544,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
540
544
  break;
541
545
  }
542
546
  case "MetaMorpho_Deposit": {
543
- const { assets = 0n, shares = 0n, owner, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
547
+ const { assets = 0n, shares = 0n, owner, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
544
548
  // Accrue interest to calculate the expected share price.
545
549
  const vault = dataBefore
546
550
  .getAccrualVault(address)
547
551
  .accrueInterest(dataBefore.block.timestamp);
548
- const maxSharePrice = vault.toAssets(MathLib.wToRay(MathLib.WAD + slippage));
552
+ const maxSharePrice = vault.toAssets(blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippage));
549
553
  if (shares === 0n)
550
554
  actions.push({
551
555
  type: "erc4626Deposit",
@@ -559,12 +563,12 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
559
563
  break;
560
564
  }
561
565
  case "MetaMorpho_Withdraw": {
562
- const { assets = 0n, shares = 0n, owner, receiver, slippage = DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
566
+ const { assets = 0n, shares = 0n, owner, receiver, slippage = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, } = operation.args;
563
567
  // Accrue interest to calculate the expected share price.
564
568
  const vault = dataBefore
565
569
  .getAccrualVault(address)
566
570
  .accrueInterest(dataBefore.block.timestamp);
567
- const minSharePrice = vault.toAssets(MathLib.wToRay(MathLib.WAD - slippage));
571
+ const minSharePrice = vault.toAssets(blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippage));
568
572
  if (assets > 0n)
569
573
  actions.push({
570
574
  type: "erc4626Withdraw",
@@ -617,10 +621,11 @@ export const encodeOperation = (operation, dataBefore, supportsSignature = true,
617
621
  requirements,
618
622
  };
619
623
  };
620
- export function encodeBundle(operations, startData, supportsSignature = true) {
621
- const bundle = new ActionBundle([startData]);
624
+ exports.encodeOperation = encodeOperation;
625
+ function encodeBundle(operations, startData, supportsSignature = true) {
626
+ const bundle = new ActionBundle_js_1.ActionBundle([startData]);
622
627
  for (let index = 0; index < operations.length; ++index) {
623
- const { dataAfter, actions, requirements } = encodeOperation(operations[index], bundle.steps[index], supportsSignature, index);
628
+ const { dataAfter, actions, requirements } = (0, exports.encodeOperation)(operations[index], bundle.steps[index], supportsSignature, index);
624
629
  bundle.steps.push(dataAfter);
625
630
  bundle.actions.push(...actions);
626
631
  bundle.requirements.signatures.push(...requirements.signatures);
package/lib/bundle.js CHANGED
@@ -1,11 +1,15 @@
1
- import { encodeBundle } from "./actions.js";
2
- import { finalizeBundle, populateBundle, } from "./operations.js";
3
- export const setupBundle = (inputOperations, startData, receiver, { supportsSignature, unwrapTokens, unwrapSlippage, ...options } = {}) => {
4
- let { operations } = populateBundle(inputOperations, startData, options);
5
- operations = finalizeBundle(operations, startData, receiver, unwrapTokens, unwrapSlippage);
6
- const bundle = encodeBundle(operations, startData, supportsSignature);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupBundle = void 0;
4
+ const actions_js_1 = require("./actions.js");
5
+ const operations_js_1 = require("./operations.js");
6
+ const setupBundle = (inputOperations, startData, receiver, { supportsSignature, unwrapTokens, unwrapSlippage, ...options } = {}) => {
7
+ let { operations } = (0, operations_js_1.populateBundle)(inputOperations, startData, options);
8
+ operations = (0, operations_js_1.finalizeBundle)(operations, startData, receiver, unwrapTokens, unwrapSlippage);
9
+ const bundle = (0, actions_js_1.encodeBundle)(operations, startData, supportsSignature);
7
10
  return {
8
11
  operations,
9
12
  bundle,
10
13
  };
11
14
  };
15
+ exports.setupBundle = setupBundle;
package/lib/errors.js CHANGED
@@ -1,4 +1,7 @@
1
- export var BundlerErrors;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BundlerErrors = void 0;
4
+ var BundlerErrors;
2
5
  (function (BundlerErrors) {
3
6
  class Bundle extends Error {
4
7
  error;
@@ -33,4 +36,4 @@ export var BundlerErrors;
33
36
  }
34
37
  }
35
38
  BundlerErrors.UnexpectedSignature = UnexpectedSignature;
36
- })(BundlerErrors || (BundlerErrors = {}));
39
+ })(BundlerErrors || (exports.BundlerErrors = BundlerErrors = {}));
package/lib/index.js CHANGED
@@ -1,8 +1,24 @@
1
- export * from "./actions.js";
2
- export * from "./operations.js";
3
- export * from "./errors.js";
4
- export * from "./types/index.js";
5
- export * from "./BundlerAction.js";
6
- export * from "./bundle.js";
7
- export * from "./ActionBundle.js";
8
- export * from "./abis.js";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./actions.js"), exports);
18
+ __exportStar(require("./operations.js"), exports);
19
+ __exportStar(require("./errors.js"), exports);
20
+ __exportStar(require("./types/index.js"), exports);
21
+ __exportStar(require("./BundlerAction.js"), exports);
22
+ __exportStar(require("./bundle.js"), exports);
23
+ __exportStar(require("./ActionBundle.js"), exports);
24
+ __exportStar(require("./abis.js"), exports);