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
@@ -62,6 +62,7 @@ import {
62
62
  resolveTokenWithDecimals,
63
63
  } from '../internal/utils.js'
64
64
  import type { TransactionReceipt } from '../Transaction.js'
65
+ import { getPortalAddress } from '../zones/zone.js'
65
66
  import * as policyActions from './policy.js'
66
67
  import * as tokenActions from './token.js'
67
68
  import * as zoneActions from './zone.js'
@@ -69,9 +70,9 @@ import * as zoneActions from './zone.js'
69
70
  /** TIP-403 policy ID that allows every sender, recipient, and mint recipient. */
70
71
  export const alwaysAllowPolicyId = 1n
71
72
 
72
- /** Admission-only TIP-403 policy attached to an Earn vault share token. */
73
+ /** Admission-only TIP-403 policy attached to an Earn share token. */
73
74
  export type ExitSafePolicy = {
74
- /** Compound policy attached to the vault share token. */
75
+ /** Compound policy attached to the Earn share token. */
75
76
  transferPolicyId: bigint
76
77
  /** Sender policy. Must be {@link alwaysAllowPolicyId} so holders can exit. */
77
78
  senderPolicyId: bigint
@@ -87,14 +88,14 @@ export type ExitSafePolicyReceipts = {
87
88
  eligibilityPolicy: TransactionReceipt
88
89
  /** Compound policy creation receipt. */
89
90
  compoundPolicy: TransactionReceipt
90
- /** Vault share token policy update receipt. */
91
+ /** Earn share token policy update receipt. */
91
92
  tokenPolicy: TransactionReceipt
92
93
  /** Eligibility policy admin transfer receipt, when an administrator is provided. */
93
94
  policyAdmin?: TransactionReceipt | undefined
94
95
  }
95
96
 
96
97
  /**
97
- * Creates and attaches an admission-only TIP-403 policy to an Earn vault share
98
+ * Creates and attaches an admission-only TIP-403 policy to an Earn share
98
99
  * token. Existing holders remain able to send shares while recipients and mint
99
100
  * recipients must belong to the same whitelist.
100
101
  *
@@ -123,7 +124,7 @@ export type ExitSafePolicyReceipts = {
123
124
  * })
124
125
  * ```
125
126
  *
126
- * @param client - Client authorized to change the vault share token policy.
127
+ * @param client - Client authorized to change the Earn share token policy.
127
128
  * @param parameters - Share token, administrator, and initial members.
128
129
  * @returns The configured policy IDs and transaction receipts.
129
130
  */
@@ -205,9 +206,9 @@ export namespace configureExitSafePolicy {
205
206
  export type Args = {
206
207
  /** Address that will administer recipient eligibility. */
207
208
  accessAdministrator: Address
208
- /** Addresses initially eligible to receive or be minted vault shares. */
209
+ /** Addresses initially eligible to receive or be minted Earn shares. */
209
210
  initialMembers: readonly Address[]
210
- /** Earn vault share token. */
211
+ /** Earn share token. */
211
212
  shareToken: Address
212
213
  }
213
214
  export type Parameters<
@@ -224,7 +225,7 @@ export namespace configureExitSafePolicy {
224
225
  }
225
226
 
226
227
  /**
227
- * Verifies that an Earn vault share token uses the expected exit-safe TIP-403
228
+ * Verifies that an Earn share token uses the expected exit-safe TIP-403
228
229
  * policy and that every required member can receive transfers and mints.
229
230
  *
230
231
  * @example
@@ -307,7 +308,7 @@ export async function validateExitSafePolicy<chain extends Chain | undefined>(
307
308
  ])
308
309
 
309
310
  if (tokenPolicyId !== policy.transferPolicyId)
310
- throw new Error('Earn vault share token transfer policy mismatch.')
311
+ throw new Error('Earn share token transfer policy mismatch.')
311
312
  if (
312
313
  compound[0] !== policy.senderPolicyId ||
313
314
  compound[1] !== policy.recipientPolicyId ||
@@ -337,9 +338,9 @@ export namespace validateExitSafePolicy {
337
338
  accessAdministrator: Address
338
339
  /** Expected exit-safe policy IDs. */
339
340
  policy: ExitSafePolicy
340
- /** Addresses that must be eligible to receive or be minted vault shares. */
341
+ /** Addresses that must be eligible to receive or be minted Earn shares. */
341
342
  requiredMembers: readonly Address[]
342
- /** Earn vault share token. */
343
+ /** Earn share token. */
343
344
  shareToken: Address
344
345
  }
345
346
  export type Parameters = Omit<ReadParameters, 'account'> & Args
@@ -349,7 +350,7 @@ export namespace validateExitSafePolicy {
349
350
  }
350
351
 
351
352
  /**
352
- * Deposits assets into a vault and mints vault shares to `recipient`. The
353
+ * Deposits assets into a vault and mints Earn shares to `recipient`. The
353
354
  * transaction includes the required asset approval.
354
355
  *
355
356
  * @example
@@ -391,17 +392,17 @@ export namespace deposit {
391
392
  export type Args = {
392
393
  /** Assets to deposit; base units or `{ formatted, decimals? }` (asset decimals). */
393
394
  assetAmount: internal_Token.AmountInput
394
- /** Vault share recipient. @default `account.address` */
395
+ /** Earn share recipient. @default `account.address` */
395
396
  recipient?: Address | undefined
396
397
  /** Vault address. */
397
398
  vault: Address
398
399
  } & OneOf<
399
400
  | {
400
- /** Minimum vault share output to accept; must be greater than zero. */
401
+ /** Minimum Earn share output to accept; must be greater than zero. */
401
402
  shareAmountMin: bigint
402
403
  }
403
404
  | {
404
- /** Quoted vault share output; floored by `slippageBps`. */
405
+ /** Quoted Earn share output; floored by `slippageBps`. */
405
406
  shareAmount: bigint
406
407
  /** Slippage tolerance in basis points under `shareAmount` (50 = 0.5%). */
407
408
  slippageBps: number
@@ -428,7 +429,7 @@ export namespace deposit {
428
429
  const [args, assetToken] = await Promise.all([
429
430
  toDepositArgs(client, parameters as never),
430
431
  readContract(client, {
431
- abi: Abis.vaultAdapter,
432
+ abi: Abis.earnVault,
432
433
  address: parameters.vault,
433
434
  functionName: 'asset',
434
435
  }),
@@ -457,7 +458,7 @@ export namespace deposit {
457
458
  })()
458
459
  return defineCall({
459
460
  address: vault,
460
- abi: Abis.vaultAdapter,
461
+ abi: Abis.earnVault,
461
462
  functionName: 'deposit',
462
463
  args: [
463
464
  internal_Token.toBaseUnits(args.assetAmount, undefined),
@@ -470,17 +471,17 @@ export namespace deposit {
470
471
  export type Args = {
471
472
  /** Assets to deposit; base units or `{ formatted, decimals? }` (asset decimals). */
472
473
  assetAmount: internal_Token.AmountInput
473
- /** Vault share recipient. */
474
+ /** Earn share recipient. */
474
475
  recipient: Address
475
476
  /** Vault address. */
476
477
  vault: Address
477
478
  } & OneOf<
478
479
  | {
479
- /** Minimum vault share output to accept. */
480
+ /** Minimum Earn share output to accept. */
480
481
  shareAmountMin: bigint
481
482
  }
482
483
  | {
483
- /** Quoted vault share output; floored by `slippageBps`. */
484
+ /** Quoted Earn share output; floored by `slippageBps`. */
484
485
  shareAmount: bigint
485
486
  /** Slippage tolerance in basis points under `shareAmount` (50 = 0.5%). */
486
487
  slippageBps: number
@@ -526,7 +527,7 @@ export namespace deposit {
526
527
  // Earn contracts are user-deployed: several adapters can emit the same
527
528
  // signature in one receipt, so filter by emitting address before decode.
528
529
  const [log] = parseEventLogs({
529
- abi: Abis.vaultAdapter,
530
+ abi: Abis.earnVault,
530
531
  eventName: 'Deposited',
531
532
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
532
533
  })
@@ -567,7 +568,7 @@ export namespace deposit {
567
568
  >(
568
569
  client: Client<Transport, chain, account>,
569
570
  parameters: deposit.Parameters<chain, account>,
570
- ): Promise<SimulateContractReturnType<typeof Abis.vaultAdapter, 'deposit'>> {
571
+ ): Promise<SimulateContractReturnType<typeof Abis.earnVault, 'deposit'>> {
571
572
  return simulateContract(client, {
572
573
  ...pickWriteParameters(parameters as never),
573
574
  ...deposit.call(await toDepositArgs(client, parameters as never)),
@@ -620,7 +621,7 @@ export async function depositSync<
620
621
  caller: args.caller,
621
622
  receipt,
622
623
  recipient: args.receiver,
623
- shareAmount: args.shares,
624
+ shareAmount: args.earnShares,
624
625
  }
625
626
  }
626
627
 
@@ -637,9 +638,9 @@ export namespace depositSync {
637
638
  caller: Address
638
639
  /** Transaction receipt. */
639
640
  receipt: TransactionReceipt
640
- /** Vault share recipient. */
641
+ /** Earn share recipient. */
641
642
  recipient: Address
642
- /** Vault shares minted. */
643
+ /** Earn shares minted. */
643
644
  shareAmount: bigint
644
645
  }>
645
646
  // TODO: exhaustive error type
@@ -647,7 +648,7 @@ export namespace depositSync {
647
648
  }
648
649
 
649
650
  /**
650
- * Deposits venue shares into a vault and mints vault shares to `recipient`.
651
+ * Deposits venue shares into a vault and mints Earn shares to `recipient`.
651
652
  * The transaction includes the required venue share approval.
652
653
  *
653
654
  * @example
@@ -690,7 +691,7 @@ export namespace depositShares {
690
691
  export type Args = {
691
692
  /** Venue shares to deposit, base units. */
692
693
  venueShareAmount: bigint
693
- /** Vault share recipient. @default `account.address` */
694
+ /** Earn share recipient. @default `account.address` */
694
695
  recipient?: Address | undefined
695
696
  /** Vault address. */
696
697
  vault: Address
@@ -698,11 +699,11 @@ export namespace depositShares {
698
699
  venueShareToken: Address
699
700
  } & OneOf<
700
701
  | {
701
- /** Minimum vault share output to accept; must be greater than zero. */
702
+ /** Minimum Earn share output to accept; must be greater than zero. */
702
703
  earnShareAmountMin: bigint
703
704
  }
704
705
  | {
705
- /** Quoted vault share output; floored by `slippageBps`. */
706
+ /** Quoted Earn share output; floored by `slippageBps`. */
706
707
  earnShareAmount: bigint
707
708
  /** Slippage tolerance in basis points under `earnShareAmount` (50 = 0.5%). */
708
709
  slippageBps: number
@@ -727,7 +728,7 @@ export namespace depositShares {
727
728
  parameters: depositShares.Parameters<chain, account>,
728
729
  ): Promise<ReturnType<action>> {
729
730
  const engine = await readContract(client, {
730
- abi: Abis.vaultAdapter,
731
+ abi: Abis.earnVault,
731
732
  address: parameters.vault,
732
733
  functionName: 'engine',
733
734
  })
@@ -759,8 +760,8 @@ export namespace depositShares {
759
760
  })()
760
761
  return defineCall({
761
762
  address: vault,
762
- abi: Abis.vaultAdapter,
763
- functionName: 'depositShares',
763
+ abi: Abis.earnVault,
764
+ functionName: 'depositVenueShares',
764
765
  args: [venueShareAmount, recipient, earnShareAmountMin],
765
766
  })
766
767
  }
@@ -768,17 +769,17 @@ export namespace depositShares {
768
769
  export type Args = {
769
770
  /** Venue shares to deposit, base units. */
770
771
  venueShareAmount: bigint
771
- /** Vault share recipient. */
772
+ /** Earn share recipient. */
772
773
  recipient: Address
773
774
  /** Vault address. */
774
775
  vault: Address
775
776
  } & OneOf<
776
777
  | {
777
- /** Minimum vault share output to accept. */
778
+ /** Minimum Earn share output to accept. */
778
779
  earnShareAmountMin: bigint
779
780
  }
780
781
  | {
781
- /** Quoted vault share output; floored by `slippageBps`. */
782
+ /** Quoted Earn share output; floored by `slippageBps`. */
782
783
  earnShareAmount: bigint
783
784
  /** Slippage tolerance in basis points under `earnShareAmount` (50 = 0.5%). */
784
785
  slippageBps: number
@@ -825,7 +826,7 @@ export namespace depositShares {
825
826
  // Earn contracts are user-deployed: several adapters can emit the same
826
827
  // signature in one receipt, so filter by emitting address before decode.
827
828
  const [log] = parseEventLogs({
828
- abi: Abis.vaultAdapter,
829
+ abi: Abis.earnVault,
829
830
  eventName: 'VenueSharesDeposited',
830
831
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
831
832
  })
@@ -867,7 +868,7 @@ export namespace depositShares {
867
868
  client: Client<Transport, chain, account>,
868
869
  parameters: depositShares.Parameters<chain, account>,
869
870
  ): Promise<
870
- SimulateContractReturnType<typeof Abis.vaultAdapter, 'depositShares'>
871
+ SimulateContractReturnType<typeof Abis.earnVault, 'depositVenueShares'>
871
872
  > {
872
873
  return simulateContract(client, {
873
874
  ...pickWriteParameters(parameters as never),
@@ -922,7 +923,7 @@ export async function depositSharesSync<
922
923
  caller: args.caller,
923
924
  earnShareAmount: args.earnShares,
924
925
  receipt,
925
- receivedVenueShareAmount: args.receivedVenueShares,
926
+ receivedVenueShareAmount: args.receivedEngineShares,
926
927
  recipient: args.receiver,
927
928
  venueShareAmount: args.requestedVenueShares,
928
929
  }
@@ -938,13 +939,13 @@ export namespace depositSharesSync {
938
939
  export type ReturnValue = Compute<{
939
940
  /** Depositing caller. */
940
941
  caller: Address
941
- /** Vault shares minted. */
942
+ /** Earn shares minted. */
942
943
  earnShareAmount: bigint
943
944
  /** Transaction receipt. */
944
945
  receipt: TransactionReceipt
945
946
  /** Venue shares measured as received by the engine. */
946
947
  receivedVenueShareAmount: bigint
947
- /** Vault share recipient. */
948
+ /** Earn share recipient. */
948
949
  recipient: Address
949
950
  /** Venue shares requested for pull. */
950
951
  venueShareAmount: bigint
@@ -966,7 +967,9 @@ export namespace depositSharesSync {
966
967
  * recipient: '0x...',
967
968
  * recoveryRecipient: '0x...',
968
969
  * shareAmountMin: 99_500_000n,
970
+ * vault: '0x...',
969
971
  * vaultAssetAmountMin: 99_000_000n,
972
+ * zoneId: 7,
970
973
  * })
971
974
  * const hash = await Actions.earn.privateDeposit(zoneClient, prepared)
972
975
  * ```
@@ -996,8 +999,8 @@ export namespace privateDeposit {
996
999
  export type ErrorType = zoneActions.requestWithdrawal.ErrorType
997
1000
 
998
1001
  /**
999
- * Builds an encrypted Zone withdrawal that deposits into the gateway's
1000
- * vault and returns the resulting shares to the Zone.
1002
+ * Builds an encrypted Zone withdrawal that deposits into the selected vault
1003
+ * and returns the resulting shares to the Zone.
1001
1004
  *
1002
1005
  * @param client - Parent-chain client.
1003
1006
  * @param parameters - Deposit intent and recovery parameters.
@@ -1015,17 +1018,30 @@ export namespace privateDeposit {
1015
1018
  callbackGas = zoneGatewayCallbackGas,
1016
1019
  fallbackRecipient = parameters.recoveryRecipient,
1017
1020
  gateway,
1021
+ portalAddress: portalAddress_,
1018
1022
  recipient,
1019
1023
  recoveryRecipient,
1020
1024
  returnMemo,
1025
+ vault,
1021
1026
  withdrawalMemo,
1027
+ zoneId,
1022
1028
  } = parameters
1029
+ const portalAddress = portalAddress_ ?? getPortalAddress(chainId, zoneId)
1023
1030
  const readParameters = pickReadParameters(parameters)
1024
1031
  const [fromBlock, config] = await Promise.all([
1025
1032
  getBlockNumber(client, { cacheTime: 0 }),
1026
- getZoneGatewayConfig(client, { ...readParameters, gateway }),
1033
+ getZoneGatewayConfig(client, {
1034
+ ...readParameters,
1035
+ flow: 0,
1036
+ gateway,
1037
+ vault,
1038
+ zoneId,
1039
+ zonePortal: portalAddress,
1040
+ }),
1027
1041
  ])
1028
- const assetToken = parameters.assetToken ?? config.vaultAsset
1042
+ const assetToken = parameters.assetToken ?? config.privateAsset
1043
+ if (!isAddressEqual(assetToken, config.privateAsset))
1044
+ throw new Error('`assetToken` must match the Zone gateway private asset.')
1029
1045
  const { encrypted, keyIndex } =
1030
1046
  await zoneActions.encryptedDeposit.prepareRecipient(client, {
1031
1047
  ...readParameters,
@@ -1035,20 +1051,14 @@ export namespace privateDeposit {
1035
1051
  zoneId: config.zoneId,
1036
1052
  })
1037
1053
  const shareAmountMin = resolveMinimumShareAmount(parameters)
1038
- const direct = isAddressEqual(assetToken, config.vaultAsset)
1039
- const data = encodeAbiParameters(Abis.zoneGatewayCallbackData, [
1054
+ const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
1040
1055
  {
1056
+ actionId,
1041
1057
  flow: 0,
1042
- outputToken: config.shareToken,
1043
- keyIndex,
1044
- encrypted,
1045
- minVaultAssets: direct
1046
- ? assetAmount
1047
- : (parameters.vaultAssetAmountMin ?? 0n),
1048
- minVaultShares: shareAmountMin,
1058
+ minEarnShares: shareAmountMin,
1049
1059
  minOutputAmount: 0n,
1050
- actionId,
1051
- refundRecipient: recoveryRecipient,
1060
+ minVaultAssets: parameters.vaultAssetAmountMin ?? assetAmount,
1061
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
1052
1062
  },
1053
1063
  ])
1054
1064
  return {
@@ -1071,9 +1081,9 @@ export namespace privateDeposit {
1071
1081
  export type Args = PrivatePreparationParameters & {
1072
1082
  /** Assets withdrawn from the Zone, base units. */
1073
1083
  assetAmount: bigint
1074
- /** Asset token withdrawn from the Zone. @default gateway vault asset */
1084
+ /** Private asset withdrawn from the Zone. @default gateway private asset */
1075
1085
  assetToken?: Address | undefined
1076
- /** Minimum gateway vault assets accepted after swapping `assetToken`. @default `0n` */
1086
+ /** Minimum vault assets accepted after conversion. @default `assetAmount` */
1077
1087
  vaultAssetAmountMin?: bigint | undefined
1078
1088
  } & MinimumShareAmountParameters
1079
1089
  export type ReturnValue = PreparedZoneRequest
@@ -1130,6 +1140,7 @@ export namespace privateDepositSync {
1130
1140
  * actionId: prepared.actionId,
1131
1141
  * fromBlock: prepared.fromBlock,
1132
1142
  * gateway: '0x...',
1143
+ * vault: '0x...',
1133
1144
  * })
1134
1145
  * ```
1135
1146
  *
@@ -1147,15 +1158,17 @@ export async function waitForPrivateDeposit<chain extends Chain | undefined>(
1147
1158
  gateway,
1148
1159
  pollingInterval = client.pollingInterval,
1149
1160
  timeout = 60_000,
1161
+ vault,
1150
1162
  } = parameters
1151
1163
  const event = getAbiItem({
1152
- abi: Abis.zoneGateway,
1164
+ abi: Abis.earnRouter,
1153
1165
  name: 'EarnDeposit',
1154
1166
  })
1155
1167
  const observerId = stringify([
1156
1168
  'waitForPrivateDeposit',
1157
1169
  client.uid,
1158
1170
  gateway,
1171
+ vault,
1159
1172
  actionId,
1160
1173
  fromBlock,
1161
1174
  ])
@@ -1186,7 +1199,7 @@ export async function waitForPrivateDeposit<chain extends Chain | undefined>(
1186
1199
  try {
1187
1200
  const [log] = await getLogs(client, {
1188
1201
  address: gateway,
1189
- args: { actionId },
1202
+ args: { actionId, earnVault: vault },
1190
1203
  event,
1191
1204
  fromBlock,
1192
1205
  strict: true,
@@ -1198,7 +1211,7 @@ export async function waitForPrivateDeposit<chain extends Chain | undefined>(
1198
1211
  actionId: log.args.actionId,
1199
1212
  inputAmount: log.args.inputAmount,
1200
1213
  inputToken: log.args.inputToken,
1201
- shares: log.args.shares,
1214
+ shares: log.args.earnShares,
1202
1215
  tempoBlockNumber: log.blockNumber,
1203
1216
  vaultAssets: log.args.vaultAssets,
1204
1217
  zoneDepositHash: log.args.zoneDepositHash,
@@ -1236,6 +1249,8 @@ export namespace waitForPrivateDeposit {
1236
1249
  pollingInterval?: number | undefined
1237
1250
  /** Timeout in milliseconds; `0` disables it. @default `60_000` */
1238
1251
  timeout?: number | undefined
1252
+ /** Vault address. */
1253
+ vault: Address
1239
1254
  }
1240
1255
  export type ReturnType = {
1241
1256
  /** Correlation id for the completed deposit. */
@@ -1244,7 +1259,7 @@ export namespace waitForPrivateDeposit {
1244
1259
  inputAmount: bigint
1245
1260
  /** Token delivered to the gateway. */
1246
1261
  inputToken: Address
1247
- /** Vault shares returned to the Zone. */
1262
+ /** Earn shares returned to the Zone. */
1248
1263
  shares: bigint
1249
1264
  /** Parent-chain block containing the gateway event. */
1250
1265
  tempoBlockNumber: bigint
@@ -1289,30 +1304,36 @@ export async function getFeeState<chain extends Chain | undefined>(
1289
1304
  parameters: getFeeState.Parameters,
1290
1305
  ): Promise<getFeeState.ReturnValue> {
1291
1306
  const { recipient, vault, ...rest } = parameters
1307
+ const fees = await readContract(client, {
1308
+ ...rest,
1309
+ abi: Abis.earnVault,
1310
+ address: vault,
1311
+ functionName: 'earnFees',
1312
+ })
1292
1313
  const contracts = [
1293
1314
  defineCall({
1294
- address: vault,
1295
- abi: Abis.vaultAdapter,
1315
+ address: fees,
1316
+ abi: Abis.earnFees,
1296
1317
  functionName: 'currentFeeConfigId',
1297
1318
  }),
1298
1319
  defineCall({
1299
- address: vault,
1300
- abi: Abis.vaultAdapter,
1320
+ address: fees,
1321
+ abi: Abis.earnFees,
1301
1322
  functionName: 'feesActive',
1302
1323
  }),
1303
1324
  defineCall({
1304
- address: vault,
1305
- abi: Abis.vaultAdapter,
1325
+ address: fees,
1326
+ abi: Abis.earnFees,
1306
1327
  functionName: 'highWaterMark',
1307
1328
  }),
1308
1329
  defineCall({
1309
- address: vault,
1310
- abi: Abis.vaultAdapter,
1330
+ address: fees,
1331
+ abi: Abis.earnFees,
1311
1332
  functionName: 'previewAccruedFees',
1312
1333
  }),
1313
1334
  defineCall({
1314
- address: vault,
1315
- abi: Abis.vaultAdapter,
1335
+ address: fees,
1336
+ abi: Abis.earnFees,
1316
1337
  functionName: 'targetBase',
1317
1338
  }),
1318
1339
  ] as const
@@ -1322,8 +1343,8 @@ export async function getFeeState<chain extends Chain | undefined>(
1322
1343
  toFeeConfig(
1323
1344
  await readContract(client, {
1324
1345
  ...rest,
1325
- abi: Abis.vaultAdapter,
1326
- address: vault,
1346
+ abi: Abis.earnFees,
1347
+ address: fees,
1327
1348
  functionName: 'feeConfig',
1328
1349
  args: [configId],
1329
1350
  }),
@@ -1336,9 +1357,9 @@ export async function getFeeState<chain extends Chain | undefined>(
1336
1357
  contracts: [
1337
1358
  ...contracts,
1338
1359
  defineCall({
1339
- address: vault,
1340
- abi: Abis.vaultAdapter,
1341
- functionName: 'claimableFeeShares',
1360
+ address: fees,
1361
+ abi: Abis.earnFees,
1362
+ functionName: 'claimableEarnShares',
1342
1363
  args: [recipient],
1343
1364
  }),
1344
1365
  ],
@@ -1373,7 +1394,7 @@ export async function getFeeState<chain extends Chain | undefined>(
1373
1394
 
1374
1395
  export namespace getFeeState {
1375
1396
  export type Args = {
1376
- /** Optional fee recipient whose claimable vault shares are included. */
1397
+ /** Optional fee recipient whose claimable Earn shares are included. */
1377
1398
  recipient?: Address | undefined
1378
1399
  /** Vault address. */
1379
1400
  vault: Address
@@ -1388,11 +1409,11 @@ export namespace getFeeState {
1388
1409
  configId: bigint
1389
1410
  /** Whether fees are configured and not emergency-disabled. */
1390
1411
  feesActive: boolean
1391
- /** Post-fee high-water mark per vault share. */
1412
+ /** Post-fee high-water mark per Earn share. */
1392
1413
  highWaterMark: bigint
1393
1414
  /** Pending fee amounts. */
1394
1415
  preview: FeePreview
1395
- /** Excess-return fee target per vault share. */
1416
+ /** Excess-return fee target per Earn share. */
1396
1417
  targetBase: bigint
1397
1418
  }
1398
1419
  // TODO: exhaustive error type
@@ -1405,22 +1426,22 @@ export type FeeConfig = {
1405
1426
  excess: {
1406
1427
  /** Excess fee recipient. */
1407
1428
  account: Address
1408
- /** Annual target growth rate, scaled to 18 decimals. */
1409
- annualTargetRate: bigint
1429
+ /** Annual target growth rate in basis points. */
1430
+ annualTargetRateBps: number
1410
1431
  /** Whether the excess fee is active. */
1411
1432
  enabled: boolean
1412
- /** Rate applied above the target, scaled to 18 decimals. */
1413
- excessFeeRate: bigint
1433
+ /** Rate applied above the target in basis points. */
1434
+ excessFeeRateBps: number
1414
1435
  }
1415
- /** Fixed fee recipients and their 18-decimal rates. */
1416
- fixedFees: readonly { account: Address; rate: bigint }[]
1436
+ /** Fixed fee recipients and their rates in basis points. */
1437
+ fixedFees: readonly { account: Address; rateBps: number }[]
1417
1438
  }
1418
1439
 
1419
1440
  /** Pending vault fee amounts. */
1420
1441
  export type FeePreview = {
1421
- /** Assets backing active vault shares. */
1442
+ /** Assets backing active Earn shares. */
1422
1443
  activeAssets: bigint
1423
- /** Fee allocations in assets and vault shares. */
1444
+ /** Fee allocations in assets and Earn shares. */
1424
1445
  allocations: readonly {
1425
1446
  account: Address
1426
1447
  feeAssets: bigint
@@ -1432,20 +1453,20 @@ export type FeePreview = {
1432
1453
  fixedFeeAssets: bigint
1433
1454
  /** Accrual above the high-water mark, asset units. */
1434
1455
  positiveAccrualAssets: bigint
1435
- /** Scaled asset value per vault share after fees. */
1456
+ /** Scaled asset value per Earn share after fees. */
1436
1457
  postFeeValuePerShare: bigint
1437
- /** Scaled asset value per vault share before fees. */
1458
+ /** Scaled asset value per Earn share before fees. */
1438
1459
  preFeeValuePerShare: bigint
1439
- /** Scaled excess-fee target per vault share. */
1460
+ /** Scaled excess-fee target per Earn share. */
1440
1461
  targetValuePerShare: bigint
1441
1462
  /** Total fee liability, asset units. */
1442
1463
  totalFeeAssets: bigint
1443
- /** Vault shares minted to cover the total fee. */
1464
+ /** Earn shares minted to cover the total fee. */
1444
1465
  totalFeeShares: bigint
1445
1466
  }
1446
1467
 
1447
1468
  /**
1448
- * Gets an account's asset and vault share balances, allowances, and current
1469
+ * Gets an account's asset and Earn share balances, allowances, and current
1449
1470
  * share value. The value includes fees.
1450
1471
  *
1451
1472
  * @example
@@ -1467,7 +1488,7 @@ export type FeePreview = {
1467
1488
  *
1468
1489
  * @param client - Client.
1469
1490
  * @param parameters - Parameters.
1470
- * @returns The asset and vault share balances, allowances, and value.
1491
+ * @returns The asset and Earn share balances, allowances, and value.
1471
1492
  */
1472
1493
  export async function getPosition<
1473
1494
  chain extends Chain | undefined,
@@ -1485,13 +1506,13 @@ export async function getPosition<
1485
1506
  contracts: [
1486
1507
  defineCall({
1487
1508
  address: vault,
1488
- abi: Abis.vaultAdapter,
1509
+ abi: Abis.earnVault,
1489
1510
  functionName: 'asset',
1490
1511
  }),
1491
1512
  defineCall({
1492
1513
  address: vault,
1493
- abi: Abis.vaultAdapter,
1494
- functionName: 'shareToken',
1514
+ abi: Abis.earnVault,
1515
+ functionName: 'earnShare',
1495
1516
  }),
1496
1517
  ],
1497
1518
  deployless: true,
@@ -1530,7 +1551,7 @@ export async function getPosition<
1530
1551
  })
1531
1552
  const value = await readContract(client, {
1532
1553
  ...rest,
1533
- abi: Abis.vaultAdapter,
1554
+ abi: Abis.earnVault,
1534
1555
  address: vault,
1535
1556
  args: [shareBalance],
1536
1557
  functionName: 'previewRedeem',
@@ -1562,13 +1583,13 @@ export namespace getPosition {
1562
1583
  assetBalance: bigint
1563
1584
  /** Token accepted by the vault. */
1564
1585
  assetToken: Address
1565
- /** Vault shares the vault may spend from the account. */
1586
+ /** Earn shares the vault may spend from the account. */
1566
1587
  shareAllowance: bigint
1567
- /** Vault share balance held by the account. */
1588
+ /** Earn share balance held by the account. */
1568
1589
  shareBalance: bigint
1569
- /** Token representing vault shares. */
1590
+ /** Token representing Earn shares. */
1570
1591
  shareToken: Address
1571
- /** Current asset value of the vault share balance, including fees. */
1592
+ /** Current asset value of the Earn share balance, including fees. */
1572
1593
  value: bigint
1573
1594
  }
1574
1595
  // TODO: exhaustive error type
@@ -1576,7 +1597,7 @@ export namespace getPosition {
1576
1597
  }
1577
1598
 
1578
1599
  /**
1579
- * Gets the asset output for an exact vault share input, including fees.
1600
+ * Gets the asset output for an exact Earn share input, including fees.
1580
1601
  *
1581
1602
  * @example
1582
1603
  * ```ts
@@ -1612,7 +1633,7 @@ export async function getRedeemQuote<chain extends Chain | undefined>(
1612
1633
 
1613
1634
  export namespace getRedeemQuote {
1614
1635
  export type Args = {
1615
- /** Exact vault share input, base units. */
1636
+ /** Exact Earn share input, base units. */
1616
1637
  shareAmount: bigint
1617
1638
  /** Vault address. */
1618
1639
  vault: Address
@@ -1620,7 +1641,7 @@ export namespace getRedeemQuote {
1620
1641
  export type Parameters = Omit<ReadParameters, 'account'> & Args
1621
1642
  /** Asset output, including fees. */
1622
1643
  export type ReturnValue = ReadContractReturnType<
1623
- typeof Abis.vaultAdapter,
1644
+ typeof Abis.earnVault,
1624
1645
  'previewRedeem',
1625
1646
  never
1626
1647
  >
@@ -1652,7 +1673,7 @@ export namespace getRedeemQuote {
1652
1673
  const { shareAmount, vault } = args
1653
1674
  return defineCall({
1654
1675
  address: vault,
1655
- abi: Abis.vaultAdapter,
1676
+ abi: Abis.earnVault,
1656
1677
  args: [shareAmount],
1657
1678
  functionName: 'previewRedeem',
1658
1679
  })
@@ -1688,12 +1709,20 @@ export async function getVault<chain extends Chain | undefined>(
1688
1709
  parameters: getVault.Parameters,
1689
1710
  ): Promise<getVault.ReturnValue> {
1690
1711
  const { vault, ...rest } = parameters
1691
- const engine = await readContract(client, {
1692
- ...rest,
1693
- abi: Abis.vaultAdapter,
1694
- address: vault,
1695
- functionName: 'engine',
1696
- })
1712
+ const [engine, fees] = await Promise.all([
1713
+ readContract(client, {
1714
+ ...rest,
1715
+ abi: Abis.earnVault,
1716
+ address: vault,
1717
+ functionName: 'engine',
1718
+ }),
1719
+ readContract(client, {
1720
+ ...rest,
1721
+ abi: Abis.earnVault,
1722
+ address: vault,
1723
+ functionName: 'earnFees',
1724
+ }),
1725
+ ])
1697
1726
  const [
1698
1727
  assetToken,
1699
1728
  engine_,
@@ -1718,7 +1747,7 @@ export async function getVault<chain extends Chain | undefined>(
1718
1747
  ] = await multicall(client, {
1719
1748
  ...rest,
1720
1749
  allowFailure: false,
1721
- contracts: getVault.calls({ engine, vault }),
1750
+ contracts: getVault.calls({ engine, fees, vault }),
1722
1751
  deployless: true,
1723
1752
  })
1724
1753
  if (!isAddressEqual(engine, engine_))
@@ -1786,131 +1815,131 @@ export namespace getVault {
1786
1815
  engineShares: bigint
1787
1816
  /** Whether fees are configured and not emergency-disabled. */
1788
1817
  feesActive: boolean
1789
- /** Whether vault share supply matches its asset backing. */
1818
+ /** Whether Earn share supply matches its asset backing. */
1790
1819
  isSynced: boolean
1791
1820
  /** Vault governance address. */
1792
1821
  operator: Address
1793
1822
  /** Open queued redemptions. */
1794
1823
  pendingRedeemCount: bigint
1795
- /** Active vault share supply. */
1824
+ /** Active Earn share supply. */
1796
1825
  shareSupply: bigint
1797
- /** Token representing vault shares. */
1826
+ /** Token representing Earn shares. */
1798
1827
  shareToken: Address
1799
1828
  }
1800
1829
  // TODO: exhaustive error type
1801
1830
  export type ErrorType = GetVaultEngineChangedErrorType | BaseErrorType
1802
1831
 
1803
1832
  /**
1804
- * Defines the reads used by {@link getVault}. Pass the vault's current
1805
- * engine address.
1833
+ * Defines the reads used by {@link getVault}. Pass the current engine and
1834
+ * fee contract addresses.
1806
1835
  *
1807
1836
  * @param args - Arguments.
1808
1837
  * @returns The calls.
1809
1838
  */
1810
- export function calls(args: Args & { engine: Address }) {
1811
- const { engine, vault } = args
1839
+ export function calls(args: Args & { engine: Address; fees: Address }) {
1840
+ const { engine, fees, vault } = args
1812
1841
  return [
1813
1842
  defineCall({
1814
1843
  address: vault,
1815
- abi: Abis.vaultAdapter,
1844
+ abi: Abis.earnVault,
1816
1845
  functionName: 'asset',
1817
1846
  }),
1818
1847
  defineCall({
1819
1848
  address: vault,
1820
- abi: Abis.vaultAdapter,
1849
+ abi: Abis.earnVault,
1821
1850
  functionName: 'engine',
1822
1851
  }),
1823
1852
  defineCall({
1824
1853
  address: vault,
1825
- abi: Abis.vaultAdapter,
1826
- functionName: 'shareToken',
1854
+ abi: Abis.earnVault,
1855
+ functionName: 'earnShare',
1827
1856
  }),
1828
1857
  defineCall({
1829
1858
  address: vault,
1830
- abi: Abis.vaultAdapter,
1859
+ abi: Abis.earnVault,
1831
1860
  functionName: 'operator',
1832
1861
  }),
1833
1862
  defineCall({
1834
1863
  address: vault,
1835
- abi: Abis.vaultAdapter,
1864
+ abi: Abis.earnVault,
1836
1865
  functionName: 'emergencyGuardian',
1837
1866
  }),
1838
1867
  defineCall({
1839
1868
  address: vault,
1840
- abi: Abis.vaultAdapter,
1869
+ abi: Abis.earnVault,
1841
1870
  functionName: 'asyncJanitor',
1842
1871
  }),
1843
1872
  defineCall({
1844
1873
  address: vault,
1845
- abi: Abis.vaultAdapter,
1874
+ abi: Abis.earnVault,
1846
1875
  functionName: 'engineMigrationMode',
1847
1876
  }),
1848
1877
  defineCall({
1849
1878
  address: vault,
1850
- abi: Abis.vaultAdapter,
1879
+ abi: Abis.earnVault,
1851
1880
  functionName: 'depositsPaused',
1852
1881
  }),
1853
1882
  defineCall({
1854
1883
  address: vault,
1855
- abi: Abis.vaultAdapter,
1884
+ abi: Abis.earnVault,
1856
1885
  functionName: 'engineShares',
1857
1886
  }),
1858
1887
  defineCall({
1859
1888
  address: vault,
1860
- abi: Abis.vaultAdapter,
1861
- functionName: 'shareSupply',
1889
+ abi: Abis.earnVault,
1890
+ functionName: 'totalEarnShares',
1862
1891
  }),
1863
1892
  defineCall({
1864
1893
  address: vault,
1865
- abi: Abis.vaultAdapter,
1866
- functionName: 'isSynced',
1894
+ abi: Abis.earnVault,
1895
+ functionName: 'isAccountingAligned',
1867
1896
  }),
1868
1897
  defineCall({
1869
1898
  address: vault,
1870
- abi: Abis.vaultAdapter,
1871
- functionName: 'pendingRedeemCount',
1899
+ abi: Abis.earnVault,
1900
+ functionName: 'openRedeemRequestCount',
1872
1901
  }),
1873
1902
  defineCall({
1874
- address: vault,
1875
- abi: Abis.vaultAdapter,
1903
+ address: fees,
1904
+ abi: Abis.earnFees,
1876
1905
  functionName: 'feesActive',
1877
1906
  }),
1878
1907
  defineCall({
1879
1908
  address: engine,
1880
- abi: Abis.vaultEngine,
1909
+ abi: Abis.earnEngine,
1881
1910
  functionName: 'totalAssets',
1882
1911
  }),
1883
1912
  defineCall({
1884
1913
  address: engine,
1885
- abi: Abis.vaultEngine,
1914
+ abi: Abis.earnEngine,
1886
1915
  functionName: 'name',
1887
1916
  }),
1888
1917
  defineCall({
1889
1918
  address: engine,
1890
- abi: Abis.vaultEngine,
1919
+ abi: Abis.earnEngine,
1891
1920
  functionName: 'symbol',
1892
1921
  }),
1893
1922
  defineCall({
1894
1923
  address: engine,
1895
- abi: Abis.vaultEngine,
1924
+ abi: Abis.earnEngine,
1896
1925
  functionName: 'supportsInterface',
1897
1926
  args: [interfaceIds.asyncRedeem],
1898
1927
  }),
1899
1928
  defineCall({
1900
1929
  address: engine,
1901
- abi: Abis.vaultEngine,
1930
+ abi: Abis.earnEngine,
1902
1931
  functionName: 'supportsInterface',
1903
1932
  args: [interfaceIds.exactWithdraw],
1904
1933
  }),
1905
1934
  defineCall({
1906
1935
  address: engine,
1907
- abi: Abis.vaultEngine,
1936
+ abi: Abis.earnEngine,
1908
1937
  functionName: 'supportsInterface',
1909
1938
  args: [interfaceIds.inKindDeposit],
1910
1939
  }),
1911
1940
  defineCall({
1912
1941
  address: engine,
1913
- abi: Abis.vaultEngine,
1942
+ abi: Abis.earnEngine,
1914
1943
  functionName: 'supportsInterface',
1915
1944
  args: [interfaceIds.syncRedeem],
1916
1945
  }),
@@ -1919,7 +1948,7 @@ export namespace getVault {
1919
1948
  }
1920
1949
 
1921
1950
  /**
1922
- * Gets the vault shares required for an exact asset output, including fees
1951
+ * Gets the Earn shares required for an exact asset output, including fees
1923
1952
  * and ceiling rounding.
1924
1953
  *
1925
1954
  * @example
@@ -1941,7 +1970,7 @@ export namespace getVault {
1941
1970
  *
1942
1971
  * @param client - Client.
1943
1972
  * @param parameters - Parameters.
1944
- * @returns The required vault share input, ceiling-rounded.
1973
+ * @returns The required Earn share input, ceiling-rounded.
1945
1974
  */
1946
1975
  export async function getWithdrawQuote<chain extends Chain | undefined>(
1947
1976
  client: Client<Transport, chain>,
@@ -1962,9 +1991,9 @@ export namespace getWithdrawQuote {
1962
1991
  vault: Address
1963
1992
  }
1964
1993
  export type Parameters = Omit<ReadParameters, 'account'> & Args
1965
- /** Required vault share input, ceiling-rounded. */
1994
+ /** Required Earn share input, ceiling-rounded. */
1966
1995
  export type ReturnValue = ReadContractReturnType<
1967
- typeof Abis.vaultAdapter,
1996
+ typeof Abis.earnVault,
1968
1997
  'previewWithdraw',
1969
1998
  never
1970
1999
  >
@@ -1996,7 +2025,7 @@ export namespace getWithdrawQuote {
1996
2025
  const { assetAmount, vault } = args
1997
2026
  return defineCall({
1998
2027
  address: vault,
1999
- abi: Abis.vaultAdapter,
2028
+ abi: Abis.earnVault,
2000
2029
  args: [assetAmount],
2001
2030
  functionName: 'previewWithdraw',
2002
2031
  })
@@ -2004,8 +2033,8 @@ export namespace getWithdrawQuote {
2004
2033
  }
2005
2034
 
2006
2035
  /**
2007
- * Redeems vault shares for assets sent to `recipient`. The transaction
2008
- * includes the required vault share approval.
2036
+ * Redeems Earn shares for assets sent to `recipient`. The transaction
2037
+ * includes the required Earn share approval.
2009
2038
  *
2010
2039
  * @example
2011
2040
  * ```ts
@@ -2043,7 +2072,7 @@ export async function redeem<
2043
2072
 
2044
2073
  export namespace redeem {
2045
2074
  export type Args = {
2046
- /** Vault shares to redeem; base units or `{ formatted, decimals? }`. */
2075
+ /** Earn shares to redeem; base units or `{ formatted, decimals? }`. */
2047
2076
  shareAmount: internal_Token.AmountInput
2048
2077
  /** Asset recipient. @default `account.address` */
2049
2078
  recipient?: Address | undefined
@@ -2073,7 +2102,7 @@ export namespace redeem {
2073
2102
  // TODO: exhaustive error type
2074
2103
  export type ErrorType = BaseErrorType
2075
2104
 
2076
- /** @internal Shared dispatch; reads the vault share token for the approval. */
2105
+ /** @internal Shared dispatch; reads the Earn share token for the approval. */
2077
2106
  export async function inner<
2078
2107
  action extends typeof sendTransaction | typeof sendTransactionSync,
2079
2108
  chain extends Chain | undefined,
@@ -2086,9 +2115,9 @@ export namespace redeem {
2086
2115
  const [args, shareToken] = await Promise.all([
2087
2116
  toRedeemArgs(client, parameters as never),
2088
2117
  readContract(client, {
2089
- abi: Abis.vaultAdapter,
2118
+ abi: Abis.earnVault,
2090
2119
  address: parameters.vault,
2091
- functionName: 'shareToken',
2120
+ functionName: 'earnShare',
2092
2121
  }),
2093
2122
  ])
2094
2123
  return (await action(client, {
@@ -2098,7 +2127,7 @@ export namespace redeem {
2098
2127
  }
2099
2128
 
2100
2129
  /**
2101
- * Defines a redeem call without an approval. Provide vault share decimals
2130
+ * Defines a redeem call without an approval. Provide Earn share decimals
2102
2131
  * for formatted inputs and an explicit output bound because this builder performs no reads.
2103
2132
  *
2104
2133
  * @param parameters - Client (optional), followed by the call arguments.
@@ -2115,7 +2144,7 @@ export namespace redeem {
2115
2144
  })()
2116
2145
  return defineCall({
2117
2146
  address: vault,
2118
- abi: Abis.vaultAdapter,
2147
+ abi: Abis.earnVault,
2119
2148
  functionName: 'redeem',
2120
2149
  args: [
2121
2150
  internal_Token.toBaseUnits(args.shareAmount, undefined),
@@ -2126,7 +2155,7 @@ export namespace redeem {
2126
2155
  }
2127
2156
  export namespace call {
2128
2157
  export type Args = {
2129
- /** Vault shares to redeem; base units or `{ formatted, decimals? }`. */
2158
+ /** Earn shares to redeem; base units or `{ formatted, decimals? }`. */
2130
2159
  shareAmount: internal_Token.AmountInput
2131
2160
  /** Asset recipient. */
2132
2161
  recipient: Address
@@ -2147,7 +2176,7 @@ export namespace redeem {
2147
2176
  }
2148
2177
 
2149
2178
  /**
2150
- * Defines the vault share approval and redeem calls for atomic execution.
2179
+ * Defines the Earn share approval and redeem calls for atomic execution.
2151
2180
  * Pass `shareToken` explicitly because this builder performs no reads.
2152
2181
  *
2153
2182
  * @param args - Arguments.
@@ -2155,7 +2184,7 @@ export namespace redeem {
2155
2184
  */
2156
2185
  export function calls(
2157
2186
  args: call.Args & {
2158
- /** Vault share token approved for the redemption. */
2187
+ /** Earn share token approved for the redemption. */
2159
2188
  shareToken: Address
2160
2189
  },
2161
2190
  ) {
@@ -2184,7 +2213,7 @@ export namespace redeem {
2184
2213
  // Earn contracts are user-deployed: several adapters can emit the same
2185
2214
  // signature in one receipt, so filter by emitting address before decode.
2186
2215
  const [log] = parseEventLogs({
2187
- abi: Abis.vaultAdapter,
2216
+ abi: Abis.earnVault,
2188
2217
  eventName: 'Redeemed',
2189
2218
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
2190
2219
  })
@@ -2193,7 +2222,7 @@ export namespace redeem {
2193
2222
  }
2194
2223
 
2195
2224
  /**
2196
- * Estimates gas for a redemption, assuming enough vault share allowance.
2225
+ * Estimates gas for a redemption, assuming enough Earn share allowance.
2197
2226
  *
2198
2227
  * @param client - Client.
2199
2228
  * @param parameters - Parameters.
@@ -2213,7 +2242,7 @@ export namespace redeem {
2213
2242
  }
2214
2243
 
2215
2244
  /**
2216
- * Simulates a redemption, assuming enough vault share allowance.
2245
+ * Simulates a redemption, assuming enough Earn share allowance.
2217
2246
  *
2218
2247
  * @param client - Client.
2219
2248
  * @param parameters - Parameters.
@@ -2225,7 +2254,7 @@ export namespace redeem {
2225
2254
  >(
2226
2255
  client: Client<Transport, chain, account>,
2227
2256
  parameters: redeem.Parameters<chain, account>,
2228
- ): Promise<SimulateContractReturnType<typeof Abis.vaultAdapter, 'redeem'>> {
2257
+ ): Promise<SimulateContractReturnType<typeof Abis.earnVault, 'redeem'>> {
2229
2258
  return simulateContract(client, {
2230
2259
  ...pickWriteParameters(parameters as never),
2231
2260
  ...redeem.call(await toRedeemArgs(client, parameters as never)),
@@ -2234,7 +2263,7 @@ export namespace redeem {
2234
2263
  }
2235
2264
 
2236
2265
  /**
2237
- * Redeems vault shares and returns the confirmed receipt and event data.
2266
+ * Redeems Earn shares and returns the confirmed receipt and event data.
2238
2267
  *
2239
2268
  * @example
2240
2269
  * ```ts
@@ -2278,7 +2307,7 @@ export async function redeemSync<
2278
2307
  caller: args.caller,
2279
2308
  receipt,
2280
2309
  recipient: args.receiver,
2281
- shareAmount: args.shares,
2310
+ shareAmount: args.earnShares,
2282
2311
  }
2283
2312
  }
2284
2313
 
@@ -2297,7 +2326,7 @@ export namespace redeemSync {
2297
2326
  receipt: TransactionReceipt
2298
2327
  /** Asset recipient. */
2299
2328
  recipient: Address
2300
- /** Vault shares burned. */
2329
+ /** Earn shares burned. */
2301
2330
  shareAmount: bigint
2302
2331
  }>
2303
2332
  // TODO: exhaustive error type
@@ -2305,7 +2334,7 @@ export namespace redeemSync {
2305
2334
  }
2306
2335
 
2307
2336
  /**
2308
- * Withdraws vault shares from a Zone and redeems them on the parent chain. Use
2337
+ * Withdraws Earn shares from a Zone and redeems them on the parent chain. Use
2309
2338
  * {@link privateRedeem.prepare} to build the encrypted callback.
2310
2339
  *
2311
2340
  * @example
@@ -2316,6 +2345,8 @@ export namespace redeemSync {
2316
2345
  * recoveryRecipient: '0x...',
2317
2346
  * shareAmount: 100_000_000n,
2318
2347
  * slippageBps: 50,
2348
+ * vault: '0x...',
2349
+ * zoneId: 7,
2319
2350
  * })
2320
2351
  * const hash = await Actions.earn.privateRedeem(zoneClient, prepared)
2321
2352
  * ```
@@ -2345,7 +2376,7 @@ export namespace privateRedeem {
2345
2376
  export type ErrorType = zoneActions.requestWithdrawal.ErrorType
2346
2377
 
2347
2378
  /**
2348
- * Builds an encrypted Zone withdrawal that redeems vault shares and returns
2379
+ * Builds an encrypted Zone withdrawal that redeems Earn shares and returns
2349
2380
  * the resulting assets to the Zone.
2350
2381
  *
2351
2382
  * @param client - Parent-chain client.
@@ -2363,20 +2394,31 @@ export namespace privateRedeem {
2363
2394
  callbackGas = zoneGatewayCallbackGas,
2364
2395
  fallbackRecipient = parameters.recoveryRecipient,
2365
2396
  gateway,
2397
+ portalAddress: portalAddress_,
2366
2398
  recipient,
2367
2399
  recoveryRecipient,
2368
2400
  returnMemo,
2369
2401
  shareAmount,
2402
+ vault,
2370
2403
  withdrawalMemo,
2404
+ zoneId,
2371
2405
  } = parameters
2406
+ const portalAddress = portalAddress_ ?? getPortalAddress(chainId, zoneId)
2372
2407
  const readParameters = pickReadParameters(parameters)
2373
2408
  const [fromBlock, config] = await Promise.all([
2374
2409
  getBlockNumber(client, { cacheTime: 0 }),
2375
- getZoneGatewayConfig(client, { ...readParameters, gateway }),
2410
+ getZoneGatewayConfig(client, {
2411
+ ...readParameters,
2412
+ flow: 1,
2413
+ gateway,
2414
+ vault,
2415
+ zoneId,
2416
+ zonePortal: portalAddress,
2417
+ }),
2376
2418
  ])
2377
- const assetToken = parameters.assetToken ?? config.vaultAsset
2378
- if (isAddressEqual(assetToken, config.shareToken))
2379
- throw new Error('`assetToken` cannot be the gateway vault share token.')
2419
+ const assetToken = parameters.assetToken ?? config.privateAsset
2420
+ if (!isAddressEqual(assetToken, config.privateAsset))
2421
+ throw new Error('`assetToken` must match the Zone gateway private asset.')
2380
2422
 
2381
2423
  const [{ encrypted, keyIndex }, assetAmountMin] = await Promise.all([
2382
2424
  zoneActions.encryptedDeposit.prepareRecipient(client, {
@@ -2397,23 +2439,19 @@ export namespace privateRedeem {
2397
2439
  const assetAmount = await getRedeemQuote(client, {
2398
2440
  ...readParameters,
2399
2441
  shareAmount,
2400
- vault: config.vaultAdapter,
2442
+ vault: config.vault,
2401
2443
  })
2402
2444
  return EarnShares.minimumOutput(assetAmount, parameters.slippageBps)
2403
2445
  })(),
2404
2446
  ])
2405
- const direct = isAddressEqual(assetToken, config.vaultAsset)
2406
- const data = encodeAbiParameters(Abis.zoneGatewayCallbackData, [
2447
+ const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
2407
2448
  {
2408
- flow: 1,
2409
- outputToken: assetToken,
2410
- keyIndex,
2411
- encrypted,
2412
- minVaultAssets: direct ? assetAmountMin : 1n,
2413
- minVaultShares: 0n,
2414
- minOutputAmount: direct ? 0n : assetAmountMin,
2415
2449
  actionId,
2416
- refundRecipient: recoveryRecipient,
2450
+ flow: 1,
2451
+ minEarnShares: 0n,
2452
+ minOutputAmount: assetAmountMin,
2453
+ minVaultAssets: assetAmountMin,
2454
+ zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
2417
2455
  },
2418
2456
  ])
2419
2457
  return {
@@ -2434,33 +2472,26 @@ export namespace privateRedeem {
2434
2472
  export namespace prepare {
2435
2473
  export type Parameters = Omit<ReadParameters, 'account'> &
2436
2474
  PrivatePreparationParameters & {
2437
- /** Vault shares withdrawn from the Zone, base units. */
2475
+ /** Earn shares withdrawn from the Zone, base units. */
2438
2476
  shareAmount: bigint
2439
- } & (
2440
- | ({
2441
- /** Asset token returned to the Zone. @default gateway vault asset */
2442
- assetToken?: undefined
2443
- } & OneOf<
2444
- | {
2445
- /** Minimum assets returned to the Zone. */
2446
- assetAmountMin: bigint
2447
- }
2448
- | {
2449
- /** Quoted assets returned to the Zone. */
2450
- assetAmount: bigint
2451
- /** Slippage tolerance under `assetAmount` (50 = 0.5%). */
2452
- slippageBps: number
2453
- }
2454
- | {
2455
- /** Slippage tolerance under a live vault quote (50 = 0.5%). */
2456
- slippageBps: number
2457
- }
2458
- >)
2459
- | ({
2460
- /** Asset token returned to the Zone after a swap. */
2461
- assetToken: Address
2462
- } & MinimumAssetAmountParameters)
2463
- )
2477
+ /** Private asset returned to the Zone. Must match the gateway. @default gateway private asset */
2478
+ assetToken?: Address | undefined
2479
+ } & OneOf<
2480
+ | {
2481
+ /** Minimum assets returned to the Zone. */
2482
+ assetAmountMin: bigint
2483
+ }
2484
+ | {
2485
+ /** Quoted assets returned to the Zone. */
2486
+ assetAmount: bigint
2487
+ /** Slippage tolerance under `assetAmount` (50 = 0.5%). */
2488
+ slippageBps: number
2489
+ }
2490
+ | {
2491
+ /** Slippage tolerance under a live vault quote (50 = 0.5%). */
2492
+ slippageBps: number
2493
+ }
2494
+ >
2464
2495
  export type ReturnValue = PreparedZoneRequest
2465
2496
  export type ErrorType = BaseErrorType
2466
2497
  }
@@ -2515,6 +2546,7 @@ export namespace privateRedeemSync {
2515
2546
  * actionId: prepared.actionId,
2516
2547
  * fromBlock: prepared.fromBlock,
2517
2548
  * gateway: '0x...',
2549
+ * vault: '0x...',
2518
2550
  * })
2519
2551
  * ```
2520
2552
  *
@@ -2532,15 +2564,17 @@ export async function waitForPrivateRedeem<chain extends Chain | undefined>(
2532
2564
  gateway,
2533
2565
  pollingInterval = client.pollingInterval,
2534
2566
  timeout = 60_000,
2567
+ vault,
2535
2568
  } = parameters
2536
2569
  const event = getAbiItem({
2537
- abi: Abis.zoneGateway,
2570
+ abi: Abis.earnRouter,
2538
2571
  name: 'EarnRedeem',
2539
2572
  })
2540
2573
  const observerId = stringify([
2541
2574
  'waitForPrivateRedeem',
2542
2575
  client.uid,
2543
2576
  gateway,
2577
+ vault,
2544
2578
  actionId,
2545
2579
  fromBlock,
2546
2580
  ])
@@ -2571,7 +2605,7 @@ export async function waitForPrivateRedeem<chain extends Chain | undefined>(
2571
2605
  try {
2572
2606
  const [log] = await getLogs(client, {
2573
2607
  address: gateway,
2574
- args: { actionId },
2608
+ args: { actionId, earnVault: vault },
2575
2609
  event,
2576
2610
  fromBlock,
2577
2611
  strict: true,
@@ -2583,7 +2617,7 @@ export async function waitForPrivateRedeem<chain extends Chain | undefined>(
2583
2617
  actionId: log.args.actionId,
2584
2618
  outputAmount: log.args.outputAmount,
2585
2619
  outputToken: log.args.outputToken,
2586
- shares: log.args.shares,
2620
+ shares: log.args.earnShares,
2587
2621
  tempoBlockNumber: log.blockNumber,
2588
2622
  vaultAssets: log.args.vaultAssets,
2589
2623
  zoneDepositHash: log.args.zoneDepositHash,
@@ -2621,6 +2655,8 @@ export namespace waitForPrivateRedeem {
2621
2655
  pollingInterval?: number | undefined
2622
2656
  /** Timeout in milliseconds; `0` disables it. @default `60_000` */
2623
2657
  timeout?: number | undefined
2658
+ /** Vault address. */
2659
+ vault: Address
2624
2660
  }
2625
2661
  export type ReturnType = {
2626
2662
  /** Correlation id for the completed redemption. */
@@ -2629,7 +2665,7 @@ export namespace waitForPrivateRedeem {
2629
2665
  outputAmount: bigint
2630
2666
  /** Token returned to the Zone. */
2631
2667
  outputToken: Address
2632
- /** Vault shares redeemed. */
2668
+ /** Earn shares redeemed. */
2633
2669
  shares: bigint
2634
2670
  /** Parent-chain block containing the gateway event. */
2635
2671
  tempoBlockNumber: bigint
@@ -2647,8 +2683,8 @@ export namespace waitForPrivateRedeem {
2647
2683
  }
2648
2684
 
2649
2685
  /**
2650
- * Withdraws an exact asset amount to `recipient`, up to the specified vault
2651
- * share limit. The transaction includes the required vault share approval;
2686
+ * Withdraws an exact asset amount to `recipient`, up to the specified Earn
2687
+ * share limit. The transaction includes the required Earn share approval;
2652
2688
  * use {@link redeem} for a full exit.
2653
2689
  *
2654
2690
  * @example
@@ -2695,7 +2731,7 @@ export namespace withdrawExact {
2695
2731
  vault: Address
2696
2732
  } & OneOf<
2697
2733
  | {
2698
- /** Maximum vault share input to burn. */
2734
+ /** Maximum Earn share input to burn. */
2699
2735
  shareAmountMax: bigint
2700
2736
  }
2701
2737
  | {
@@ -2703,7 +2739,7 @@ export namespace withdrawExact {
2703
2739
  slippageBps: number
2704
2740
  }
2705
2741
  | {
2706
- /** Quoted vault share input; raised by `slippageBps`. */
2742
+ /** Quoted Earn share input; raised by `slippageBps`. */
2707
2743
  shareAmount: bigint
2708
2744
  /** Slippage tolerance in basis points over `shareAmount` (50 = 0.5%). */
2709
2745
  slippageBps: number
@@ -2717,7 +2753,7 @@ export namespace withdrawExact {
2717
2753
  // TODO: exhaustive error type
2718
2754
  export type ErrorType = BaseErrorType
2719
2755
 
2720
- /** @internal Shared dispatch; reads the vault share token for the approval. */
2756
+ /** @internal Shared dispatch; reads the Earn share token for the approval. */
2721
2757
  export async function inner<
2722
2758
  action extends typeof sendTransaction | typeof sendTransactionSync,
2723
2759
  chain extends Chain | undefined,
@@ -2730,9 +2766,9 @@ export namespace withdrawExact {
2730
2766
  const [args, shareToken] = await Promise.all([
2731
2767
  toWithdrawExactArgs(client, parameters as never),
2732
2768
  readContract(client, {
2733
- abi: Abis.vaultAdapter,
2769
+ abi: Abis.earnVault,
2734
2770
  address: parameters.vault,
2735
- functionName: 'shareToken',
2771
+ functionName: 'earnShare',
2736
2772
  }),
2737
2773
  ])
2738
2774
  return (await action(client, {
@@ -2759,7 +2795,7 @@ export namespace withdrawExact {
2759
2795
  })()
2760
2796
  return defineCall({
2761
2797
  address: vault,
2762
- abi: Abis.vaultAdapter,
2798
+ abi: Abis.earnVault,
2763
2799
  functionName: 'withdrawExact',
2764
2800
  args: [
2765
2801
  internal_Token.toBaseUnits(args.assetAmount, undefined),
@@ -2778,11 +2814,11 @@ export namespace withdrawExact {
2778
2814
  vault: Address
2779
2815
  } & OneOf<
2780
2816
  | {
2781
- /** Maximum vault share input to burn. */
2817
+ /** Maximum Earn share input to burn. */
2782
2818
  shareAmountMax: bigint
2783
2819
  }
2784
2820
  | {
2785
- /** Quoted vault share input; raised by `slippageBps`. */
2821
+ /** Quoted Earn share input; raised by `slippageBps`. */
2786
2822
  shareAmount: bigint
2787
2823
  /** Slippage tolerance in basis points over `shareAmount` (50 = 0.5%). */
2788
2824
  slippageBps: number
@@ -2791,7 +2827,7 @@ export namespace withdrawExact {
2791
2827
  }
2792
2828
 
2793
2829
  /**
2794
- * Defines the vault share approval and withdrawal calls for atomic
2830
+ * Defines the Earn share approval and withdrawal calls for atomic
2795
2831
  * execution. Pass `shareToken` explicitly because this builder performs no reads.
2796
2832
  *
2797
2833
  * @param args - Arguments.
@@ -2799,7 +2835,7 @@ export namespace withdrawExact {
2799
2835
  */
2800
2836
  export function calls(
2801
2837
  args: call.Args & {
2802
- /** Vault share token approved for the withdrawal. */
2838
+ /** Earn share token approved for the withdrawal. */
2803
2839
  shareToken: Address
2804
2840
  },
2805
2841
  ) {
@@ -2830,7 +2866,7 @@ export namespace withdrawExact {
2830
2866
  // Earn contracts are user-deployed: several adapters can emit the same
2831
2867
  // signature in one receipt, so filter by emitting address before decode.
2832
2868
  const [log] = parseEventLogs({
2833
- abi: Abis.vaultAdapter,
2869
+ abi: Abis.earnVault,
2834
2870
  eventName: 'WithdrewExact',
2835
2871
  logs: logs.filter((log) => isAddressEqual(log.address, vault)),
2836
2872
  })
@@ -2839,7 +2875,7 @@ export namespace withdrawExact {
2839
2875
  }
2840
2876
 
2841
2877
  /**
2842
- * Estimates gas for an exact withdrawal, assuming enough vault share allowance.
2878
+ * Estimates gas for an exact withdrawal, assuming enough Earn share allowance.
2843
2879
  *
2844
2880
  * @param client - Client.
2845
2881
  * @param parameters - Parameters.
@@ -2861,7 +2897,7 @@ export namespace withdrawExact {
2861
2897
  }
2862
2898
 
2863
2899
  /**
2864
- * Simulates an exact withdrawal, assuming enough vault share allowance.
2900
+ * Simulates an exact withdrawal, assuming enough Earn share allowance.
2865
2901
  *
2866
2902
  * @param client - Client.
2867
2903
  * @param parameters - Parameters.
@@ -2874,7 +2910,7 @@ export namespace withdrawExact {
2874
2910
  client: Client<Transport, chain, account>,
2875
2911
  parameters: withdrawExact.Parameters<chain, account>,
2876
2912
  ): Promise<
2877
- SimulateContractReturnType<typeof Abis.vaultAdapter, 'withdrawExact'>
2913
+ SimulateContractReturnType<typeof Abis.earnVault, 'withdrawExact'>
2878
2914
  > {
2879
2915
  return simulateContract(client, {
2880
2916
  ...pickWriteParameters(parameters as never),
@@ -2930,7 +2966,7 @@ export async function withdrawExactSync<
2930
2966
  caller: args.caller,
2931
2967
  receipt,
2932
2968
  recipient: args.receiver,
2933
- shareAmount: args.sharesBurned,
2969
+ shareAmount: args.earnSharesBurned,
2934
2970
  }
2935
2971
  }
2936
2972
 
@@ -2950,33 +2986,20 @@ export namespace withdrawExactSync {
2950
2986
  receipt: TransactionReceipt
2951
2987
  /** Asset recipient. */
2952
2988
  recipient: Address
2953
- /** Vault shares burned. */
2989
+ /** Earn shares burned. */
2954
2990
  shareAmount: bigint
2955
2991
  }>
2956
2992
  // TODO: exhaustive error type
2957
2993
  export type ErrorType = BaseErrorType
2958
2994
  }
2959
2995
 
2960
- type MinimumAssetAmountParameters = OneOf<
2961
- | {
2962
- /** Minimum assets returned to the Zone. */
2963
- assetAmountMin: bigint
2964
- }
2965
- | {
2966
- /** Quoted assets returned to the Zone. */
2967
- assetAmount: bigint
2968
- /** Slippage tolerance under `assetAmount` (50 = 0.5%). */
2969
- slippageBps: number
2970
- }
2971
- >
2972
-
2973
2996
  type MinimumShareAmountParameters = OneOf<
2974
2997
  | {
2975
- /** Minimum vault shares returned to the Zone. */
2998
+ /** Minimum Earn shares returned to the Zone. */
2976
2999
  shareAmountMin: bigint
2977
3000
  }
2978
3001
  | {
2979
- /** Quoted vault shares returned to the Zone. */
3002
+ /** Quoted Earn shares returned to the Zone. */
2980
3003
  shareAmount: bigint
2981
3004
  /** Slippage tolerance under `shareAmount` (50 = 0.5%). */
2982
3005
  slippageBps: number
@@ -2990,16 +3013,22 @@ type PrivatePreparationParameters = {
2990
3013
  callbackGas?: bigint | undefined
2991
3014
  /** Public recipient if the parent-chain callback fails. @default `recoveryRecipient` */
2992
3015
  fallbackRecipient?: Address | undefined
2993
- /** Gateway identifying the vault and Zone configuration. */
3016
+ /** Zone gateway address. */
2994
3017
  gateway: Address
3018
+ /** Source Zone portal on the parent chain. @default Derived from `zoneId` */
3019
+ portalAddress?: Address | undefined
2995
3020
  /** Encrypted recipient for the returned tokens. */
2996
3021
  recipient: Address
2997
3022
  /** Public recipient if the encrypted return fails. */
2998
3023
  recoveryRecipient: Address
2999
3024
  /** Optional memo encrypted with the returned Zone deposit. */
3000
3025
  returnMemo?: Hex.Hex | undefined
3026
+ /** Vault address. */
3027
+ vault: Address
3001
3028
  /** Optional memo attached to the Zone withdrawal. */
3002
3029
  withdrawalMemo?: Hex.Hex | undefined
3030
+ /** Source Zone receiving the output. */
3031
+ zoneId: number
3003
3032
  }
3004
3033
 
3005
3034
  type PreparedZoneRequest = {
@@ -3068,75 +3097,107 @@ function pickReadParameters(parameters: Omit<ReadParameters, 'account'>) {
3068
3097
 
3069
3098
  async function getZoneGatewayConfig<chain extends Chain | undefined>(
3070
3099
  client: Client<Transport, chain>,
3071
- parameters: Omit<ReadParameters, 'account'> & { gateway: Address },
3100
+ parameters: Omit<ReadParameters, 'account'> & {
3101
+ flow: 0 | 1
3102
+ gateway: Address
3103
+ vault: Address
3104
+ zoneId: number
3105
+ zonePortal: Address
3106
+ },
3072
3107
  ) {
3073
- const { gateway, ...rest } = parameters
3108
+ const { flow, gateway, vault, zoneId, zonePortal, ...rest } = parameters
3074
3109
  const [
3075
- vaultAdapter,
3076
3110
  vaultAsset,
3077
3111
  shareToken,
3078
- zoneId,
3079
- zonePortal,
3080
- supportsAsyncFlow,
3112
+ allowedZoneId,
3113
+ routerVault,
3114
+ privateAsset,
3115
+ routerVaultAsset,
3116
+ routerShareToken,
3117
+ supportsFlow,
3081
3118
  ] = await multicall(client, {
3082
3119
  ...rest,
3083
3120
  allowFailure: false,
3084
3121
  contracts: [
3085
3122
  {
3086
- abi: Abis.zoneGateway,
3123
+ abi: Abis.earnVault,
3124
+ address: vault,
3125
+ functionName: 'asset',
3126
+ },
3127
+ {
3128
+ abi: Abis.earnVault,
3129
+ address: vault,
3130
+ functionName: 'earnShare',
3131
+ },
3132
+ {
3133
+ abi: Abis.earnRouter,
3087
3134
  address: gateway,
3088
- functionName: 'vaultAdapter',
3135
+ functionName: 'allowedZoneId',
3089
3136
  },
3090
3137
  {
3091
- abi: Abis.zoneGateway,
3138
+ abi: Abis.earnRouter,
3092
3139
  address: gateway,
3093
- functionName: 'vaultAsset',
3140
+ functionName: 'earnVault',
3094
3141
  },
3095
3142
  {
3096
- abi: Abis.zoneGateway,
3143
+ abi: Abis.earnRouter,
3097
3144
  address: gateway,
3098
- functionName: 'shareToken',
3145
+ functionName: 'privateAsset',
3099
3146
  },
3100
3147
  {
3101
- abi: Abis.zoneGateway,
3148
+ abi: Abis.earnRouter,
3102
3149
  address: gateway,
3103
- functionName: 'zoneId',
3150
+ functionName: 'vaultAsset',
3104
3151
  },
3105
3152
  {
3106
- abi: Abis.zoneGateway,
3153
+ abi: Abis.earnRouter,
3107
3154
  address: gateway,
3108
- functionName: 'zonePortal',
3155
+ functionName: 'earnShare',
3109
3156
  },
3110
3157
  {
3111
- abi: Abis.zoneGateway,
3158
+ abi: Abis.earnRouter,
3112
3159
  address: gateway,
3113
- args: [2],
3160
+ args: [flow],
3114
3161
  functionName: 'supportsFlow',
3115
3162
  },
3116
3163
  ],
3117
3164
  deployless: true,
3118
3165
  })
3119
- if (supportsAsyncFlow)
3120
- throw new Error('Async Zone gateways are not supported.')
3121
- return { shareToken, vaultAdapter, vaultAsset, zoneId, zonePortal }
3166
+ if (!supportsFlow) throw new Error('Zone gateway flow is not supported.')
3167
+ if (allowedZoneId !== zoneId)
3168
+ throw new Error('Zone gateway is configured for a different Zone.')
3169
+ if (!isAddressEqual(routerVault, vault))
3170
+ throw new Error('Zone gateway is configured for a different Earn vault.')
3171
+ if (!isAddressEqual(routerVaultAsset, vaultAsset))
3172
+ throw new Error('Zone gateway vault asset does not match the Earn vault.')
3173
+ if (!isAddressEqual(routerShareToken, shareToken))
3174
+ throw new Error('Zone gateway share token does not match the Earn vault.')
3175
+ return {
3176
+ privateAsset,
3177
+ shareToken,
3178
+ vault,
3179
+ vaultAsset,
3180
+ zoneId,
3181
+ zonePortal,
3182
+ }
3122
3183
  }
3123
3184
 
3124
3185
  // ERC-165 ids of the optional engine capability interfaces (XOR of each
3125
3186
  // interface's function selectors).
3126
3187
  const interfaceIds = {
3127
- /** `IVaultEngineAsync`. */
3188
+ /** `IEarnEngineAsyncRedeem`. */
3128
3189
  asyncRedeem: '0xa1a6a1d7',
3129
- /** `IVaultEngineExactWithdraw`. */
3190
+ /** `IEarnEngineExactWithdraw`. */
3130
3191
  exactWithdraw: '0x0adfb0b9',
3131
- /** `IVaultEngineShares`. */
3132
- inKindDeposit: '0x7d28a2f2',
3133
- /** `IVaultEngineSync`. */
3134
- syncRedeem: '0x370457f4',
3192
+ /** `IEarnEngineInKindDeposit`. */
3193
+ inKindDeposit: '0xce4790a9',
3194
+ /** `IEarnEngineRedeem`. */
3195
+ syncRedeem: '0x94a2d467',
3135
3196
  } as const
3136
3197
 
3137
- /** Trims the decoded `IVaultFees.FeeConfig` to its active fixed-fee count. */
3198
+ /** Trims the decoded `FeeConfig` to its active fixed-fee count. */
3138
3199
  function toFeeConfig(
3139
- config: ReadContractReturnType<typeof Abis.vaultAdapter, 'feeConfig'>,
3200
+ config: ReadContractReturnType<typeof Abis.earnFees, 'feeConfig'>,
3140
3201
  ): FeeConfig {
3141
3202
  return {
3142
3203
  excess: config.excess,
@@ -3144,15 +3205,32 @@ function toFeeConfig(
3144
3205
  }
3145
3206
  }
3146
3207
 
3147
- /** Trims the decoded `IVaultFees.FeePreview` to its active allocation count. */
3208
+ /** Maps decoded fee fields to the action result. */
3148
3209
  function toFeePreview(
3149
- preview: ReadContractReturnType<
3150
- typeof Abis.vaultAdapter,
3151
- 'previewAccruedFees'
3152
- >,
3210
+ preview: ReadContractReturnType<typeof Abis.earnFees, 'previewAccruedFees'>,
3153
3211
  ): FeePreview {
3154
- const { allocationCount, allocations, ...rest } = preview
3155
- return { ...rest, allocations: allocations.slice(0, allocationCount) }
3212
+ const {
3213
+ allocationCount,
3214
+ allocations,
3215
+ postFeeValuePerEarnShare,
3216
+ preFeeValuePerEarnShare,
3217
+ targetValuePerEarnShare,
3218
+ totalFeeEarnShares,
3219
+ ...rest
3220
+ } = preview
3221
+ return {
3222
+ ...rest,
3223
+ allocations: allocations
3224
+ .slice(0, allocationCount)
3225
+ .map(({ feeEarnShares, ...allocation }) => ({
3226
+ ...allocation,
3227
+ feeShares: feeEarnShares,
3228
+ })),
3229
+ postFeeValuePerShare: postFeeValuePerEarnShare,
3230
+ preFeeValuePerShare: preFeeValuePerEarnShare,
3231
+ targetValuePerShare: targetValuePerEarnShare,
3232
+ totalFeeShares: totalFeeEarnShares,
3233
+ }
3156
3234
  }
3157
3235
 
3158
3236
  /** Resolves `deposit` parameters into the adapter call args. @internal */
@@ -3278,7 +3356,7 @@ function maximumInput(shareAmount: bigint, slippageBps: number): bigint {
3278
3356
 
3279
3357
  /**
3280
3358
  * Converts an amount to base units, resolving missing decimals with live
3281
- * reads of the vault's asset or share token. Vault share tokens are not
3359
+ * reads of the vault's asset or share token. Earn share tokens are not
3282
3360
  * genesis-declared, so nothing is cached. @internal
3283
3361
  */
3284
3362
  async function toBaseUnitsLive(
@@ -3294,9 +3372,9 @@ async function toBaseUnitsLive(
3294
3372
  if (amount.decimals !== undefined)
3295
3373
  return internal_Token.toBaseUnits(amount, amount.decimals)
3296
3374
  const address = await readContract(client, {
3297
- abi: Abis.vaultAdapter,
3375
+ abi: Abis.earnVault,
3298
3376
  address: vault,
3299
- functionName: token,
3377
+ functionName: token === 'asset' ? 'asset' : 'earnShare',
3300
3378
  })
3301
3379
  const { decimals } = await resolveTokenWithDecimals(client, {
3302
3380
  token: address,