viem 2.55.7 → 2.55.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js +1 -1
- package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
- package/_cjs/actions/public/estimateFeesPerGas.js +1 -1
- package/_cjs/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_cjs/actions/public/fillTransaction.js +1 -1
- package/_cjs/actions/public/fillTransaction.js.map +1 -1
- package/_cjs/chains/definitions/0gMainnet.js +1 -1
- package/_cjs/chains/definitions/0gMainnet.js.map +1 -1
- package/_cjs/chains/definitions/0gTestnet.js +2 -2
- package/_cjs/chains/definitions/0gTestnet.js.map +1 -1
- package/_cjs/chains/definitions/eduChain.js +9 -2
- package/_cjs/chains/definitions/eduChain.js.map +1 -1
- package/_cjs/chains/definitions/eduChainTestnet.js +3 -4
- package/_cjs/chains/definitions/eduChainTestnet.js.map +1 -1
- package/_cjs/chains/definitions/polygonAmoy.js +1 -1
- package/_cjs/chains/definitions/polygonAmoy.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/tempo/Abis.js +918 -543
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +171 -137
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +3 -1
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/zones/Abis.js +6 -0
- package/_cjs/tempo/zones/Abis.js.map +1 -1
- package/_cjs/tempo/zones/Addresses.js +17 -0
- package/_cjs/tempo/zones/Addresses.js.map +1 -0
- package/_cjs/tempo/zones/index.js +2 -2
- package/_cjs/tempo/zones/index.js.map +1 -1
- package/_cjs/tempo/zones/zone.js +30 -16
- package/_cjs/tempo/zones/zone.js.map +1 -1
- package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +1 -1
- package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -1
- package/_esm/actions/public/estimateFeesPerGas.js +1 -1
- package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_esm/actions/public/fillTransaction.js +1 -1
- package/_esm/actions/public/fillTransaction.js.map +1 -1
- package/_esm/chains/definitions/0gMainnet.js +1 -1
- package/_esm/chains/definitions/0gMainnet.js.map +1 -1
- package/_esm/chains/definitions/0gTestnet.js +2 -2
- package/_esm/chains/definitions/0gTestnet.js.map +1 -1
- package/_esm/chains/definitions/eduChain.js +9 -2
- package/_esm/chains/definitions/eduChain.js.map +1 -1
- package/_esm/chains/definitions/eduChainTestnet.js +3 -4
- package/_esm/chains/definitions/eduChainTestnet.js.map +1 -1
- package/_esm/chains/definitions/polygonAmoy.js +1 -1
- package/_esm/chains/definitions/polygonAmoy.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/tempo/Abis.js +919 -544
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Addresses.js +1 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/actions/earn.js +214 -174
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/chainConfig.js +3 -1
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/zones/Abis.js +6 -0
- package/_esm/tempo/zones/Abis.js.map +1 -1
- package/_esm/tempo/zones/Addresses.js +14 -0
- package/_esm/tempo/zones/Addresses.js.map +1 -0
- package/_esm/tempo/zones/index.js +2 -1
- package/_esm/tempo/zones/index.js.map +1 -1
- package/_esm/tempo/zones/zone.js +29 -15
- package/_esm/tempo/zones/zone.js.map +1 -1
- package/_types/chains/definitions/0gMainnet.d.ts +1 -1
- package/_types/chains/definitions/0gTestnet.d.ts +3 -3
- package/_types/chains/definitions/eduChain.d.ts +9 -11
- package/_types/chains/definitions/eduChain.d.ts.map +1 -1
- package/_types/chains/definitions/eduChainTestnet.d.ts +3 -4
- package/_types/chains/definitions/eduChainTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/polygonAmoy.d.ts +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/package.json +1 -0
- package/_types/tempo/Abis.d.ts +1423 -777
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +1 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +21 -15
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/actions/earn.d.ts +850 -1913
- package/_types/tempo/actions/earn.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/zones/Abis.d.ts +20 -0
- package/_types/tempo/zones/Abis.d.ts.map +1 -1
- package/_types/tempo/zones/Addresses.d.ts +13 -0
- package/_types/tempo/zones/Addresses.d.ts.map +1 -0
- package/_types/tempo/zones/index.d.ts +2 -1
- package/_types/tempo/zones/index.d.ts.map +1 -1
- package/_types/tempo/zones/zone.d.ts +14 -33
- package/_types/tempo/zones/zone.d.ts.map +1 -1
- package/account-abstraction/utils/formatters/userOperationRequest.ts +4 -3
- package/actions/public/estimateFeesPerGas.ts +1 -1
- package/actions/public/fillTransaction.ts +1 -1
- package/chains/definitions/0gMainnet.ts +1 -1
- package/chains/definitions/0gTestnet.ts +2 -2
- package/chains/definitions/eduChain.ts +9 -2
- package/chains/definitions/eduChainTestnet.ts +3 -4
- package/chains/definitions/polygonAmoy.ts +1 -1
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Abis.ts +920 -545
- package/tempo/Addresses.ts +1 -0
- package/tempo/Decorator.ts +21 -15
- package/tempo/actions/earn.ts +311 -250
- package/tempo/chainConfig.ts +5 -1
- package/tempo/zones/Abis.ts +6 -0
- package/tempo/zones/Addresses.ts +15 -0
- package/tempo/zones/index.ts +1 -1
- package/tempo/zones/zone.ts +38 -17
package/tempo/actions/earn.ts
CHANGED
|
@@ -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
|
|
73
|
+
/** Admission-only TIP-403 policy attached to an Earn share token. */
|
|
73
74
|
export type ExitSafePolicy = {
|
|
74
|
-
/** Compound policy attached to the
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
|
209
|
+
/** Addresses initially eligible to receive or be minted Earn shares. */
|
|
209
210
|
initialMembers: readonly Address[]
|
|
210
|
-
/** Earn
|
|
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
|
|
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
|
|
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
|
|
341
|
+
/** Addresses that must be eligible to receive or be minted Earn shares. */
|
|
341
342
|
requiredMembers: readonly Address[]
|
|
342
|
-
/** Earn
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
401
|
+
/** Minimum Earn share output to accept; must be greater than zero. */
|
|
401
402
|
shareAmountMin: bigint
|
|
402
403
|
}
|
|
403
404
|
| {
|
|
404
|
-
/** Quoted
|
|
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.
|
|
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.
|
|
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
|
-
/**
|
|
474
|
+
/** Earn share recipient. */
|
|
474
475
|
recipient: Address
|
|
475
476
|
/** Vault address. */
|
|
476
477
|
vault: Address
|
|
477
478
|
} & OneOf<
|
|
478
479
|
| {
|
|
479
|
-
/** Minimum
|
|
480
|
+
/** Minimum Earn share output to accept. */
|
|
480
481
|
shareAmountMin: bigint
|
|
481
482
|
}
|
|
482
483
|
| {
|
|
483
|
-
/** Quoted
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
/**
|
|
641
|
+
/** Earn share recipient. */
|
|
641
642
|
recipient: Address
|
|
642
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
702
|
+
/** Minimum Earn share output to accept; must be greater than zero. */
|
|
702
703
|
earnShareAmountMin: bigint
|
|
703
704
|
}
|
|
704
705
|
| {
|
|
705
|
-
/** Quoted
|
|
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.
|
|
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.
|
|
763
|
-
functionName: '
|
|
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
|
-
/**
|
|
772
|
+
/** Earn share recipient. */
|
|
772
773
|
recipient: Address
|
|
773
774
|
/** Vault address. */
|
|
774
775
|
vault: Address
|
|
775
776
|
} & OneOf<
|
|
776
777
|
| {
|
|
777
|
-
/** Minimum
|
|
778
|
+
/** Minimum Earn share output to accept. */
|
|
778
779
|
earnShareAmountMin: bigint
|
|
779
780
|
}
|
|
780
781
|
| {
|
|
781
|
-
/** Quoted
|
|
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.
|
|
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.
|
|
871
|
+
SimulateContractReturnType<typeof Abis.earnVault, 'depositVenueShares'>
|
|
871
872
|
> {
|
|
872
873
|
return simulateContract(client, {
|
|
873
874
|
...pickWriteParameters(parameters as never),
|
|
@@ -938,13 +939,13 @@ export namespace depositSharesSync {
|
|
|
938
939
|
export type ReturnValue = Compute<{
|
|
939
940
|
/** Depositing caller. */
|
|
940
941
|
caller: Address
|
|
941
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
1000
|
-
*
|
|
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,15 +1018,26 @@ 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, {
|
|
1033
|
+
getZoneGatewayConfig(client, {
|
|
1034
|
+
...readParameters,
|
|
1035
|
+
flow: 0,
|
|
1036
|
+
gateway,
|
|
1037
|
+
vault,
|
|
1038
|
+
zoneId,
|
|
1039
|
+
zonePortal: portalAddress,
|
|
1040
|
+
}),
|
|
1027
1041
|
])
|
|
1028
1042
|
const assetToken = parameters.assetToken ?? config.vaultAsset
|
|
1029
1043
|
const { encrypted, keyIndex } =
|
|
@@ -1036,19 +1050,18 @@ export namespace privateDeposit {
|
|
|
1036
1050
|
})
|
|
1037
1051
|
const shareAmountMin = resolveMinimumShareAmount(parameters)
|
|
1038
1052
|
const direct = isAddressEqual(assetToken, config.vaultAsset)
|
|
1039
|
-
const data = encodeAbiParameters(Abis.
|
|
1053
|
+
const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
|
|
1040
1054
|
{
|
|
1055
|
+
actionId,
|
|
1056
|
+
earnVault: config.vault,
|
|
1041
1057
|
flow: 0,
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
encrypted,
|
|
1058
|
+
minEarnShares: shareAmountMin,
|
|
1059
|
+
minOutputAmount: 0n,
|
|
1045
1060
|
minVaultAssets: direct
|
|
1046
1061
|
? assetAmount
|
|
1047
1062
|
: (parameters.vaultAssetAmountMin ?? 0n),
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
actionId,
|
|
1051
|
-
refundRecipient: recoveryRecipient,
|
|
1063
|
+
outputToken: config.shareToken,
|
|
1064
|
+
zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
|
|
1052
1065
|
},
|
|
1053
1066
|
])
|
|
1054
1067
|
return {
|
|
@@ -1071,9 +1084,9 @@ export namespace privateDeposit {
|
|
|
1071
1084
|
export type Args = PrivatePreparationParameters & {
|
|
1072
1085
|
/** Assets withdrawn from the Zone, base units. */
|
|
1073
1086
|
assetAmount: bigint
|
|
1074
|
-
/** Asset token withdrawn from the Zone. @default
|
|
1087
|
+
/** Asset token withdrawn from the Zone. @default vault asset */
|
|
1075
1088
|
assetToken?: Address | undefined
|
|
1076
|
-
/** Minimum
|
|
1089
|
+
/** Minimum vault assets accepted after swapping `assetToken`. @default `0n` */
|
|
1077
1090
|
vaultAssetAmountMin?: bigint | undefined
|
|
1078
1091
|
} & MinimumShareAmountParameters
|
|
1079
1092
|
export type ReturnValue = PreparedZoneRequest
|
|
@@ -1130,6 +1143,7 @@ export namespace privateDepositSync {
|
|
|
1130
1143
|
* actionId: prepared.actionId,
|
|
1131
1144
|
* fromBlock: prepared.fromBlock,
|
|
1132
1145
|
* gateway: '0x...',
|
|
1146
|
+
* vault: '0x...',
|
|
1133
1147
|
* })
|
|
1134
1148
|
* ```
|
|
1135
1149
|
*
|
|
@@ -1147,15 +1161,17 @@ export async function waitForPrivateDeposit<chain extends Chain | undefined>(
|
|
|
1147
1161
|
gateway,
|
|
1148
1162
|
pollingInterval = client.pollingInterval,
|
|
1149
1163
|
timeout = 60_000,
|
|
1164
|
+
vault,
|
|
1150
1165
|
} = parameters
|
|
1151
1166
|
const event = getAbiItem({
|
|
1152
|
-
abi: Abis.
|
|
1167
|
+
abi: Abis.earnRouter,
|
|
1153
1168
|
name: 'EarnDeposit',
|
|
1154
1169
|
})
|
|
1155
1170
|
const observerId = stringify([
|
|
1156
1171
|
'waitForPrivateDeposit',
|
|
1157
1172
|
client.uid,
|
|
1158
1173
|
gateway,
|
|
1174
|
+
vault,
|
|
1159
1175
|
actionId,
|
|
1160
1176
|
fromBlock,
|
|
1161
1177
|
])
|
|
@@ -1186,7 +1202,7 @@ export async function waitForPrivateDeposit<chain extends Chain | undefined>(
|
|
|
1186
1202
|
try {
|
|
1187
1203
|
const [log] = await getLogs(client, {
|
|
1188
1204
|
address: gateway,
|
|
1189
|
-
args: { actionId },
|
|
1205
|
+
args: { actionId, earnVault: vault },
|
|
1190
1206
|
event,
|
|
1191
1207
|
fromBlock,
|
|
1192
1208
|
strict: true,
|
|
@@ -1198,7 +1214,7 @@ export async function waitForPrivateDeposit<chain extends Chain | undefined>(
|
|
|
1198
1214
|
actionId: log.args.actionId,
|
|
1199
1215
|
inputAmount: log.args.inputAmount,
|
|
1200
1216
|
inputToken: log.args.inputToken,
|
|
1201
|
-
shares: log.args.
|
|
1217
|
+
shares: log.args.earnShares,
|
|
1202
1218
|
tempoBlockNumber: log.blockNumber,
|
|
1203
1219
|
vaultAssets: log.args.vaultAssets,
|
|
1204
1220
|
zoneDepositHash: log.args.zoneDepositHash,
|
|
@@ -1236,6 +1252,8 @@ export namespace waitForPrivateDeposit {
|
|
|
1236
1252
|
pollingInterval?: number | undefined
|
|
1237
1253
|
/** Timeout in milliseconds; `0` disables it. @default `60_000` */
|
|
1238
1254
|
timeout?: number | undefined
|
|
1255
|
+
/** Vault address. */
|
|
1256
|
+
vault: Address
|
|
1239
1257
|
}
|
|
1240
1258
|
export type ReturnType = {
|
|
1241
1259
|
/** Correlation id for the completed deposit. */
|
|
@@ -1244,7 +1262,7 @@ export namespace waitForPrivateDeposit {
|
|
|
1244
1262
|
inputAmount: bigint
|
|
1245
1263
|
/** Token delivered to the gateway. */
|
|
1246
1264
|
inputToken: Address
|
|
1247
|
-
/**
|
|
1265
|
+
/** Earn shares returned to the Zone. */
|
|
1248
1266
|
shares: bigint
|
|
1249
1267
|
/** Parent-chain block containing the gateway event. */
|
|
1250
1268
|
tempoBlockNumber: bigint
|
|
@@ -1289,30 +1307,36 @@ export async function getFeeState<chain extends Chain | undefined>(
|
|
|
1289
1307
|
parameters: getFeeState.Parameters,
|
|
1290
1308
|
): Promise<getFeeState.ReturnValue> {
|
|
1291
1309
|
const { recipient, vault, ...rest } = parameters
|
|
1310
|
+
const fees = await readContract(client, {
|
|
1311
|
+
...rest,
|
|
1312
|
+
abi: Abis.earnVault,
|
|
1313
|
+
address: vault,
|
|
1314
|
+
functionName: 'earnFees',
|
|
1315
|
+
})
|
|
1292
1316
|
const contracts = [
|
|
1293
1317
|
defineCall({
|
|
1294
|
-
address:
|
|
1295
|
-
abi: Abis.
|
|
1318
|
+
address: fees,
|
|
1319
|
+
abi: Abis.earnFees,
|
|
1296
1320
|
functionName: 'currentFeeConfigId',
|
|
1297
1321
|
}),
|
|
1298
1322
|
defineCall({
|
|
1299
|
-
address:
|
|
1300
|
-
abi: Abis.
|
|
1323
|
+
address: fees,
|
|
1324
|
+
abi: Abis.earnFees,
|
|
1301
1325
|
functionName: 'feesActive',
|
|
1302
1326
|
}),
|
|
1303
1327
|
defineCall({
|
|
1304
|
-
address:
|
|
1305
|
-
abi: Abis.
|
|
1328
|
+
address: fees,
|
|
1329
|
+
abi: Abis.earnFees,
|
|
1306
1330
|
functionName: 'highWaterMark',
|
|
1307
1331
|
}),
|
|
1308
1332
|
defineCall({
|
|
1309
|
-
address:
|
|
1310
|
-
abi: Abis.
|
|
1333
|
+
address: fees,
|
|
1334
|
+
abi: Abis.earnFees,
|
|
1311
1335
|
functionName: 'previewAccruedFees',
|
|
1312
1336
|
}),
|
|
1313
1337
|
defineCall({
|
|
1314
|
-
address:
|
|
1315
|
-
abi: Abis.
|
|
1338
|
+
address: fees,
|
|
1339
|
+
abi: Abis.earnFees,
|
|
1316
1340
|
functionName: 'targetBase',
|
|
1317
1341
|
}),
|
|
1318
1342
|
] as const
|
|
@@ -1322,8 +1346,8 @@ export async function getFeeState<chain extends Chain | undefined>(
|
|
|
1322
1346
|
toFeeConfig(
|
|
1323
1347
|
await readContract(client, {
|
|
1324
1348
|
...rest,
|
|
1325
|
-
abi: Abis.
|
|
1326
|
-
address:
|
|
1349
|
+
abi: Abis.earnFees,
|
|
1350
|
+
address: fees,
|
|
1327
1351
|
functionName: 'feeConfig',
|
|
1328
1352
|
args: [configId],
|
|
1329
1353
|
}),
|
|
@@ -1336,9 +1360,9 @@ export async function getFeeState<chain extends Chain | undefined>(
|
|
|
1336
1360
|
contracts: [
|
|
1337
1361
|
...contracts,
|
|
1338
1362
|
defineCall({
|
|
1339
|
-
address:
|
|
1340
|
-
abi: Abis.
|
|
1341
|
-
functionName: '
|
|
1363
|
+
address: fees,
|
|
1364
|
+
abi: Abis.earnFees,
|
|
1365
|
+
functionName: 'claimableEarnShares',
|
|
1342
1366
|
args: [recipient],
|
|
1343
1367
|
}),
|
|
1344
1368
|
],
|
|
@@ -1373,7 +1397,7 @@ export async function getFeeState<chain extends Chain | undefined>(
|
|
|
1373
1397
|
|
|
1374
1398
|
export namespace getFeeState {
|
|
1375
1399
|
export type Args = {
|
|
1376
|
-
/** Optional fee recipient whose claimable
|
|
1400
|
+
/** Optional fee recipient whose claimable Earn shares are included. */
|
|
1377
1401
|
recipient?: Address | undefined
|
|
1378
1402
|
/** Vault address. */
|
|
1379
1403
|
vault: Address
|
|
@@ -1388,11 +1412,11 @@ export namespace getFeeState {
|
|
|
1388
1412
|
configId: bigint
|
|
1389
1413
|
/** Whether fees are configured and not emergency-disabled. */
|
|
1390
1414
|
feesActive: boolean
|
|
1391
|
-
/** Post-fee high-water mark per
|
|
1415
|
+
/** Post-fee high-water mark per Earn share. */
|
|
1392
1416
|
highWaterMark: bigint
|
|
1393
1417
|
/** Pending fee amounts. */
|
|
1394
1418
|
preview: FeePreview
|
|
1395
|
-
/** Excess-return fee target per
|
|
1419
|
+
/** Excess-return fee target per Earn share. */
|
|
1396
1420
|
targetBase: bigint
|
|
1397
1421
|
}
|
|
1398
1422
|
// TODO: exhaustive error type
|
|
@@ -1418,9 +1442,9 @@ export type FeeConfig = {
|
|
|
1418
1442
|
|
|
1419
1443
|
/** Pending vault fee amounts. */
|
|
1420
1444
|
export type FeePreview = {
|
|
1421
|
-
/** Assets backing active
|
|
1445
|
+
/** Assets backing active Earn shares. */
|
|
1422
1446
|
activeAssets: bigint
|
|
1423
|
-
/** Fee allocations in assets and
|
|
1447
|
+
/** Fee allocations in assets and Earn shares. */
|
|
1424
1448
|
allocations: readonly {
|
|
1425
1449
|
account: Address
|
|
1426
1450
|
feeAssets: bigint
|
|
@@ -1432,20 +1456,20 @@ export type FeePreview = {
|
|
|
1432
1456
|
fixedFeeAssets: bigint
|
|
1433
1457
|
/** Accrual above the high-water mark, asset units. */
|
|
1434
1458
|
positiveAccrualAssets: bigint
|
|
1435
|
-
/** Scaled asset value per
|
|
1459
|
+
/** Scaled asset value per Earn share after fees. */
|
|
1436
1460
|
postFeeValuePerShare: bigint
|
|
1437
|
-
/** Scaled asset value per
|
|
1461
|
+
/** Scaled asset value per Earn share before fees. */
|
|
1438
1462
|
preFeeValuePerShare: bigint
|
|
1439
|
-
/** Scaled excess-fee target per
|
|
1463
|
+
/** Scaled excess-fee target per Earn share. */
|
|
1440
1464
|
targetValuePerShare: bigint
|
|
1441
1465
|
/** Total fee liability, asset units. */
|
|
1442
1466
|
totalFeeAssets: bigint
|
|
1443
|
-
/**
|
|
1467
|
+
/** Earn shares minted to cover the total fee. */
|
|
1444
1468
|
totalFeeShares: bigint
|
|
1445
1469
|
}
|
|
1446
1470
|
|
|
1447
1471
|
/**
|
|
1448
|
-
* Gets an account's asset and
|
|
1472
|
+
* Gets an account's asset and Earn share balances, allowances, and current
|
|
1449
1473
|
* share value. The value includes fees.
|
|
1450
1474
|
*
|
|
1451
1475
|
* @example
|
|
@@ -1467,7 +1491,7 @@ export type FeePreview = {
|
|
|
1467
1491
|
*
|
|
1468
1492
|
* @param client - Client.
|
|
1469
1493
|
* @param parameters - Parameters.
|
|
1470
|
-
* @returns The asset and
|
|
1494
|
+
* @returns The asset and Earn share balances, allowances, and value.
|
|
1471
1495
|
*/
|
|
1472
1496
|
export async function getPosition<
|
|
1473
1497
|
chain extends Chain | undefined,
|
|
@@ -1485,13 +1509,13 @@ export async function getPosition<
|
|
|
1485
1509
|
contracts: [
|
|
1486
1510
|
defineCall({
|
|
1487
1511
|
address: vault,
|
|
1488
|
-
abi: Abis.
|
|
1512
|
+
abi: Abis.earnVault,
|
|
1489
1513
|
functionName: 'asset',
|
|
1490
1514
|
}),
|
|
1491
1515
|
defineCall({
|
|
1492
1516
|
address: vault,
|
|
1493
|
-
abi: Abis.
|
|
1494
|
-
functionName: '
|
|
1517
|
+
abi: Abis.earnVault,
|
|
1518
|
+
functionName: 'earnShare',
|
|
1495
1519
|
}),
|
|
1496
1520
|
],
|
|
1497
1521
|
deployless: true,
|
|
@@ -1530,7 +1554,7 @@ export async function getPosition<
|
|
|
1530
1554
|
})
|
|
1531
1555
|
const value = await readContract(client, {
|
|
1532
1556
|
...rest,
|
|
1533
|
-
abi: Abis.
|
|
1557
|
+
abi: Abis.earnVault,
|
|
1534
1558
|
address: vault,
|
|
1535
1559
|
args: [shareBalance],
|
|
1536
1560
|
functionName: 'previewRedeem',
|
|
@@ -1562,13 +1586,13 @@ export namespace getPosition {
|
|
|
1562
1586
|
assetBalance: bigint
|
|
1563
1587
|
/** Token accepted by the vault. */
|
|
1564
1588
|
assetToken: Address
|
|
1565
|
-
/**
|
|
1589
|
+
/** Earn shares the vault may spend from the account. */
|
|
1566
1590
|
shareAllowance: bigint
|
|
1567
|
-
/**
|
|
1591
|
+
/** Earn share balance held by the account. */
|
|
1568
1592
|
shareBalance: bigint
|
|
1569
|
-
/** Token representing
|
|
1593
|
+
/** Token representing Earn shares. */
|
|
1570
1594
|
shareToken: Address
|
|
1571
|
-
/** Current asset value of the
|
|
1595
|
+
/** Current asset value of the Earn share balance, including fees. */
|
|
1572
1596
|
value: bigint
|
|
1573
1597
|
}
|
|
1574
1598
|
// TODO: exhaustive error type
|
|
@@ -1576,7 +1600,7 @@ export namespace getPosition {
|
|
|
1576
1600
|
}
|
|
1577
1601
|
|
|
1578
1602
|
/**
|
|
1579
|
-
* Gets the asset output for an exact
|
|
1603
|
+
* Gets the asset output for an exact Earn share input, including fees.
|
|
1580
1604
|
*
|
|
1581
1605
|
* @example
|
|
1582
1606
|
* ```ts
|
|
@@ -1612,7 +1636,7 @@ export async function getRedeemQuote<chain extends Chain | undefined>(
|
|
|
1612
1636
|
|
|
1613
1637
|
export namespace getRedeemQuote {
|
|
1614
1638
|
export type Args = {
|
|
1615
|
-
/** Exact
|
|
1639
|
+
/** Exact Earn share input, base units. */
|
|
1616
1640
|
shareAmount: bigint
|
|
1617
1641
|
/** Vault address. */
|
|
1618
1642
|
vault: Address
|
|
@@ -1620,7 +1644,7 @@ export namespace getRedeemQuote {
|
|
|
1620
1644
|
export type Parameters = Omit<ReadParameters, 'account'> & Args
|
|
1621
1645
|
/** Asset output, including fees. */
|
|
1622
1646
|
export type ReturnValue = ReadContractReturnType<
|
|
1623
|
-
typeof Abis.
|
|
1647
|
+
typeof Abis.earnVault,
|
|
1624
1648
|
'previewRedeem',
|
|
1625
1649
|
never
|
|
1626
1650
|
>
|
|
@@ -1652,7 +1676,7 @@ export namespace getRedeemQuote {
|
|
|
1652
1676
|
const { shareAmount, vault } = args
|
|
1653
1677
|
return defineCall({
|
|
1654
1678
|
address: vault,
|
|
1655
|
-
abi: Abis.
|
|
1679
|
+
abi: Abis.earnVault,
|
|
1656
1680
|
args: [shareAmount],
|
|
1657
1681
|
functionName: 'previewRedeem',
|
|
1658
1682
|
})
|
|
@@ -1688,12 +1712,20 @@ export async function getVault<chain extends Chain | undefined>(
|
|
|
1688
1712
|
parameters: getVault.Parameters,
|
|
1689
1713
|
): Promise<getVault.ReturnValue> {
|
|
1690
1714
|
const { vault, ...rest } = parameters
|
|
1691
|
-
const engine = await
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1715
|
+
const [engine, fees] = await Promise.all([
|
|
1716
|
+
readContract(client, {
|
|
1717
|
+
...rest,
|
|
1718
|
+
abi: Abis.earnVault,
|
|
1719
|
+
address: vault,
|
|
1720
|
+
functionName: 'engine',
|
|
1721
|
+
}),
|
|
1722
|
+
readContract(client, {
|
|
1723
|
+
...rest,
|
|
1724
|
+
abi: Abis.earnVault,
|
|
1725
|
+
address: vault,
|
|
1726
|
+
functionName: 'earnFees',
|
|
1727
|
+
}),
|
|
1728
|
+
])
|
|
1697
1729
|
const [
|
|
1698
1730
|
assetToken,
|
|
1699
1731
|
engine_,
|
|
@@ -1718,7 +1750,7 @@ export async function getVault<chain extends Chain | undefined>(
|
|
|
1718
1750
|
] = await multicall(client, {
|
|
1719
1751
|
...rest,
|
|
1720
1752
|
allowFailure: false,
|
|
1721
|
-
contracts: getVault.calls({ engine, vault }),
|
|
1753
|
+
contracts: getVault.calls({ engine, fees, vault }),
|
|
1722
1754
|
deployless: true,
|
|
1723
1755
|
})
|
|
1724
1756
|
if (!isAddressEqual(engine, engine_))
|
|
@@ -1786,131 +1818,131 @@ export namespace getVault {
|
|
|
1786
1818
|
engineShares: bigint
|
|
1787
1819
|
/** Whether fees are configured and not emergency-disabled. */
|
|
1788
1820
|
feesActive: boolean
|
|
1789
|
-
/** Whether
|
|
1821
|
+
/** Whether Earn share supply matches its asset backing. */
|
|
1790
1822
|
isSynced: boolean
|
|
1791
1823
|
/** Vault governance address. */
|
|
1792
1824
|
operator: Address
|
|
1793
1825
|
/** Open queued redemptions. */
|
|
1794
1826
|
pendingRedeemCount: bigint
|
|
1795
|
-
/** Active
|
|
1827
|
+
/** Active Earn share supply. */
|
|
1796
1828
|
shareSupply: bigint
|
|
1797
|
-
/** Token representing
|
|
1829
|
+
/** Token representing Earn shares. */
|
|
1798
1830
|
shareToken: Address
|
|
1799
1831
|
}
|
|
1800
1832
|
// TODO: exhaustive error type
|
|
1801
1833
|
export type ErrorType = GetVaultEngineChangedErrorType | BaseErrorType
|
|
1802
1834
|
|
|
1803
1835
|
/**
|
|
1804
|
-
* Defines the reads used by {@link getVault}. Pass the
|
|
1805
|
-
*
|
|
1836
|
+
* Defines the reads used by {@link getVault}. Pass the current engine and
|
|
1837
|
+
* fee contract addresses.
|
|
1806
1838
|
*
|
|
1807
1839
|
* @param args - Arguments.
|
|
1808
1840
|
* @returns The calls.
|
|
1809
1841
|
*/
|
|
1810
|
-
export function calls(args: Args & { engine: Address }) {
|
|
1811
|
-
const { engine, vault } = args
|
|
1842
|
+
export function calls(args: Args & { engine: Address; fees: Address }) {
|
|
1843
|
+
const { engine, fees, vault } = args
|
|
1812
1844
|
return [
|
|
1813
1845
|
defineCall({
|
|
1814
1846
|
address: vault,
|
|
1815
|
-
abi: Abis.
|
|
1847
|
+
abi: Abis.earnVault,
|
|
1816
1848
|
functionName: 'asset',
|
|
1817
1849
|
}),
|
|
1818
1850
|
defineCall({
|
|
1819
1851
|
address: vault,
|
|
1820
|
-
abi: Abis.
|
|
1852
|
+
abi: Abis.earnVault,
|
|
1821
1853
|
functionName: 'engine',
|
|
1822
1854
|
}),
|
|
1823
1855
|
defineCall({
|
|
1824
1856
|
address: vault,
|
|
1825
|
-
abi: Abis.
|
|
1826
|
-
functionName: '
|
|
1857
|
+
abi: Abis.earnVault,
|
|
1858
|
+
functionName: 'earnShare',
|
|
1827
1859
|
}),
|
|
1828
1860
|
defineCall({
|
|
1829
1861
|
address: vault,
|
|
1830
|
-
abi: Abis.
|
|
1862
|
+
abi: Abis.earnVault,
|
|
1831
1863
|
functionName: 'operator',
|
|
1832
1864
|
}),
|
|
1833
1865
|
defineCall({
|
|
1834
1866
|
address: vault,
|
|
1835
|
-
abi: Abis.
|
|
1867
|
+
abi: Abis.earnVault,
|
|
1836
1868
|
functionName: 'emergencyGuardian',
|
|
1837
1869
|
}),
|
|
1838
1870
|
defineCall({
|
|
1839
1871
|
address: vault,
|
|
1840
|
-
abi: Abis.
|
|
1872
|
+
abi: Abis.earnVault,
|
|
1841
1873
|
functionName: 'asyncJanitor',
|
|
1842
1874
|
}),
|
|
1843
1875
|
defineCall({
|
|
1844
1876
|
address: vault,
|
|
1845
|
-
abi: Abis.
|
|
1877
|
+
abi: Abis.earnVault,
|
|
1846
1878
|
functionName: 'engineMigrationMode',
|
|
1847
1879
|
}),
|
|
1848
1880
|
defineCall({
|
|
1849
1881
|
address: vault,
|
|
1850
|
-
abi: Abis.
|
|
1882
|
+
abi: Abis.earnVault,
|
|
1851
1883
|
functionName: 'depositsPaused',
|
|
1852
1884
|
}),
|
|
1853
1885
|
defineCall({
|
|
1854
1886
|
address: vault,
|
|
1855
|
-
abi: Abis.
|
|
1887
|
+
abi: Abis.earnVault,
|
|
1856
1888
|
functionName: 'engineShares',
|
|
1857
1889
|
}),
|
|
1858
1890
|
defineCall({
|
|
1859
1891
|
address: vault,
|
|
1860
|
-
abi: Abis.
|
|
1861
|
-
functionName: '
|
|
1892
|
+
abi: Abis.earnVault,
|
|
1893
|
+
functionName: 'totalEarnShares',
|
|
1862
1894
|
}),
|
|
1863
1895
|
defineCall({
|
|
1864
1896
|
address: vault,
|
|
1865
|
-
abi: Abis.
|
|
1866
|
-
functionName: '
|
|
1897
|
+
abi: Abis.earnVault,
|
|
1898
|
+
functionName: 'isAccountingAligned',
|
|
1867
1899
|
}),
|
|
1868
1900
|
defineCall({
|
|
1869
1901
|
address: vault,
|
|
1870
|
-
abi: Abis.
|
|
1871
|
-
functionName: '
|
|
1902
|
+
abi: Abis.earnVault,
|
|
1903
|
+
functionName: 'openRedeemRequestCount',
|
|
1872
1904
|
}),
|
|
1873
1905
|
defineCall({
|
|
1874
|
-
address:
|
|
1875
|
-
abi: Abis.
|
|
1906
|
+
address: fees,
|
|
1907
|
+
abi: Abis.earnFees,
|
|
1876
1908
|
functionName: 'feesActive',
|
|
1877
1909
|
}),
|
|
1878
1910
|
defineCall({
|
|
1879
1911
|
address: engine,
|
|
1880
|
-
abi: Abis.
|
|
1912
|
+
abi: Abis.earnEngine,
|
|
1881
1913
|
functionName: 'totalAssets',
|
|
1882
1914
|
}),
|
|
1883
1915
|
defineCall({
|
|
1884
1916
|
address: engine,
|
|
1885
|
-
abi: Abis.
|
|
1917
|
+
abi: Abis.earnEngine,
|
|
1886
1918
|
functionName: 'name',
|
|
1887
1919
|
}),
|
|
1888
1920
|
defineCall({
|
|
1889
1921
|
address: engine,
|
|
1890
|
-
abi: Abis.
|
|
1922
|
+
abi: Abis.earnEngine,
|
|
1891
1923
|
functionName: 'symbol',
|
|
1892
1924
|
}),
|
|
1893
1925
|
defineCall({
|
|
1894
1926
|
address: engine,
|
|
1895
|
-
abi: Abis.
|
|
1927
|
+
abi: Abis.earnEngine,
|
|
1896
1928
|
functionName: 'supportsInterface',
|
|
1897
1929
|
args: [interfaceIds.asyncRedeem],
|
|
1898
1930
|
}),
|
|
1899
1931
|
defineCall({
|
|
1900
1932
|
address: engine,
|
|
1901
|
-
abi: Abis.
|
|
1933
|
+
abi: Abis.earnEngine,
|
|
1902
1934
|
functionName: 'supportsInterface',
|
|
1903
1935
|
args: [interfaceIds.exactWithdraw],
|
|
1904
1936
|
}),
|
|
1905
1937
|
defineCall({
|
|
1906
1938
|
address: engine,
|
|
1907
|
-
abi: Abis.
|
|
1939
|
+
abi: Abis.earnEngine,
|
|
1908
1940
|
functionName: 'supportsInterface',
|
|
1909
1941
|
args: [interfaceIds.inKindDeposit],
|
|
1910
1942
|
}),
|
|
1911
1943
|
defineCall({
|
|
1912
1944
|
address: engine,
|
|
1913
|
-
abi: Abis.
|
|
1945
|
+
abi: Abis.earnEngine,
|
|
1914
1946
|
functionName: 'supportsInterface',
|
|
1915
1947
|
args: [interfaceIds.syncRedeem],
|
|
1916
1948
|
}),
|
|
@@ -1919,7 +1951,7 @@ export namespace getVault {
|
|
|
1919
1951
|
}
|
|
1920
1952
|
|
|
1921
1953
|
/**
|
|
1922
|
-
* Gets the
|
|
1954
|
+
* Gets the Earn shares required for an exact asset output, including fees
|
|
1923
1955
|
* and ceiling rounding.
|
|
1924
1956
|
*
|
|
1925
1957
|
* @example
|
|
@@ -1941,7 +1973,7 @@ export namespace getVault {
|
|
|
1941
1973
|
*
|
|
1942
1974
|
* @param client - Client.
|
|
1943
1975
|
* @param parameters - Parameters.
|
|
1944
|
-
* @returns The required
|
|
1976
|
+
* @returns The required Earn share input, ceiling-rounded.
|
|
1945
1977
|
*/
|
|
1946
1978
|
export async function getWithdrawQuote<chain extends Chain | undefined>(
|
|
1947
1979
|
client: Client<Transport, chain>,
|
|
@@ -1962,9 +1994,9 @@ export namespace getWithdrawQuote {
|
|
|
1962
1994
|
vault: Address
|
|
1963
1995
|
}
|
|
1964
1996
|
export type Parameters = Omit<ReadParameters, 'account'> & Args
|
|
1965
|
-
/** Required
|
|
1997
|
+
/** Required Earn share input, ceiling-rounded. */
|
|
1966
1998
|
export type ReturnValue = ReadContractReturnType<
|
|
1967
|
-
typeof Abis.
|
|
1999
|
+
typeof Abis.earnVault,
|
|
1968
2000
|
'previewWithdraw',
|
|
1969
2001
|
never
|
|
1970
2002
|
>
|
|
@@ -1996,7 +2028,7 @@ export namespace getWithdrawQuote {
|
|
|
1996
2028
|
const { assetAmount, vault } = args
|
|
1997
2029
|
return defineCall({
|
|
1998
2030
|
address: vault,
|
|
1999
|
-
abi: Abis.
|
|
2031
|
+
abi: Abis.earnVault,
|
|
2000
2032
|
args: [assetAmount],
|
|
2001
2033
|
functionName: 'previewWithdraw',
|
|
2002
2034
|
})
|
|
@@ -2004,8 +2036,8 @@ export namespace getWithdrawQuote {
|
|
|
2004
2036
|
}
|
|
2005
2037
|
|
|
2006
2038
|
/**
|
|
2007
|
-
* Redeems
|
|
2008
|
-
* includes the required
|
|
2039
|
+
* Redeems Earn shares for assets sent to `recipient`. The transaction
|
|
2040
|
+
* includes the required Earn share approval.
|
|
2009
2041
|
*
|
|
2010
2042
|
* @example
|
|
2011
2043
|
* ```ts
|
|
@@ -2043,7 +2075,7 @@ export async function redeem<
|
|
|
2043
2075
|
|
|
2044
2076
|
export namespace redeem {
|
|
2045
2077
|
export type Args = {
|
|
2046
|
-
/**
|
|
2078
|
+
/** Earn shares to redeem; base units or `{ formatted, decimals? }`. */
|
|
2047
2079
|
shareAmount: internal_Token.AmountInput
|
|
2048
2080
|
/** Asset recipient. @default `account.address` */
|
|
2049
2081
|
recipient?: Address | undefined
|
|
@@ -2073,7 +2105,7 @@ export namespace redeem {
|
|
|
2073
2105
|
// TODO: exhaustive error type
|
|
2074
2106
|
export type ErrorType = BaseErrorType
|
|
2075
2107
|
|
|
2076
|
-
/** @internal Shared dispatch; reads the
|
|
2108
|
+
/** @internal Shared dispatch; reads the Earn share token for the approval. */
|
|
2077
2109
|
export async function inner<
|
|
2078
2110
|
action extends typeof sendTransaction | typeof sendTransactionSync,
|
|
2079
2111
|
chain extends Chain | undefined,
|
|
@@ -2086,9 +2118,9 @@ export namespace redeem {
|
|
|
2086
2118
|
const [args, shareToken] = await Promise.all([
|
|
2087
2119
|
toRedeemArgs(client, parameters as never),
|
|
2088
2120
|
readContract(client, {
|
|
2089
|
-
abi: Abis.
|
|
2121
|
+
abi: Abis.earnVault,
|
|
2090
2122
|
address: parameters.vault,
|
|
2091
|
-
functionName: '
|
|
2123
|
+
functionName: 'earnShare',
|
|
2092
2124
|
}),
|
|
2093
2125
|
])
|
|
2094
2126
|
return (await action(client, {
|
|
@@ -2098,7 +2130,7 @@ export namespace redeem {
|
|
|
2098
2130
|
}
|
|
2099
2131
|
|
|
2100
2132
|
/**
|
|
2101
|
-
* Defines a redeem call without an approval. Provide
|
|
2133
|
+
* Defines a redeem call without an approval. Provide Earn share decimals
|
|
2102
2134
|
* for formatted inputs and an explicit output bound because this builder performs no reads.
|
|
2103
2135
|
*
|
|
2104
2136
|
* @param parameters - Client (optional), followed by the call arguments.
|
|
@@ -2115,7 +2147,7 @@ export namespace redeem {
|
|
|
2115
2147
|
})()
|
|
2116
2148
|
return defineCall({
|
|
2117
2149
|
address: vault,
|
|
2118
|
-
abi: Abis.
|
|
2150
|
+
abi: Abis.earnVault,
|
|
2119
2151
|
functionName: 'redeem',
|
|
2120
2152
|
args: [
|
|
2121
2153
|
internal_Token.toBaseUnits(args.shareAmount, undefined),
|
|
@@ -2126,7 +2158,7 @@ export namespace redeem {
|
|
|
2126
2158
|
}
|
|
2127
2159
|
export namespace call {
|
|
2128
2160
|
export type Args = {
|
|
2129
|
-
/**
|
|
2161
|
+
/** Earn shares to redeem; base units or `{ formatted, decimals? }`. */
|
|
2130
2162
|
shareAmount: internal_Token.AmountInput
|
|
2131
2163
|
/** Asset recipient. */
|
|
2132
2164
|
recipient: Address
|
|
@@ -2147,7 +2179,7 @@ export namespace redeem {
|
|
|
2147
2179
|
}
|
|
2148
2180
|
|
|
2149
2181
|
/**
|
|
2150
|
-
* Defines the
|
|
2182
|
+
* Defines the Earn share approval and redeem calls for atomic execution.
|
|
2151
2183
|
* Pass `shareToken` explicitly because this builder performs no reads.
|
|
2152
2184
|
*
|
|
2153
2185
|
* @param args - Arguments.
|
|
@@ -2155,7 +2187,7 @@ export namespace redeem {
|
|
|
2155
2187
|
*/
|
|
2156
2188
|
export function calls(
|
|
2157
2189
|
args: call.Args & {
|
|
2158
|
-
/**
|
|
2190
|
+
/** Earn share token approved for the redemption. */
|
|
2159
2191
|
shareToken: Address
|
|
2160
2192
|
},
|
|
2161
2193
|
) {
|
|
@@ -2184,7 +2216,7 @@ export namespace redeem {
|
|
|
2184
2216
|
// Earn contracts are user-deployed: several adapters can emit the same
|
|
2185
2217
|
// signature in one receipt, so filter by emitting address before decode.
|
|
2186
2218
|
const [log] = parseEventLogs({
|
|
2187
|
-
abi: Abis.
|
|
2219
|
+
abi: Abis.earnVault,
|
|
2188
2220
|
eventName: 'Redeemed',
|
|
2189
2221
|
logs: logs.filter((log) => isAddressEqual(log.address, vault)),
|
|
2190
2222
|
})
|
|
@@ -2193,7 +2225,7 @@ export namespace redeem {
|
|
|
2193
2225
|
}
|
|
2194
2226
|
|
|
2195
2227
|
/**
|
|
2196
|
-
* Estimates gas for a redemption, assuming enough
|
|
2228
|
+
* Estimates gas for a redemption, assuming enough Earn share allowance.
|
|
2197
2229
|
*
|
|
2198
2230
|
* @param client - Client.
|
|
2199
2231
|
* @param parameters - Parameters.
|
|
@@ -2213,7 +2245,7 @@ export namespace redeem {
|
|
|
2213
2245
|
}
|
|
2214
2246
|
|
|
2215
2247
|
/**
|
|
2216
|
-
* Simulates a redemption, assuming enough
|
|
2248
|
+
* Simulates a redemption, assuming enough Earn share allowance.
|
|
2217
2249
|
*
|
|
2218
2250
|
* @param client - Client.
|
|
2219
2251
|
* @param parameters - Parameters.
|
|
@@ -2225,7 +2257,7 @@ export namespace redeem {
|
|
|
2225
2257
|
>(
|
|
2226
2258
|
client: Client<Transport, chain, account>,
|
|
2227
2259
|
parameters: redeem.Parameters<chain, account>,
|
|
2228
|
-
): Promise<SimulateContractReturnType<typeof Abis.
|
|
2260
|
+
): Promise<SimulateContractReturnType<typeof Abis.earnVault, 'redeem'>> {
|
|
2229
2261
|
return simulateContract(client, {
|
|
2230
2262
|
...pickWriteParameters(parameters as never),
|
|
2231
2263
|
...redeem.call(await toRedeemArgs(client, parameters as never)),
|
|
@@ -2234,7 +2266,7 @@ export namespace redeem {
|
|
|
2234
2266
|
}
|
|
2235
2267
|
|
|
2236
2268
|
/**
|
|
2237
|
-
* Redeems
|
|
2269
|
+
* Redeems Earn shares and returns the confirmed receipt and event data.
|
|
2238
2270
|
*
|
|
2239
2271
|
* @example
|
|
2240
2272
|
* ```ts
|
|
@@ -2278,7 +2310,7 @@ export async function redeemSync<
|
|
|
2278
2310
|
caller: args.caller,
|
|
2279
2311
|
receipt,
|
|
2280
2312
|
recipient: args.receiver,
|
|
2281
|
-
shareAmount: args.
|
|
2313
|
+
shareAmount: args.earnShares,
|
|
2282
2314
|
}
|
|
2283
2315
|
}
|
|
2284
2316
|
|
|
@@ -2297,7 +2329,7 @@ export namespace redeemSync {
|
|
|
2297
2329
|
receipt: TransactionReceipt
|
|
2298
2330
|
/** Asset recipient. */
|
|
2299
2331
|
recipient: Address
|
|
2300
|
-
/**
|
|
2332
|
+
/** Earn shares burned. */
|
|
2301
2333
|
shareAmount: bigint
|
|
2302
2334
|
}>
|
|
2303
2335
|
// TODO: exhaustive error type
|
|
@@ -2305,7 +2337,7 @@ export namespace redeemSync {
|
|
|
2305
2337
|
}
|
|
2306
2338
|
|
|
2307
2339
|
/**
|
|
2308
|
-
* Withdraws
|
|
2340
|
+
* Withdraws Earn shares from a Zone and redeems them on the parent chain. Use
|
|
2309
2341
|
* {@link privateRedeem.prepare} to build the encrypted callback.
|
|
2310
2342
|
*
|
|
2311
2343
|
* @example
|
|
@@ -2316,6 +2348,8 @@ export namespace redeemSync {
|
|
|
2316
2348
|
* recoveryRecipient: '0x...',
|
|
2317
2349
|
* shareAmount: 100_000_000n,
|
|
2318
2350
|
* slippageBps: 50,
|
|
2351
|
+
* vault: '0x...',
|
|
2352
|
+
* zoneId: 7,
|
|
2319
2353
|
* })
|
|
2320
2354
|
* const hash = await Actions.earn.privateRedeem(zoneClient, prepared)
|
|
2321
2355
|
* ```
|
|
@@ -2345,7 +2379,7 @@ export namespace privateRedeem {
|
|
|
2345
2379
|
export type ErrorType = zoneActions.requestWithdrawal.ErrorType
|
|
2346
2380
|
|
|
2347
2381
|
/**
|
|
2348
|
-
* Builds an encrypted Zone withdrawal that redeems
|
|
2382
|
+
* Builds an encrypted Zone withdrawal that redeems Earn shares and returns
|
|
2349
2383
|
* the resulting assets to the Zone.
|
|
2350
2384
|
*
|
|
2351
2385
|
* @param client - Parent-chain client.
|
|
@@ -2363,20 +2397,31 @@ export namespace privateRedeem {
|
|
|
2363
2397
|
callbackGas = zoneGatewayCallbackGas,
|
|
2364
2398
|
fallbackRecipient = parameters.recoveryRecipient,
|
|
2365
2399
|
gateway,
|
|
2400
|
+
portalAddress: portalAddress_,
|
|
2366
2401
|
recipient,
|
|
2367
2402
|
recoveryRecipient,
|
|
2368
2403
|
returnMemo,
|
|
2369
2404
|
shareAmount,
|
|
2405
|
+
vault,
|
|
2370
2406
|
withdrawalMemo,
|
|
2407
|
+
zoneId,
|
|
2371
2408
|
} = parameters
|
|
2409
|
+
const portalAddress = portalAddress_ ?? getPortalAddress(chainId, zoneId)
|
|
2372
2410
|
const readParameters = pickReadParameters(parameters)
|
|
2373
2411
|
const [fromBlock, config] = await Promise.all([
|
|
2374
2412
|
getBlockNumber(client, { cacheTime: 0 }),
|
|
2375
|
-
getZoneGatewayConfig(client, {
|
|
2413
|
+
getZoneGatewayConfig(client, {
|
|
2414
|
+
...readParameters,
|
|
2415
|
+
flow: 1,
|
|
2416
|
+
gateway,
|
|
2417
|
+
vault,
|
|
2418
|
+
zoneId,
|
|
2419
|
+
zonePortal: portalAddress,
|
|
2420
|
+
}),
|
|
2376
2421
|
])
|
|
2377
2422
|
const assetToken = parameters.assetToken ?? config.vaultAsset
|
|
2378
2423
|
if (isAddressEqual(assetToken, config.shareToken))
|
|
2379
|
-
throw new Error('`assetToken` cannot be the
|
|
2424
|
+
throw new Error('`assetToken` cannot be the Earn share token.')
|
|
2380
2425
|
|
|
2381
2426
|
const [{ encrypted, keyIndex }, assetAmountMin] = await Promise.all([
|
|
2382
2427
|
zoneActions.encryptedDeposit.prepareRecipient(client, {
|
|
@@ -2397,23 +2442,22 @@ export namespace privateRedeem {
|
|
|
2397
2442
|
const assetAmount = await getRedeemQuote(client, {
|
|
2398
2443
|
...readParameters,
|
|
2399
2444
|
shareAmount,
|
|
2400
|
-
vault: config.
|
|
2445
|
+
vault: config.vault,
|
|
2401
2446
|
})
|
|
2402
2447
|
return EarnShares.minimumOutput(assetAmount, parameters.slippageBps)
|
|
2403
2448
|
})(),
|
|
2404
2449
|
])
|
|
2405
2450
|
const direct = isAddressEqual(assetToken, config.vaultAsset)
|
|
2406
|
-
const data = encodeAbiParameters(Abis.
|
|
2451
|
+
const data = encodeAbiParameters(Abis.earnRouterCallbackData, [
|
|
2407
2452
|
{
|
|
2453
|
+
actionId,
|
|
2454
|
+
earnVault: config.vault,
|
|
2408
2455
|
flow: 1,
|
|
2409
|
-
|
|
2410
|
-
keyIndex,
|
|
2411
|
-
encrypted,
|
|
2412
|
-
minVaultAssets: direct ? assetAmountMin : 1n,
|
|
2413
|
-
minVaultShares: 0n,
|
|
2456
|
+
minEarnShares: 0n,
|
|
2414
2457
|
minOutputAmount: direct ? 0n : assetAmountMin,
|
|
2415
|
-
|
|
2416
|
-
|
|
2458
|
+
minVaultAssets: direct ? assetAmountMin : 1n,
|
|
2459
|
+
outputToken: assetToken,
|
|
2460
|
+
zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
|
|
2417
2461
|
},
|
|
2418
2462
|
])
|
|
2419
2463
|
return {
|
|
@@ -2434,11 +2478,11 @@ export namespace privateRedeem {
|
|
|
2434
2478
|
export namespace prepare {
|
|
2435
2479
|
export type Parameters = Omit<ReadParameters, 'account'> &
|
|
2436
2480
|
PrivatePreparationParameters & {
|
|
2437
|
-
/**
|
|
2481
|
+
/** Earn shares withdrawn from the Zone, base units. */
|
|
2438
2482
|
shareAmount: bigint
|
|
2439
2483
|
} & (
|
|
2440
2484
|
| ({
|
|
2441
|
-
/** Asset token returned to the Zone. @default
|
|
2485
|
+
/** Asset token returned to the Zone. @default vault asset */
|
|
2442
2486
|
assetToken?: undefined
|
|
2443
2487
|
} & OneOf<
|
|
2444
2488
|
| {
|
|
@@ -2515,6 +2559,7 @@ export namespace privateRedeemSync {
|
|
|
2515
2559
|
* actionId: prepared.actionId,
|
|
2516
2560
|
* fromBlock: prepared.fromBlock,
|
|
2517
2561
|
* gateway: '0x...',
|
|
2562
|
+
* vault: '0x...',
|
|
2518
2563
|
* })
|
|
2519
2564
|
* ```
|
|
2520
2565
|
*
|
|
@@ -2532,15 +2577,17 @@ export async function waitForPrivateRedeem<chain extends Chain | undefined>(
|
|
|
2532
2577
|
gateway,
|
|
2533
2578
|
pollingInterval = client.pollingInterval,
|
|
2534
2579
|
timeout = 60_000,
|
|
2580
|
+
vault,
|
|
2535
2581
|
} = parameters
|
|
2536
2582
|
const event = getAbiItem({
|
|
2537
|
-
abi: Abis.
|
|
2583
|
+
abi: Abis.earnRouter,
|
|
2538
2584
|
name: 'EarnRedeem',
|
|
2539
2585
|
})
|
|
2540
2586
|
const observerId = stringify([
|
|
2541
2587
|
'waitForPrivateRedeem',
|
|
2542
2588
|
client.uid,
|
|
2543
2589
|
gateway,
|
|
2590
|
+
vault,
|
|
2544
2591
|
actionId,
|
|
2545
2592
|
fromBlock,
|
|
2546
2593
|
])
|
|
@@ -2571,7 +2618,7 @@ export async function waitForPrivateRedeem<chain extends Chain | undefined>(
|
|
|
2571
2618
|
try {
|
|
2572
2619
|
const [log] = await getLogs(client, {
|
|
2573
2620
|
address: gateway,
|
|
2574
|
-
args: { actionId },
|
|
2621
|
+
args: { actionId, earnVault: vault },
|
|
2575
2622
|
event,
|
|
2576
2623
|
fromBlock,
|
|
2577
2624
|
strict: true,
|
|
@@ -2583,7 +2630,7 @@ export async function waitForPrivateRedeem<chain extends Chain | undefined>(
|
|
|
2583
2630
|
actionId: log.args.actionId,
|
|
2584
2631
|
outputAmount: log.args.outputAmount,
|
|
2585
2632
|
outputToken: log.args.outputToken,
|
|
2586
|
-
shares: log.args.
|
|
2633
|
+
shares: log.args.earnShares,
|
|
2587
2634
|
tempoBlockNumber: log.blockNumber,
|
|
2588
2635
|
vaultAssets: log.args.vaultAssets,
|
|
2589
2636
|
zoneDepositHash: log.args.zoneDepositHash,
|
|
@@ -2621,6 +2668,8 @@ export namespace waitForPrivateRedeem {
|
|
|
2621
2668
|
pollingInterval?: number | undefined
|
|
2622
2669
|
/** Timeout in milliseconds; `0` disables it. @default `60_000` */
|
|
2623
2670
|
timeout?: number | undefined
|
|
2671
|
+
/** Vault address. */
|
|
2672
|
+
vault: Address
|
|
2624
2673
|
}
|
|
2625
2674
|
export type ReturnType = {
|
|
2626
2675
|
/** Correlation id for the completed redemption. */
|
|
@@ -2629,7 +2678,7 @@ export namespace waitForPrivateRedeem {
|
|
|
2629
2678
|
outputAmount: bigint
|
|
2630
2679
|
/** Token returned to the Zone. */
|
|
2631
2680
|
outputToken: Address
|
|
2632
|
-
/**
|
|
2681
|
+
/** Earn shares redeemed. */
|
|
2633
2682
|
shares: bigint
|
|
2634
2683
|
/** Parent-chain block containing the gateway event. */
|
|
2635
2684
|
tempoBlockNumber: bigint
|
|
@@ -2647,8 +2696,8 @@ export namespace waitForPrivateRedeem {
|
|
|
2647
2696
|
}
|
|
2648
2697
|
|
|
2649
2698
|
/**
|
|
2650
|
-
* Withdraws an exact asset amount to `recipient`, up to the specified
|
|
2651
|
-
* share limit. The transaction includes the required
|
|
2699
|
+
* Withdraws an exact asset amount to `recipient`, up to the specified Earn
|
|
2700
|
+
* share limit. The transaction includes the required Earn share approval;
|
|
2652
2701
|
* use {@link redeem} for a full exit.
|
|
2653
2702
|
*
|
|
2654
2703
|
* @example
|
|
@@ -2695,7 +2744,7 @@ export namespace withdrawExact {
|
|
|
2695
2744
|
vault: Address
|
|
2696
2745
|
} & OneOf<
|
|
2697
2746
|
| {
|
|
2698
|
-
/** Maximum
|
|
2747
|
+
/** Maximum Earn share input to burn. */
|
|
2699
2748
|
shareAmountMax: bigint
|
|
2700
2749
|
}
|
|
2701
2750
|
| {
|
|
@@ -2703,7 +2752,7 @@ export namespace withdrawExact {
|
|
|
2703
2752
|
slippageBps: number
|
|
2704
2753
|
}
|
|
2705
2754
|
| {
|
|
2706
|
-
/** Quoted
|
|
2755
|
+
/** Quoted Earn share input; raised by `slippageBps`. */
|
|
2707
2756
|
shareAmount: bigint
|
|
2708
2757
|
/** Slippage tolerance in basis points over `shareAmount` (50 = 0.5%). */
|
|
2709
2758
|
slippageBps: number
|
|
@@ -2717,7 +2766,7 @@ export namespace withdrawExact {
|
|
|
2717
2766
|
// TODO: exhaustive error type
|
|
2718
2767
|
export type ErrorType = BaseErrorType
|
|
2719
2768
|
|
|
2720
|
-
/** @internal Shared dispatch; reads the
|
|
2769
|
+
/** @internal Shared dispatch; reads the Earn share token for the approval. */
|
|
2721
2770
|
export async function inner<
|
|
2722
2771
|
action extends typeof sendTransaction | typeof sendTransactionSync,
|
|
2723
2772
|
chain extends Chain | undefined,
|
|
@@ -2730,9 +2779,9 @@ export namespace withdrawExact {
|
|
|
2730
2779
|
const [args, shareToken] = await Promise.all([
|
|
2731
2780
|
toWithdrawExactArgs(client, parameters as never),
|
|
2732
2781
|
readContract(client, {
|
|
2733
|
-
abi: Abis.
|
|
2782
|
+
abi: Abis.earnVault,
|
|
2734
2783
|
address: parameters.vault,
|
|
2735
|
-
functionName: '
|
|
2784
|
+
functionName: 'earnShare',
|
|
2736
2785
|
}),
|
|
2737
2786
|
])
|
|
2738
2787
|
return (await action(client, {
|
|
@@ -2759,7 +2808,7 @@ export namespace withdrawExact {
|
|
|
2759
2808
|
})()
|
|
2760
2809
|
return defineCall({
|
|
2761
2810
|
address: vault,
|
|
2762
|
-
abi: Abis.
|
|
2811
|
+
abi: Abis.earnVault,
|
|
2763
2812
|
functionName: 'withdrawExact',
|
|
2764
2813
|
args: [
|
|
2765
2814
|
internal_Token.toBaseUnits(args.assetAmount, undefined),
|
|
@@ -2778,11 +2827,11 @@ export namespace withdrawExact {
|
|
|
2778
2827
|
vault: Address
|
|
2779
2828
|
} & OneOf<
|
|
2780
2829
|
| {
|
|
2781
|
-
/** Maximum
|
|
2830
|
+
/** Maximum Earn share input to burn. */
|
|
2782
2831
|
shareAmountMax: bigint
|
|
2783
2832
|
}
|
|
2784
2833
|
| {
|
|
2785
|
-
/** Quoted
|
|
2834
|
+
/** Quoted Earn share input; raised by `slippageBps`. */
|
|
2786
2835
|
shareAmount: bigint
|
|
2787
2836
|
/** Slippage tolerance in basis points over `shareAmount` (50 = 0.5%). */
|
|
2788
2837
|
slippageBps: number
|
|
@@ -2791,7 +2840,7 @@ export namespace withdrawExact {
|
|
|
2791
2840
|
}
|
|
2792
2841
|
|
|
2793
2842
|
/**
|
|
2794
|
-
* Defines the
|
|
2843
|
+
* Defines the Earn share approval and withdrawal calls for atomic
|
|
2795
2844
|
* execution. Pass `shareToken` explicitly because this builder performs no reads.
|
|
2796
2845
|
*
|
|
2797
2846
|
* @param args - Arguments.
|
|
@@ -2799,7 +2848,7 @@ export namespace withdrawExact {
|
|
|
2799
2848
|
*/
|
|
2800
2849
|
export function calls(
|
|
2801
2850
|
args: call.Args & {
|
|
2802
|
-
/**
|
|
2851
|
+
/** Earn share token approved for the withdrawal. */
|
|
2803
2852
|
shareToken: Address
|
|
2804
2853
|
},
|
|
2805
2854
|
) {
|
|
@@ -2830,7 +2879,7 @@ export namespace withdrawExact {
|
|
|
2830
2879
|
// Earn contracts are user-deployed: several adapters can emit the same
|
|
2831
2880
|
// signature in one receipt, so filter by emitting address before decode.
|
|
2832
2881
|
const [log] = parseEventLogs({
|
|
2833
|
-
abi: Abis.
|
|
2882
|
+
abi: Abis.earnVault,
|
|
2834
2883
|
eventName: 'WithdrewExact',
|
|
2835
2884
|
logs: logs.filter((log) => isAddressEqual(log.address, vault)),
|
|
2836
2885
|
})
|
|
@@ -2839,7 +2888,7 @@ export namespace withdrawExact {
|
|
|
2839
2888
|
}
|
|
2840
2889
|
|
|
2841
2890
|
/**
|
|
2842
|
-
* Estimates gas for an exact withdrawal, assuming enough
|
|
2891
|
+
* Estimates gas for an exact withdrawal, assuming enough Earn share allowance.
|
|
2843
2892
|
*
|
|
2844
2893
|
* @param client - Client.
|
|
2845
2894
|
* @param parameters - Parameters.
|
|
@@ -2861,7 +2910,7 @@ export namespace withdrawExact {
|
|
|
2861
2910
|
}
|
|
2862
2911
|
|
|
2863
2912
|
/**
|
|
2864
|
-
* Simulates an exact withdrawal, assuming enough
|
|
2913
|
+
* Simulates an exact withdrawal, assuming enough Earn share allowance.
|
|
2865
2914
|
*
|
|
2866
2915
|
* @param client - Client.
|
|
2867
2916
|
* @param parameters - Parameters.
|
|
@@ -2874,7 +2923,7 @@ export namespace withdrawExact {
|
|
|
2874
2923
|
client: Client<Transport, chain, account>,
|
|
2875
2924
|
parameters: withdrawExact.Parameters<chain, account>,
|
|
2876
2925
|
): Promise<
|
|
2877
|
-
SimulateContractReturnType<typeof Abis.
|
|
2926
|
+
SimulateContractReturnType<typeof Abis.earnVault, 'withdrawExact'>
|
|
2878
2927
|
> {
|
|
2879
2928
|
return simulateContract(client, {
|
|
2880
2929
|
...pickWriteParameters(parameters as never),
|
|
@@ -2930,7 +2979,7 @@ export async function withdrawExactSync<
|
|
|
2930
2979
|
caller: args.caller,
|
|
2931
2980
|
receipt,
|
|
2932
2981
|
recipient: args.receiver,
|
|
2933
|
-
shareAmount: args.
|
|
2982
|
+
shareAmount: args.earnSharesBurned,
|
|
2934
2983
|
}
|
|
2935
2984
|
}
|
|
2936
2985
|
|
|
@@ -2950,7 +2999,7 @@ export namespace withdrawExactSync {
|
|
|
2950
2999
|
receipt: TransactionReceipt
|
|
2951
3000
|
/** Asset recipient. */
|
|
2952
3001
|
recipient: Address
|
|
2953
|
-
/**
|
|
3002
|
+
/** Earn shares burned. */
|
|
2954
3003
|
shareAmount: bigint
|
|
2955
3004
|
}>
|
|
2956
3005
|
// TODO: exhaustive error type
|
|
@@ -2972,11 +3021,11 @@ type MinimumAssetAmountParameters = OneOf<
|
|
|
2972
3021
|
|
|
2973
3022
|
type MinimumShareAmountParameters = OneOf<
|
|
2974
3023
|
| {
|
|
2975
|
-
/** Minimum
|
|
3024
|
+
/** Minimum Earn shares returned to the Zone. */
|
|
2976
3025
|
shareAmountMin: bigint
|
|
2977
3026
|
}
|
|
2978
3027
|
| {
|
|
2979
|
-
/** Quoted
|
|
3028
|
+
/** Quoted Earn shares returned to the Zone. */
|
|
2980
3029
|
shareAmount: bigint
|
|
2981
3030
|
/** Slippage tolerance under `shareAmount` (50 = 0.5%). */
|
|
2982
3031
|
slippageBps: number
|
|
@@ -2990,16 +3039,22 @@ type PrivatePreparationParameters = {
|
|
|
2990
3039
|
callbackGas?: bigint | undefined
|
|
2991
3040
|
/** Public recipient if the parent-chain callback fails. @default `recoveryRecipient` */
|
|
2992
3041
|
fallbackRecipient?: Address | undefined
|
|
2993
|
-
/**
|
|
3042
|
+
/** Zone gateway address. */
|
|
2994
3043
|
gateway: Address
|
|
3044
|
+
/** Source Zone portal on the parent chain. @default Derived from `zoneId` */
|
|
3045
|
+
portalAddress?: Address | undefined
|
|
2995
3046
|
/** Encrypted recipient for the returned tokens. */
|
|
2996
3047
|
recipient: Address
|
|
2997
3048
|
/** Public recipient if the encrypted return fails. */
|
|
2998
3049
|
recoveryRecipient: Address
|
|
2999
3050
|
/** Optional memo encrypted with the returned Zone deposit. */
|
|
3000
3051
|
returnMemo?: Hex.Hex | undefined
|
|
3052
|
+
/** Vault address. */
|
|
3053
|
+
vault: Address
|
|
3001
3054
|
/** Optional memo attached to the Zone withdrawal. */
|
|
3002
3055
|
withdrawalMemo?: Hex.Hex | undefined
|
|
3056
|
+
/** Source Zone receiving the output. */
|
|
3057
|
+
zoneId: number
|
|
3003
3058
|
}
|
|
3004
3059
|
|
|
3005
3060
|
type PreparedZoneRequest = {
|
|
@@ -3068,75 +3123,64 @@ function pickReadParameters(parameters: Omit<ReadParameters, 'account'>) {
|
|
|
3068
3123
|
|
|
3069
3124
|
async function getZoneGatewayConfig<chain extends Chain | undefined>(
|
|
3070
3125
|
client: Client<Transport, chain>,
|
|
3071
|
-
parameters: Omit<ReadParameters, 'account'> & {
|
|
3126
|
+
parameters: Omit<ReadParameters, 'account'> & {
|
|
3127
|
+
flow: 0 | 1
|
|
3128
|
+
gateway: Address
|
|
3129
|
+
vault: Address
|
|
3130
|
+
zoneId: number
|
|
3131
|
+
zonePortal: Address
|
|
3132
|
+
},
|
|
3072
3133
|
) {
|
|
3073
|
-
const { gateway, ...rest } = parameters
|
|
3074
|
-
const [
|
|
3075
|
-
vaultAdapter,
|
|
3076
|
-
vaultAsset,
|
|
3077
|
-
shareToken,
|
|
3078
|
-
zoneId,
|
|
3079
|
-
zonePortal,
|
|
3080
|
-
supportsAsyncFlow,
|
|
3081
|
-
] = await multicall(client, {
|
|
3134
|
+
const { flow, gateway, vault, zoneId, zonePortal, ...rest } = parameters
|
|
3135
|
+
const [vaultAsset, shareToken, supportsFlow] = await multicall(client, {
|
|
3082
3136
|
...rest,
|
|
3083
3137
|
allowFailure: false,
|
|
3084
3138
|
contracts: [
|
|
3085
3139
|
{
|
|
3086
|
-
abi: Abis.
|
|
3087
|
-
address:
|
|
3088
|
-
functionName: '
|
|
3089
|
-
},
|
|
3090
|
-
{
|
|
3091
|
-
abi: Abis.zoneGateway,
|
|
3092
|
-
address: gateway,
|
|
3093
|
-
functionName: 'vaultAsset',
|
|
3094
|
-
},
|
|
3095
|
-
{
|
|
3096
|
-
abi: Abis.zoneGateway,
|
|
3097
|
-
address: gateway,
|
|
3098
|
-
functionName: 'shareToken',
|
|
3099
|
-
},
|
|
3100
|
-
{
|
|
3101
|
-
abi: Abis.zoneGateway,
|
|
3102
|
-
address: gateway,
|
|
3103
|
-
functionName: 'zoneId',
|
|
3140
|
+
abi: Abis.earnVault,
|
|
3141
|
+
address: vault,
|
|
3142
|
+
functionName: 'asset',
|
|
3104
3143
|
},
|
|
3105
3144
|
{
|
|
3106
|
-
abi: Abis.
|
|
3107
|
-
address:
|
|
3108
|
-
functionName: '
|
|
3145
|
+
abi: Abis.earnVault,
|
|
3146
|
+
address: vault,
|
|
3147
|
+
functionName: 'earnShare',
|
|
3109
3148
|
},
|
|
3110
3149
|
{
|
|
3111
|
-
abi: Abis.
|
|
3150
|
+
abi: Abis.earnRouter,
|
|
3112
3151
|
address: gateway,
|
|
3113
|
-
args: [
|
|
3152
|
+
args: [flow],
|
|
3114
3153
|
functionName: 'supportsFlow',
|
|
3115
3154
|
},
|
|
3116
3155
|
],
|
|
3117
3156
|
deployless: true,
|
|
3118
3157
|
})
|
|
3119
|
-
if (
|
|
3120
|
-
|
|
3121
|
-
|
|
3158
|
+
if (!supportsFlow) throw new Error('Zone gateway flow is not supported.')
|
|
3159
|
+
return {
|
|
3160
|
+
shareToken,
|
|
3161
|
+
vault,
|
|
3162
|
+
vaultAsset,
|
|
3163
|
+
zoneId,
|
|
3164
|
+
zonePortal,
|
|
3165
|
+
}
|
|
3122
3166
|
}
|
|
3123
3167
|
|
|
3124
3168
|
// ERC-165 ids of the optional engine capability interfaces (XOR of each
|
|
3125
3169
|
// interface's function selectors).
|
|
3126
3170
|
const interfaceIds = {
|
|
3127
|
-
/** `
|
|
3171
|
+
/** `IEarnEngineAsyncRedeem`. */
|
|
3128
3172
|
asyncRedeem: '0xa1a6a1d7',
|
|
3129
|
-
/** `
|
|
3173
|
+
/** `IEarnEngineExactWithdraw`. */
|
|
3130
3174
|
exactWithdraw: '0x0adfb0b9',
|
|
3131
|
-
/** `
|
|
3132
|
-
inKindDeposit: '
|
|
3133
|
-
/** `
|
|
3134
|
-
syncRedeem: '
|
|
3175
|
+
/** `IEarnEngineInKindDeposit`. */
|
|
3176
|
+
inKindDeposit: '0xce4790a9',
|
|
3177
|
+
/** `IEarnEngineRedeem`. */
|
|
3178
|
+
syncRedeem: '0x94a2d467',
|
|
3135
3179
|
} as const
|
|
3136
3180
|
|
|
3137
|
-
/** Trims the decoded `
|
|
3181
|
+
/** Trims the decoded `FeeConfig` to its active fixed-fee count. */
|
|
3138
3182
|
function toFeeConfig(
|
|
3139
|
-
config: ReadContractReturnType<typeof Abis.
|
|
3183
|
+
config: ReadContractReturnType<typeof Abis.earnFees, 'feeConfig'>,
|
|
3140
3184
|
): FeeConfig {
|
|
3141
3185
|
return {
|
|
3142
3186
|
excess: config.excess,
|
|
@@ -3144,15 +3188,32 @@ function toFeeConfig(
|
|
|
3144
3188
|
}
|
|
3145
3189
|
}
|
|
3146
3190
|
|
|
3147
|
-
/**
|
|
3191
|
+
/** Maps decoded fee fields to the action result. */
|
|
3148
3192
|
function toFeePreview(
|
|
3149
|
-
preview: ReadContractReturnType<
|
|
3150
|
-
typeof Abis.vaultAdapter,
|
|
3151
|
-
'previewAccruedFees'
|
|
3152
|
-
>,
|
|
3193
|
+
preview: ReadContractReturnType<typeof Abis.earnFees, 'previewAccruedFees'>,
|
|
3153
3194
|
): FeePreview {
|
|
3154
|
-
const {
|
|
3155
|
-
|
|
3195
|
+
const {
|
|
3196
|
+
allocationCount,
|
|
3197
|
+
allocations,
|
|
3198
|
+
postFeeValuePerEarnShare,
|
|
3199
|
+
preFeeValuePerEarnShare,
|
|
3200
|
+
targetValuePerEarnShare,
|
|
3201
|
+
totalFeeEarnShares,
|
|
3202
|
+
...rest
|
|
3203
|
+
} = preview
|
|
3204
|
+
return {
|
|
3205
|
+
...rest,
|
|
3206
|
+
allocations: allocations
|
|
3207
|
+
.slice(0, allocationCount)
|
|
3208
|
+
.map(({ feeEarnShares, ...allocation }) => ({
|
|
3209
|
+
...allocation,
|
|
3210
|
+
feeShares: feeEarnShares,
|
|
3211
|
+
})),
|
|
3212
|
+
postFeeValuePerShare: postFeeValuePerEarnShare,
|
|
3213
|
+
preFeeValuePerShare: preFeeValuePerEarnShare,
|
|
3214
|
+
targetValuePerShare: targetValuePerEarnShare,
|
|
3215
|
+
totalFeeShares: totalFeeEarnShares,
|
|
3216
|
+
}
|
|
3156
3217
|
}
|
|
3157
3218
|
|
|
3158
3219
|
/** Resolves `deposit` parameters into the adapter call args. @internal */
|
|
@@ -3278,7 +3339,7 @@ function maximumInput(shareAmount: bigint, slippageBps: number): bigint {
|
|
|
3278
3339
|
|
|
3279
3340
|
/**
|
|
3280
3341
|
* Converts an amount to base units, resolving missing decimals with live
|
|
3281
|
-
* reads of the vault's asset or share token.
|
|
3342
|
+
* reads of the vault's asset or share token. Earn share tokens are not
|
|
3282
3343
|
* genesis-declared, so nothing is cached. @internal
|
|
3283
3344
|
*/
|
|
3284
3345
|
async function toBaseUnitsLive(
|
|
@@ -3294,9 +3355,9 @@ async function toBaseUnitsLive(
|
|
|
3294
3355
|
if (amount.decimals !== undefined)
|
|
3295
3356
|
return internal_Token.toBaseUnits(amount, amount.decimals)
|
|
3296
3357
|
const address = await readContract(client, {
|
|
3297
|
-
abi: Abis.
|
|
3358
|
+
abi: Abis.earnVault,
|
|
3298
3359
|
address: vault,
|
|
3299
|
-
functionName: token,
|
|
3360
|
+
functionName: token === 'asset' ? 'asset' : 'earnShare',
|
|
3300
3361
|
})
|
|
3301
3362
|
const { decimals } = await resolveTokenWithDecimals(client, {
|
|
3302
3363
|
token: address,
|