viem 2.55.8 → 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 (90) hide show
  1. package/CHANGELOG.md +26 -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/zones/Abis.js +6 -0
  28. package/_cjs/tempo/zones/Abis.js.map +1 -1
  29. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +1 -1
  30. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
  31. package/_esm/actions/public/estimateFeesPerGas.js +1 -1
  32. package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
  33. package/_esm/actions/public/fillTransaction.js +1 -1
  34. package/_esm/actions/public/fillTransaction.js.map +1 -1
  35. package/_esm/chains/definitions/0gMainnet.js +1 -1
  36. package/_esm/chains/definitions/0gMainnet.js.map +1 -1
  37. package/_esm/chains/definitions/0gTestnet.js +2 -2
  38. package/_esm/chains/definitions/0gTestnet.js.map +1 -1
  39. package/_esm/chains/definitions/eduChain.js +9 -2
  40. package/_esm/chains/definitions/eduChain.js.map +1 -1
  41. package/_esm/chains/definitions/eduChainTestnet.js +3 -4
  42. package/_esm/chains/definitions/eduChainTestnet.js.map +1 -1
  43. package/_esm/chains/definitions/polygonAmoy.js +1 -1
  44. package/_esm/chains/definitions/polygonAmoy.js.map +1 -1
  45. package/_esm/errors/version.js +1 -1
  46. package/_esm/errors/version.js.map +1 -1
  47. package/_esm/tempo/Abis.js +919 -544
  48. package/_esm/tempo/Abis.js.map +1 -1
  49. package/_esm/tempo/Addresses.js +1 -0
  50. package/_esm/tempo/Addresses.js.map +1 -1
  51. package/_esm/tempo/Decorator.js.map +1 -1
  52. package/_esm/tempo/actions/earn.js +214 -174
  53. package/_esm/tempo/actions/earn.js.map +1 -1
  54. package/_esm/tempo/zones/Abis.js +6 -0
  55. package/_esm/tempo/zones/Abis.js.map +1 -1
  56. package/_types/chains/definitions/0gMainnet.d.ts +1 -1
  57. package/_types/chains/definitions/0gTestnet.d.ts +3 -3
  58. package/_types/chains/definitions/eduChain.d.ts +9 -11
  59. package/_types/chains/definitions/eduChain.d.ts.map +1 -1
  60. package/_types/chains/definitions/eduChainTestnet.d.ts +3 -4
  61. package/_types/chains/definitions/eduChainTestnet.d.ts.map +1 -1
  62. package/_types/chains/definitions/polygonAmoy.d.ts +1 -1
  63. package/_types/errors/version.d.ts +1 -1
  64. package/_types/errors/version.d.ts.map +1 -1
  65. package/_types/package.json +1 -0
  66. package/_types/tempo/Abis.d.ts +1423 -777
  67. package/_types/tempo/Abis.d.ts.map +1 -1
  68. package/_types/tempo/Addresses.d.ts +1 -0
  69. package/_types/tempo/Addresses.d.ts.map +1 -1
  70. package/_types/tempo/Decorator.d.ts +21 -15
  71. package/_types/tempo/Decorator.d.ts.map +1 -1
  72. package/_types/tempo/actions/earn.d.ts +850 -1913
  73. package/_types/tempo/actions/earn.d.ts.map +1 -1
  74. package/_types/tempo/zones/Abis.d.ts +20 -0
  75. package/_types/tempo/zones/Abis.d.ts.map +1 -1
  76. package/account-abstraction/utils/formatters/userOperationRequest.ts +4 -3
  77. package/actions/public/estimateFeesPerGas.ts +1 -1
  78. package/actions/public/fillTransaction.ts +1 -1
  79. package/chains/definitions/0gMainnet.ts +1 -1
  80. package/chains/definitions/0gTestnet.ts +2 -2
  81. package/chains/definitions/eduChain.ts +9 -2
  82. package/chains/definitions/eduChainTestnet.ts +3 -4
  83. package/chains/definitions/polygonAmoy.ts +1 -1
  84. package/errors/version.ts +1 -1
  85. package/package.json +2 -2
  86. package/tempo/Abis.ts +920 -545
  87. package/tempo/Addresses.ts +1 -0
  88. package/tempo/Decorator.ts +21 -15
  89. package/tempo/actions/earn.ts +311 -250
  90. package/tempo/zones/Abis.ts +6 -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
  });
@@ -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,11 +639,19 @@ 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
656
  const assetToken = parameters.assetToken ?? config.vaultAsset;
646
657
  const { encrypted, keyIndex } = await zoneActions.encryptedDeposit.prepareRecipient(client, {
@@ -652,19 +663,18 @@ export async function privateDeposit(client, parameters) {
652
663
  });
653
664
  const shareAmountMin = resolveMinimumShareAmount(parameters);
654
665
  const direct = isAddressEqual(assetToken, config.vaultAsset);
655
- const data = encodeAbiParameters(Abis.zoneGatewayCallbackData, [
666
+ const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
656
667
  {
668
+ actionId,
669
+ earnVault: config.vault,
657
670
  flow: 0,
658
- outputToken: config.shareToken,
659
- keyIndex,
660
- encrypted,
671
+ minEarnShares: shareAmountMin,
672
+ minOutputAmount: 0n,
661
673
  minVaultAssets: direct
662
674
  ? assetAmount
663
675
  : (parameters.vaultAssetAmountMin ?? 0n),
664
- minVaultShares: shareAmountMin,
665
- minOutputAmount: 0n,
666
- actionId,
667
- refundRecipient: recoveryRecipient,
676
+ outputToken: config.shareToken,
677
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
668
678
  },
669
679
  ]);
670
680
  return {
@@ -714,6 +724,7 @@ export async function privateDepositSync(client, parameters) {
714
724
  * actionId: prepared.actionId,
715
725
  * fromBlock: prepared.fromBlock,
716
726
  * gateway: '0x...',
727
+ * vault: '0x...',
717
728
  * })
718
729
  * ```
719
730
  *
@@ -722,15 +733,16 @@ export async function privateDepositSync(client, parameters) {
722
733
  * @returns The completed gateway deposit.
723
734
  */
724
735
  export async function waitForPrivateDeposit(client, parameters) {
725
- const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
736
+ const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
726
737
  const event = getAbiItem({
727
- abi: Abis.zoneGateway,
738
+ abi: Abis.earnRouter,
728
739
  name: 'EarnDeposit',
729
740
  });
730
741
  const observerId = stringify([
731
742
  'waitForPrivateDeposit',
732
743
  client.uid,
733
744
  gateway,
745
+ vault,
734
746
  actionId,
735
747
  fromBlock,
736
748
  ]);
@@ -754,7 +766,7 @@ export async function waitForPrivateDeposit(client, parameters) {
754
766
  try {
755
767
  const [log] = await getLogs(client, {
756
768
  address: gateway,
757
- args: { actionId },
769
+ args: { actionId, earnVault: vault },
758
770
  event,
759
771
  fromBlock,
760
772
  strict: true,
@@ -767,7 +779,7 @@ export async function waitForPrivateDeposit(client, parameters) {
767
779
  actionId: log.args.actionId,
768
780
  inputAmount: log.args.inputAmount,
769
781
  inputToken: log.args.inputToken,
770
- shares: log.args.shares,
782
+ shares: log.args.earnShares,
771
783
  tempoBlockNumber: log.blockNumber,
772
784
  vaultAssets: log.args.vaultAssets,
773
785
  zoneDepositHash: log.args.zoneDepositHash,
@@ -812,30 +824,36 @@ export async function waitForPrivateDeposit(client, parameters) {
812
824
  */
813
825
  export async function getFeeState(client, parameters) {
814
826
  const { recipient, vault, ...rest } = parameters;
827
+ const fees = await readContract(client, {
828
+ ...rest,
829
+ abi: Abis.earnVault,
830
+ address: vault,
831
+ functionName: 'earnFees',
832
+ });
815
833
  const contracts = [
816
834
  defineCall({
817
- address: vault,
818
- abi: Abis.vaultAdapter,
835
+ address: fees,
836
+ abi: Abis.earnFees,
819
837
  functionName: 'currentFeeConfigId',
820
838
  }),
821
839
  defineCall({
822
- address: vault,
823
- abi: Abis.vaultAdapter,
840
+ address: fees,
841
+ abi: Abis.earnFees,
824
842
  functionName: 'feesActive',
825
843
  }),
826
844
  defineCall({
827
- address: vault,
828
- abi: Abis.vaultAdapter,
845
+ address: fees,
846
+ abi: Abis.earnFees,
829
847
  functionName: 'highWaterMark',
830
848
  }),
831
849
  defineCall({
832
- address: vault,
833
- abi: Abis.vaultAdapter,
850
+ address: fees,
851
+ abi: Abis.earnFees,
834
852
  functionName: 'previewAccruedFees',
835
853
  }),
836
854
  defineCall({
837
- address: vault,
838
- abi: Abis.vaultAdapter,
855
+ address: fees,
856
+ abi: Abis.earnFees,
839
857
  functionName: 'targetBase',
840
858
  }),
841
859
  ];
@@ -843,8 +861,8 @@ export async function getFeeState(client, parameters) {
843
861
  // consistent with the batched id.
844
862
  const feeConfig = async (configId) => toFeeConfig(await readContract(client, {
845
863
  ...rest,
846
- abi: Abis.vaultAdapter,
847
- address: vault,
864
+ abi: Abis.earnFees,
865
+ address: fees,
848
866
  functionName: 'feeConfig',
849
867
  args: [configId],
850
868
  }));
@@ -855,9 +873,9 @@ export async function getFeeState(client, parameters) {
855
873
  contracts: [
856
874
  ...contracts,
857
875
  defineCall({
858
- address: vault,
859
- abi: Abis.vaultAdapter,
860
- functionName: 'claimableFeeShares',
876
+ address: fees,
877
+ abi: Abis.earnFees,
878
+ functionName: 'claimableEarnShares',
861
879
  args: [recipient],
862
880
  }),
863
881
  ],
@@ -889,7 +907,7 @@ export async function getFeeState(client, parameters) {
889
907
  };
890
908
  }
891
909
  /**
892
- * Gets an account's asset and vault share balances, allowances, and current
910
+ * Gets an account's asset and Earn share balances, allowances, and current
893
911
  * share value. The value includes fees.
894
912
  *
895
913
  * @example
@@ -911,7 +929,7 @@ export async function getFeeState(client, parameters) {
911
929
  *
912
930
  * @param client - Client.
913
931
  * @param parameters - Parameters.
914
- * @returns The asset and vault share balances, allowances, and value.
932
+ * @returns The asset and Earn share balances, allowances, and value.
915
933
  */
916
934
  export async function getPosition(client, parameters) {
917
935
  const { account: account_ = client.account, vault, ...rest } = parameters;
@@ -924,13 +942,13 @@ export async function getPosition(client, parameters) {
924
942
  contracts: [
925
943
  defineCall({
926
944
  address: vault,
927
- abi: Abis.vaultAdapter,
945
+ abi: Abis.earnVault,
928
946
  functionName: 'asset',
929
947
  }),
930
948
  defineCall({
931
949
  address: vault,
932
- abi: Abis.vaultAdapter,
933
- functionName: 'shareToken',
950
+ abi: Abis.earnVault,
951
+ functionName: 'earnShare',
934
952
  }),
935
953
  ],
936
954
  deployless: true,
@@ -968,7 +986,7 @@ export async function getPosition(client, parameters) {
968
986
  });
969
987
  const value = await readContract(client, {
970
988
  ...rest,
971
- abi: Abis.vaultAdapter,
989
+ abi: Abis.earnVault,
972
990
  address: vault,
973
991
  args: [shareBalance],
974
992
  functionName: 'previewRedeem',
@@ -984,7 +1002,7 @@ export async function getPosition(client, parameters) {
984
1002
  };
985
1003
  }
986
1004
  /**
987
- * Gets the asset output for an exact vault share input, including fees.
1005
+ * Gets the asset output for an exact Earn share input, including fees.
988
1006
  *
989
1007
  * @example
990
1008
  * ```ts
@@ -1040,7 +1058,7 @@ export async function getRedeemQuote(client, parameters) {
1040
1058
  const { shareAmount, vault } = args;
1041
1059
  return defineCall({
1042
1060
  address: vault,
1043
- abi: Abis.vaultAdapter,
1061
+ abi: Abis.earnVault,
1044
1062
  args: [shareAmount],
1045
1063
  functionName: 'previewRedeem',
1046
1064
  });
@@ -1073,16 +1091,24 @@ export async function getRedeemQuote(client, parameters) {
1073
1091
  */
1074
1092
  export async function getVault(client, parameters) {
1075
1093
  const { vault, ...rest } = parameters;
1076
- const engine = await readContract(client, {
1077
- ...rest,
1078
- abi: Abis.vaultAdapter,
1079
- address: vault,
1080
- functionName: 'engine',
1081
- });
1094
+ const [engine, fees] = await Promise.all([
1095
+ readContract(client, {
1096
+ ...rest,
1097
+ abi: Abis.earnVault,
1098
+ address: vault,
1099
+ functionName: 'engine',
1100
+ }),
1101
+ readContract(client, {
1102
+ ...rest,
1103
+ abi: Abis.earnVault,
1104
+ address: vault,
1105
+ functionName: 'earnFees',
1106
+ }),
1107
+ ]);
1082
1108
  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
1109
  ...rest,
1084
1110
  allowFailure: false,
1085
- contracts: getVault.calls({ engine, vault }),
1111
+ contracts: getVault.calls({ engine, fees, vault }),
1086
1112
  deployless: true,
1087
1113
  });
1088
1114
  if (!isAddressEqual(engine, engine_))
@@ -1107,116 +1133,116 @@ export async function getVault(client, parameters) {
1107
1133
  }
1108
1134
  (function (getVault) {
1109
1135
  /**
1110
- * Defines the reads used by {@link getVault}. Pass the vault's current
1111
- * engine address.
1136
+ * Defines the reads used by {@link getVault}. Pass the current engine and
1137
+ * fee contract addresses.
1112
1138
  *
1113
1139
  * @param args - Arguments.
1114
1140
  * @returns The calls.
1115
1141
  */
1116
1142
  function calls(args) {
1117
- const { engine, vault } = args;
1143
+ const { engine, fees, vault } = args;
1118
1144
  return [
1119
1145
  defineCall({
1120
1146
  address: vault,
1121
- abi: Abis.vaultAdapter,
1147
+ abi: Abis.earnVault,
1122
1148
  functionName: 'asset',
1123
1149
  }),
1124
1150
  defineCall({
1125
1151
  address: vault,
1126
- abi: Abis.vaultAdapter,
1152
+ abi: Abis.earnVault,
1127
1153
  functionName: 'engine',
1128
1154
  }),
1129
1155
  defineCall({
1130
1156
  address: vault,
1131
- abi: Abis.vaultAdapter,
1132
- functionName: 'shareToken',
1157
+ abi: Abis.earnVault,
1158
+ functionName: 'earnShare',
1133
1159
  }),
1134
1160
  defineCall({
1135
1161
  address: vault,
1136
- abi: Abis.vaultAdapter,
1162
+ abi: Abis.earnVault,
1137
1163
  functionName: 'operator',
1138
1164
  }),
1139
1165
  defineCall({
1140
1166
  address: vault,
1141
- abi: Abis.vaultAdapter,
1167
+ abi: Abis.earnVault,
1142
1168
  functionName: 'emergencyGuardian',
1143
1169
  }),
1144
1170
  defineCall({
1145
1171
  address: vault,
1146
- abi: Abis.vaultAdapter,
1172
+ abi: Abis.earnVault,
1147
1173
  functionName: 'asyncJanitor',
1148
1174
  }),
1149
1175
  defineCall({
1150
1176
  address: vault,
1151
- abi: Abis.vaultAdapter,
1177
+ abi: Abis.earnVault,
1152
1178
  functionName: 'engineMigrationMode',
1153
1179
  }),
1154
1180
  defineCall({
1155
1181
  address: vault,
1156
- abi: Abis.vaultAdapter,
1182
+ abi: Abis.earnVault,
1157
1183
  functionName: 'depositsPaused',
1158
1184
  }),
1159
1185
  defineCall({
1160
1186
  address: vault,
1161
- abi: Abis.vaultAdapter,
1187
+ abi: Abis.earnVault,
1162
1188
  functionName: 'engineShares',
1163
1189
  }),
1164
1190
  defineCall({
1165
1191
  address: vault,
1166
- abi: Abis.vaultAdapter,
1167
- functionName: 'shareSupply',
1192
+ abi: Abis.earnVault,
1193
+ functionName: 'totalEarnShares',
1168
1194
  }),
1169
1195
  defineCall({
1170
1196
  address: vault,
1171
- abi: Abis.vaultAdapter,
1172
- functionName: 'isSynced',
1197
+ abi: Abis.earnVault,
1198
+ functionName: 'isAccountingAligned',
1173
1199
  }),
1174
1200
  defineCall({
1175
1201
  address: vault,
1176
- abi: Abis.vaultAdapter,
1177
- functionName: 'pendingRedeemCount',
1202
+ abi: Abis.earnVault,
1203
+ functionName: 'openRedeemRequestCount',
1178
1204
  }),
1179
1205
  defineCall({
1180
- address: vault,
1181
- abi: Abis.vaultAdapter,
1206
+ address: fees,
1207
+ abi: Abis.earnFees,
1182
1208
  functionName: 'feesActive',
1183
1209
  }),
1184
1210
  defineCall({
1185
1211
  address: engine,
1186
- abi: Abis.vaultEngine,
1212
+ abi: Abis.earnEngine,
1187
1213
  functionName: 'totalAssets',
1188
1214
  }),
1189
1215
  defineCall({
1190
1216
  address: engine,
1191
- abi: Abis.vaultEngine,
1217
+ abi: Abis.earnEngine,
1192
1218
  functionName: 'name',
1193
1219
  }),
1194
1220
  defineCall({
1195
1221
  address: engine,
1196
- abi: Abis.vaultEngine,
1222
+ abi: Abis.earnEngine,
1197
1223
  functionName: 'symbol',
1198
1224
  }),
1199
1225
  defineCall({
1200
1226
  address: engine,
1201
- abi: Abis.vaultEngine,
1227
+ abi: Abis.earnEngine,
1202
1228
  functionName: 'supportsInterface',
1203
1229
  args: [interfaceIds.asyncRedeem],
1204
1230
  }),
1205
1231
  defineCall({
1206
1232
  address: engine,
1207
- abi: Abis.vaultEngine,
1233
+ abi: Abis.earnEngine,
1208
1234
  functionName: 'supportsInterface',
1209
1235
  args: [interfaceIds.exactWithdraw],
1210
1236
  }),
1211
1237
  defineCall({
1212
1238
  address: engine,
1213
- abi: Abis.vaultEngine,
1239
+ abi: Abis.earnEngine,
1214
1240
  functionName: 'supportsInterface',
1215
1241
  args: [interfaceIds.inKindDeposit],
1216
1242
  }),
1217
1243
  defineCall({
1218
1244
  address: engine,
1219
- abi: Abis.vaultEngine,
1245
+ abi: Abis.earnEngine,
1220
1246
  functionName: 'supportsInterface',
1221
1247
  args: [interfaceIds.syncRedeem],
1222
1248
  }),
@@ -1225,7 +1251,7 @@ export async function getVault(client, parameters) {
1225
1251
  getVault.calls = calls;
1226
1252
  })(getVault || (getVault = {}));
1227
1253
  /**
1228
- * Gets the vault shares required for an exact asset output, including fees
1254
+ * Gets the Earn shares required for an exact asset output, including fees
1229
1255
  * and ceiling rounding.
1230
1256
  *
1231
1257
  * @example
@@ -1247,7 +1273,7 @@ export async function getVault(client, parameters) {
1247
1273
  *
1248
1274
  * @param client - Client.
1249
1275
  * @param parameters - Parameters.
1250
- * @returns The required vault share input, ceiling-rounded.
1276
+ * @returns The required Earn share input, ceiling-rounded.
1251
1277
  */
1252
1278
  export async function getWithdrawQuote(client, parameters) {
1253
1279
  const { assetAmount, vault, ...rest } = parameters;
@@ -1282,7 +1308,7 @@ export async function getWithdrawQuote(client, parameters) {
1282
1308
  const { assetAmount, vault } = args;
1283
1309
  return defineCall({
1284
1310
  address: vault,
1285
- abi: Abis.vaultAdapter,
1311
+ abi: Abis.earnVault,
1286
1312
  args: [assetAmount],
1287
1313
  functionName: 'previewWithdraw',
1288
1314
  });
@@ -1290,8 +1316,8 @@ export async function getWithdrawQuote(client, parameters) {
1290
1316
  getWithdrawQuote.call = call;
1291
1317
  })(getWithdrawQuote || (getWithdrawQuote = {}));
1292
1318
  /**
1293
- * Redeems vault shares for assets sent to `recipient`. The transaction
1294
- * includes the required vault share approval.
1319
+ * Redeems Earn shares for assets sent to `recipient`. The transaction
1320
+ * includes the required Earn share approval.
1295
1321
  *
1296
1322
  * @example
1297
1323
  * ```ts
@@ -1321,14 +1347,14 @@ export async function redeem(client, parameters) {
1321
1347
  return redeem.inner(sendTransaction, client, parameters);
1322
1348
  }
1323
1349
  (function (redeem) {
1324
- /** @internal Shared dispatch; reads the vault share token for the approval. */
1350
+ /** @internal Shared dispatch; reads the Earn share token for the approval. */
1325
1351
  async function inner(action, client, parameters) {
1326
1352
  const [args, shareToken] = await Promise.all([
1327
1353
  toRedeemArgs(client, parameters),
1328
1354
  readContract(client, {
1329
- abi: Abis.vaultAdapter,
1355
+ abi: Abis.earnVault,
1330
1356
  address: parameters.vault,
1331
- functionName: 'shareToken',
1357
+ functionName: 'earnShare',
1332
1358
  }),
1333
1359
  ]);
1334
1360
  return (await action(client, {
@@ -1338,7 +1364,7 @@ export async function redeem(client, parameters) {
1338
1364
  }
1339
1365
  redeem.inner = inner;
1340
1366
  /**
1341
- * Defines a redeem call without an approval. Provide vault share decimals
1367
+ * Defines a redeem call without an approval. Provide Earn share decimals
1342
1368
  * for formatted inputs and an explicit output bound because this builder performs no reads.
1343
1369
  *
1344
1370
  * @param parameters - Client (optional), followed by the call arguments.
@@ -1354,7 +1380,7 @@ export async function redeem(client, parameters) {
1354
1380
  })();
1355
1381
  return defineCall({
1356
1382
  address: vault,
1357
- abi: Abis.vaultAdapter,
1383
+ abi: Abis.earnVault,
1358
1384
  functionName: 'redeem',
1359
1385
  args: [
1360
1386
  internal_Token.toBaseUnits(args.shareAmount, undefined),
@@ -1365,7 +1391,7 @@ export async function redeem(client, parameters) {
1365
1391
  }
1366
1392
  redeem.call = call;
1367
1393
  /**
1368
- * Defines the vault share approval and redeem calls for atomic execution.
1394
+ * Defines the Earn share approval and redeem calls for atomic execution.
1369
1395
  * Pass `shareToken` explicitly because this builder performs no reads.
1370
1396
  *
1371
1397
  * @param args - Arguments.
@@ -1397,7 +1423,7 @@ export async function redeem(client, parameters) {
1397
1423
  // Earn contracts are user-deployed: several adapters can emit the same
1398
1424
  // signature in one receipt, so filter by emitting address before decode.
1399
1425
  const [log] = parseEventLogs({
1400
- abi: Abis.vaultAdapter,
1426
+ abi: Abis.earnVault,
1401
1427
  eventName: 'Redeemed',
1402
1428
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
1403
1429
  });
@@ -1407,7 +1433,7 @@ export async function redeem(client, parameters) {
1407
1433
  }
1408
1434
  redeem.extractEvent = extractEvent;
1409
1435
  /**
1410
- * Estimates gas for a redemption, assuming enough vault share allowance.
1436
+ * Estimates gas for a redemption, assuming enough Earn share allowance.
1411
1437
  *
1412
1438
  * @param client - Client.
1413
1439
  * @param parameters - Parameters.
@@ -1421,7 +1447,7 @@ export async function redeem(client, parameters) {
1421
1447
  }
1422
1448
  redeem.estimateGas = estimateGas;
1423
1449
  /**
1424
- * Simulates a redemption, assuming enough vault share allowance.
1450
+ * Simulates a redemption, assuming enough Earn share allowance.
1425
1451
  *
1426
1452
  * @param client - Client.
1427
1453
  * @param parameters - Parameters.
@@ -1436,7 +1462,7 @@ export async function redeem(client, parameters) {
1436
1462
  redeem.simulate = simulate;
1437
1463
  })(redeem || (redeem = {}));
1438
1464
  /**
1439
- * Redeems vault shares and returns the confirmed receipt and event data.
1465
+ * Redeems Earn shares and returns the confirmed receipt and event data.
1440
1466
  *
1441
1467
  * @example
1442
1468
  * ```ts
@@ -1474,11 +1500,11 @@ export async function redeemSync(client, parameters) {
1474
1500
  caller: args.caller,
1475
1501
  receipt,
1476
1502
  recipient: args.receiver,
1477
- shareAmount: args.shares,
1503
+ shareAmount: args.earnShares,
1478
1504
  };
1479
1505
  }
1480
1506
  /**
1481
- * Withdraws vault shares from a Zone and redeems them on the parent chain. Use
1507
+ * Withdraws Earn shares from a Zone and redeems them on the parent chain. Use
1482
1508
  * {@link privateRedeem.prepare} to build the encrypted callback.
1483
1509
  *
1484
1510
  * @example
@@ -1489,6 +1515,8 @@ export async function redeemSync(client, parameters) {
1489
1515
  * recoveryRecipient: '0x...',
1490
1516
  * shareAmount: 100_000_000n,
1491
1517
  * slippageBps: 50,
1518
+ * vault: '0x...',
1519
+ * zoneId: 7,
1492
1520
  * })
1493
1521
  * const hash = await Actions.earn.privateRedeem(zoneClient, prepared)
1494
1522
  * ```
@@ -1503,7 +1531,7 @@ export async function privateRedeem(client, parameters) {
1503
1531
  }
1504
1532
  (function (privateRedeem) {
1505
1533
  /**
1506
- * Builds an encrypted Zone withdrawal that redeems vault shares and returns
1534
+ * Builds an encrypted Zone withdrawal that redeems Earn shares and returns
1507
1535
  * the resulting assets to the Zone.
1508
1536
  *
1509
1537
  * @param client - Parent-chain client.
@@ -1514,15 +1542,23 @@ export async function privateRedeem(client, parameters) {
1514
1542
  const chainId = client.chain?.id;
1515
1543
  if (!chainId)
1516
1544
  throw new Error('`chain` is required.');
1517
- const { actionId = Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, recipient, recoveryRecipient, returnMemo, shareAmount, withdrawalMemo, } = parameters;
1545
+ const { actionId = Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, portalAddress: portalAddress_, recipient, recoveryRecipient, returnMemo, shareAmount, vault, withdrawalMemo, zoneId, } = parameters;
1546
+ const portalAddress = portalAddress_ ?? getPortalAddress(chainId, zoneId);
1518
1547
  const readParameters = pickReadParameters(parameters);
1519
1548
  const [fromBlock, config] = await Promise.all([
1520
1549
  getBlockNumber(client, { cacheTime: 0 }),
1521
- getZoneGatewayConfig(client, { ...readParameters, gateway }),
1550
+ getZoneGatewayConfig(client, {
1551
+ ...readParameters,
1552
+ flow: 1,
1553
+ gateway,
1554
+ vault,
1555
+ zoneId,
1556
+ zonePortal: portalAddress,
1557
+ }),
1522
1558
  ]);
1523
1559
  const assetToken = parameters.assetToken ?? config.vaultAsset;
1524
1560
  if (isAddressEqual(assetToken, config.shareToken))
1525
- throw new Error('`assetToken` cannot be the gateway vault share token.');
1561
+ throw new Error('`assetToken` cannot be the Earn share token.');
1526
1562
  const [{ encrypted, keyIndex }, assetAmountMin] = await Promise.all([
1527
1563
  zoneActions.encryptedDeposit.prepareRecipient(client, {
1528
1564
  ...readParameters,
@@ -1539,23 +1575,22 @@ export async function privateRedeem(client, parameters) {
1539
1575
  const assetAmount = await getRedeemQuote(client, {
1540
1576
  ...readParameters,
1541
1577
  shareAmount,
1542
- vault: config.vaultAdapter,
1578
+ vault: config.vault,
1543
1579
  });
1544
1580
  return EarnShares.minimumOutput(assetAmount, parameters.slippageBps);
1545
1581
  })(),
1546
1582
  ]);
1547
1583
  const direct = isAddressEqual(assetToken, config.vaultAsset);
1548
- const data = encodeAbiParameters(Abis.zoneGatewayCallbackData, [
1584
+ const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
1549
1585
  {
1586
+ actionId,
1587
+ earnVault: config.vault,
1550
1588
  flow: 1,
1551
- outputToken: assetToken,
1552
- keyIndex,
1553
- encrypted,
1554
- minVaultAssets: direct ? assetAmountMin : 1n,
1555
- minVaultShares: 0n,
1589
+ minEarnShares: 0n,
1556
1590
  minOutputAmount: direct ? 0n : assetAmountMin,
1557
- actionId,
1558
- refundRecipient: recoveryRecipient,
1591
+ minVaultAssets: direct ? assetAmountMin : 1n,
1592
+ outputToken: assetToken,
1593
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
1559
1594
  },
1560
1595
  ]);
1561
1596
  return {
@@ -1605,6 +1640,7 @@ export async function privateRedeemSync(client, parameters) {
1605
1640
  * actionId: prepared.actionId,
1606
1641
  * fromBlock: prepared.fromBlock,
1607
1642
  * gateway: '0x...',
1643
+ * vault: '0x...',
1608
1644
  * })
1609
1645
  * ```
1610
1646
  *
@@ -1613,15 +1649,16 @@ export async function privateRedeemSync(client, parameters) {
1613
1649
  * @returns The completed gateway redemption.
1614
1650
  */
1615
1651
  export async function waitForPrivateRedeem(client, parameters) {
1616
- const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
1652
+ const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
1617
1653
  const event = getAbiItem({
1618
- abi: Abis.zoneGateway,
1654
+ abi: Abis.earnRouter,
1619
1655
  name: 'EarnRedeem',
1620
1656
  });
1621
1657
  const observerId = stringify([
1622
1658
  'waitForPrivateRedeem',
1623
1659
  client.uid,
1624
1660
  gateway,
1661
+ vault,
1625
1662
  actionId,
1626
1663
  fromBlock,
1627
1664
  ]);
@@ -1645,7 +1682,7 @@ export async function waitForPrivateRedeem(client, parameters) {
1645
1682
  try {
1646
1683
  const [log] = await getLogs(client, {
1647
1684
  address: gateway,
1648
- args: { actionId },
1685
+ args: { actionId, earnVault: vault },
1649
1686
  event,
1650
1687
  fromBlock,
1651
1688
  strict: true,
@@ -1658,7 +1695,7 @@ export async function waitForPrivateRedeem(client, parameters) {
1658
1695
  actionId: log.args.actionId,
1659
1696
  outputAmount: log.args.outputAmount,
1660
1697
  outputToken: log.args.outputToken,
1661
- shares: log.args.shares,
1698
+ shares: log.args.earnShares,
1662
1699
  tempoBlockNumber: log.blockNumber,
1663
1700
  vaultAssets: log.args.vaultAssets,
1664
1701
  zoneDepositHash: log.args.zoneDepositHash,
@@ -1679,8 +1716,8 @@ export async function waitForPrivateRedeem(client, parameters) {
1679
1716
  return await promise;
1680
1717
  }
1681
1718
  /**
1682
- * Withdraws an exact asset amount to `recipient`, up to the specified vault
1683
- * share limit. The transaction includes the required vault share approval;
1719
+ * Withdraws an exact asset amount to `recipient`, up to the specified Earn
1720
+ * share limit. The transaction includes the required Earn share approval;
1684
1721
  * use {@link redeem} for a full exit.
1685
1722
  *
1686
1723
  * @example
@@ -1711,14 +1748,14 @@ export async function withdrawExact(client, parameters) {
1711
1748
  return withdrawExact.inner(sendTransaction, client, parameters);
1712
1749
  }
1713
1750
  (function (withdrawExact) {
1714
- /** @internal Shared dispatch; reads the vault share token for the approval. */
1751
+ /** @internal Shared dispatch; reads the Earn share token for the approval. */
1715
1752
  async function inner(action, client, parameters) {
1716
1753
  const [args, shareToken] = await Promise.all([
1717
1754
  toWithdrawExactArgs(client, parameters),
1718
1755
  readContract(client, {
1719
- abi: Abis.vaultAdapter,
1756
+ abi: Abis.earnVault,
1720
1757
  address: parameters.vault,
1721
- functionName: 'shareToken',
1758
+ functionName: 'earnShare',
1722
1759
  }),
1723
1760
  ]);
1724
1761
  return (await action(client, {
@@ -1744,7 +1781,7 @@ export async function withdrawExact(client, parameters) {
1744
1781
  })();
1745
1782
  return defineCall({
1746
1783
  address: vault,
1747
- abi: Abis.vaultAdapter,
1784
+ abi: Abis.earnVault,
1748
1785
  functionName: 'withdrawExact',
1749
1786
  args: [
1750
1787
  internal_Token.toBaseUnits(args.assetAmount, undefined),
@@ -1755,7 +1792,7 @@ export async function withdrawExact(client, parameters) {
1755
1792
  }
1756
1793
  withdrawExact.call = call;
1757
1794
  /**
1758
- * Defines the vault share approval and withdrawal calls for atomic
1795
+ * Defines the Earn share approval and withdrawal calls for atomic
1759
1796
  * execution. Pass `shareToken` explicitly because this builder performs no reads.
1760
1797
  *
1761
1798
  * @param args - Arguments.
@@ -1789,7 +1826,7 @@ export async function withdrawExact(client, parameters) {
1789
1826
  // Earn contracts are user-deployed: several adapters can emit the same
1790
1827
  // signature in one receipt, so filter by emitting address before decode.
1791
1828
  const [log] = parseEventLogs({
1792
- abi: Abis.vaultAdapter,
1829
+ abi: Abis.earnVault,
1793
1830
  eventName: 'WithdrewExact',
1794
1831
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
1795
1832
  });
@@ -1799,7 +1836,7 @@ export async function withdrawExact(client, parameters) {
1799
1836
  }
1800
1837
  withdrawExact.extractEvent = extractEvent;
1801
1838
  /**
1802
- * Estimates gas for an exact withdrawal, assuming enough vault share allowance.
1839
+ * Estimates gas for an exact withdrawal, assuming enough Earn share allowance.
1803
1840
  *
1804
1841
  * @param client - Client.
1805
1842
  * @param parameters - Parameters.
@@ -1813,7 +1850,7 @@ export async function withdrawExact(client, parameters) {
1813
1850
  }
1814
1851
  withdrawExact.estimateGas = estimateGas;
1815
1852
  /**
1816
- * Simulates an exact withdrawal, assuming enough vault share allowance.
1853
+ * Simulates an exact withdrawal, assuming enough Earn share allowance.
1817
1854
  *
1818
1855
  * @param client - Client.
1819
1856
  * @param parameters - Parameters.
@@ -1866,7 +1903,7 @@ export async function withdrawExactSync(client, parameters) {
1866
1903
  caller: args.caller,
1867
1904
  receipt,
1868
1905
  recipient: args.receiver,
1869
- shareAmount: args.sharesBurned,
1906
+ shareAmount: args.earnSharesBurned,
1870
1907
  };
1871
1908
  }
1872
1909
  const zoneGatewayCallbackGas = 10000000n;
@@ -1896,72 +1933,75 @@ function pickReadParameters(parameters) {
1896
1933
  return { blockOverrides, blockTag: parameters.blockTag, stateOverride };
1897
1934
  }
1898
1935
  async function getZoneGatewayConfig(client, parameters) {
1899
- const { gateway, ...rest } = parameters;
1900
- const [vaultAdapter, vaultAsset, shareToken, zoneId, zonePortal, supportsAsyncFlow,] = await multicall(client, {
1936
+ const { flow, gateway, vault, zoneId, zonePortal, ...rest } = parameters;
1937
+ const [vaultAsset, shareToken, supportsFlow] = await multicall(client, {
1901
1938
  ...rest,
1902
1939
  allowFailure: false,
1903
1940
  contracts: [
1904
1941
  {
1905
- abi: Abis.zoneGateway,
1906
- address: gateway,
1907
- functionName: 'vaultAdapter',
1908
- },
1909
- {
1910
- abi: Abis.zoneGateway,
1911
- address: gateway,
1912
- functionName: 'vaultAsset',
1913
- },
1914
- {
1915
- abi: Abis.zoneGateway,
1916
- address: gateway,
1917
- functionName: 'shareToken',
1918
- },
1919
- {
1920
- abi: Abis.zoneGateway,
1921
- address: gateway,
1922
- functionName: 'zoneId',
1942
+ abi: Abis.earnVault,
1943
+ address: vault,
1944
+ functionName: 'asset',
1923
1945
  },
1924
1946
  {
1925
- abi: Abis.zoneGateway,
1926
- address: gateway,
1927
- functionName: 'zonePortal',
1947
+ abi: Abis.earnVault,
1948
+ address: vault,
1949
+ functionName: 'earnShare',
1928
1950
  },
1929
1951
  {
1930
- abi: Abis.zoneGateway,
1952
+ abi: Abis.earnRouter,
1931
1953
  address: gateway,
1932
- args: [2],
1954
+ args: [flow],
1933
1955
  functionName: 'supportsFlow',
1934
1956
  },
1935
1957
  ],
1936
1958
  deployless: true,
1937
1959
  });
1938
- if (supportsAsyncFlow)
1939
- throw new Error('Async Zone gateways are not supported.');
1940
- return { shareToken, vaultAdapter, vaultAsset, zoneId, zonePortal };
1960
+ if (!supportsFlow)
1961
+ throw new Error('Zone gateway flow is not supported.');
1962
+ return {
1963
+ shareToken,
1964
+ vault,
1965
+ vaultAsset,
1966
+ zoneId,
1967
+ zonePortal,
1968
+ };
1941
1969
  }
1942
1970
  // ERC-165 ids of the optional engine capability interfaces (XOR of each
1943
1971
  // interface's function selectors).
1944
1972
  const interfaceIds = {
1945
- /** `IVaultEngineAsync`. */
1973
+ /** `IEarnEngineAsyncRedeem`. */
1946
1974
  asyncRedeem: '0xa1a6a1d7',
1947
- /** `IVaultEngineExactWithdraw`. */
1975
+ /** `IEarnEngineExactWithdraw`. */
1948
1976
  exactWithdraw: '0x0adfb0b9',
1949
- /** `IVaultEngineShares`. */
1950
- inKindDeposit: '0x7d28a2f2',
1951
- /** `IVaultEngineSync`. */
1952
- syncRedeem: '0x370457f4',
1977
+ /** `IEarnEngineInKindDeposit`. */
1978
+ inKindDeposit: '0xce4790a9',
1979
+ /** `IEarnEngineRedeem`. */
1980
+ syncRedeem: '0x94a2d467',
1953
1981
  };
1954
- /** Trims the decoded `IVaultFees.FeeConfig` to its active fixed-fee count. */
1982
+ /** Trims the decoded `FeeConfig` to its active fixed-fee count. */
1955
1983
  function toFeeConfig(config) {
1956
1984
  return {
1957
1985
  excess: config.excess,
1958
1986
  fixedFees: config.fixedFees.slice(0, config.fixedFeeCount),
1959
1987
  };
1960
1988
  }
1961
- /** Trims the decoded `IVaultFees.FeePreview` to its active allocation count. */
1989
+ /** Maps decoded fee fields to the action result. */
1962
1990
  function toFeePreview(preview) {
1963
- const { allocationCount, allocations, ...rest } = preview;
1964
- return { ...rest, allocations: allocations.slice(0, allocationCount) };
1991
+ const { allocationCount, allocations, postFeeValuePerEarnShare, preFeeValuePerEarnShare, targetValuePerEarnShare, totalFeeEarnShares, ...rest } = preview;
1992
+ return {
1993
+ ...rest,
1994
+ allocations: allocations
1995
+ .slice(0, allocationCount)
1996
+ .map(({ feeEarnShares, ...allocation }) => ({
1997
+ ...allocation,
1998
+ feeShares: feeEarnShares,
1999
+ })),
2000
+ postFeeValuePerShare: postFeeValuePerEarnShare,
2001
+ preFeeValuePerShare: preFeeValuePerEarnShare,
2002
+ targetValuePerShare: targetValuePerEarnShare,
2003
+ totalFeeShares: totalFeeEarnShares,
2004
+ };
1965
2005
  }
1966
2006
  /** Resolves `deposit` parameters into the adapter call args. @internal */
1967
2007
  async function toDepositArgs(client, parameters) {
@@ -2069,7 +2109,7 @@ function maximumInput(shareAmount, slippageBps) {
2069
2109
  }
2070
2110
  /**
2071
2111
  * 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
2112
+ * reads of the vault's asset or share token. Earn share tokens are not
2073
2113
  * genesis-declared, so nothing is cached. @internal
2074
2114
  */
2075
2115
  async function toBaseUnitsLive(client, options) {
@@ -2079,9 +2119,9 @@ async function toBaseUnitsLive(client, options) {
2079
2119
  if (amount.decimals !== undefined)
2080
2120
  return internal_Token.toBaseUnits(amount, amount.decimals);
2081
2121
  const address = await readContract(client, {
2082
- abi: Abis.vaultAdapter,
2122
+ abi: Abis.earnVault,
2083
2123
  address: vault,
2084
- functionName: token,
2124
+ functionName: token === 'asset' ? 'asset' : 'earnShare',
2085
2125
  });
2086
2126
  const { decimals } = await resolveTokenWithDecimals(client, {
2087
2127
  token: address,