viem 2.55.7 → 2.55.10

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 (117) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js +1 -1
  3. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  4. package/_cjs/actions/public/estimateFeesPerGas.js +1 -1
  5. package/_cjs/actions/public/estimateFeesPerGas.js.map +1 -1
  6. package/_cjs/actions/public/fillTransaction.js +1 -1
  7. package/_cjs/actions/public/fillTransaction.js.map +1 -1
  8. package/_cjs/chains/definitions/0gMainnet.js +1 -1
  9. package/_cjs/chains/definitions/0gMainnet.js.map +1 -1
  10. package/_cjs/chains/definitions/0gTestnet.js +2 -2
  11. package/_cjs/chains/definitions/0gTestnet.js.map +1 -1
  12. package/_cjs/chains/definitions/eduChain.js +9 -2
  13. package/_cjs/chains/definitions/eduChain.js.map +1 -1
  14. package/_cjs/chains/definitions/eduChainTestnet.js +3 -4
  15. package/_cjs/chains/definitions/eduChainTestnet.js.map +1 -1
  16. package/_cjs/chains/definitions/polygonAmoy.js +1 -1
  17. package/_cjs/chains/definitions/polygonAmoy.js.map +1 -1
  18. package/_cjs/errors/version.js +1 -1
  19. package/_cjs/errors/version.js.map +1 -1
  20. package/_cjs/tempo/Abis.js +918 -543
  21. package/_cjs/tempo/Abis.js.map +1 -1
  22. package/_cjs/tempo/Addresses.js +2 -1
  23. package/_cjs/tempo/Addresses.js.map +1 -1
  24. package/_cjs/tempo/Decorator.js.map +1 -1
  25. package/_cjs/tempo/actions/earn.js +171 -137
  26. package/_cjs/tempo/actions/earn.js.map +1 -1
  27. package/_cjs/tempo/chainConfig.js +3 -1
  28. package/_cjs/tempo/chainConfig.js.map +1 -1
  29. package/_cjs/tempo/zones/Abis.js +6 -0
  30. package/_cjs/tempo/zones/Abis.js.map +1 -1
  31. package/_cjs/tempo/zones/Addresses.js +17 -0
  32. package/_cjs/tempo/zones/Addresses.js.map +1 -0
  33. package/_cjs/tempo/zones/index.js +2 -2
  34. package/_cjs/tempo/zones/index.js.map +1 -1
  35. package/_cjs/tempo/zones/zone.js +30 -16
  36. package/_cjs/tempo/zones/zone.js.map +1 -1
  37. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +1 -1
  38. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  39. package/_esm/actions/public/estimateFeesPerGas.js +1 -1
  40. package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
  41. package/_esm/actions/public/fillTransaction.js +1 -1
  42. package/_esm/actions/public/fillTransaction.js.map +1 -1
  43. package/_esm/chains/definitions/0gMainnet.js +1 -1
  44. package/_esm/chains/definitions/0gMainnet.js.map +1 -1
  45. package/_esm/chains/definitions/0gTestnet.js +2 -2
  46. package/_esm/chains/definitions/0gTestnet.js.map +1 -1
  47. package/_esm/chains/definitions/eduChain.js +9 -2
  48. package/_esm/chains/definitions/eduChain.js.map +1 -1
  49. package/_esm/chains/definitions/eduChainTestnet.js +3 -4
  50. package/_esm/chains/definitions/eduChainTestnet.js.map +1 -1
  51. package/_esm/chains/definitions/polygonAmoy.js +1 -1
  52. package/_esm/chains/definitions/polygonAmoy.js.map +1 -1
  53. package/_esm/errors/version.js +1 -1
  54. package/_esm/errors/version.js.map +1 -1
  55. package/_esm/tempo/Abis.js +919 -544
  56. package/_esm/tempo/Abis.js.map +1 -1
  57. package/_esm/tempo/Addresses.js +1 -0
  58. package/_esm/tempo/Addresses.js.map +1 -1
  59. package/_esm/tempo/Decorator.js.map +1 -1
  60. package/_esm/tempo/actions/earn.js +214 -174
  61. package/_esm/tempo/actions/earn.js.map +1 -1
  62. package/_esm/tempo/chainConfig.js +3 -1
  63. package/_esm/tempo/chainConfig.js.map +1 -1
  64. package/_esm/tempo/zones/Abis.js +6 -0
  65. package/_esm/tempo/zones/Abis.js.map +1 -1
  66. package/_esm/tempo/zones/Addresses.js +14 -0
  67. package/_esm/tempo/zones/Addresses.js.map +1 -0
  68. package/_esm/tempo/zones/index.js +2 -1
  69. package/_esm/tempo/zones/index.js.map +1 -1
  70. package/_esm/tempo/zones/zone.js +29 -15
  71. package/_esm/tempo/zones/zone.js.map +1 -1
  72. package/_types/chains/definitions/0gMainnet.d.ts +1 -1
  73. package/_types/chains/definitions/0gTestnet.d.ts +3 -3
  74. package/_types/chains/definitions/eduChain.d.ts +9 -11
  75. package/_types/chains/definitions/eduChain.d.ts.map +1 -1
  76. package/_types/chains/definitions/eduChainTestnet.d.ts +3 -4
  77. package/_types/chains/definitions/eduChainTestnet.d.ts.map +1 -1
  78. package/_types/chains/definitions/polygonAmoy.d.ts +1 -1
  79. package/_types/errors/version.d.ts +1 -1
  80. package/_types/errors/version.d.ts.map +1 -1
  81. package/_types/package.json +1 -0
  82. package/_types/tempo/Abis.d.ts +1423 -777
  83. package/_types/tempo/Abis.d.ts.map +1 -1
  84. package/_types/tempo/Addresses.d.ts +1 -0
  85. package/_types/tempo/Addresses.d.ts.map +1 -1
  86. package/_types/tempo/Decorator.d.ts +21 -15
  87. package/_types/tempo/Decorator.d.ts.map +1 -1
  88. package/_types/tempo/actions/earn.d.ts +850 -1913
  89. package/_types/tempo/actions/earn.d.ts.map +1 -1
  90. package/_types/tempo/chainConfig.d.ts.map +1 -1
  91. package/_types/tempo/zones/Abis.d.ts +20 -0
  92. package/_types/tempo/zones/Abis.d.ts.map +1 -1
  93. package/_types/tempo/zones/Addresses.d.ts +13 -0
  94. package/_types/tempo/zones/Addresses.d.ts.map +1 -0
  95. package/_types/tempo/zones/index.d.ts +2 -1
  96. package/_types/tempo/zones/index.d.ts.map +1 -1
  97. package/_types/tempo/zones/zone.d.ts +14 -33
  98. package/_types/tempo/zones/zone.d.ts.map +1 -1
  99. package/account-abstraction/utils/formatters/userOperationRequest.ts +4 -3
  100. package/actions/public/estimateFeesPerGas.ts +1 -1
  101. package/actions/public/fillTransaction.ts +1 -1
  102. package/chains/definitions/0gMainnet.ts +1 -1
  103. package/chains/definitions/0gTestnet.ts +2 -2
  104. package/chains/definitions/eduChain.ts +9 -2
  105. package/chains/definitions/eduChainTestnet.ts +3 -4
  106. package/chains/definitions/polygonAmoy.ts +1 -1
  107. package/errors/version.ts +1 -1
  108. package/package.json +2 -2
  109. package/tempo/Abis.ts +920 -545
  110. package/tempo/Addresses.ts +1 -0
  111. package/tempo/Decorator.ts +21 -15
  112. package/tempo/actions/earn.ts +311 -250
  113. package/tempo/chainConfig.ts +5 -1
  114. package/tempo/zones/Abis.ts +6 -0
  115. package/tempo/zones/Addresses.ts +15 -0
  116. package/tempo/zones/index.ts +1 -1
  117. package/tempo/zones/zone.ts +38 -17
@@ -49,6 +49,7 @@ const Abis = require("../Abis.js");
49
49
  const Addresses = require("../Addresses.js");
50
50
  const errors_js_1 = require("../errors.js");
51
51
  const utils_js_1 = require("../internal/utils.js");
52
+ const zone_js_1 = require("../zones/zone.js");
52
53
  const policyActions = require("./policy.js");
53
54
  const tokenActions = require("./token.js");
54
55
  const zoneActions = require("./zone.js");
@@ -159,7 +160,7 @@ async function validateExitSafePolicy(client, parameters) {
159
160
  })),
160
161
  ]);
161
162
  if (tokenPolicyId !== policy.transferPolicyId)
162
- throw new Error('Earn vault share token transfer policy mismatch.');
163
+ throw new Error('Earn share token transfer policy mismatch.');
163
164
  if (compound[0] !== policy.senderPolicyId ||
164
165
  compound[1] !== policy.recipientPolicyId ||
165
166
  compound[2] !== policy.mintRecipientPolicyId)
@@ -184,7 +185,7 @@ async function deposit(client, parameters) {
184
185
  const [args, assetToken] = await Promise.all([
185
186
  toDepositArgs(client, parameters),
186
187
  (0, readContract_js_1.readContract)(client, {
187
- abi: Abis.vaultAdapter,
188
+ abi: Abis.earnVault,
188
189
  address: parameters.vault,
189
190
  functionName: 'asset',
190
191
  }),
@@ -205,7 +206,7 @@ async function deposit(client, parameters) {
205
206
  })();
206
207
  return (0, utils_js_1.defineCall)({
207
208
  address: vault,
208
- abi: Abis.vaultAdapter,
209
+ abi: Abis.earnVault,
209
210
  functionName: 'deposit',
210
211
  args: [
211
212
  internal_Token.toBaseUnits(args.assetAmount, undefined),
@@ -232,7 +233,7 @@ async function deposit(client, parameters) {
232
233
  function extractEvent(logs, parameters) {
233
234
  const { vault } = parameters;
234
235
  const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
235
- abi: Abis.vaultAdapter,
236
+ abi: Abis.earnVault,
236
237
  eventName: 'Deposited',
237
238
  logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
238
239
  });
@@ -268,7 +269,7 @@ async function depositSync(client, parameters) {
268
269
  caller: args.caller,
269
270
  receipt,
270
271
  recipient: args.receiver,
271
- shareAmount: args.shares,
272
+ shareAmount: args.earnShares,
272
273
  };
273
274
  }
274
275
  async function depositShares(client, parameters) {
@@ -277,7 +278,7 @@ async function depositShares(client, parameters) {
277
278
  (function (depositShares) {
278
279
  async function inner(action, client, parameters) {
279
280
  const engine = await (0, readContract_js_1.readContract)(client, {
280
- abi: Abis.vaultAdapter,
281
+ abi: Abis.earnVault,
281
282
  address: parameters.vault,
282
283
  functionName: 'engine',
283
284
  });
@@ -301,8 +302,8 @@ async function depositShares(client, parameters) {
301
302
  })();
302
303
  return (0, utils_js_1.defineCall)({
303
304
  address: vault,
304
- abi: Abis.vaultAdapter,
305
- functionName: 'depositShares',
305
+ abi: Abis.earnVault,
306
+ functionName: 'depositVenueShares',
306
307
  args: [venueShareAmount, recipient, earnShareAmountMin],
307
308
  });
308
309
  }
@@ -323,7 +324,7 @@ async function depositShares(client, parameters) {
323
324
  function extractEvent(logs, parameters) {
324
325
  const { vault } = parameters;
325
326
  const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
326
- abi: Abis.vaultAdapter,
327
+ abi: Abis.earnVault,
327
328
  eventName: 'VenueSharesDeposited',
328
329
  logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
329
330
  });
@@ -372,11 +373,19 @@ async function privateDeposit(client, parameters) {
372
373
  const chainId = client.chain?.id;
373
374
  if (!chainId)
374
375
  throw new Error('`chain` is required.');
375
- const { actionId = ox_1.Hex.random(32), assetAmount, callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, recipient, recoveryRecipient, returnMemo, withdrawalMemo, } = parameters;
376
+ const { actionId = ox_1.Hex.random(32), assetAmount, callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, portalAddress: portalAddress_, recipient, recoveryRecipient, returnMemo, vault, withdrawalMemo, zoneId, } = parameters;
377
+ const portalAddress = portalAddress_ ?? (0, zone_js_1.getPortalAddress)(chainId, zoneId);
376
378
  const readParameters = pickReadParameters(parameters);
377
379
  const [fromBlock, config] = await Promise.all([
378
380
  (0, getBlockNumber_js_1.getBlockNumber)(client, { cacheTime: 0 }),
379
- getZoneGatewayConfig(client, { ...readParameters, gateway }),
381
+ getZoneGatewayConfig(client, {
382
+ ...readParameters,
383
+ flow: 0,
384
+ gateway,
385
+ vault,
386
+ zoneId,
387
+ zonePortal: portalAddress,
388
+ }),
380
389
  ]);
381
390
  const assetToken = parameters.assetToken ?? config.vaultAsset;
382
391
  const { encrypted, keyIndex } = await zoneActions.encryptedDeposit.prepareRecipient(client, {
@@ -388,19 +397,18 @@ async function privateDeposit(client, parameters) {
388
397
  });
389
398
  const shareAmountMin = resolveMinimumShareAmount(parameters);
390
399
  const direct = (0, isAddressEqual_js_1.isAddressEqual)(assetToken, config.vaultAsset);
391
- const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.zoneGatewayCallbackData, [
400
+ const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.earnRouterCallbackData, [
392
401
  {
402
+ actionId,
403
+ earnVault: config.vault,
393
404
  flow: 0,
394
- outputToken: config.shareToken,
395
- keyIndex,
396
- encrypted,
405
+ minEarnShares: shareAmountMin,
406
+ minOutputAmount: 0n,
397
407
  minVaultAssets: direct
398
408
  ? assetAmount
399
409
  : (parameters.vaultAssetAmountMin ?? 0n),
400
- minVaultShares: shareAmountMin,
401
- minOutputAmount: 0n,
402
- actionId,
403
- refundRecipient: recoveryRecipient,
410
+ outputToken: config.shareToken,
411
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
404
412
  },
405
413
  ]);
406
414
  return {
@@ -428,15 +436,16 @@ async function privateDepositSync(client, parameters) {
428
436
  return zoneActions.requestWithdrawalSync(client, parameters);
429
437
  }
430
438
  async function waitForPrivateDeposit(client, parameters) {
431
- const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
439
+ const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
432
440
  const event = (0, getAbiItem_js_1.getAbiItem)({
433
- abi: Abis.zoneGateway,
441
+ abi: Abis.earnRouter,
434
442
  name: 'EarnDeposit',
435
443
  });
436
444
  const observerId = (0, stringify_js_1.stringify)([
437
445
  'waitForPrivateDeposit',
438
446
  client.uid,
439
447
  gateway,
448
+ vault,
440
449
  actionId,
441
450
  fromBlock,
442
451
  ]);
@@ -460,7 +469,7 @@ async function waitForPrivateDeposit(client, parameters) {
460
469
  try {
461
470
  const [log] = await (0, getLogs_js_1.getLogs)(client, {
462
471
  address: gateway,
463
- args: { actionId },
472
+ args: { actionId, earnVault: vault },
464
473
  event,
465
474
  fromBlock,
466
475
  strict: true,
@@ -473,7 +482,7 @@ async function waitForPrivateDeposit(client, parameters) {
473
482
  actionId: log.args.actionId,
474
483
  inputAmount: log.args.inputAmount,
475
484
  inputToken: log.args.inputToken,
476
- shares: log.args.shares,
485
+ shares: log.args.earnShares,
477
486
  tempoBlockNumber: log.blockNumber,
478
487
  vaultAssets: log.args.vaultAssets,
479
488
  zoneDepositHash: log.args.zoneDepositHash,
@@ -495,37 +504,43 @@ async function waitForPrivateDeposit(client, parameters) {
495
504
  }
496
505
  async function getFeeState(client, parameters) {
497
506
  const { recipient, vault, ...rest } = parameters;
507
+ const fees = await (0, readContract_js_1.readContract)(client, {
508
+ ...rest,
509
+ abi: Abis.earnVault,
510
+ address: vault,
511
+ functionName: 'earnFees',
512
+ });
498
513
  const contracts = [
499
514
  (0, utils_js_1.defineCall)({
500
- address: vault,
501
- abi: Abis.vaultAdapter,
515
+ address: fees,
516
+ abi: Abis.earnFees,
502
517
  functionName: 'currentFeeConfigId',
503
518
  }),
504
519
  (0, utils_js_1.defineCall)({
505
- address: vault,
506
- abi: Abis.vaultAdapter,
520
+ address: fees,
521
+ abi: Abis.earnFees,
507
522
  functionName: 'feesActive',
508
523
  }),
509
524
  (0, utils_js_1.defineCall)({
510
- address: vault,
511
- abi: Abis.vaultAdapter,
525
+ address: fees,
526
+ abi: Abis.earnFees,
512
527
  functionName: 'highWaterMark',
513
528
  }),
514
529
  (0, utils_js_1.defineCall)({
515
- address: vault,
516
- abi: Abis.vaultAdapter,
530
+ address: fees,
531
+ abi: Abis.earnFees,
517
532
  functionName: 'previewAccruedFees',
518
533
  }),
519
534
  (0, utils_js_1.defineCall)({
520
- address: vault,
521
- abi: Abis.vaultAdapter,
535
+ address: fees,
536
+ abi: Abis.earnFees,
522
537
  functionName: 'targetBase',
523
538
  }),
524
539
  ];
525
540
  const feeConfig = async (configId) => toFeeConfig(await (0, readContract_js_1.readContract)(client, {
526
541
  ...rest,
527
- abi: Abis.vaultAdapter,
528
- address: vault,
542
+ abi: Abis.earnFees,
543
+ address: fees,
529
544
  functionName: 'feeConfig',
530
545
  args: [configId],
531
546
  }));
@@ -536,9 +551,9 @@ async function getFeeState(client, parameters) {
536
551
  contracts: [
537
552
  ...contracts,
538
553
  (0, utils_js_1.defineCall)({
539
- address: vault,
540
- abi: Abis.vaultAdapter,
541
- functionName: 'claimableFeeShares',
554
+ address: fees,
555
+ abi: Abis.earnFees,
556
+ functionName: 'claimableEarnShares',
542
557
  args: [recipient],
543
558
  }),
544
559
  ],
@@ -580,13 +595,13 @@ async function getPosition(client, parameters) {
580
595
  contracts: [
581
596
  (0, utils_js_1.defineCall)({
582
597
  address: vault,
583
- abi: Abis.vaultAdapter,
598
+ abi: Abis.earnVault,
584
599
  functionName: 'asset',
585
600
  }),
586
601
  (0, utils_js_1.defineCall)({
587
602
  address: vault,
588
- abi: Abis.vaultAdapter,
589
- functionName: 'shareToken',
603
+ abi: Abis.earnVault,
604
+ functionName: 'earnShare',
590
605
  }),
591
606
  ],
592
607
  deployless: true,
@@ -624,7 +639,7 @@ async function getPosition(client, parameters) {
624
639
  });
625
640
  const value = await (0, readContract_js_1.readContract)(client, {
626
641
  ...rest,
627
- abi: Abis.vaultAdapter,
642
+ abi: Abis.earnVault,
628
643
  address: vault,
629
644
  args: [shareBalance],
630
645
  functionName: 'previewRedeem',
@@ -651,7 +666,7 @@ async function getRedeemQuote(client, parameters) {
651
666
  const { shareAmount, vault } = args;
652
667
  return (0, utils_js_1.defineCall)({
653
668
  address: vault,
654
- abi: Abis.vaultAdapter,
669
+ abi: Abis.earnVault,
655
670
  args: [shareAmount],
656
671
  functionName: 'previewRedeem',
657
672
  });
@@ -660,16 +675,24 @@ async function getRedeemQuote(client, parameters) {
660
675
  })(getRedeemQuote || (exports.getRedeemQuote = getRedeemQuote = {}));
661
676
  async function getVault(client, parameters) {
662
677
  const { vault, ...rest } = parameters;
663
- const engine = await (0, readContract_js_1.readContract)(client, {
664
- ...rest,
665
- abi: Abis.vaultAdapter,
666
- address: vault,
667
- functionName: 'engine',
668
- });
678
+ const [engine, fees] = await Promise.all([
679
+ (0, readContract_js_1.readContract)(client, {
680
+ ...rest,
681
+ abi: Abis.earnVault,
682
+ address: vault,
683
+ functionName: 'engine',
684
+ }),
685
+ (0, readContract_js_1.readContract)(client, {
686
+ ...rest,
687
+ abi: Abis.earnVault,
688
+ address: vault,
689
+ functionName: 'earnFees',
690
+ }),
691
+ ]);
669
692
  const [assetToken, engine_, shareToken, operator, emergencyGuardian, asyncJanitor, engineMigrationMode, depositsPaused, engineShares, shareSupply, isSynced, pendingRedeemCount, feesActive, totalAssets, name, symbol, asyncRedeem, exactWithdraw, inKindDeposit, syncRedeem,] = await (0, multicall_js_1.multicall)(client, {
670
693
  ...rest,
671
694
  allowFailure: false,
672
- contracts: getVault.calls({ engine, vault }),
695
+ contracts: getVault.calls({ engine, fees, vault }),
673
696
  deployless: true,
674
697
  });
675
698
  if (!(0, isAddressEqual_js_1.isAddressEqual)(engine, engine_))
@@ -693,109 +716,109 @@ async function getVault(client, parameters) {
693
716
  }
694
717
  (function (getVault) {
695
718
  function calls(args) {
696
- const { engine, vault } = args;
719
+ const { engine, fees, vault } = args;
697
720
  return [
698
721
  (0, utils_js_1.defineCall)({
699
722
  address: vault,
700
- abi: Abis.vaultAdapter,
723
+ abi: Abis.earnVault,
701
724
  functionName: 'asset',
702
725
  }),
703
726
  (0, utils_js_1.defineCall)({
704
727
  address: vault,
705
- abi: Abis.vaultAdapter,
728
+ abi: Abis.earnVault,
706
729
  functionName: 'engine',
707
730
  }),
708
731
  (0, utils_js_1.defineCall)({
709
732
  address: vault,
710
- abi: Abis.vaultAdapter,
711
- functionName: 'shareToken',
733
+ abi: Abis.earnVault,
734
+ functionName: 'earnShare',
712
735
  }),
713
736
  (0, utils_js_1.defineCall)({
714
737
  address: vault,
715
- abi: Abis.vaultAdapter,
738
+ abi: Abis.earnVault,
716
739
  functionName: 'operator',
717
740
  }),
718
741
  (0, utils_js_1.defineCall)({
719
742
  address: vault,
720
- abi: Abis.vaultAdapter,
743
+ abi: Abis.earnVault,
721
744
  functionName: 'emergencyGuardian',
722
745
  }),
723
746
  (0, utils_js_1.defineCall)({
724
747
  address: vault,
725
- abi: Abis.vaultAdapter,
748
+ abi: Abis.earnVault,
726
749
  functionName: 'asyncJanitor',
727
750
  }),
728
751
  (0, utils_js_1.defineCall)({
729
752
  address: vault,
730
- abi: Abis.vaultAdapter,
753
+ abi: Abis.earnVault,
731
754
  functionName: 'engineMigrationMode',
732
755
  }),
733
756
  (0, utils_js_1.defineCall)({
734
757
  address: vault,
735
- abi: Abis.vaultAdapter,
758
+ abi: Abis.earnVault,
736
759
  functionName: 'depositsPaused',
737
760
  }),
738
761
  (0, utils_js_1.defineCall)({
739
762
  address: vault,
740
- abi: Abis.vaultAdapter,
763
+ abi: Abis.earnVault,
741
764
  functionName: 'engineShares',
742
765
  }),
743
766
  (0, utils_js_1.defineCall)({
744
767
  address: vault,
745
- abi: Abis.vaultAdapter,
746
- functionName: 'shareSupply',
768
+ abi: Abis.earnVault,
769
+ functionName: 'totalEarnShares',
747
770
  }),
748
771
  (0, utils_js_1.defineCall)({
749
772
  address: vault,
750
- abi: Abis.vaultAdapter,
751
- functionName: 'isSynced',
773
+ abi: Abis.earnVault,
774
+ functionName: 'isAccountingAligned',
752
775
  }),
753
776
  (0, utils_js_1.defineCall)({
754
777
  address: vault,
755
- abi: Abis.vaultAdapter,
756
- functionName: 'pendingRedeemCount',
778
+ abi: Abis.earnVault,
779
+ functionName: 'openRedeemRequestCount',
757
780
  }),
758
781
  (0, utils_js_1.defineCall)({
759
- address: vault,
760
- abi: Abis.vaultAdapter,
782
+ address: fees,
783
+ abi: Abis.earnFees,
761
784
  functionName: 'feesActive',
762
785
  }),
763
786
  (0, utils_js_1.defineCall)({
764
787
  address: engine,
765
- abi: Abis.vaultEngine,
788
+ abi: Abis.earnEngine,
766
789
  functionName: 'totalAssets',
767
790
  }),
768
791
  (0, utils_js_1.defineCall)({
769
792
  address: engine,
770
- abi: Abis.vaultEngine,
793
+ abi: Abis.earnEngine,
771
794
  functionName: 'name',
772
795
  }),
773
796
  (0, utils_js_1.defineCall)({
774
797
  address: engine,
775
- abi: Abis.vaultEngine,
798
+ abi: Abis.earnEngine,
776
799
  functionName: 'symbol',
777
800
  }),
778
801
  (0, utils_js_1.defineCall)({
779
802
  address: engine,
780
- abi: Abis.vaultEngine,
803
+ abi: Abis.earnEngine,
781
804
  functionName: 'supportsInterface',
782
805
  args: [interfaceIds.asyncRedeem],
783
806
  }),
784
807
  (0, utils_js_1.defineCall)({
785
808
  address: engine,
786
- abi: Abis.vaultEngine,
809
+ abi: Abis.earnEngine,
787
810
  functionName: 'supportsInterface',
788
811
  args: [interfaceIds.exactWithdraw],
789
812
  }),
790
813
  (0, utils_js_1.defineCall)({
791
814
  address: engine,
792
- abi: Abis.vaultEngine,
815
+ abi: Abis.earnEngine,
793
816
  functionName: 'supportsInterface',
794
817
  args: [interfaceIds.inKindDeposit],
795
818
  }),
796
819
  (0, utils_js_1.defineCall)({
797
820
  address: engine,
798
- abi: Abis.vaultEngine,
821
+ abi: Abis.earnEngine,
799
822
  functionName: 'supportsInterface',
800
823
  args: [interfaceIds.syncRedeem],
801
824
  }),
@@ -815,7 +838,7 @@ async function getWithdrawQuote(client, parameters) {
815
838
  const { assetAmount, vault } = args;
816
839
  return (0, utils_js_1.defineCall)({
817
840
  address: vault,
818
- abi: Abis.vaultAdapter,
841
+ abi: Abis.earnVault,
819
842
  args: [assetAmount],
820
843
  functionName: 'previewWithdraw',
821
844
  });
@@ -830,9 +853,9 @@ async function redeem(client, parameters) {
830
853
  const [args, shareToken] = await Promise.all([
831
854
  toRedeemArgs(client, parameters),
832
855
  (0, readContract_js_1.readContract)(client, {
833
- abi: Abis.vaultAdapter,
856
+ abi: Abis.earnVault,
834
857
  address: parameters.vault,
835
- functionName: 'shareToken',
858
+ functionName: 'earnShare',
836
859
  }),
837
860
  ]);
838
861
  return (await action(client, {
@@ -851,7 +874,7 @@ async function redeem(client, parameters) {
851
874
  })();
852
875
  return (0, utils_js_1.defineCall)({
853
876
  address: vault,
854
- abi: Abis.vaultAdapter,
877
+ abi: Abis.earnVault,
855
878
  functionName: 'redeem',
856
879
  args: [
857
880
  internal_Token.toBaseUnits(args.shareAmount, undefined),
@@ -878,7 +901,7 @@ async function redeem(client, parameters) {
878
901
  function extractEvent(logs, parameters) {
879
902
  const { vault } = parameters;
880
903
  const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
881
- abi: Abis.vaultAdapter,
904
+ abi: Abis.earnVault,
882
905
  eventName: 'Redeemed',
883
906
  logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
884
907
  });
@@ -914,7 +937,7 @@ async function redeemSync(client, parameters) {
914
937
  caller: args.caller,
915
938
  receipt,
916
939
  recipient: args.receiver,
917
- shareAmount: args.shares,
940
+ shareAmount: args.earnShares,
918
941
  };
919
942
  }
920
943
  async function privateRedeem(client, parameters) {
@@ -926,15 +949,23 @@ async function privateRedeem(client, parameters) {
926
949
  const chainId = client.chain?.id;
927
950
  if (!chainId)
928
951
  throw new Error('`chain` is required.');
929
- const { actionId = ox_1.Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, recipient, recoveryRecipient, returnMemo, shareAmount, withdrawalMemo, } = parameters;
952
+ const { actionId = ox_1.Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, portalAddress: portalAddress_, recipient, recoveryRecipient, returnMemo, shareAmount, vault, withdrawalMemo, zoneId, } = parameters;
953
+ const portalAddress = portalAddress_ ?? (0, zone_js_1.getPortalAddress)(chainId, zoneId);
930
954
  const readParameters = pickReadParameters(parameters);
931
955
  const [fromBlock, config] = await Promise.all([
932
956
  (0, getBlockNumber_js_1.getBlockNumber)(client, { cacheTime: 0 }),
933
- getZoneGatewayConfig(client, { ...readParameters, gateway }),
957
+ getZoneGatewayConfig(client, {
958
+ ...readParameters,
959
+ flow: 1,
960
+ gateway,
961
+ vault,
962
+ zoneId,
963
+ zonePortal: portalAddress,
964
+ }),
934
965
  ]);
935
966
  const assetToken = parameters.assetToken ?? config.vaultAsset;
936
967
  if ((0, isAddressEqual_js_1.isAddressEqual)(assetToken, config.shareToken))
937
- throw new Error('`assetToken` cannot be the gateway vault share token.');
968
+ throw new Error('`assetToken` cannot be the Earn share token.');
938
969
  const [{ encrypted, keyIndex }, assetAmountMin] = await Promise.all([
939
970
  zoneActions.encryptedDeposit.prepareRecipient(client, {
940
971
  ...readParameters,
@@ -951,23 +982,22 @@ async function privateRedeem(client, parameters) {
951
982
  const assetAmount = await getRedeemQuote(client, {
952
983
  ...readParameters,
953
984
  shareAmount,
954
- vault: config.vaultAdapter,
985
+ vault: config.vault,
955
986
  });
956
987
  return tempo_1.EarnShares.minimumOutput(assetAmount, parameters.slippageBps);
957
988
  })(),
958
989
  ]);
959
990
  const direct = (0, isAddressEqual_js_1.isAddressEqual)(assetToken, config.vaultAsset);
960
- const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.zoneGatewayCallbackData, [
991
+ const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.earnRouterCallbackData, [
961
992
  {
993
+ actionId,
994
+ earnVault: config.vault,
962
995
  flow: 1,
963
- outputToken: assetToken,
964
- keyIndex,
965
- encrypted,
966
- minVaultAssets: direct ? assetAmountMin : 1n,
967
- minVaultShares: 0n,
996
+ minEarnShares: 0n,
968
997
  minOutputAmount: direct ? 0n : assetAmountMin,
969
- actionId,
970
- refundRecipient: recoveryRecipient,
998
+ minVaultAssets: direct ? assetAmountMin : 1n,
999
+ outputToken: assetToken,
1000
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
971
1001
  },
972
1002
  ]);
973
1003
  return {
@@ -995,15 +1025,16 @@ async function privateRedeemSync(client, parameters) {
995
1025
  return zoneActions.requestWithdrawalSync(client, parameters);
996
1026
  }
997
1027
  async function waitForPrivateRedeem(client, parameters) {
998
- const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
1028
+ const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
999
1029
  const event = (0, getAbiItem_js_1.getAbiItem)({
1000
- abi: Abis.zoneGateway,
1030
+ abi: Abis.earnRouter,
1001
1031
  name: 'EarnRedeem',
1002
1032
  });
1003
1033
  const observerId = (0, stringify_js_1.stringify)([
1004
1034
  'waitForPrivateRedeem',
1005
1035
  client.uid,
1006
1036
  gateway,
1037
+ vault,
1007
1038
  actionId,
1008
1039
  fromBlock,
1009
1040
  ]);
@@ -1027,7 +1058,7 @@ async function waitForPrivateRedeem(client, parameters) {
1027
1058
  try {
1028
1059
  const [log] = await (0, getLogs_js_1.getLogs)(client, {
1029
1060
  address: gateway,
1030
- args: { actionId },
1061
+ args: { actionId, earnVault: vault },
1031
1062
  event,
1032
1063
  fromBlock,
1033
1064
  strict: true,
@@ -1040,7 +1071,7 @@ async function waitForPrivateRedeem(client, parameters) {
1040
1071
  actionId: log.args.actionId,
1041
1072
  outputAmount: log.args.outputAmount,
1042
1073
  outputToken: log.args.outputToken,
1043
- shares: log.args.shares,
1074
+ shares: log.args.earnShares,
1044
1075
  tempoBlockNumber: log.blockNumber,
1045
1076
  vaultAssets: log.args.vaultAssets,
1046
1077
  zoneDepositHash: log.args.zoneDepositHash,
@@ -1068,9 +1099,9 @@ async function withdrawExact(client, parameters) {
1068
1099
  const [args, shareToken] = await Promise.all([
1069
1100
  toWithdrawExactArgs(client, parameters),
1070
1101
  (0, readContract_js_1.readContract)(client, {
1071
- abi: Abis.vaultAdapter,
1102
+ abi: Abis.earnVault,
1072
1103
  address: parameters.vault,
1073
- functionName: 'shareToken',
1104
+ functionName: 'earnShare',
1074
1105
  }),
1075
1106
  ]);
1076
1107
  return (await action(client, {
@@ -1089,7 +1120,7 @@ async function withdrawExact(client, parameters) {
1089
1120
  })();
1090
1121
  return (0, utils_js_1.defineCall)({
1091
1122
  address: vault,
1092
- abi: Abis.vaultAdapter,
1123
+ abi: Abis.earnVault,
1093
1124
  functionName: 'withdrawExact',
1094
1125
  args: [
1095
1126
  internal_Token.toBaseUnits(args.assetAmount, undefined),
@@ -1118,7 +1149,7 @@ async function withdrawExact(client, parameters) {
1118
1149
  function extractEvent(logs, parameters) {
1119
1150
  const { vault } = parameters;
1120
1151
  const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
1121
- abi: Abis.vaultAdapter,
1152
+ abi: Abis.earnVault,
1122
1153
  eventName: 'WithdrewExact',
1123
1154
  logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
1124
1155
  });
@@ -1154,7 +1185,7 @@ async function withdrawExactSync(client, parameters) {
1154
1185
  caller: args.caller,
1155
1186
  receipt,
1156
1187
  recipient: args.receiver,
1157
- shareAmount: args.sharesBurned,
1188
+ shareAmount: args.earnSharesBurned,
1158
1189
  };
1159
1190
  }
1160
1191
  const zoneGatewayCallbackGas = 10000000n;
@@ -1184,54 +1215,45 @@ function pickReadParameters(parameters) {
1184
1215
  return { blockOverrides, blockTag: parameters.blockTag, stateOverride };
1185
1216
  }
1186
1217
  async function getZoneGatewayConfig(client, parameters) {
1187
- const { gateway, ...rest } = parameters;
1188
- const [vaultAdapter, vaultAsset, shareToken, zoneId, zonePortal, supportsAsyncFlow,] = await (0, multicall_js_1.multicall)(client, {
1218
+ const { flow, gateway, vault, zoneId, zonePortal, ...rest } = parameters;
1219
+ const [vaultAsset, shareToken, supportsFlow] = await (0, multicall_js_1.multicall)(client, {
1189
1220
  ...rest,
1190
1221
  allowFailure: false,
1191
1222
  contracts: [
1192
1223
  {
1193
- abi: Abis.zoneGateway,
1194
- address: gateway,
1195
- functionName: 'vaultAdapter',
1196
- },
1197
- {
1198
- abi: Abis.zoneGateway,
1199
- address: gateway,
1200
- functionName: 'vaultAsset',
1201
- },
1202
- {
1203
- abi: Abis.zoneGateway,
1204
- address: gateway,
1205
- functionName: 'shareToken',
1206
- },
1207
- {
1208
- abi: Abis.zoneGateway,
1209
- address: gateway,
1210
- functionName: 'zoneId',
1224
+ abi: Abis.earnVault,
1225
+ address: vault,
1226
+ functionName: 'asset',
1211
1227
  },
1212
1228
  {
1213
- abi: Abis.zoneGateway,
1214
- address: gateway,
1215
- functionName: 'zonePortal',
1229
+ abi: Abis.earnVault,
1230
+ address: vault,
1231
+ functionName: 'earnShare',
1216
1232
  },
1217
1233
  {
1218
- abi: Abis.zoneGateway,
1234
+ abi: Abis.earnRouter,
1219
1235
  address: gateway,
1220
- args: [2],
1236
+ args: [flow],
1221
1237
  functionName: 'supportsFlow',
1222
1238
  },
1223
1239
  ],
1224
1240
  deployless: true,
1225
1241
  });
1226
- if (supportsAsyncFlow)
1227
- throw new Error('Async Zone gateways are not supported.');
1228
- return { shareToken, vaultAdapter, vaultAsset, zoneId, zonePortal };
1242
+ if (!supportsFlow)
1243
+ throw new Error('Zone gateway flow is not supported.');
1244
+ return {
1245
+ shareToken,
1246
+ vault,
1247
+ vaultAsset,
1248
+ zoneId,
1249
+ zonePortal,
1250
+ };
1229
1251
  }
1230
1252
  const interfaceIds = {
1231
1253
  asyncRedeem: '0xa1a6a1d7',
1232
1254
  exactWithdraw: '0x0adfb0b9',
1233
- inKindDeposit: '0x7d28a2f2',
1234
- syncRedeem: '0x370457f4',
1255
+ inKindDeposit: '0xce4790a9',
1256
+ syncRedeem: '0x94a2d467',
1235
1257
  };
1236
1258
  function toFeeConfig(config) {
1237
1259
  return {
@@ -1240,8 +1262,20 @@ function toFeeConfig(config) {
1240
1262
  };
1241
1263
  }
1242
1264
  function toFeePreview(preview) {
1243
- const { allocationCount, allocations, ...rest } = preview;
1244
- return { ...rest, allocations: allocations.slice(0, allocationCount) };
1265
+ const { allocationCount, allocations, postFeeValuePerEarnShare, preFeeValuePerEarnShare, targetValuePerEarnShare, totalFeeEarnShares, ...rest } = preview;
1266
+ return {
1267
+ ...rest,
1268
+ allocations: allocations
1269
+ .slice(0, allocationCount)
1270
+ .map(({ feeEarnShares, ...allocation }) => ({
1271
+ ...allocation,
1272
+ feeShares: feeEarnShares,
1273
+ })),
1274
+ postFeeValuePerShare: postFeeValuePerEarnShare,
1275
+ preFeeValuePerShare: preFeeValuePerEarnShare,
1276
+ targetValuePerShare: targetValuePerEarnShare,
1277
+ totalFeeShares: totalFeeEarnShares,
1278
+ };
1245
1279
  }
1246
1280
  async function toDepositArgs(client, parameters) {
1247
1281
  const { vault } = parameters;
@@ -1348,9 +1382,9 @@ async function toBaseUnitsLive(client, options) {
1348
1382
  if (amount.decimals !== undefined)
1349
1383
  return internal_Token.toBaseUnits(amount, amount.decimals);
1350
1384
  const address = await (0, readContract_js_1.readContract)(client, {
1351
- abi: Abis.vaultAdapter,
1385
+ abi: Abis.earnVault,
1352
1386
  address: vault,
1353
- functionName: token,
1387
+ functionName: token === 'asset' ? 'asset' : 'earnShare',
1354
1388
  });
1355
1389
  const { decimals } = await (0, utils_js_1.resolveTokenWithDecimals)(client, {
1356
1390
  token: address,