viem 2.55.8 → 2.55.11

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 (143) hide show
  1. package/CHANGELOG.md +40 -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/chains/definitions/story.js +7 -7
  19. package/_cjs/chains/definitions/story.js.map +1 -1
  20. package/_cjs/chains/definitions/storyAeneid.js +8 -8
  21. package/_cjs/chains/definitions/storyAeneid.js.map +1 -1
  22. package/_cjs/errors/typedData.js +11 -1
  23. package/_cjs/errors/typedData.js.map +1 -1
  24. package/_cjs/errors/version.js +1 -1
  25. package/_cjs/errors/version.js.map +1 -1
  26. package/_cjs/index.js +5 -4
  27. package/_cjs/index.js.map +1 -1
  28. package/_cjs/tempo/Abis.js +1335 -571
  29. package/_cjs/tempo/Abis.js.map +1 -1
  30. package/_cjs/tempo/Addresses.js +2 -1
  31. package/_cjs/tempo/Addresses.js.map +1 -1
  32. package/_cjs/tempo/Decorator.js.map +1 -1
  33. package/_cjs/tempo/actions/earn.js +197 -135
  34. package/_cjs/tempo/actions/earn.js.map +1 -1
  35. package/_cjs/tempo/actions/token.js +18 -6
  36. package/_cjs/tempo/actions/token.js.map +1 -1
  37. package/_cjs/tempo/zones/Abis.js +6 -0
  38. package/_cjs/tempo/zones/Abis.js.map +1 -1
  39. package/_cjs/tokens/definitions/usdc.js +7 -0
  40. package/_cjs/tokens/definitions/usdc.js.map +1 -1
  41. package/_cjs/utils/promise/withRetry.js +2 -2
  42. package/_cjs/utils/promise/withRetry.js.map +1 -1
  43. package/_cjs/utils/typedData.js +3 -0
  44. package/_cjs/utils/typedData.js.map +1 -1
  45. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +1 -1
  46. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  47. package/_esm/actions/public/estimateFeesPerGas.js +1 -1
  48. package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
  49. package/_esm/actions/public/fillTransaction.js +1 -1
  50. package/_esm/actions/public/fillTransaction.js.map +1 -1
  51. package/_esm/chains/definitions/0gMainnet.js +1 -1
  52. package/_esm/chains/definitions/0gMainnet.js.map +1 -1
  53. package/_esm/chains/definitions/0gTestnet.js +2 -2
  54. package/_esm/chains/definitions/0gTestnet.js.map +1 -1
  55. package/_esm/chains/definitions/eduChain.js +9 -2
  56. package/_esm/chains/definitions/eduChain.js.map +1 -1
  57. package/_esm/chains/definitions/eduChainTestnet.js +3 -4
  58. package/_esm/chains/definitions/eduChainTestnet.js.map +1 -1
  59. package/_esm/chains/definitions/polygonAmoy.js +1 -1
  60. package/_esm/chains/definitions/polygonAmoy.js.map +1 -1
  61. package/_esm/chains/definitions/story.js +7 -7
  62. package/_esm/chains/definitions/story.js.map +1 -1
  63. package/_esm/chains/definitions/storyAeneid.js +8 -8
  64. package/_esm/chains/definitions/storyAeneid.js.map +1 -1
  65. package/_esm/errors/typedData.js +9 -0
  66. package/_esm/errors/typedData.js.map +1 -1
  67. package/_esm/errors/version.js +1 -1
  68. package/_esm/errors/version.js.map +1 -1
  69. package/_esm/index.js +1 -1
  70. package/_esm/index.js.map +1 -1
  71. package/_esm/tempo/Abis.js +1336 -572
  72. package/_esm/tempo/Abis.js.map +1 -1
  73. package/_esm/tempo/Addresses.js +1 -0
  74. package/_esm/tempo/Addresses.js.map +1 -1
  75. package/_esm/tempo/Decorator.js.map +1 -1
  76. package/_esm/tempo/actions/earn.js +240 -172
  77. package/_esm/tempo/actions/earn.js.map +1 -1
  78. package/_esm/tempo/actions/token.js +21 -8
  79. package/_esm/tempo/actions/token.js.map +1 -1
  80. package/_esm/tempo/zones/Abis.js +6 -0
  81. package/_esm/tempo/zones/Abis.js.map +1 -1
  82. package/_esm/tokens/definitions/usdc.js +7 -0
  83. package/_esm/tokens/definitions/usdc.js.map +1 -1
  84. package/_esm/utils/promise/withRetry.js +2 -2
  85. package/_esm/utils/promise/withRetry.js.map +1 -1
  86. package/_esm/utils/typedData.js +4 -1
  87. package/_esm/utils/typedData.js.map +1 -1
  88. package/_types/chains/definitions/0gMainnet.d.ts +1 -1
  89. package/_types/chains/definitions/0gTestnet.d.ts +3 -3
  90. package/_types/chains/definitions/eduChain.d.ts +9 -11
  91. package/_types/chains/definitions/eduChain.d.ts.map +1 -1
  92. package/_types/chains/definitions/eduChainTestnet.d.ts +3 -4
  93. package/_types/chains/definitions/eduChainTestnet.d.ts.map +1 -1
  94. package/_types/chains/definitions/polygonAmoy.d.ts +1 -1
  95. package/_types/chains/definitions/story.d.ts +7 -7
  96. package/_types/chains/definitions/storyAeneid.d.ts +8 -8
  97. package/_types/errors/typedData.d.ts +8 -0
  98. package/_types/errors/typedData.d.ts.map +1 -1
  99. package/_types/errors/version.d.ts +1 -1
  100. package/_types/errors/version.d.ts.map +1 -1
  101. package/_types/index.d.ts +1 -1
  102. package/_types/index.d.ts.map +1 -1
  103. package/_types/package.json +1 -0
  104. package/_types/tempo/Abis.d.ts +2153 -950
  105. package/_types/tempo/Abis.d.ts.map +1 -1
  106. package/_types/tempo/Addresses.d.ts +1 -0
  107. package/_types/tempo/Addresses.d.ts.map +1 -1
  108. package/_types/tempo/Decorator.d.ts +21 -15
  109. package/_types/tempo/Decorator.d.ts.map +1 -1
  110. package/_types/tempo/actions/earn.d.ts +1369 -1825
  111. package/_types/tempo/actions/earn.d.ts.map +1 -1
  112. package/_types/tempo/actions/token.d.ts +1 -1
  113. package/_types/tempo/actions/token.d.ts.map +1 -1
  114. package/_types/tempo/zones/Abis.d.ts +20 -0
  115. package/_types/tempo/zones/Abis.d.ts.map +1 -1
  116. package/_types/tokens/definitions/usdc.d.ts +7 -0
  117. package/_types/tokens/definitions/usdc.d.ts.map +1 -1
  118. package/_types/tokens/sets.d.ts +14 -0
  119. package/_types/tokens/sets.d.ts.map +1 -1
  120. package/_types/utils/typedData.d.ts.map +1 -1
  121. package/account-abstraction/utils/formatters/userOperationRequest.ts +4 -3
  122. package/actions/public/estimateFeesPerGas.ts +1 -1
  123. package/actions/public/fillTransaction.ts +1 -1
  124. package/chains/definitions/0gMainnet.ts +1 -1
  125. package/chains/definitions/0gTestnet.ts +2 -2
  126. package/chains/definitions/eduChain.ts +9 -2
  127. package/chains/definitions/eduChainTestnet.ts +3 -4
  128. package/chains/definitions/polygonAmoy.ts +1 -1
  129. package/chains/definitions/story.ts +7 -7
  130. package/chains/definitions/storyAeneid.ts +8 -8
  131. package/errors/typedData.ts +13 -0
  132. package/errors/version.ts +1 -1
  133. package/index.ts +2 -0
  134. package/package.json +2 -2
  135. package/tempo/Abis.ts +1341 -576
  136. package/tempo/Addresses.ts +1 -0
  137. package/tempo/Decorator.ts +21 -15
  138. package/tempo/actions/earn.ts +365 -287
  139. package/tempo/actions/token.ts +60 -9
  140. package/tempo/zones/Abis.ts +6 -0
  141. package/tokens/definitions/usdc.ts +7 -0
  142. package/utils/promise/withRetry.ts +4 -4
  143. package/utils/typedData.ts +5 -0
@@ -25,13 +25,14 @@ import * as Abis from '../Abis.js';
25
25
  import * as Addresses from '../Addresses.js';
26
26
  import { GetVaultEngineChangedError, WaitForPrivateDepositTimeoutError, WaitForPrivateRedeemTimeoutError, } from '../errors.js';
27
27
  import { defineCall, pickWriteParameters, resolveCallParameters, resolveTokenWithDecimals, } from '../internal/utils.js';
28
+ import { getPortalAddress } from '../zones/zone.js';
28
29
  import * as policyActions from './policy.js';
29
30
  import * as tokenActions from './token.js';
30
31
  import * as zoneActions from './zone.js';
31
32
  /** TIP-403 policy ID that allows every sender, recipient, and mint recipient. */
32
33
  export const alwaysAllowPolicyId = 1n;
33
34
  /**
34
- * Creates and attaches an admission-only TIP-403 policy to an Earn vault share
35
+ * Creates and attaches an admission-only TIP-403 policy to an Earn share
35
36
  * token. Existing holders remain able to send shares while recipients and mint
36
37
  * recipients must belong to the same whitelist.
37
38
  *
@@ -60,7 +61,7 @@ export const alwaysAllowPolicyId = 1n;
60
61
  * })
61
62
  * ```
62
63
  *
63
- * @param client - Client authorized to change the vault share token policy.
64
+ * @param client - Client authorized to change the Earn share token policy.
64
65
  * @param parameters - Share token, administrator, and initial members.
65
66
  * @returns The configured policy IDs and transaction receipts.
66
67
  */
@@ -127,7 +128,7 @@ export async function configureExitSafePolicy(client, parameters) {
127
128
  };
128
129
  }
129
130
  /**
130
- * Verifies that an Earn vault share token uses the expected exit-safe TIP-403
131
+ * Verifies that an Earn share token uses the expected exit-safe TIP-403
131
132
  * policy and that every required member can receive transfers and mints.
132
133
  *
133
134
  * @example
@@ -202,7 +203,7 @@ export async function validateExitSafePolicy(client, parameters) {
202
203
  })),
203
204
  ]);
204
205
  if (tokenPolicyId !== policy.transferPolicyId)
205
- throw new Error('Earn vault share token transfer policy mismatch.');
206
+ throw new Error('Earn share token transfer policy mismatch.');
206
207
  if (compound[0] !== policy.senderPolicyId ||
207
208
  compound[1] !== policy.recipientPolicyId ||
208
209
  compound[2] !== policy.mintRecipientPolicyId)
@@ -220,7 +221,7 @@ export async function validateExitSafePolicy(client, parameters) {
220
221
  throw new Error(`Required TIP-403 member is unauthorized: ${unauthorized.member}`);
221
222
  }
222
223
  /**
223
- * Deposits assets into a vault and mints vault shares to `recipient`. The
224
+ * Deposits assets into a vault and mints Earn shares to `recipient`. The
224
225
  * transaction includes the required asset approval.
225
226
  *
226
227
  * @example
@@ -257,7 +258,7 @@ export async function deposit(client, parameters) {
257
258
  const [args, assetToken] = await Promise.all([
258
259
  toDepositArgs(client, parameters),
259
260
  readContract(client, {
260
- abi: Abis.vaultAdapter,
261
+ abi: Abis.earnVault,
261
262
  address: parameters.vault,
262
263
  functionName: 'asset',
263
264
  }),
@@ -285,7 +286,7 @@ export async function deposit(client, parameters) {
285
286
  })();
286
287
  return defineCall({
287
288
  address: vault,
288
- abi: Abis.vaultAdapter,
289
+ abi: Abis.earnVault,
289
290
  functionName: 'deposit',
290
291
  args: [
291
292
  internal_Token.toBaseUnits(args.assetAmount, undefined),
@@ -328,7 +329,7 @@ export async function deposit(client, parameters) {
328
329
  // Earn contracts are user-deployed: several adapters can emit the same
329
330
  // signature in one receipt, so filter by emitting address before decode.
330
331
  const [log] = parseEventLogs({
331
- abi: Abis.vaultAdapter,
332
+ abi: Abis.earnVault,
332
333
  eventName: 'Deposited',
333
334
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
334
335
  });
@@ -405,11 +406,11 @@ export async function depositSync(client, parameters) {
405
406
  caller: args.caller,
406
407
  receipt,
407
408
  recipient: args.receiver,
408
- shareAmount: args.shares,
409
+ shareAmount: args.earnShares,
409
410
  };
410
411
  }
411
412
  /**
412
- * Deposits venue shares into a vault and mints vault shares to `recipient`.
413
+ * Deposits venue shares into a vault and mints Earn shares to `recipient`.
413
414
  * The transaction includes the required venue share approval.
414
415
  *
415
416
  * @example
@@ -445,7 +446,7 @@ export async function depositShares(client, parameters) {
445
446
  /** @internal Shared dispatch; reads the engine for the approval. */
446
447
  async function inner(action, client, parameters) {
447
448
  const engine = await readContract(client, {
448
- abi: Abis.vaultAdapter,
449
+ abi: Abis.earnVault,
449
450
  address: parameters.vault,
450
451
  functionName: 'engine',
451
452
  });
@@ -476,8 +477,8 @@ export async function depositShares(client, parameters) {
476
477
  })();
477
478
  return defineCall({
478
479
  address: vault,
479
- abi: Abis.vaultAdapter,
480
- functionName: 'depositShares',
480
+ abi: Abis.earnVault,
481
+ functionName: 'depositVenueShares',
481
482
  args: [venueShareAmount, recipient, earnShareAmountMin],
482
483
  });
483
484
  }
@@ -514,7 +515,7 @@ export async function depositShares(client, parameters) {
514
515
  // Earn contracts are user-deployed: several adapters can emit the same
515
516
  // signature in one receipt, so filter by emitting address before decode.
516
517
  const [log] = parseEventLogs({
517
- abi: Abis.vaultAdapter,
518
+ abi: Abis.earnVault,
518
519
  eventName: 'VenueSharesDeposited',
519
520
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
520
521
  });
@@ -592,7 +593,7 @@ export async function depositSharesSync(client, parameters) {
592
593
  caller: args.caller,
593
594
  earnShareAmount: args.earnShares,
594
595
  receipt,
595
- receivedVenueShareAmount: args.receivedVenueShares,
596
+ receivedVenueShareAmount: args.receivedEngineShares,
596
597
  recipient: args.receiver,
597
598
  venueShareAmount: args.requestedVenueShares,
598
599
  };
@@ -610,7 +611,9 @@ export async function depositSharesSync(client, parameters) {
610
611
  * recipient: '0x...',
611
612
  * recoveryRecipient: '0x...',
612
613
  * shareAmountMin: 99_500_000n,
614
+ * vault: '0x...',
613
615
  * vaultAssetAmountMin: 99_000_000n,
616
+ * zoneId: 7,
614
617
  * })
615
618
  * const hash = await Actions.earn.privateDeposit(zoneClient, prepared)
616
619
  * ```
@@ -625,8 +628,8 @@ export async function privateDeposit(client, parameters) {
625
628
  }
626
629
  (function (privateDeposit) {
627
630
  /**
628
- * Builds an encrypted Zone withdrawal that deposits into the gateway's
629
- * vault and returns the resulting shares to the Zone.
631
+ * Builds an encrypted Zone withdrawal that deposits into the selected vault
632
+ * and returns the resulting shares to the Zone.
630
633
  *
631
634
  * @param client - Parent-chain client.
632
635
  * @param parameters - Deposit intent and recovery parameters.
@@ -636,13 +639,23 @@ export async function privateDeposit(client, parameters) {
636
639
  const chainId = client.chain?.id;
637
640
  if (!chainId)
638
641
  throw new Error('`chain` is required.');
639
- const { actionId = Hex.random(32), assetAmount, callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, recipient, recoveryRecipient, returnMemo, withdrawalMemo, } = parameters;
642
+ const { actionId = Hex.random(32), assetAmount, callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, portalAddress: portalAddress_, recipient, recoveryRecipient, returnMemo, vault, withdrawalMemo, zoneId, } = parameters;
643
+ const portalAddress = portalAddress_ ?? getPortalAddress(chainId, zoneId);
640
644
  const readParameters = pickReadParameters(parameters);
641
645
  const [fromBlock, config] = await Promise.all([
642
646
  getBlockNumber(client, { cacheTime: 0 }),
643
- getZoneGatewayConfig(client, { ...readParameters, gateway }),
647
+ getZoneGatewayConfig(client, {
648
+ ...readParameters,
649
+ flow: 0,
650
+ gateway,
651
+ vault,
652
+ zoneId,
653
+ zonePortal: portalAddress,
654
+ }),
644
655
  ]);
645
- const assetToken = parameters.assetToken ?? config.vaultAsset;
656
+ const assetToken = parameters.assetToken ?? config.privateAsset;
657
+ if (!isAddressEqual(assetToken, config.privateAsset))
658
+ throw new Error('`assetToken` must match the Zone gateway private asset.');
646
659
  const { encrypted, keyIndex } = await zoneActions.encryptedDeposit.prepareRecipient(client, {
647
660
  ...readParameters,
648
661
  memo: returnMemo,
@@ -651,20 +664,14 @@ export async function privateDeposit(client, parameters) {
651
664
  zoneId: config.zoneId,
652
665
  });
653
666
  const shareAmountMin = resolveMinimumShareAmount(parameters);
654
- const direct = isAddressEqual(assetToken, config.vaultAsset);
655
- const data = encodeAbiParameters(Abis.zoneGatewayCallbackData, [
667
+ const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
656
668
  {
669
+ actionId,
657
670
  flow: 0,
658
- outputToken: config.shareToken,
659
- keyIndex,
660
- encrypted,
661
- minVaultAssets: direct
662
- ? assetAmount
663
- : (parameters.vaultAssetAmountMin ?? 0n),
664
- minVaultShares: shareAmountMin,
671
+ minEarnShares: shareAmountMin,
665
672
  minOutputAmount: 0n,
666
- actionId,
667
- refundRecipient: recoveryRecipient,
673
+ minVaultAssets: parameters.vaultAssetAmountMin ?? assetAmount,
674
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
668
675
  },
669
676
  ]);
670
677
  return {
@@ -714,6 +721,7 @@ export async function privateDepositSync(client, parameters) {
714
721
  * actionId: prepared.actionId,
715
722
  * fromBlock: prepared.fromBlock,
716
723
  * gateway: '0x...',
724
+ * vault: '0x...',
717
725
  * })
718
726
  * ```
719
727
  *
@@ -722,15 +730,16 @@ export async function privateDepositSync(client, parameters) {
722
730
  * @returns The completed gateway deposit.
723
731
  */
724
732
  export async function waitForPrivateDeposit(client, parameters) {
725
- const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
733
+ const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
726
734
  const event = getAbiItem({
727
- abi: Abis.zoneGateway,
735
+ abi: Abis.earnRouter,
728
736
  name: 'EarnDeposit',
729
737
  });
730
738
  const observerId = stringify([
731
739
  'waitForPrivateDeposit',
732
740
  client.uid,
733
741
  gateway,
742
+ vault,
734
743
  actionId,
735
744
  fromBlock,
736
745
  ]);
@@ -754,7 +763,7 @@ export async function waitForPrivateDeposit(client, parameters) {
754
763
  try {
755
764
  const [log] = await getLogs(client, {
756
765
  address: gateway,
757
- args: { actionId },
766
+ args: { actionId, earnVault: vault },
758
767
  event,
759
768
  fromBlock,
760
769
  strict: true,
@@ -767,7 +776,7 @@ export async function waitForPrivateDeposit(client, parameters) {
767
776
  actionId: log.args.actionId,
768
777
  inputAmount: log.args.inputAmount,
769
778
  inputToken: log.args.inputToken,
770
- shares: log.args.shares,
779
+ shares: log.args.earnShares,
771
780
  tempoBlockNumber: log.blockNumber,
772
781
  vaultAssets: log.args.vaultAssets,
773
782
  zoneDepositHash: log.args.zoneDepositHash,
@@ -812,30 +821,36 @@ export async function waitForPrivateDeposit(client, parameters) {
812
821
  */
813
822
  export async function getFeeState(client, parameters) {
814
823
  const { recipient, vault, ...rest } = parameters;
824
+ const fees = await readContract(client, {
825
+ ...rest,
826
+ abi: Abis.earnVault,
827
+ address: vault,
828
+ functionName: 'earnFees',
829
+ });
815
830
  const contracts = [
816
831
  defineCall({
817
- address: vault,
818
- abi: Abis.vaultAdapter,
832
+ address: fees,
833
+ abi: Abis.earnFees,
819
834
  functionName: 'currentFeeConfigId',
820
835
  }),
821
836
  defineCall({
822
- address: vault,
823
- abi: Abis.vaultAdapter,
837
+ address: fees,
838
+ abi: Abis.earnFees,
824
839
  functionName: 'feesActive',
825
840
  }),
826
841
  defineCall({
827
- address: vault,
828
- abi: Abis.vaultAdapter,
842
+ address: fees,
843
+ abi: Abis.earnFees,
829
844
  functionName: 'highWaterMark',
830
845
  }),
831
846
  defineCall({
832
- address: vault,
833
- abi: Abis.vaultAdapter,
847
+ address: fees,
848
+ abi: Abis.earnFees,
834
849
  functionName: 'previewAccruedFees',
835
850
  }),
836
851
  defineCall({
837
- address: vault,
838
- abi: Abis.vaultAdapter,
852
+ address: fees,
853
+ abi: Abis.earnFees,
839
854
  functionName: 'targetBase',
840
855
  }),
841
856
  ];
@@ -843,8 +858,8 @@ export async function getFeeState(client, parameters) {
843
858
  // consistent with the batched id.
844
859
  const feeConfig = async (configId) => toFeeConfig(await readContract(client, {
845
860
  ...rest,
846
- abi: Abis.vaultAdapter,
847
- address: vault,
861
+ abi: Abis.earnFees,
862
+ address: fees,
848
863
  functionName: 'feeConfig',
849
864
  args: [configId],
850
865
  }));
@@ -855,9 +870,9 @@ export async function getFeeState(client, parameters) {
855
870
  contracts: [
856
871
  ...contracts,
857
872
  defineCall({
858
- address: vault,
859
- abi: Abis.vaultAdapter,
860
- functionName: 'claimableFeeShares',
873
+ address: fees,
874
+ abi: Abis.earnFees,
875
+ functionName: 'claimableEarnShares',
861
876
  args: [recipient],
862
877
  }),
863
878
  ],
@@ -889,7 +904,7 @@ export async function getFeeState(client, parameters) {
889
904
  };
890
905
  }
891
906
  /**
892
- * Gets an account's asset and vault share balances, allowances, and current
907
+ * Gets an account's asset and Earn share balances, allowances, and current
893
908
  * share value. The value includes fees.
894
909
  *
895
910
  * @example
@@ -911,7 +926,7 @@ export async function getFeeState(client, parameters) {
911
926
  *
912
927
  * @param client - Client.
913
928
  * @param parameters - Parameters.
914
- * @returns The asset and vault share balances, allowances, and value.
929
+ * @returns The asset and Earn share balances, allowances, and value.
915
930
  */
916
931
  export async function getPosition(client, parameters) {
917
932
  const { account: account_ = client.account, vault, ...rest } = parameters;
@@ -924,13 +939,13 @@ export async function getPosition(client, parameters) {
924
939
  contracts: [
925
940
  defineCall({
926
941
  address: vault,
927
- abi: Abis.vaultAdapter,
942
+ abi: Abis.earnVault,
928
943
  functionName: 'asset',
929
944
  }),
930
945
  defineCall({
931
946
  address: vault,
932
- abi: Abis.vaultAdapter,
933
- functionName: 'shareToken',
947
+ abi: Abis.earnVault,
948
+ functionName: 'earnShare',
934
949
  }),
935
950
  ],
936
951
  deployless: true,
@@ -968,7 +983,7 @@ export async function getPosition(client, parameters) {
968
983
  });
969
984
  const value = await readContract(client, {
970
985
  ...rest,
971
- abi: Abis.vaultAdapter,
986
+ abi: Abis.earnVault,
972
987
  address: vault,
973
988
  args: [shareBalance],
974
989
  functionName: 'previewRedeem',
@@ -984,7 +999,7 @@ export async function getPosition(client, parameters) {
984
999
  };
985
1000
  }
986
1001
  /**
987
- * Gets the asset output for an exact vault share input, including fees.
1002
+ * Gets the asset output for an exact Earn share input, including fees.
988
1003
  *
989
1004
  * @example
990
1005
  * ```ts
@@ -1040,7 +1055,7 @@ export async function getRedeemQuote(client, parameters) {
1040
1055
  const { shareAmount, vault } = args;
1041
1056
  return defineCall({
1042
1057
  address: vault,
1043
- abi: Abis.vaultAdapter,
1058
+ abi: Abis.earnVault,
1044
1059
  args: [shareAmount],
1045
1060
  functionName: 'previewRedeem',
1046
1061
  });
@@ -1073,16 +1088,24 @@ export async function getRedeemQuote(client, parameters) {
1073
1088
  */
1074
1089
  export async function getVault(client, parameters) {
1075
1090
  const { vault, ...rest } = parameters;
1076
- const engine = await readContract(client, {
1077
- ...rest,
1078
- abi: Abis.vaultAdapter,
1079
- address: vault,
1080
- functionName: 'engine',
1081
- });
1091
+ const [engine, fees] = await Promise.all([
1092
+ readContract(client, {
1093
+ ...rest,
1094
+ abi: Abis.earnVault,
1095
+ address: vault,
1096
+ functionName: 'engine',
1097
+ }),
1098
+ readContract(client, {
1099
+ ...rest,
1100
+ abi: Abis.earnVault,
1101
+ address: vault,
1102
+ functionName: 'earnFees',
1103
+ }),
1104
+ ]);
1082
1105
  const [assetToken, engine_, shareToken, operator, emergencyGuardian, asyncJanitor, engineMigrationMode, depositsPaused, engineShares, shareSupply, isSynced, pendingRedeemCount, feesActive, totalAssets, name, symbol, asyncRedeem, exactWithdraw, inKindDeposit, syncRedeem,] = await multicall(client, {
1083
1106
  ...rest,
1084
1107
  allowFailure: false,
1085
- contracts: getVault.calls({ engine, vault }),
1108
+ contracts: getVault.calls({ engine, fees, vault }),
1086
1109
  deployless: true,
1087
1110
  });
1088
1111
  if (!isAddressEqual(engine, engine_))
@@ -1107,116 +1130,116 @@ export async function getVault(client, parameters) {
1107
1130
  }
1108
1131
  (function (getVault) {
1109
1132
  /**
1110
- * Defines the reads used by {@link getVault}. Pass the vault's current
1111
- * engine address.
1133
+ * Defines the reads used by {@link getVault}. Pass the current engine and
1134
+ * fee contract addresses.
1112
1135
  *
1113
1136
  * @param args - Arguments.
1114
1137
  * @returns The calls.
1115
1138
  */
1116
1139
  function calls(args) {
1117
- const { engine, vault } = args;
1140
+ const { engine, fees, vault } = args;
1118
1141
  return [
1119
1142
  defineCall({
1120
1143
  address: vault,
1121
- abi: Abis.vaultAdapter,
1144
+ abi: Abis.earnVault,
1122
1145
  functionName: 'asset',
1123
1146
  }),
1124
1147
  defineCall({
1125
1148
  address: vault,
1126
- abi: Abis.vaultAdapter,
1149
+ abi: Abis.earnVault,
1127
1150
  functionName: 'engine',
1128
1151
  }),
1129
1152
  defineCall({
1130
1153
  address: vault,
1131
- abi: Abis.vaultAdapter,
1132
- functionName: 'shareToken',
1154
+ abi: Abis.earnVault,
1155
+ functionName: 'earnShare',
1133
1156
  }),
1134
1157
  defineCall({
1135
1158
  address: vault,
1136
- abi: Abis.vaultAdapter,
1159
+ abi: Abis.earnVault,
1137
1160
  functionName: 'operator',
1138
1161
  }),
1139
1162
  defineCall({
1140
1163
  address: vault,
1141
- abi: Abis.vaultAdapter,
1164
+ abi: Abis.earnVault,
1142
1165
  functionName: 'emergencyGuardian',
1143
1166
  }),
1144
1167
  defineCall({
1145
1168
  address: vault,
1146
- abi: Abis.vaultAdapter,
1169
+ abi: Abis.earnVault,
1147
1170
  functionName: 'asyncJanitor',
1148
1171
  }),
1149
1172
  defineCall({
1150
1173
  address: vault,
1151
- abi: Abis.vaultAdapter,
1174
+ abi: Abis.earnVault,
1152
1175
  functionName: 'engineMigrationMode',
1153
1176
  }),
1154
1177
  defineCall({
1155
1178
  address: vault,
1156
- abi: Abis.vaultAdapter,
1179
+ abi: Abis.earnVault,
1157
1180
  functionName: 'depositsPaused',
1158
1181
  }),
1159
1182
  defineCall({
1160
1183
  address: vault,
1161
- abi: Abis.vaultAdapter,
1184
+ abi: Abis.earnVault,
1162
1185
  functionName: 'engineShares',
1163
1186
  }),
1164
1187
  defineCall({
1165
1188
  address: vault,
1166
- abi: Abis.vaultAdapter,
1167
- functionName: 'shareSupply',
1189
+ abi: Abis.earnVault,
1190
+ functionName: 'totalEarnShares',
1168
1191
  }),
1169
1192
  defineCall({
1170
1193
  address: vault,
1171
- abi: Abis.vaultAdapter,
1172
- functionName: 'isSynced',
1194
+ abi: Abis.earnVault,
1195
+ functionName: 'isAccountingAligned',
1173
1196
  }),
1174
1197
  defineCall({
1175
1198
  address: vault,
1176
- abi: Abis.vaultAdapter,
1177
- functionName: 'pendingRedeemCount',
1199
+ abi: Abis.earnVault,
1200
+ functionName: 'openRedeemRequestCount',
1178
1201
  }),
1179
1202
  defineCall({
1180
- address: vault,
1181
- abi: Abis.vaultAdapter,
1203
+ address: fees,
1204
+ abi: Abis.earnFees,
1182
1205
  functionName: 'feesActive',
1183
1206
  }),
1184
1207
  defineCall({
1185
1208
  address: engine,
1186
- abi: Abis.vaultEngine,
1209
+ abi: Abis.earnEngine,
1187
1210
  functionName: 'totalAssets',
1188
1211
  }),
1189
1212
  defineCall({
1190
1213
  address: engine,
1191
- abi: Abis.vaultEngine,
1214
+ abi: Abis.earnEngine,
1192
1215
  functionName: 'name',
1193
1216
  }),
1194
1217
  defineCall({
1195
1218
  address: engine,
1196
- abi: Abis.vaultEngine,
1219
+ abi: Abis.earnEngine,
1197
1220
  functionName: 'symbol',
1198
1221
  }),
1199
1222
  defineCall({
1200
1223
  address: engine,
1201
- abi: Abis.vaultEngine,
1224
+ abi: Abis.earnEngine,
1202
1225
  functionName: 'supportsInterface',
1203
1226
  args: [interfaceIds.asyncRedeem],
1204
1227
  }),
1205
1228
  defineCall({
1206
1229
  address: engine,
1207
- abi: Abis.vaultEngine,
1230
+ abi: Abis.earnEngine,
1208
1231
  functionName: 'supportsInterface',
1209
1232
  args: [interfaceIds.exactWithdraw],
1210
1233
  }),
1211
1234
  defineCall({
1212
1235
  address: engine,
1213
- abi: Abis.vaultEngine,
1236
+ abi: Abis.earnEngine,
1214
1237
  functionName: 'supportsInterface',
1215
1238
  args: [interfaceIds.inKindDeposit],
1216
1239
  }),
1217
1240
  defineCall({
1218
1241
  address: engine,
1219
- abi: Abis.vaultEngine,
1242
+ abi: Abis.earnEngine,
1220
1243
  functionName: 'supportsInterface',
1221
1244
  args: [interfaceIds.syncRedeem],
1222
1245
  }),
@@ -1225,7 +1248,7 @@ export async function getVault(client, parameters) {
1225
1248
  getVault.calls = calls;
1226
1249
  })(getVault || (getVault = {}));
1227
1250
  /**
1228
- * Gets the vault shares required for an exact asset output, including fees
1251
+ * Gets the Earn shares required for an exact asset output, including fees
1229
1252
  * and ceiling rounding.
1230
1253
  *
1231
1254
  * @example
@@ -1247,7 +1270,7 @@ export async function getVault(client, parameters) {
1247
1270
  *
1248
1271
  * @param client - Client.
1249
1272
  * @param parameters - Parameters.
1250
- * @returns The required vault share input, ceiling-rounded.
1273
+ * @returns The required Earn share input, ceiling-rounded.
1251
1274
  */
1252
1275
  export async function getWithdrawQuote(client, parameters) {
1253
1276
  const { assetAmount, vault, ...rest } = parameters;
@@ -1282,7 +1305,7 @@ export async function getWithdrawQuote(client, parameters) {
1282
1305
  const { assetAmount, vault } = args;
1283
1306
  return defineCall({
1284
1307
  address: vault,
1285
- abi: Abis.vaultAdapter,
1308
+ abi: Abis.earnVault,
1286
1309
  args: [assetAmount],
1287
1310
  functionName: 'previewWithdraw',
1288
1311
  });
@@ -1290,8 +1313,8 @@ export async function getWithdrawQuote(client, parameters) {
1290
1313
  getWithdrawQuote.call = call;
1291
1314
  })(getWithdrawQuote || (getWithdrawQuote = {}));
1292
1315
  /**
1293
- * Redeems vault shares for assets sent to `recipient`. The transaction
1294
- * includes the required vault share approval.
1316
+ * Redeems Earn shares for assets sent to `recipient`. The transaction
1317
+ * includes the required Earn share approval.
1295
1318
  *
1296
1319
  * @example
1297
1320
  * ```ts
@@ -1321,14 +1344,14 @@ export async function redeem(client, parameters) {
1321
1344
  return redeem.inner(sendTransaction, client, parameters);
1322
1345
  }
1323
1346
  (function (redeem) {
1324
- /** @internal Shared dispatch; reads the vault share token for the approval. */
1347
+ /** @internal Shared dispatch; reads the Earn share token for the approval. */
1325
1348
  async function inner(action, client, parameters) {
1326
1349
  const [args, shareToken] = await Promise.all([
1327
1350
  toRedeemArgs(client, parameters),
1328
1351
  readContract(client, {
1329
- abi: Abis.vaultAdapter,
1352
+ abi: Abis.earnVault,
1330
1353
  address: parameters.vault,
1331
- functionName: 'shareToken',
1354
+ functionName: 'earnShare',
1332
1355
  }),
1333
1356
  ]);
1334
1357
  return (await action(client, {
@@ -1338,7 +1361,7 @@ export async function redeem(client, parameters) {
1338
1361
  }
1339
1362
  redeem.inner = inner;
1340
1363
  /**
1341
- * Defines a redeem call without an approval. Provide vault share decimals
1364
+ * Defines a redeem call without an approval. Provide Earn share decimals
1342
1365
  * for formatted inputs and an explicit output bound because this builder performs no reads.
1343
1366
  *
1344
1367
  * @param parameters - Client (optional), followed by the call arguments.
@@ -1354,7 +1377,7 @@ export async function redeem(client, parameters) {
1354
1377
  })();
1355
1378
  return defineCall({
1356
1379
  address: vault,
1357
- abi: Abis.vaultAdapter,
1380
+ abi: Abis.earnVault,
1358
1381
  functionName: 'redeem',
1359
1382
  args: [
1360
1383
  internal_Token.toBaseUnits(args.shareAmount, undefined),
@@ -1365,7 +1388,7 @@ export async function redeem(client, parameters) {
1365
1388
  }
1366
1389
  redeem.call = call;
1367
1390
  /**
1368
- * Defines the vault share approval and redeem calls for atomic execution.
1391
+ * Defines the Earn share approval and redeem calls for atomic execution.
1369
1392
  * Pass `shareToken` explicitly because this builder performs no reads.
1370
1393
  *
1371
1394
  * @param args - Arguments.
@@ -1397,7 +1420,7 @@ export async function redeem(client, parameters) {
1397
1420
  // Earn contracts are user-deployed: several adapters can emit the same
1398
1421
  // signature in one receipt, so filter by emitting address before decode.
1399
1422
  const [log] = parseEventLogs({
1400
- abi: Abis.vaultAdapter,
1423
+ abi: Abis.earnVault,
1401
1424
  eventName: 'Redeemed',
1402
1425
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
1403
1426
  });
@@ -1407,7 +1430,7 @@ export async function redeem(client, parameters) {
1407
1430
  }
1408
1431
  redeem.extractEvent = extractEvent;
1409
1432
  /**
1410
- * Estimates gas for a redemption, assuming enough vault share allowance.
1433
+ * Estimates gas for a redemption, assuming enough Earn share allowance.
1411
1434
  *
1412
1435
  * @param client - Client.
1413
1436
  * @param parameters - Parameters.
@@ -1421,7 +1444,7 @@ export async function redeem(client, parameters) {
1421
1444
  }
1422
1445
  redeem.estimateGas = estimateGas;
1423
1446
  /**
1424
- * Simulates a redemption, assuming enough vault share allowance.
1447
+ * Simulates a redemption, assuming enough Earn share allowance.
1425
1448
  *
1426
1449
  * @param client - Client.
1427
1450
  * @param parameters - Parameters.
@@ -1436,7 +1459,7 @@ export async function redeem(client, parameters) {
1436
1459
  redeem.simulate = simulate;
1437
1460
  })(redeem || (redeem = {}));
1438
1461
  /**
1439
- * Redeems vault shares and returns the confirmed receipt and event data.
1462
+ * Redeems Earn shares and returns the confirmed receipt and event data.
1440
1463
  *
1441
1464
  * @example
1442
1465
  * ```ts
@@ -1474,11 +1497,11 @@ export async function redeemSync(client, parameters) {
1474
1497
  caller: args.caller,
1475
1498
  receipt,
1476
1499
  recipient: args.receiver,
1477
- shareAmount: args.shares,
1500
+ shareAmount: args.earnShares,
1478
1501
  };
1479
1502
  }
1480
1503
  /**
1481
- * Withdraws vault shares from a Zone and redeems them on the parent chain. Use
1504
+ * Withdraws Earn shares from a Zone and redeems them on the parent chain. Use
1482
1505
  * {@link privateRedeem.prepare} to build the encrypted callback.
1483
1506
  *
1484
1507
  * @example
@@ -1489,6 +1512,8 @@ export async function redeemSync(client, parameters) {
1489
1512
  * recoveryRecipient: '0x...',
1490
1513
  * shareAmount: 100_000_000n,
1491
1514
  * slippageBps: 50,
1515
+ * vault: '0x...',
1516
+ * zoneId: 7,
1492
1517
  * })
1493
1518
  * const hash = await Actions.earn.privateRedeem(zoneClient, prepared)
1494
1519
  * ```
@@ -1503,7 +1528,7 @@ export async function privateRedeem(client, parameters) {
1503
1528
  }
1504
1529
  (function (privateRedeem) {
1505
1530
  /**
1506
- * Builds an encrypted Zone withdrawal that redeems vault shares and returns
1531
+ * Builds an encrypted Zone withdrawal that redeems Earn shares and returns
1507
1532
  * the resulting assets to the Zone.
1508
1533
  *
1509
1534
  * @param client - Parent-chain client.
@@ -1514,15 +1539,23 @@ export async function privateRedeem(client, parameters) {
1514
1539
  const chainId = client.chain?.id;
1515
1540
  if (!chainId)
1516
1541
  throw new Error('`chain` is required.');
1517
- const { actionId = Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, recipient, recoveryRecipient, returnMemo, shareAmount, withdrawalMemo, } = parameters;
1542
+ const { actionId = Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, portalAddress: portalAddress_, recipient, recoveryRecipient, returnMemo, shareAmount, vault, withdrawalMemo, zoneId, } = parameters;
1543
+ const portalAddress = portalAddress_ ?? getPortalAddress(chainId, zoneId);
1518
1544
  const readParameters = pickReadParameters(parameters);
1519
1545
  const [fromBlock, config] = await Promise.all([
1520
1546
  getBlockNumber(client, { cacheTime: 0 }),
1521
- getZoneGatewayConfig(client, { ...readParameters, gateway }),
1547
+ getZoneGatewayConfig(client, {
1548
+ ...readParameters,
1549
+ flow: 1,
1550
+ gateway,
1551
+ vault,
1552
+ zoneId,
1553
+ zonePortal: portalAddress,
1554
+ }),
1522
1555
  ]);
1523
- const assetToken = parameters.assetToken ?? config.vaultAsset;
1524
- if (isAddressEqual(assetToken, config.shareToken))
1525
- throw new Error('`assetToken` cannot be the gateway vault share token.');
1556
+ const assetToken = parameters.assetToken ?? config.privateAsset;
1557
+ if (!isAddressEqual(assetToken, config.privateAsset))
1558
+ throw new Error('`assetToken` must match the Zone gateway private asset.');
1526
1559
  const [{ encrypted, keyIndex }, assetAmountMin] = await Promise.all([
1527
1560
  zoneActions.encryptedDeposit.prepareRecipient(client, {
1528
1561
  ...readParameters,
@@ -1539,23 +1572,19 @@ export async function privateRedeem(client, parameters) {
1539
1572
  const assetAmount = await getRedeemQuote(client, {
1540
1573
  ...readParameters,
1541
1574
  shareAmount,
1542
- vault: config.vaultAdapter,
1575
+ vault: config.vault,
1543
1576
  });
1544
1577
  return EarnShares.minimumOutput(assetAmount, parameters.slippageBps);
1545
1578
  })(),
1546
1579
  ]);
1547
- const direct = isAddressEqual(assetToken, config.vaultAsset);
1548
- const data = encodeAbiParameters(Abis.zoneGatewayCallbackData, [
1580
+ const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
1549
1581
  {
1550
- flow: 1,
1551
- outputToken: assetToken,
1552
- keyIndex,
1553
- encrypted,
1554
- minVaultAssets: direct ? assetAmountMin : 1n,
1555
- minVaultShares: 0n,
1556
- minOutputAmount: direct ? 0n : assetAmountMin,
1557
1582
  actionId,
1558
- refundRecipient: recoveryRecipient,
1583
+ flow: 1,
1584
+ minEarnShares: 0n,
1585
+ minOutputAmount: assetAmountMin,
1586
+ minVaultAssets: assetAmountMin,
1587
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
1559
1588
  },
1560
1589
  ]);
1561
1590
  return {
@@ -1605,6 +1634,7 @@ export async function privateRedeemSync(client, parameters) {
1605
1634
  * actionId: prepared.actionId,
1606
1635
  * fromBlock: prepared.fromBlock,
1607
1636
  * gateway: '0x...',
1637
+ * vault: '0x...',
1608
1638
  * })
1609
1639
  * ```
1610
1640
  *
@@ -1613,15 +1643,16 @@ export async function privateRedeemSync(client, parameters) {
1613
1643
  * @returns The completed gateway redemption.
1614
1644
  */
1615
1645
  export async function waitForPrivateRedeem(client, parameters) {
1616
- const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
1646
+ const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
1617
1647
  const event = getAbiItem({
1618
- abi: Abis.zoneGateway,
1648
+ abi: Abis.earnRouter,
1619
1649
  name: 'EarnRedeem',
1620
1650
  });
1621
1651
  const observerId = stringify([
1622
1652
  'waitForPrivateRedeem',
1623
1653
  client.uid,
1624
1654
  gateway,
1655
+ vault,
1625
1656
  actionId,
1626
1657
  fromBlock,
1627
1658
  ]);
@@ -1645,7 +1676,7 @@ export async function waitForPrivateRedeem(client, parameters) {
1645
1676
  try {
1646
1677
  const [log] = await getLogs(client, {
1647
1678
  address: gateway,
1648
- args: { actionId },
1679
+ args: { actionId, earnVault: vault },
1649
1680
  event,
1650
1681
  fromBlock,
1651
1682
  strict: true,
@@ -1658,7 +1689,7 @@ export async function waitForPrivateRedeem(client, parameters) {
1658
1689
  actionId: log.args.actionId,
1659
1690
  outputAmount: log.args.outputAmount,
1660
1691
  outputToken: log.args.outputToken,
1661
- shares: log.args.shares,
1692
+ shares: log.args.earnShares,
1662
1693
  tempoBlockNumber: log.blockNumber,
1663
1694
  vaultAssets: log.args.vaultAssets,
1664
1695
  zoneDepositHash: log.args.zoneDepositHash,
@@ -1679,8 +1710,8 @@ export async function waitForPrivateRedeem(client, parameters) {
1679
1710
  return await promise;
1680
1711
  }
1681
1712
  /**
1682
- * Withdraws an exact asset amount to `recipient`, up to the specified vault
1683
- * share limit. The transaction includes the required vault share approval;
1713
+ * Withdraws an exact asset amount to `recipient`, up to the specified Earn
1714
+ * share limit. The transaction includes the required Earn share approval;
1684
1715
  * use {@link redeem} for a full exit.
1685
1716
  *
1686
1717
  * @example
@@ -1711,14 +1742,14 @@ export async function withdrawExact(client, parameters) {
1711
1742
  return withdrawExact.inner(sendTransaction, client, parameters);
1712
1743
  }
1713
1744
  (function (withdrawExact) {
1714
- /** @internal Shared dispatch; reads the vault share token for the approval. */
1745
+ /** @internal Shared dispatch; reads the Earn share token for the approval. */
1715
1746
  async function inner(action, client, parameters) {
1716
1747
  const [args, shareToken] = await Promise.all([
1717
1748
  toWithdrawExactArgs(client, parameters),
1718
1749
  readContract(client, {
1719
- abi: Abis.vaultAdapter,
1750
+ abi: Abis.earnVault,
1720
1751
  address: parameters.vault,
1721
- functionName: 'shareToken',
1752
+ functionName: 'earnShare',
1722
1753
  }),
1723
1754
  ]);
1724
1755
  return (await action(client, {
@@ -1744,7 +1775,7 @@ export async function withdrawExact(client, parameters) {
1744
1775
  })();
1745
1776
  return defineCall({
1746
1777
  address: vault,
1747
- abi: Abis.vaultAdapter,
1778
+ abi: Abis.earnVault,
1748
1779
  functionName: 'withdrawExact',
1749
1780
  args: [
1750
1781
  internal_Token.toBaseUnits(args.assetAmount, undefined),
@@ -1755,7 +1786,7 @@ export async function withdrawExact(client, parameters) {
1755
1786
  }
1756
1787
  withdrawExact.call = call;
1757
1788
  /**
1758
- * Defines the vault share approval and withdrawal calls for atomic
1789
+ * Defines the Earn share approval and withdrawal calls for atomic
1759
1790
  * execution. Pass `shareToken` explicitly because this builder performs no reads.
1760
1791
  *
1761
1792
  * @param args - Arguments.
@@ -1789,7 +1820,7 @@ export async function withdrawExact(client, parameters) {
1789
1820
  // Earn contracts are user-deployed: several adapters can emit the same
1790
1821
  // signature in one receipt, so filter by emitting address before decode.
1791
1822
  const [log] = parseEventLogs({
1792
- abi: Abis.vaultAdapter,
1823
+ abi: Abis.earnVault,
1793
1824
  eventName: 'WithdrewExact',
1794
1825
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
1795
1826
  });
@@ -1799,7 +1830,7 @@ export async function withdrawExact(client, parameters) {
1799
1830
  }
1800
1831
  withdrawExact.extractEvent = extractEvent;
1801
1832
  /**
1802
- * Estimates gas for an exact withdrawal, assuming enough vault share allowance.
1833
+ * Estimates gas for an exact withdrawal, assuming enough Earn share allowance.
1803
1834
  *
1804
1835
  * @param client - Client.
1805
1836
  * @param parameters - Parameters.
@@ -1813,7 +1844,7 @@ export async function withdrawExact(client, parameters) {
1813
1844
  }
1814
1845
  withdrawExact.estimateGas = estimateGas;
1815
1846
  /**
1816
- * Simulates an exact withdrawal, assuming enough vault share allowance.
1847
+ * Simulates an exact withdrawal, assuming enough Earn share allowance.
1817
1848
  *
1818
1849
  * @param client - Client.
1819
1850
  * @param parameters - Parameters.
@@ -1866,7 +1897,7 @@ export async function withdrawExactSync(client, parameters) {
1866
1897
  caller: args.caller,
1867
1898
  receipt,
1868
1899
  recipient: args.receiver,
1869
- shareAmount: args.sharesBurned,
1900
+ shareAmount: args.earnSharesBurned,
1870
1901
  };
1871
1902
  }
1872
1903
  const zoneGatewayCallbackGas = 10000000n;
@@ -1896,72 +1927,109 @@ function pickReadParameters(parameters) {
1896
1927
  return { blockOverrides, blockTag: parameters.blockTag, stateOverride };
1897
1928
  }
1898
1929
  async function getZoneGatewayConfig(client, parameters) {
1899
- const { gateway, ...rest } = parameters;
1900
- const [vaultAdapter, vaultAsset, shareToken, zoneId, zonePortal, supportsAsyncFlow,] = await multicall(client, {
1930
+ const { flow, gateway, vault, zoneId, zonePortal, ...rest } = parameters;
1931
+ const [vaultAsset, shareToken, allowedZoneId, routerVault, privateAsset, routerVaultAsset, routerShareToken, supportsFlow,] = await multicall(client, {
1901
1932
  ...rest,
1902
1933
  allowFailure: false,
1903
1934
  contracts: [
1904
1935
  {
1905
- abi: Abis.zoneGateway,
1936
+ abi: Abis.earnVault,
1937
+ address: vault,
1938
+ functionName: 'asset',
1939
+ },
1940
+ {
1941
+ abi: Abis.earnVault,
1942
+ address: vault,
1943
+ functionName: 'earnShare',
1944
+ },
1945
+ {
1946
+ abi: Abis.earnRouter,
1906
1947
  address: gateway,
1907
- functionName: 'vaultAdapter',
1948
+ functionName: 'allowedZoneId',
1908
1949
  },
1909
1950
  {
1910
- abi: Abis.zoneGateway,
1951
+ abi: Abis.earnRouter,
1911
1952
  address: gateway,
1912
- functionName: 'vaultAsset',
1953
+ functionName: 'earnVault',
1913
1954
  },
1914
1955
  {
1915
- abi: Abis.zoneGateway,
1956
+ abi: Abis.earnRouter,
1916
1957
  address: gateway,
1917
- functionName: 'shareToken',
1958
+ functionName: 'privateAsset',
1918
1959
  },
1919
1960
  {
1920
- abi: Abis.zoneGateway,
1961
+ abi: Abis.earnRouter,
1921
1962
  address: gateway,
1922
- functionName: 'zoneId',
1963
+ functionName: 'vaultAsset',
1923
1964
  },
1924
1965
  {
1925
- abi: Abis.zoneGateway,
1966
+ abi: Abis.earnRouter,
1926
1967
  address: gateway,
1927
- functionName: 'zonePortal',
1968
+ functionName: 'earnShare',
1928
1969
  },
1929
1970
  {
1930
- abi: Abis.zoneGateway,
1971
+ abi: Abis.earnRouter,
1931
1972
  address: gateway,
1932
- args: [2],
1973
+ args: [flow],
1933
1974
  functionName: 'supportsFlow',
1934
1975
  },
1935
1976
  ],
1936
1977
  deployless: true,
1937
1978
  });
1938
- if (supportsAsyncFlow)
1939
- throw new Error('Async Zone gateways are not supported.');
1940
- return { shareToken, vaultAdapter, vaultAsset, zoneId, zonePortal };
1979
+ if (!supportsFlow)
1980
+ throw new Error('Zone gateway flow is not supported.');
1981
+ if (allowedZoneId !== zoneId)
1982
+ throw new Error('Zone gateway is configured for a different Zone.');
1983
+ if (!isAddressEqual(routerVault, vault))
1984
+ throw new Error('Zone gateway is configured for a different Earn vault.');
1985
+ if (!isAddressEqual(routerVaultAsset, vaultAsset))
1986
+ throw new Error('Zone gateway vault asset does not match the Earn vault.');
1987
+ if (!isAddressEqual(routerShareToken, shareToken))
1988
+ throw new Error('Zone gateway share token does not match the Earn vault.');
1989
+ return {
1990
+ privateAsset,
1991
+ shareToken,
1992
+ vault,
1993
+ vaultAsset,
1994
+ zoneId,
1995
+ zonePortal,
1996
+ };
1941
1997
  }
1942
1998
  // ERC-165 ids of the optional engine capability interfaces (XOR of each
1943
1999
  // interface's function selectors).
1944
2000
  const interfaceIds = {
1945
- /** `IVaultEngineAsync`. */
2001
+ /** `IEarnEngineAsyncRedeem`. */
1946
2002
  asyncRedeem: '0xa1a6a1d7',
1947
- /** `IVaultEngineExactWithdraw`. */
2003
+ /** `IEarnEngineExactWithdraw`. */
1948
2004
  exactWithdraw: '0x0adfb0b9',
1949
- /** `IVaultEngineShares`. */
1950
- inKindDeposit: '0x7d28a2f2',
1951
- /** `IVaultEngineSync`. */
1952
- syncRedeem: '0x370457f4',
2005
+ /** `IEarnEngineInKindDeposit`. */
2006
+ inKindDeposit: '0xce4790a9',
2007
+ /** `IEarnEngineRedeem`. */
2008
+ syncRedeem: '0x94a2d467',
1953
2009
  };
1954
- /** Trims the decoded `IVaultFees.FeeConfig` to its active fixed-fee count. */
2010
+ /** Trims the decoded `FeeConfig` to its active fixed-fee count. */
1955
2011
  function toFeeConfig(config) {
1956
2012
  return {
1957
2013
  excess: config.excess,
1958
2014
  fixedFees: config.fixedFees.slice(0, config.fixedFeeCount),
1959
2015
  };
1960
2016
  }
1961
- /** Trims the decoded `IVaultFees.FeePreview` to its active allocation count. */
2017
+ /** Maps decoded fee fields to the action result. */
1962
2018
  function toFeePreview(preview) {
1963
- const { allocationCount, allocations, ...rest } = preview;
1964
- return { ...rest, allocations: allocations.slice(0, allocationCount) };
2019
+ const { allocationCount, allocations, postFeeValuePerEarnShare, preFeeValuePerEarnShare, targetValuePerEarnShare, totalFeeEarnShares, ...rest } = preview;
2020
+ return {
2021
+ ...rest,
2022
+ allocations: allocations
2023
+ .slice(0, allocationCount)
2024
+ .map(({ feeEarnShares, ...allocation }) => ({
2025
+ ...allocation,
2026
+ feeShares: feeEarnShares,
2027
+ })),
2028
+ postFeeValuePerShare: postFeeValuePerEarnShare,
2029
+ preFeeValuePerShare: preFeeValuePerEarnShare,
2030
+ targetValuePerShare: targetValuePerEarnShare,
2031
+ totalFeeShares: totalFeeEarnShares,
2032
+ };
1965
2033
  }
1966
2034
  /** Resolves `deposit` parameters into the adapter call args. @internal */
1967
2035
  async function toDepositArgs(client, parameters) {
@@ -2069,7 +2137,7 @@ function maximumInput(shareAmount, slippageBps) {
2069
2137
  }
2070
2138
  /**
2071
2139
  * Converts an amount to base units, resolving missing decimals with live
2072
- * reads of the vault's asset or share token. Vault share tokens are not
2140
+ * reads of the vault's asset or share token. Earn share tokens are not
2073
2141
  * genesis-declared, so nothing is cached. @internal
2074
2142
  */
2075
2143
  async function toBaseUnitsLive(client, options) {
@@ -2079,9 +2147,9 @@ async function toBaseUnitsLive(client, options) {
2079
2147
  if (amount.decimals !== undefined)
2080
2148
  return internal_Token.toBaseUnits(amount, amount.decimals);
2081
2149
  const address = await readContract(client, {
2082
- abi: Abis.vaultAdapter,
2150
+ abi: Abis.earnVault,
2083
2151
  address: vault,
2084
- functionName: token,
2152
+ functionName: token === 'asset' ? 'asset' : 'earnShare',
2085
2153
  });
2086
2154
  const { decimals } = await resolveTokenWithDecimals(client, {
2087
2155
  token: address,