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.
- package/CHANGELOG.md +40 -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/chains/definitions/story.js +7 -7
- package/_cjs/chains/definitions/story.js.map +1 -1
- package/_cjs/chains/definitions/storyAeneid.js +8 -8
- package/_cjs/chains/definitions/storyAeneid.js.map +1 -1
- package/_cjs/errors/typedData.js +11 -1
- package/_cjs/errors/typedData.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/index.js +5 -4
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/Abis.js +1335 -571
- 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 +197 -135
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/token.js +18 -6
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/zones/Abis.js +6 -0
- package/_cjs/tempo/zones/Abis.js.map +1 -1
- package/_cjs/tokens/definitions/usdc.js +7 -0
- package/_cjs/tokens/definitions/usdc.js.map +1 -1
- package/_cjs/utils/promise/withRetry.js +2 -2
- package/_cjs/utils/promise/withRetry.js.map +1 -1
- package/_cjs/utils/typedData.js +3 -0
- package/_cjs/utils/typedData.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/chains/definitions/story.js +7 -7
- package/_esm/chains/definitions/story.js.map +1 -1
- package/_esm/chains/definitions/storyAeneid.js +8 -8
- package/_esm/chains/definitions/storyAeneid.js.map +1 -1
- package/_esm/errors/typedData.js +9 -0
- package/_esm/errors/typedData.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/Abis.js +1336 -572
- 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 +240 -172
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/token.js +21 -8
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/zones/Abis.js +6 -0
- package/_esm/tempo/zones/Abis.js.map +1 -1
- package/_esm/tokens/definitions/usdc.js +7 -0
- package/_esm/tokens/definitions/usdc.js.map +1 -1
- package/_esm/utils/promise/withRetry.js +2 -2
- package/_esm/utils/promise/withRetry.js.map +1 -1
- package/_esm/utils/typedData.js +4 -1
- package/_esm/utils/typedData.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/chains/definitions/story.d.ts +7 -7
- package/_types/chains/definitions/storyAeneid.d.ts +8 -8
- package/_types/errors/typedData.d.ts +8 -0
- package/_types/errors/typedData.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/package.json +1 -0
- package/_types/tempo/Abis.d.ts +2153 -950
- 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 +1369 -1825
- package/_types/tempo/actions/earn.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts +1 -1
- package/_types/tempo/actions/token.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/tokens/definitions/usdc.d.ts +7 -0
- package/_types/tokens/definitions/usdc.d.ts.map +1 -1
- package/_types/tokens/sets.d.ts +14 -0
- package/_types/tokens/sets.d.ts.map +1 -1
- package/_types/utils/typedData.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/chains/definitions/story.ts +7 -7
- package/chains/definitions/storyAeneid.ts +8 -8
- package/errors/typedData.ts +13 -0
- package/errors/version.ts +1 -1
- package/index.ts +2 -0
- package/package.json +2 -2
- package/tempo/Abis.ts +1341 -576
- package/tempo/Addresses.ts +1 -0
- package/tempo/Decorator.ts +21 -15
- package/tempo/actions/earn.ts +365 -287
- package/tempo/actions/token.ts +60 -9
- package/tempo/zones/Abis.ts +6 -0
- package/tokens/definitions/usdc.ts +7 -0
- package/utils/promise/withRetry.ts +4 -4
- package/utils/typedData.ts +5 -0
|
@@ -49,6 +49,7 @@ const Abis = require("../Abis.js");
|
|
|
49
49
|
const Addresses = require("../Addresses.js");
|
|
50
50
|
const errors_js_1 = require("../errors.js");
|
|
51
51
|
const utils_js_1 = require("../internal/utils.js");
|
|
52
|
+
const zone_js_1 = require("../zones/zone.js");
|
|
52
53
|
const policyActions = require("./policy.js");
|
|
53
54
|
const tokenActions = require("./token.js");
|
|
54
55
|
const zoneActions = require("./zone.js");
|
|
@@ -159,7 +160,7 @@ async function validateExitSafePolicy(client, parameters) {
|
|
|
159
160
|
})),
|
|
160
161
|
]);
|
|
161
162
|
if (tokenPolicyId !== policy.transferPolicyId)
|
|
162
|
-
throw new Error('Earn
|
|
163
|
+
throw new Error('Earn share token transfer policy mismatch.');
|
|
163
164
|
if (compound[0] !== policy.senderPolicyId ||
|
|
164
165
|
compound[1] !== policy.recipientPolicyId ||
|
|
165
166
|
compound[2] !== policy.mintRecipientPolicyId)
|
|
@@ -184,7 +185,7 @@ async function deposit(client, parameters) {
|
|
|
184
185
|
const [args, assetToken] = await Promise.all([
|
|
185
186
|
toDepositArgs(client, parameters),
|
|
186
187
|
(0, readContract_js_1.readContract)(client, {
|
|
187
|
-
abi: Abis.
|
|
188
|
+
abi: Abis.earnVault,
|
|
188
189
|
address: parameters.vault,
|
|
189
190
|
functionName: 'asset',
|
|
190
191
|
}),
|
|
@@ -205,7 +206,7 @@ async function deposit(client, parameters) {
|
|
|
205
206
|
})();
|
|
206
207
|
return (0, utils_js_1.defineCall)({
|
|
207
208
|
address: vault,
|
|
208
|
-
abi: Abis.
|
|
209
|
+
abi: Abis.earnVault,
|
|
209
210
|
functionName: 'deposit',
|
|
210
211
|
args: [
|
|
211
212
|
internal_Token.toBaseUnits(args.assetAmount, undefined),
|
|
@@ -232,7 +233,7 @@ async function deposit(client, parameters) {
|
|
|
232
233
|
function extractEvent(logs, parameters) {
|
|
233
234
|
const { vault } = parameters;
|
|
234
235
|
const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
|
|
235
|
-
abi: Abis.
|
|
236
|
+
abi: Abis.earnVault,
|
|
236
237
|
eventName: 'Deposited',
|
|
237
238
|
logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
|
|
238
239
|
});
|
|
@@ -268,7 +269,7 @@ async function depositSync(client, parameters) {
|
|
|
268
269
|
caller: args.caller,
|
|
269
270
|
receipt,
|
|
270
271
|
recipient: args.receiver,
|
|
271
|
-
shareAmount: args.
|
|
272
|
+
shareAmount: args.earnShares,
|
|
272
273
|
};
|
|
273
274
|
}
|
|
274
275
|
async function depositShares(client, parameters) {
|
|
@@ -277,7 +278,7 @@ async function depositShares(client, parameters) {
|
|
|
277
278
|
(function (depositShares) {
|
|
278
279
|
async function inner(action, client, parameters) {
|
|
279
280
|
const engine = await (0, readContract_js_1.readContract)(client, {
|
|
280
|
-
abi: Abis.
|
|
281
|
+
abi: Abis.earnVault,
|
|
281
282
|
address: parameters.vault,
|
|
282
283
|
functionName: 'engine',
|
|
283
284
|
});
|
|
@@ -301,8 +302,8 @@ async function depositShares(client, parameters) {
|
|
|
301
302
|
})();
|
|
302
303
|
return (0, utils_js_1.defineCall)({
|
|
303
304
|
address: vault,
|
|
304
|
-
abi: Abis.
|
|
305
|
-
functionName: '
|
|
305
|
+
abi: Abis.earnVault,
|
|
306
|
+
functionName: 'depositVenueShares',
|
|
306
307
|
args: [venueShareAmount, recipient, earnShareAmountMin],
|
|
307
308
|
});
|
|
308
309
|
}
|
|
@@ -323,7 +324,7 @@ async function depositShares(client, parameters) {
|
|
|
323
324
|
function extractEvent(logs, parameters) {
|
|
324
325
|
const { vault } = parameters;
|
|
325
326
|
const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
|
|
326
|
-
abi: Abis.
|
|
327
|
+
abi: Abis.earnVault,
|
|
327
328
|
eventName: 'VenueSharesDeposited',
|
|
328
329
|
logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
|
|
329
330
|
});
|
|
@@ -358,7 +359,7 @@ async function depositSharesSync(client, parameters) {
|
|
|
358
359
|
caller: args.caller,
|
|
359
360
|
earnShareAmount: args.earnShares,
|
|
360
361
|
receipt,
|
|
361
|
-
receivedVenueShareAmount: args.
|
|
362
|
+
receivedVenueShareAmount: args.receivedEngineShares,
|
|
362
363
|
recipient: args.receiver,
|
|
363
364
|
venueShareAmount: args.requestedVenueShares,
|
|
364
365
|
};
|
|
@@ -372,13 +373,23 @@ async function privateDeposit(client, parameters) {
|
|
|
372
373
|
const chainId = client.chain?.id;
|
|
373
374
|
if (!chainId)
|
|
374
375
|
throw new Error('`chain` is required.');
|
|
375
|
-
const { actionId = ox_1.Hex.random(32), assetAmount, callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, recipient, recoveryRecipient, returnMemo, withdrawalMemo, } = parameters;
|
|
376
|
+
const { actionId = ox_1.Hex.random(32), assetAmount, callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, portalAddress: portalAddress_, recipient, recoveryRecipient, returnMemo, vault, withdrawalMemo, zoneId, } = parameters;
|
|
377
|
+
const portalAddress = portalAddress_ ?? (0, zone_js_1.getPortalAddress)(chainId, zoneId);
|
|
376
378
|
const readParameters = pickReadParameters(parameters);
|
|
377
379
|
const [fromBlock, config] = await Promise.all([
|
|
378
380
|
(0, getBlockNumber_js_1.getBlockNumber)(client, { cacheTime: 0 }),
|
|
379
|
-
getZoneGatewayConfig(client, {
|
|
381
|
+
getZoneGatewayConfig(client, {
|
|
382
|
+
...readParameters,
|
|
383
|
+
flow: 0,
|
|
384
|
+
gateway,
|
|
385
|
+
vault,
|
|
386
|
+
zoneId,
|
|
387
|
+
zonePortal: portalAddress,
|
|
388
|
+
}),
|
|
380
389
|
]);
|
|
381
|
-
const assetToken = parameters.assetToken ?? config.
|
|
390
|
+
const assetToken = parameters.assetToken ?? config.privateAsset;
|
|
391
|
+
if (!(0, isAddressEqual_js_1.isAddressEqual)(assetToken, config.privateAsset))
|
|
392
|
+
throw new Error('`assetToken` must match the Zone gateway private asset.');
|
|
382
393
|
const { encrypted, keyIndex } = await zoneActions.encryptedDeposit.prepareRecipient(client, {
|
|
383
394
|
...readParameters,
|
|
384
395
|
memo: returnMemo,
|
|
@@ -387,20 +398,14 @@ async function privateDeposit(client, parameters) {
|
|
|
387
398
|
zoneId: config.zoneId,
|
|
388
399
|
});
|
|
389
400
|
const shareAmountMin = resolveMinimumShareAmount(parameters);
|
|
390
|
-
const
|
|
391
|
-
const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.zoneGatewayCallbackData, [
|
|
401
|
+
const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.earnRouterCallbackData, [
|
|
392
402
|
{
|
|
403
|
+
actionId,
|
|
393
404
|
flow: 0,
|
|
394
|
-
|
|
395
|
-
keyIndex,
|
|
396
|
-
encrypted,
|
|
397
|
-
minVaultAssets: direct
|
|
398
|
-
? assetAmount
|
|
399
|
-
: (parameters.vaultAssetAmountMin ?? 0n),
|
|
400
|
-
minVaultShares: shareAmountMin,
|
|
405
|
+
minEarnShares: shareAmountMin,
|
|
401
406
|
minOutputAmount: 0n,
|
|
402
|
-
|
|
403
|
-
refundRecipient: recoveryRecipient,
|
|
407
|
+
minVaultAssets: parameters.vaultAssetAmountMin ?? assetAmount,
|
|
408
|
+
zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
|
|
404
409
|
},
|
|
405
410
|
]);
|
|
406
411
|
return {
|
|
@@ -428,15 +433,16 @@ async function privateDepositSync(client, parameters) {
|
|
|
428
433
|
return zoneActions.requestWithdrawalSync(client, parameters);
|
|
429
434
|
}
|
|
430
435
|
async function waitForPrivateDeposit(client, parameters) {
|
|
431
|
-
const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
|
|
436
|
+
const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
|
|
432
437
|
const event = (0, getAbiItem_js_1.getAbiItem)({
|
|
433
|
-
abi: Abis.
|
|
438
|
+
abi: Abis.earnRouter,
|
|
434
439
|
name: 'EarnDeposit',
|
|
435
440
|
});
|
|
436
441
|
const observerId = (0, stringify_js_1.stringify)([
|
|
437
442
|
'waitForPrivateDeposit',
|
|
438
443
|
client.uid,
|
|
439
444
|
gateway,
|
|
445
|
+
vault,
|
|
440
446
|
actionId,
|
|
441
447
|
fromBlock,
|
|
442
448
|
]);
|
|
@@ -460,7 +466,7 @@ async function waitForPrivateDeposit(client, parameters) {
|
|
|
460
466
|
try {
|
|
461
467
|
const [log] = await (0, getLogs_js_1.getLogs)(client, {
|
|
462
468
|
address: gateway,
|
|
463
|
-
args: { actionId },
|
|
469
|
+
args: { actionId, earnVault: vault },
|
|
464
470
|
event,
|
|
465
471
|
fromBlock,
|
|
466
472
|
strict: true,
|
|
@@ -473,7 +479,7 @@ async function waitForPrivateDeposit(client, parameters) {
|
|
|
473
479
|
actionId: log.args.actionId,
|
|
474
480
|
inputAmount: log.args.inputAmount,
|
|
475
481
|
inputToken: log.args.inputToken,
|
|
476
|
-
shares: log.args.
|
|
482
|
+
shares: log.args.earnShares,
|
|
477
483
|
tempoBlockNumber: log.blockNumber,
|
|
478
484
|
vaultAssets: log.args.vaultAssets,
|
|
479
485
|
zoneDepositHash: log.args.zoneDepositHash,
|
|
@@ -495,37 +501,43 @@ async function waitForPrivateDeposit(client, parameters) {
|
|
|
495
501
|
}
|
|
496
502
|
async function getFeeState(client, parameters) {
|
|
497
503
|
const { recipient, vault, ...rest } = parameters;
|
|
504
|
+
const fees = await (0, readContract_js_1.readContract)(client, {
|
|
505
|
+
...rest,
|
|
506
|
+
abi: Abis.earnVault,
|
|
507
|
+
address: vault,
|
|
508
|
+
functionName: 'earnFees',
|
|
509
|
+
});
|
|
498
510
|
const contracts = [
|
|
499
511
|
(0, utils_js_1.defineCall)({
|
|
500
|
-
address:
|
|
501
|
-
abi: Abis.
|
|
512
|
+
address: fees,
|
|
513
|
+
abi: Abis.earnFees,
|
|
502
514
|
functionName: 'currentFeeConfigId',
|
|
503
515
|
}),
|
|
504
516
|
(0, utils_js_1.defineCall)({
|
|
505
|
-
address:
|
|
506
|
-
abi: Abis.
|
|
517
|
+
address: fees,
|
|
518
|
+
abi: Abis.earnFees,
|
|
507
519
|
functionName: 'feesActive',
|
|
508
520
|
}),
|
|
509
521
|
(0, utils_js_1.defineCall)({
|
|
510
|
-
address:
|
|
511
|
-
abi: Abis.
|
|
522
|
+
address: fees,
|
|
523
|
+
abi: Abis.earnFees,
|
|
512
524
|
functionName: 'highWaterMark',
|
|
513
525
|
}),
|
|
514
526
|
(0, utils_js_1.defineCall)({
|
|
515
|
-
address:
|
|
516
|
-
abi: Abis.
|
|
527
|
+
address: fees,
|
|
528
|
+
abi: Abis.earnFees,
|
|
517
529
|
functionName: 'previewAccruedFees',
|
|
518
530
|
}),
|
|
519
531
|
(0, utils_js_1.defineCall)({
|
|
520
|
-
address:
|
|
521
|
-
abi: Abis.
|
|
532
|
+
address: fees,
|
|
533
|
+
abi: Abis.earnFees,
|
|
522
534
|
functionName: 'targetBase',
|
|
523
535
|
}),
|
|
524
536
|
];
|
|
525
537
|
const feeConfig = async (configId) => toFeeConfig(await (0, readContract_js_1.readContract)(client, {
|
|
526
538
|
...rest,
|
|
527
|
-
abi: Abis.
|
|
528
|
-
address:
|
|
539
|
+
abi: Abis.earnFees,
|
|
540
|
+
address: fees,
|
|
529
541
|
functionName: 'feeConfig',
|
|
530
542
|
args: [configId],
|
|
531
543
|
}));
|
|
@@ -536,9 +548,9 @@ async function getFeeState(client, parameters) {
|
|
|
536
548
|
contracts: [
|
|
537
549
|
...contracts,
|
|
538
550
|
(0, utils_js_1.defineCall)({
|
|
539
|
-
address:
|
|
540
|
-
abi: Abis.
|
|
541
|
-
functionName: '
|
|
551
|
+
address: fees,
|
|
552
|
+
abi: Abis.earnFees,
|
|
553
|
+
functionName: 'claimableEarnShares',
|
|
542
554
|
args: [recipient],
|
|
543
555
|
}),
|
|
544
556
|
],
|
|
@@ -580,13 +592,13 @@ async function getPosition(client, parameters) {
|
|
|
580
592
|
contracts: [
|
|
581
593
|
(0, utils_js_1.defineCall)({
|
|
582
594
|
address: vault,
|
|
583
|
-
abi: Abis.
|
|
595
|
+
abi: Abis.earnVault,
|
|
584
596
|
functionName: 'asset',
|
|
585
597
|
}),
|
|
586
598
|
(0, utils_js_1.defineCall)({
|
|
587
599
|
address: vault,
|
|
588
|
-
abi: Abis.
|
|
589
|
-
functionName: '
|
|
600
|
+
abi: Abis.earnVault,
|
|
601
|
+
functionName: 'earnShare',
|
|
590
602
|
}),
|
|
591
603
|
],
|
|
592
604
|
deployless: true,
|
|
@@ -624,7 +636,7 @@ async function getPosition(client, parameters) {
|
|
|
624
636
|
});
|
|
625
637
|
const value = await (0, readContract_js_1.readContract)(client, {
|
|
626
638
|
...rest,
|
|
627
|
-
abi: Abis.
|
|
639
|
+
abi: Abis.earnVault,
|
|
628
640
|
address: vault,
|
|
629
641
|
args: [shareBalance],
|
|
630
642
|
functionName: 'previewRedeem',
|
|
@@ -651,7 +663,7 @@ async function getRedeemQuote(client, parameters) {
|
|
|
651
663
|
const { shareAmount, vault } = args;
|
|
652
664
|
return (0, utils_js_1.defineCall)({
|
|
653
665
|
address: vault,
|
|
654
|
-
abi: Abis.
|
|
666
|
+
abi: Abis.earnVault,
|
|
655
667
|
args: [shareAmount],
|
|
656
668
|
functionName: 'previewRedeem',
|
|
657
669
|
});
|
|
@@ -660,16 +672,24 @@ async function getRedeemQuote(client, parameters) {
|
|
|
660
672
|
})(getRedeemQuote || (exports.getRedeemQuote = getRedeemQuote = {}));
|
|
661
673
|
async function getVault(client, parameters) {
|
|
662
674
|
const { vault, ...rest } = parameters;
|
|
663
|
-
const engine = await
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
675
|
+
const [engine, fees] = await Promise.all([
|
|
676
|
+
(0, readContract_js_1.readContract)(client, {
|
|
677
|
+
...rest,
|
|
678
|
+
abi: Abis.earnVault,
|
|
679
|
+
address: vault,
|
|
680
|
+
functionName: 'engine',
|
|
681
|
+
}),
|
|
682
|
+
(0, readContract_js_1.readContract)(client, {
|
|
683
|
+
...rest,
|
|
684
|
+
abi: Abis.earnVault,
|
|
685
|
+
address: vault,
|
|
686
|
+
functionName: 'earnFees',
|
|
687
|
+
}),
|
|
688
|
+
]);
|
|
669
689
|
const [assetToken, engine_, shareToken, operator, emergencyGuardian, asyncJanitor, engineMigrationMode, depositsPaused, engineShares, shareSupply, isSynced, pendingRedeemCount, feesActive, totalAssets, name, symbol, asyncRedeem, exactWithdraw, inKindDeposit, syncRedeem,] = await (0, multicall_js_1.multicall)(client, {
|
|
670
690
|
...rest,
|
|
671
691
|
allowFailure: false,
|
|
672
|
-
contracts: getVault.calls({ engine, vault }),
|
|
692
|
+
contracts: getVault.calls({ engine, fees, vault }),
|
|
673
693
|
deployless: true,
|
|
674
694
|
});
|
|
675
695
|
if (!(0, isAddressEqual_js_1.isAddressEqual)(engine, engine_))
|
|
@@ -693,109 +713,109 @@ async function getVault(client, parameters) {
|
|
|
693
713
|
}
|
|
694
714
|
(function (getVault) {
|
|
695
715
|
function calls(args) {
|
|
696
|
-
const { engine, vault } = args;
|
|
716
|
+
const { engine, fees, vault } = args;
|
|
697
717
|
return [
|
|
698
718
|
(0, utils_js_1.defineCall)({
|
|
699
719
|
address: vault,
|
|
700
|
-
abi: Abis.
|
|
720
|
+
abi: Abis.earnVault,
|
|
701
721
|
functionName: 'asset',
|
|
702
722
|
}),
|
|
703
723
|
(0, utils_js_1.defineCall)({
|
|
704
724
|
address: vault,
|
|
705
|
-
abi: Abis.
|
|
725
|
+
abi: Abis.earnVault,
|
|
706
726
|
functionName: 'engine',
|
|
707
727
|
}),
|
|
708
728
|
(0, utils_js_1.defineCall)({
|
|
709
729
|
address: vault,
|
|
710
|
-
abi: Abis.
|
|
711
|
-
functionName: '
|
|
730
|
+
abi: Abis.earnVault,
|
|
731
|
+
functionName: 'earnShare',
|
|
712
732
|
}),
|
|
713
733
|
(0, utils_js_1.defineCall)({
|
|
714
734
|
address: vault,
|
|
715
|
-
abi: Abis.
|
|
735
|
+
abi: Abis.earnVault,
|
|
716
736
|
functionName: 'operator',
|
|
717
737
|
}),
|
|
718
738
|
(0, utils_js_1.defineCall)({
|
|
719
739
|
address: vault,
|
|
720
|
-
abi: Abis.
|
|
740
|
+
abi: Abis.earnVault,
|
|
721
741
|
functionName: 'emergencyGuardian',
|
|
722
742
|
}),
|
|
723
743
|
(0, utils_js_1.defineCall)({
|
|
724
744
|
address: vault,
|
|
725
|
-
abi: Abis.
|
|
745
|
+
abi: Abis.earnVault,
|
|
726
746
|
functionName: 'asyncJanitor',
|
|
727
747
|
}),
|
|
728
748
|
(0, utils_js_1.defineCall)({
|
|
729
749
|
address: vault,
|
|
730
|
-
abi: Abis.
|
|
750
|
+
abi: Abis.earnVault,
|
|
731
751
|
functionName: 'engineMigrationMode',
|
|
732
752
|
}),
|
|
733
753
|
(0, utils_js_1.defineCall)({
|
|
734
754
|
address: vault,
|
|
735
|
-
abi: Abis.
|
|
755
|
+
abi: Abis.earnVault,
|
|
736
756
|
functionName: 'depositsPaused',
|
|
737
757
|
}),
|
|
738
758
|
(0, utils_js_1.defineCall)({
|
|
739
759
|
address: vault,
|
|
740
|
-
abi: Abis.
|
|
760
|
+
abi: Abis.earnVault,
|
|
741
761
|
functionName: 'engineShares',
|
|
742
762
|
}),
|
|
743
763
|
(0, utils_js_1.defineCall)({
|
|
744
764
|
address: vault,
|
|
745
|
-
abi: Abis.
|
|
746
|
-
functionName: '
|
|
765
|
+
abi: Abis.earnVault,
|
|
766
|
+
functionName: 'totalEarnShares',
|
|
747
767
|
}),
|
|
748
768
|
(0, utils_js_1.defineCall)({
|
|
749
769
|
address: vault,
|
|
750
|
-
abi: Abis.
|
|
751
|
-
functionName: '
|
|
770
|
+
abi: Abis.earnVault,
|
|
771
|
+
functionName: 'isAccountingAligned',
|
|
752
772
|
}),
|
|
753
773
|
(0, utils_js_1.defineCall)({
|
|
754
774
|
address: vault,
|
|
755
|
-
abi: Abis.
|
|
756
|
-
functionName: '
|
|
775
|
+
abi: Abis.earnVault,
|
|
776
|
+
functionName: 'openRedeemRequestCount',
|
|
757
777
|
}),
|
|
758
778
|
(0, utils_js_1.defineCall)({
|
|
759
|
-
address:
|
|
760
|
-
abi: Abis.
|
|
779
|
+
address: fees,
|
|
780
|
+
abi: Abis.earnFees,
|
|
761
781
|
functionName: 'feesActive',
|
|
762
782
|
}),
|
|
763
783
|
(0, utils_js_1.defineCall)({
|
|
764
784
|
address: engine,
|
|
765
|
-
abi: Abis.
|
|
785
|
+
abi: Abis.earnEngine,
|
|
766
786
|
functionName: 'totalAssets',
|
|
767
787
|
}),
|
|
768
788
|
(0, utils_js_1.defineCall)({
|
|
769
789
|
address: engine,
|
|
770
|
-
abi: Abis.
|
|
790
|
+
abi: Abis.earnEngine,
|
|
771
791
|
functionName: 'name',
|
|
772
792
|
}),
|
|
773
793
|
(0, utils_js_1.defineCall)({
|
|
774
794
|
address: engine,
|
|
775
|
-
abi: Abis.
|
|
795
|
+
abi: Abis.earnEngine,
|
|
776
796
|
functionName: 'symbol',
|
|
777
797
|
}),
|
|
778
798
|
(0, utils_js_1.defineCall)({
|
|
779
799
|
address: engine,
|
|
780
|
-
abi: Abis.
|
|
800
|
+
abi: Abis.earnEngine,
|
|
781
801
|
functionName: 'supportsInterface',
|
|
782
802
|
args: [interfaceIds.asyncRedeem],
|
|
783
803
|
}),
|
|
784
804
|
(0, utils_js_1.defineCall)({
|
|
785
805
|
address: engine,
|
|
786
|
-
abi: Abis.
|
|
806
|
+
abi: Abis.earnEngine,
|
|
787
807
|
functionName: 'supportsInterface',
|
|
788
808
|
args: [interfaceIds.exactWithdraw],
|
|
789
809
|
}),
|
|
790
810
|
(0, utils_js_1.defineCall)({
|
|
791
811
|
address: engine,
|
|
792
|
-
abi: Abis.
|
|
812
|
+
abi: Abis.earnEngine,
|
|
793
813
|
functionName: 'supportsInterface',
|
|
794
814
|
args: [interfaceIds.inKindDeposit],
|
|
795
815
|
}),
|
|
796
816
|
(0, utils_js_1.defineCall)({
|
|
797
817
|
address: engine,
|
|
798
|
-
abi: Abis.
|
|
818
|
+
abi: Abis.earnEngine,
|
|
799
819
|
functionName: 'supportsInterface',
|
|
800
820
|
args: [interfaceIds.syncRedeem],
|
|
801
821
|
}),
|
|
@@ -815,7 +835,7 @@ async function getWithdrawQuote(client, parameters) {
|
|
|
815
835
|
const { assetAmount, vault } = args;
|
|
816
836
|
return (0, utils_js_1.defineCall)({
|
|
817
837
|
address: vault,
|
|
818
|
-
abi: Abis.
|
|
838
|
+
abi: Abis.earnVault,
|
|
819
839
|
args: [assetAmount],
|
|
820
840
|
functionName: 'previewWithdraw',
|
|
821
841
|
});
|
|
@@ -830,9 +850,9 @@ async function redeem(client, parameters) {
|
|
|
830
850
|
const [args, shareToken] = await Promise.all([
|
|
831
851
|
toRedeemArgs(client, parameters),
|
|
832
852
|
(0, readContract_js_1.readContract)(client, {
|
|
833
|
-
abi: Abis.
|
|
853
|
+
abi: Abis.earnVault,
|
|
834
854
|
address: parameters.vault,
|
|
835
|
-
functionName: '
|
|
855
|
+
functionName: 'earnShare',
|
|
836
856
|
}),
|
|
837
857
|
]);
|
|
838
858
|
return (await action(client, {
|
|
@@ -851,7 +871,7 @@ async function redeem(client, parameters) {
|
|
|
851
871
|
})();
|
|
852
872
|
return (0, utils_js_1.defineCall)({
|
|
853
873
|
address: vault,
|
|
854
|
-
abi: Abis.
|
|
874
|
+
abi: Abis.earnVault,
|
|
855
875
|
functionName: 'redeem',
|
|
856
876
|
args: [
|
|
857
877
|
internal_Token.toBaseUnits(args.shareAmount, undefined),
|
|
@@ -878,7 +898,7 @@ async function redeem(client, parameters) {
|
|
|
878
898
|
function extractEvent(logs, parameters) {
|
|
879
899
|
const { vault } = parameters;
|
|
880
900
|
const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
|
|
881
|
-
abi: Abis.
|
|
901
|
+
abi: Abis.earnVault,
|
|
882
902
|
eventName: 'Redeemed',
|
|
883
903
|
logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
|
|
884
904
|
});
|
|
@@ -914,7 +934,7 @@ async function redeemSync(client, parameters) {
|
|
|
914
934
|
caller: args.caller,
|
|
915
935
|
receipt,
|
|
916
936
|
recipient: args.receiver,
|
|
917
|
-
shareAmount: args.
|
|
937
|
+
shareAmount: args.earnShares,
|
|
918
938
|
};
|
|
919
939
|
}
|
|
920
940
|
async function privateRedeem(client, parameters) {
|
|
@@ -926,15 +946,23 @@ async function privateRedeem(client, parameters) {
|
|
|
926
946
|
const chainId = client.chain?.id;
|
|
927
947
|
if (!chainId)
|
|
928
948
|
throw new Error('`chain` is required.');
|
|
929
|
-
const { actionId = ox_1.Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, recipient, recoveryRecipient, returnMemo, shareAmount, withdrawalMemo, } = parameters;
|
|
949
|
+
const { actionId = ox_1.Hex.random(32), callbackGas = zoneGatewayCallbackGas, fallbackRecipient = parameters.recoveryRecipient, gateway, portalAddress: portalAddress_, recipient, recoveryRecipient, returnMemo, shareAmount, vault, withdrawalMemo, zoneId, } = parameters;
|
|
950
|
+
const portalAddress = portalAddress_ ?? (0, zone_js_1.getPortalAddress)(chainId, zoneId);
|
|
930
951
|
const readParameters = pickReadParameters(parameters);
|
|
931
952
|
const [fromBlock, config] = await Promise.all([
|
|
932
953
|
(0, getBlockNumber_js_1.getBlockNumber)(client, { cacheTime: 0 }),
|
|
933
|
-
getZoneGatewayConfig(client, {
|
|
954
|
+
getZoneGatewayConfig(client, {
|
|
955
|
+
...readParameters,
|
|
956
|
+
flow: 1,
|
|
957
|
+
gateway,
|
|
958
|
+
vault,
|
|
959
|
+
zoneId,
|
|
960
|
+
zonePortal: portalAddress,
|
|
961
|
+
}),
|
|
934
962
|
]);
|
|
935
|
-
const assetToken = parameters.assetToken ?? config.
|
|
936
|
-
if ((0, isAddressEqual_js_1.isAddressEqual)(assetToken, config.
|
|
937
|
-
throw new Error('`assetToken`
|
|
963
|
+
const assetToken = parameters.assetToken ?? config.privateAsset;
|
|
964
|
+
if (!(0, isAddressEqual_js_1.isAddressEqual)(assetToken, config.privateAsset))
|
|
965
|
+
throw new Error('`assetToken` must match the Zone gateway private asset.');
|
|
938
966
|
const [{ encrypted, keyIndex }, assetAmountMin] = await Promise.all([
|
|
939
967
|
zoneActions.encryptedDeposit.prepareRecipient(client, {
|
|
940
968
|
...readParameters,
|
|
@@ -951,23 +979,19 @@ async function privateRedeem(client, parameters) {
|
|
|
951
979
|
const assetAmount = await getRedeemQuote(client, {
|
|
952
980
|
...readParameters,
|
|
953
981
|
shareAmount,
|
|
954
|
-
vault: config.
|
|
982
|
+
vault: config.vault,
|
|
955
983
|
});
|
|
956
984
|
return tempo_1.EarnShares.minimumOutput(assetAmount, parameters.slippageBps);
|
|
957
985
|
})(),
|
|
958
986
|
]);
|
|
959
|
-
const
|
|
960
|
-
const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.zoneGatewayCallbackData, [
|
|
987
|
+
const data = (0, encodeAbiParameters_js_1.encodeAbiParameters)(Abis.earnRouterCallbackData, [
|
|
961
988
|
{
|
|
962
|
-
flow: 1,
|
|
963
|
-
outputToken: assetToken,
|
|
964
|
-
keyIndex,
|
|
965
|
-
encrypted,
|
|
966
|
-
minVaultAssets: direct ? assetAmountMin : 1n,
|
|
967
|
-
minVaultShares: 0n,
|
|
968
|
-
minOutputAmount: direct ? 0n : assetAmountMin,
|
|
969
989
|
actionId,
|
|
970
|
-
|
|
990
|
+
flow: 1,
|
|
991
|
+
minEarnShares: 0n,
|
|
992
|
+
minOutputAmount: assetAmountMin,
|
|
993
|
+
minVaultAssets: assetAmountMin,
|
|
994
|
+
zoneReturn: { encrypted, keyIndex, refundRecipient: recoveryRecipient },
|
|
971
995
|
},
|
|
972
996
|
]);
|
|
973
997
|
return {
|
|
@@ -995,15 +1019,16 @@ async function privateRedeemSync(client, parameters) {
|
|
|
995
1019
|
return zoneActions.requestWithdrawalSync(client, parameters);
|
|
996
1020
|
}
|
|
997
1021
|
async function waitForPrivateRedeem(client, parameters) {
|
|
998
|
-
const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, } = parameters;
|
|
1022
|
+
const { actionId, fromBlock, gateway, pollingInterval = client.pollingInterval, timeout = 60_000, vault, } = parameters;
|
|
999
1023
|
const event = (0, getAbiItem_js_1.getAbiItem)({
|
|
1000
|
-
abi: Abis.
|
|
1024
|
+
abi: Abis.earnRouter,
|
|
1001
1025
|
name: 'EarnRedeem',
|
|
1002
1026
|
});
|
|
1003
1027
|
const observerId = (0, stringify_js_1.stringify)([
|
|
1004
1028
|
'waitForPrivateRedeem',
|
|
1005
1029
|
client.uid,
|
|
1006
1030
|
gateway,
|
|
1031
|
+
vault,
|
|
1007
1032
|
actionId,
|
|
1008
1033
|
fromBlock,
|
|
1009
1034
|
]);
|
|
@@ -1027,7 +1052,7 @@ async function waitForPrivateRedeem(client, parameters) {
|
|
|
1027
1052
|
try {
|
|
1028
1053
|
const [log] = await (0, getLogs_js_1.getLogs)(client, {
|
|
1029
1054
|
address: gateway,
|
|
1030
|
-
args: { actionId },
|
|
1055
|
+
args: { actionId, earnVault: vault },
|
|
1031
1056
|
event,
|
|
1032
1057
|
fromBlock,
|
|
1033
1058
|
strict: true,
|
|
@@ -1040,7 +1065,7 @@ async function waitForPrivateRedeem(client, parameters) {
|
|
|
1040
1065
|
actionId: log.args.actionId,
|
|
1041
1066
|
outputAmount: log.args.outputAmount,
|
|
1042
1067
|
outputToken: log.args.outputToken,
|
|
1043
|
-
shares: log.args.
|
|
1068
|
+
shares: log.args.earnShares,
|
|
1044
1069
|
tempoBlockNumber: log.blockNumber,
|
|
1045
1070
|
vaultAssets: log.args.vaultAssets,
|
|
1046
1071
|
zoneDepositHash: log.args.zoneDepositHash,
|
|
@@ -1068,9 +1093,9 @@ async function withdrawExact(client, parameters) {
|
|
|
1068
1093
|
const [args, shareToken] = await Promise.all([
|
|
1069
1094
|
toWithdrawExactArgs(client, parameters),
|
|
1070
1095
|
(0, readContract_js_1.readContract)(client, {
|
|
1071
|
-
abi: Abis.
|
|
1096
|
+
abi: Abis.earnVault,
|
|
1072
1097
|
address: parameters.vault,
|
|
1073
|
-
functionName: '
|
|
1098
|
+
functionName: 'earnShare',
|
|
1074
1099
|
}),
|
|
1075
1100
|
]);
|
|
1076
1101
|
return (await action(client, {
|
|
@@ -1089,7 +1114,7 @@ async function withdrawExact(client, parameters) {
|
|
|
1089
1114
|
})();
|
|
1090
1115
|
return (0, utils_js_1.defineCall)({
|
|
1091
1116
|
address: vault,
|
|
1092
|
-
abi: Abis.
|
|
1117
|
+
abi: Abis.earnVault,
|
|
1093
1118
|
functionName: 'withdrawExact',
|
|
1094
1119
|
args: [
|
|
1095
1120
|
internal_Token.toBaseUnits(args.assetAmount, undefined),
|
|
@@ -1118,7 +1143,7 @@ async function withdrawExact(client, parameters) {
|
|
|
1118
1143
|
function extractEvent(logs, parameters) {
|
|
1119
1144
|
const { vault } = parameters;
|
|
1120
1145
|
const [log] = (0, parseEventLogs_js_1.parseEventLogs)({
|
|
1121
|
-
abi: Abis.
|
|
1146
|
+
abi: Abis.earnVault,
|
|
1122
1147
|
eventName: 'WithdrewExact',
|
|
1123
1148
|
logs: logs.filter((log) => (0, isAddressEqual_js_1.isAddressEqual)(log.address, vault)),
|
|
1124
1149
|
});
|
|
@@ -1154,7 +1179,7 @@ async function withdrawExactSync(client, parameters) {
|
|
|
1154
1179
|
caller: args.caller,
|
|
1155
1180
|
receipt,
|
|
1156
1181
|
recipient: args.receiver,
|
|
1157
|
-
shareAmount: args.
|
|
1182
|
+
shareAmount: args.earnSharesBurned,
|
|
1158
1183
|
};
|
|
1159
1184
|
}
|
|
1160
1185
|
const zoneGatewayCallbackGas = 10000000n;
|
|
@@ -1184,54 +1209,79 @@ function pickReadParameters(parameters) {
|
|
|
1184
1209
|
return { blockOverrides, blockTag: parameters.blockTag, stateOverride };
|
|
1185
1210
|
}
|
|
1186
1211
|
async function getZoneGatewayConfig(client, parameters) {
|
|
1187
|
-
const { gateway, ...rest } = parameters;
|
|
1188
|
-
const [
|
|
1212
|
+
const { flow, gateway, vault, zoneId, zonePortal, ...rest } = parameters;
|
|
1213
|
+
const [vaultAsset, shareToken, allowedZoneId, routerVault, privateAsset, routerVaultAsset, routerShareToken, supportsFlow,] = await (0, multicall_js_1.multicall)(client, {
|
|
1189
1214
|
...rest,
|
|
1190
1215
|
allowFailure: false,
|
|
1191
1216
|
contracts: [
|
|
1192
1217
|
{
|
|
1193
|
-
abi: Abis.
|
|
1218
|
+
abi: Abis.earnVault,
|
|
1219
|
+
address: vault,
|
|
1220
|
+
functionName: 'asset',
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
abi: Abis.earnVault,
|
|
1224
|
+
address: vault,
|
|
1225
|
+
functionName: 'earnShare',
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
abi: Abis.earnRouter,
|
|
1194
1229
|
address: gateway,
|
|
1195
|
-
functionName: '
|
|
1230
|
+
functionName: 'allowedZoneId',
|
|
1196
1231
|
},
|
|
1197
1232
|
{
|
|
1198
|
-
abi: Abis.
|
|
1233
|
+
abi: Abis.earnRouter,
|
|
1199
1234
|
address: gateway,
|
|
1200
|
-
functionName: '
|
|
1235
|
+
functionName: 'earnVault',
|
|
1201
1236
|
},
|
|
1202
1237
|
{
|
|
1203
|
-
abi: Abis.
|
|
1238
|
+
abi: Abis.earnRouter,
|
|
1204
1239
|
address: gateway,
|
|
1205
|
-
functionName: '
|
|
1240
|
+
functionName: 'privateAsset',
|
|
1206
1241
|
},
|
|
1207
1242
|
{
|
|
1208
|
-
abi: Abis.
|
|
1243
|
+
abi: Abis.earnRouter,
|
|
1209
1244
|
address: gateway,
|
|
1210
|
-
functionName: '
|
|
1245
|
+
functionName: 'vaultAsset',
|
|
1211
1246
|
},
|
|
1212
1247
|
{
|
|
1213
|
-
abi: Abis.
|
|
1248
|
+
abi: Abis.earnRouter,
|
|
1214
1249
|
address: gateway,
|
|
1215
|
-
functionName: '
|
|
1250
|
+
functionName: 'earnShare',
|
|
1216
1251
|
},
|
|
1217
1252
|
{
|
|
1218
|
-
abi: Abis.
|
|
1253
|
+
abi: Abis.earnRouter,
|
|
1219
1254
|
address: gateway,
|
|
1220
|
-
args: [
|
|
1255
|
+
args: [flow],
|
|
1221
1256
|
functionName: 'supportsFlow',
|
|
1222
1257
|
},
|
|
1223
1258
|
],
|
|
1224
1259
|
deployless: true,
|
|
1225
1260
|
});
|
|
1226
|
-
if (
|
|
1227
|
-
throw new Error('
|
|
1228
|
-
|
|
1261
|
+
if (!supportsFlow)
|
|
1262
|
+
throw new Error('Zone gateway flow is not supported.');
|
|
1263
|
+
if (allowedZoneId !== zoneId)
|
|
1264
|
+
throw new Error('Zone gateway is configured for a different Zone.');
|
|
1265
|
+
if (!(0, isAddressEqual_js_1.isAddressEqual)(routerVault, vault))
|
|
1266
|
+
throw new Error('Zone gateway is configured for a different Earn vault.');
|
|
1267
|
+
if (!(0, isAddressEqual_js_1.isAddressEqual)(routerVaultAsset, vaultAsset))
|
|
1268
|
+
throw new Error('Zone gateway vault asset does not match the Earn vault.');
|
|
1269
|
+
if (!(0, isAddressEqual_js_1.isAddressEqual)(routerShareToken, shareToken))
|
|
1270
|
+
throw new Error('Zone gateway share token does not match the Earn vault.');
|
|
1271
|
+
return {
|
|
1272
|
+
privateAsset,
|
|
1273
|
+
shareToken,
|
|
1274
|
+
vault,
|
|
1275
|
+
vaultAsset,
|
|
1276
|
+
zoneId,
|
|
1277
|
+
zonePortal,
|
|
1278
|
+
};
|
|
1229
1279
|
}
|
|
1230
1280
|
const interfaceIds = {
|
|
1231
1281
|
asyncRedeem: '0xa1a6a1d7',
|
|
1232
1282
|
exactWithdraw: '0x0adfb0b9',
|
|
1233
|
-
inKindDeposit: '
|
|
1234
|
-
syncRedeem: '
|
|
1283
|
+
inKindDeposit: '0xce4790a9',
|
|
1284
|
+
syncRedeem: '0x94a2d467',
|
|
1235
1285
|
};
|
|
1236
1286
|
function toFeeConfig(config) {
|
|
1237
1287
|
return {
|
|
@@ -1240,8 +1290,20 @@ function toFeeConfig(config) {
|
|
|
1240
1290
|
};
|
|
1241
1291
|
}
|
|
1242
1292
|
function toFeePreview(preview) {
|
|
1243
|
-
const { allocationCount, allocations, ...rest } = preview;
|
|
1244
|
-
return {
|
|
1293
|
+
const { allocationCount, allocations, postFeeValuePerEarnShare, preFeeValuePerEarnShare, targetValuePerEarnShare, totalFeeEarnShares, ...rest } = preview;
|
|
1294
|
+
return {
|
|
1295
|
+
...rest,
|
|
1296
|
+
allocations: allocations
|
|
1297
|
+
.slice(0, allocationCount)
|
|
1298
|
+
.map(({ feeEarnShares, ...allocation }) => ({
|
|
1299
|
+
...allocation,
|
|
1300
|
+
feeShares: feeEarnShares,
|
|
1301
|
+
})),
|
|
1302
|
+
postFeeValuePerShare: postFeeValuePerEarnShare,
|
|
1303
|
+
preFeeValuePerShare: preFeeValuePerEarnShare,
|
|
1304
|
+
targetValuePerShare: targetValuePerEarnShare,
|
|
1305
|
+
totalFeeShares: totalFeeEarnShares,
|
|
1306
|
+
};
|
|
1245
1307
|
}
|
|
1246
1308
|
async function toDepositArgs(client, parameters) {
|
|
1247
1309
|
const { vault } = parameters;
|
|
@@ -1348,9 +1410,9 @@ async function toBaseUnitsLive(client, options) {
|
|
|
1348
1410
|
if (amount.decimals !== undefined)
|
|
1349
1411
|
return internal_Token.toBaseUnits(amount, amount.decimals);
|
|
1350
1412
|
const address = await (0, readContract_js_1.readContract)(client, {
|
|
1351
|
-
abi: Abis.
|
|
1413
|
+
abi: Abis.earnVault,
|
|
1352
1414
|
address: vault,
|
|
1353
|
-
functionName: token,
|
|
1415
|
+
functionName: token === 'asset' ? 'asset' : 'earnShare',
|
|
1354
1416
|
});
|
|
1355
1417
|
const { decimals } = await (0, utils_js_1.resolveTokenWithDecimals)(client, {
|
|
1356
1418
|
token: address,
|