@paxoslabs/amplify-sdk 0.4.2 → 0.4.3-alpha.0
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 +79 -64
- package/dist/{chain-utils-CRMbWzu7.d.mts → chain-utils-CbVFMjwR.d.mts} +13 -1
- package/dist/{chain-utils-CRMbWzu7.d.ts → chain-utils-CbVFMjwR.d.ts} +13 -1
- package/dist/{chunk-5CV25BTQ.js → chunk-4OEL42W2.mjs} +83 -4
- package/dist/chunk-4OEL42W2.mjs.map +1 -0
- package/dist/{chunk-RW7PZETN.mjs → chunk-7RAFG3NI.mjs} +167 -228
- package/dist/chunk-7RAFG3NI.mjs.map +1 -0
- package/dist/{chunk-CQZCGPZK.mjs → chunk-E2HBXOZY.js} +92 -3
- package/dist/chunk-E2HBXOZY.js.map +1 -0
- package/dist/{chunk-WZXCJAKM.js → chunk-EHRZFLWL.js} +12 -12
- package/dist/{chunk-WZXCJAKM.js.map → chunk-EHRZFLWL.js.map} +1 -1
- package/dist/{chunk-GMMBJB4B.mjs → chunk-GSYGURYO.mjs} +71 -46
- package/dist/chunk-GSYGURYO.mjs.map +1 -0
- package/dist/{chunk-VZED4E3L.mjs → chunk-HBFBGNRH.mjs} +3 -3
- package/dist/{chunk-VZED4E3L.mjs.map → chunk-HBFBGNRH.mjs.map} +1 -1
- package/dist/{chunk-TPU2HZAX.mjs → chunk-L3X5UBG6.mjs} +86 -169
- package/dist/chunk-L3X5UBG6.mjs.map +1 -0
- package/dist/{chunk-BQG3XKTU.js → chunk-R5G6F7RP.js} +168 -227
- package/dist/chunk-R5G6F7RP.js.map +1 -0
- package/dist/{chunk-OZJNKGW6.js → chunk-WHL5LQRP.js} +120 -95
- package/dist/chunk-WHL5LQRP.js.map +1 -0
- package/dist/{chunk-2YPKHXFJ.js → chunk-ZJBJFFBQ.js} +180 -263
- package/dist/chunk-ZJBJFFBQ.js.map +1 -0
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +16 -16
- package/dist/core.mjs +4 -4
- package/dist/display.d.mts +23 -11
- package/dist/display.d.ts +23 -11
- package/dist/display.js +10 -10
- package/dist/display.mjs +4 -4
- package/dist/index.d.mts +107 -7
- package/dist/index.d.ts +107 -7
- package/dist/index.js +75 -51
- package/dist/index.mjs +5 -5
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +7 -7
- package/dist/utils.mjs +2 -2
- package/dist/vaults.d.mts +107 -94
- package/dist/vaults.d.ts +107 -94
- package/dist/vaults.js +25 -25
- package/dist/vaults.mjs +4 -4
- package/package.json +18 -11
- package/dist/chunk-2YPKHXFJ.js.map +0 -1
- package/dist/chunk-5CV25BTQ.js.map +0 -1
- package/dist/chunk-BQG3XKTU.js.map +0 -1
- package/dist/chunk-CQZCGPZK.mjs.map +0 -1
- package/dist/chunk-GMMBJB4B.mjs.map +0 -1
- package/dist/chunk-OZJNKGW6.js.map +0 -1
- package/dist/chunk-RW7PZETN.mjs.map +0 -1
- package/dist/chunk-TPU2HZAX.mjs.map +0 -1
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkE2HBXOZY_js = require('./chunk-E2HBXOZY.js');
|
|
4
|
+
var chunkEHRZFLWL_js = require('./chunk-EHRZFLWL.js');
|
|
5
5
|
var chunk3I3PYX2F_js = require('./chunk-3I3PYX2F.js');
|
|
6
|
-
var
|
|
6
|
+
var chunkR5G6F7RP_js = require('./chunk-R5G6F7RP.js');
|
|
7
7
|
var viem = require('viem');
|
|
8
8
|
|
|
9
9
|
var isDepositSpendApproved = async ({
|
|
10
|
-
|
|
10
|
+
vaultName,
|
|
11
11
|
chainId,
|
|
12
12
|
depositAssetAddress,
|
|
13
13
|
recipientAddress
|
|
14
14
|
}) => {
|
|
15
15
|
try {
|
|
16
|
-
const normalizedChainId =
|
|
17
|
-
const config = await
|
|
18
|
-
|
|
16
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
17
|
+
const config = await chunkE2HBXOZY_js.resolveVault({
|
|
18
|
+
vaultName,
|
|
19
19
|
chainId: normalizedChainId,
|
|
20
|
-
assetAddress: depositAssetAddress
|
|
20
|
+
assetAddress: depositAssetAddress,
|
|
21
|
+
callerEndpoint: "isDepositSpendApproved"
|
|
21
22
|
});
|
|
22
|
-
if (!config) {
|
|
23
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
24
|
-
`Vault not found for ${yieldType} on chain ${normalizedChainId}`,
|
|
25
|
-
{
|
|
26
|
-
endpoint: "isDepositSpendApproved"
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
23
|
const communityCodeDepositorAddress = config.vault.communityCodeDepositorAddress;
|
|
31
24
|
if (!communityCodeDepositorAddress) {
|
|
32
|
-
throw new
|
|
25
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
33
26
|
`Community code depositor contract address not configured for vault ${config.id}`,
|
|
34
27
|
{
|
|
35
28
|
endpoint: "isDepositSpendApproved"
|
|
@@ -44,7 +37,7 @@ var isDepositSpendApproved = async ({
|
|
|
44
37
|
domainSeparator,
|
|
45
38
|
tokenName,
|
|
46
39
|
tokenVersion
|
|
47
|
-
} = await
|
|
40
|
+
} = await chunkEHRZFLWL_js.getTokenPermitInfoWithAllowance({
|
|
48
41
|
chainId: normalizedChainId,
|
|
49
42
|
tokenAddress: depositAssetAddress,
|
|
50
43
|
owner: recipientAddress,
|
|
@@ -63,10 +56,10 @@ var isDepositSpendApproved = async ({
|
|
|
63
56
|
error: null
|
|
64
57
|
};
|
|
65
58
|
} catch (error) {
|
|
66
|
-
if (error instanceof
|
|
59
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
67
60
|
throw error;
|
|
68
61
|
}
|
|
69
|
-
throw new
|
|
62
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
70
63
|
`Failed to check deposit approval: ${error instanceof Error ? error.message : String(error)}`,
|
|
71
64
|
{
|
|
72
65
|
endpoint: "isDepositSpendApproved",
|
|
@@ -76,29 +69,22 @@ var isDepositSpendApproved = async ({
|
|
|
76
69
|
}
|
|
77
70
|
};
|
|
78
71
|
var isWithdrawalSpendApproved = async ({
|
|
79
|
-
|
|
72
|
+
vaultName,
|
|
80
73
|
chainId,
|
|
81
74
|
wantAssetAddress,
|
|
82
75
|
recipientAddress
|
|
83
76
|
}) => {
|
|
84
77
|
try {
|
|
85
|
-
const normalizedChainId =
|
|
86
|
-
const config = await
|
|
87
|
-
|
|
78
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
79
|
+
const config = await chunkE2HBXOZY_js.resolveVault({
|
|
80
|
+
vaultName,
|
|
88
81
|
chainId: normalizedChainId,
|
|
89
|
-
assetAddress: wantAssetAddress
|
|
82
|
+
assetAddress: wantAssetAddress,
|
|
83
|
+
callerEndpoint: "isWithdrawalSpendApproved"
|
|
90
84
|
});
|
|
91
|
-
if (!config) {
|
|
92
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
93
|
-
`Vault not found for ${yieldType} on chain ${normalizedChainId}`,
|
|
94
|
-
{
|
|
95
|
-
endpoint: "isWithdrawalSpendApproved"
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
85
|
const boringVaultAddress = config.vault.boringVaultAddress;
|
|
100
86
|
if (!boringVaultAddress) {
|
|
101
|
-
throw new
|
|
87
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
102
88
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
103
89
|
{
|
|
104
90
|
endpoint: "isWithdrawalSpendApproved"
|
|
@@ -107,14 +93,14 @@ var isWithdrawalSpendApproved = async ({
|
|
|
107
93
|
}
|
|
108
94
|
const withdrawQueueAddress = config.vault.withdrawQueueAddress;
|
|
109
95
|
if (!withdrawQueueAddress) {
|
|
110
|
-
throw new
|
|
96
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
111
97
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
112
98
|
{
|
|
113
99
|
endpoint: "isWithdrawalSpendApproved"
|
|
114
100
|
}
|
|
115
101
|
);
|
|
116
102
|
}
|
|
117
|
-
const [allowance, decimals] = await
|
|
103
|
+
const [allowance, decimals] = await chunkEHRZFLWL_js.getErc20AllowanceWithDecimals({
|
|
118
104
|
chainId: normalizedChainId,
|
|
119
105
|
tokenAddress: boringVaultAddress,
|
|
120
106
|
recipientAddress,
|
|
@@ -137,44 +123,39 @@ var isWithdrawalSpendApproved = async ({
|
|
|
137
123
|
error: null
|
|
138
124
|
};
|
|
139
125
|
} catch (error) {
|
|
140
|
-
if (error instanceof
|
|
126
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
141
127
|
throw error;
|
|
142
128
|
}
|
|
143
|
-
throw new
|
|
129
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
144
130
|
`Failed to check withdrawal approval: ${error instanceof Error ? error.message : String(error)}`,
|
|
145
131
|
{ endpoint: "isWithdrawalSpendApproved", cause: error }
|
|
146
132
|
);
|
|
147
133
|
}
|
|
148
134
|
};
|
|
149
135
|
async function prepareApproveDepositTokenTxData({
|
|
150
|
-
|
|
136
|
+
vaultName,
|
|
151
137
|
depositAsset,
|
|
152
138
|
approvalAmount,
|
|
153
139
|
chainId
|
|
154
140
|
}) {
|
|
155
|
-
const normalizedChainId =
|
|
141
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
156
142
|
try {
|
|
157
|
-
const config = await
|
|
143
|
+
const config = await chunkE2HBXOZY_js.resolveVault({
|
|
144
|
+
vaultName,
|
|
158
145
|
assetAddress: depositAsset,
|
|
159
|
-
|
|
160
|
-
|
|
146
|
+
chainId: normalizedChainId,
|
|
147
|
+
callerEndpoint: "prepareApproveDepositToken"
|
|
161
148
|
});
|
|
162
|
-
if (!config) {
|
|
163
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
164
|
-
`No vault found for token address ${depositAsset} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
165
|
-
{ endpoint: "prepareApproveDepositToken" }
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
149
|
const communityCodeDepositorAddress = config.vault.communityCodeDepositorAddress;
|
|
169
150
|
if (!communityCodeDepositorAddress) {
|
|
170
|
-
throw new
|
|
151
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
171
152
|
`Community Code Depositor contract address not configured for vault ${config.id}`,
|
|
172
153
|
{ endpoint: "prepareApproveDepositToken" }
|
|
173
154
|
);
|
|
174
155
|
}
|
|
175
|
-
const assets = await
|
|
156
|
+
const assets = await chunkR5G6F7RP_js.getAssetsFromCache({ address: depositAsset });
|
|
176
157
|
if (assets.length === 0) {
|
|
177
|
-
throw new
|
|
158
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
178
159
|
`Asset metadata not found for token ${depositAsset} on chain ${normalizedChainId}`,
|
|
179
160
|
{ endpoint: "prepareApproveDepositToken" }
|
|
180
161
|
);
|
|
@@ -183,13 +164,13 @@ async function prepareApproveDepositTokenTxData({
|
|
|
183
164
|
(asset) => asset.address.toLowerCase() === depositAsset.toLowerCase() && asset.chains.includes(normalizedChainId)
|
|
184
165
|
);
|
|
185
166
|
if (!verifiedAsset) {
|
|
186
|
-
throw new
|
|
167
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
187
168
|
`Asset ${depositAsset} not verified on chain ${normalizedChainId}`,
|
|
188
169
|
{ endpoint: "prepareApproveDepositToken" }
|
|
189
170
|
);
|
|
190
171
|
}
|
|
191
172
|
const decimals = verifiedAsset.decimals;
|
|
192
|
-
const amount = approvalAmount ? viem.parseUnits(approvalAmount, decimals) :
|
|
173
|
+
const amount = approvalAmount ? viem.parseUnits(approvalAmount, decimals) : chunkR5G6F7RP_js.DEFAULT_APPROVAL_AMOUNT;
|
|
193
174
|
return {
|
|
194
175
|
abi: viem.erc20Abi,
|
|
195
176
|
address: depositAsset,
|
|
@@ -197,10 +178,10 @@ async function prepareApproveDepositTokenTxData({
|
|
|
197
178
|
args: [communityCodeDepositorAddress, amount]
|
|
198
179
|
};
|
|
199
180
|
} catch (error) {
|
|
200
|
-
if (error instanceof
|
|
181
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
201
182
|
throw error;
|
|
202
183
|
}
|
|
203
|
-
throw new
|
|
184
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
204
185
|
`Failed to prepare approval transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
205
186
|
{
|
|
206
187
|
endpoint: "prepareApproveDepositToken",
|
|
@@ -441,7 +422,7 @@ var CommunityCodeDepositorAbi = [
|
|
|
441
422
|
|
|
442
423
|
// src/vaults/deposit/utils.ts
|
|
443
424
|
var calculateMinimumMint = (depositAmount, rate, vaultTokenDecimals, slippage) => {
|
|
444
|
-
const slippageValue = slippage ??
|
|
425
|
+
const slippageValue = slippage ?? chunkR5G6F7RP_js.DEFAULT_SLIPPAGE_BPS;
|
|
445
426
|
const slippageAsBigInt = BigInt(slippageValue) * chunk3I3PYX2F_js.WAD.bigint / BigInt(1e4);
|
|
446
427
|
const minimumMint = depositAmount * chunk3I3PYX2F_js.WAD.bigint / rate;
|
|
447
428
|
const slippageAmount = minimumMint * slippageAsBigInt / chunk3I3PYX2F_js.WAD.bigint;
|
|
@@ -454,33 +435,26 @@ var calculateMinimumMint = (depositAmount, rate, vaultTokenDecimals, slippage) =
|
|
|
454
435
|
// src/vaults/deposit/deposit.ts
|
|
455
436
|
async function prepareDepositTxData(params) {
|
|
456
437
|
const {
|
|
457
|
-
|
|
438
|
+
vaultName,
|
|
458
439
|
depositAsset,
|
|
459
440
|
depositAmount,
|
|
460
441
|
chainId,
|
|
461
|
-
slippage =
|
|
442
|
+
slippage = chunkR5G6F7RP_js.DEFAULT_SLIPPAGE_BPS,
|
|
462
443
|
to,
|
|
463
444
|
distributorCode
|
|
464
445
|
} = params;
|
|
465
446
|
try {
|
|
466
|
-
const normalizedChainId =
|
|
467
|
-
const vault = await
|
|
447
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
448
|
+
const vault = await chunkE2HBXOZY_js.resolveVault({
|
|
449
|
+
vaultName,
|
|
468
450
|
assetAddress: depositAsset,
|
|
469
|
-
|
|
470
|
-
|
|
451
|
+
chainId: normalizedChainId,
|
|
452
|
+
callerEndpoint: "prepareDepositTransactionData"
|
|
471
453
|
});
|
|
472
|
-
|
|
473
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
474
|
-
`No vault found for token address ${depositAsset} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
475
|
-
{
|
|
476
|
-
endpoint: "prepareDepositTransactionData"
|
|
477
|
-
}
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
const assets = await chunkBQG3XKTU_js.getAssetsFromCache({ address: depositAsset });
|
|
454
|
+
const assets = await chunkR5G6F7RP_js.getAssetsFromCache({ address: depositAsset });
|
|
481
455
|
const asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets.find((a) => a.address.toLowerCase() === depositAsset.toLowerCase());
|
|
482
456
|
if (!asset) {
|
|
483
|
-
throw new
|
|
457
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
484
458
|
`Asset metadata not found for token ${depositAsset} on chain ${normalizedChainId}`,
|
|
485
459
|
{
|
|
486
460
|
endpoint: "prepareDepositTransactionData"
|
|
@@ -489,26 +463,26 @@ async function prepareDepositTxData(params) {
|
|
|
489
463
|
}
|
|
490
464
|
const communityCodeDepositorAddress = vault.vault.communityCodeDepositorAddress;
|
|
491
465
|
if (!communityCodeDepositorAddress) {
|
|
492
|
-
throw new
|
|
466
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
493
467
|
`Community Code Depositor contract address not found for vault ${vault.id}`,
|
|
494
468
|
{ endpoint: "prepareDepositTransactionData" }
|
|
495
469
|
);
|
|
496
470
|
}
|
|
497
471
|
const accountantAddress = vault.vault.accountantAddress;
|
|
498
472
|
if (!accountantAddress) {
|
|
499
|
-
throw new
|
|
473
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
500
474
|
`Accountant contract address not found for vault ${vault.id}`,
|
|
501
475
|
{ endpoint: "prepareDepositTransactionData" }
|
|
502
476
|
);
|
|
503
477
|
}
|
|
504
478
|
const depositAssetAddress = asset.address;
|
|
505
|
-
const [depositAssetDecimalsResult, rateInQuoteResult] = await
|
|
479
|
+
const [depositAssetDecimalsResult, rateInQuoteResult] = await chunkEHRZFLWL_js.getRateInQuoteWithAssetDecimals({
|
|
506
480
|
assetAddress: depositAssetAddress,
|
|
507
481
|
accountantAddress,
|
|
508
482
|
chainId: normalizedChainId
|
|
509
483
|
});
|
|
510
484
|
if (depositAssetDecimalsResult.status === "failure") {
|
|
511
|
-
throw new
|
|
485
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
512
486
|
`Failed to get asset decimals: ${depositAssetDecimalsResult.error?.message || "Unknown error"}`,
|
|
513
487
|
{
|
|
514
488
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -517,7 +491,7 @@ async function prepareDepositTxData(params) {
|
|
|
517
491
|
);
|
|
518
492
|
}
|
|
519
493
|
if (rateInQuoteResult.status === "failure") {
|
|
520
|
-
throw new
|
|
494
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
521
495
|
`Failed to get exchange rate: ${rateInQuoteResult.error?.message || "Unknown error"}`,
|
|
522
496
|
{
|
|
523
497
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -536,7 +510,7 @@ async function prepareDepositTxData(params) {
|
|
|
536
510
|
slippage
|
|
537
511
|
);
|
|
538
512
|
if (!communityCodeDepositorAddress) {
|
|
539
|
-
throw new
|
|
513
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
540
514
|
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
541
515
|
{ endpoint: "prepareDepositTransactionData" }
|
|
542
516
|
);
|
|
@@ -555,10 +529,10 @@ async function prepareDepositTxData(params) {
|
|
|
555
529
|
chainId: normalizedChainId
|
|
556
530
|
};
|
|
557
531
|
} catch (error) {
|
|
558
|
-
if (error instanceof
|
|
532
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
559
533
|
throw error;
|
|
560
534
|
}
|
|
561
|
-
throw new
|
|
535
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
562
536
|
`Failed to prepare deposit transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
563
537
|
{
|
|
564
538
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -601,7 +575,7 @@ function toEthSignTypedDataV4(permitData) {
|
|
|
601
575
|
}
|
|
602
576
|
async function prepareDepositPermitSignature(params) {
|
|
603
577
|
const {
|
|
604
|
-
|
|
578
|
+
vaultName,
|
|
605
579
|
depositAsset,
|
|
606
580
|
depositAmount,
|
|
607
581
|
to,
|
|
@@ -614,34 +588,16 @@ async function prepareDepositPermitSignature(params) {
|
|
|
614
588
|
tokenVersion: prefetchedTokenVersion
|
|
615
589
|
} = params;
|
|
616
590
|
try {
|
|
617
|
-
const normalizedChainId =
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
});
|
|
625
|
-
} catch (error) {
|
|
626
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
627
|
-
`Failed to resolve vault for token ${depositAsset} with yield type ${yieldType} on chain ${normalizedChainId}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
628
|
-
{
|
|
629
|
-
endpoint: "prepareDepositPermitSignature",
|
|
630
|
-
cause: error
|
|
631
|
-
}
|
|
632
|
-
);
|
|
633
|
-
}
|
|
634
|
-
if (!vault) {
|
|
635
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
636
|
-
`No vault found for token address ${depositAsset} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
637
|
-
{
|
|
638
|
-
endpoint: "prepareDepositPermitSignature"
|
|
639
|
-
}
|
|
640
|
-
);
|
|
641
|
-
}
|
|
591
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
592
|
+
const vault = await chunkE2HBXOZY_js.resolveVault({
|
|
593
|
+
vaultName,
|
|
594
|
+
assetAddress: depositAsset,
|
|
595
|
+
chainId: normalizedChainId,
|
|
596
|
+
callerEndpoint: "prepareDepositPermitSignature"
|
|
597
|
+
});
|
|
642
598
|
const communityCodeDepositorAddress = vault.vault.communityCodeDepositorAddress;
|
|
643
599
|
if (!communityCodeDepositorAddress) {
|
|
644
|
-
throw new
|
|
600
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
645
601
|
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
646
602
|
{ endpoint: "prepareDepositPermitSignature" }
|
|
647
603
|
);
|
|
@@ -655,24 +611,24 @@ async function prepareDepositPermitSignature(params) {
|
|
|
655
611
|
resolvedTokenVersion = prefetchedTokenVersion;
|
|
656
612
|
resolvedNonce = prefetchedNonce;
|
|
657
613
|
} else {
|
|
658
|
-
const client = await
|
|
614
|
+
const client = await chunkR5G6F7RP_js.getClient(normalizedChainId);
|
|
659
615
|
try {
|
|
660
616
|
const [nameResult, versionResult, nonceResult] = await client.multicall(
|
|
661
617
|
{
|
|
662
618
|
contracts: [
|
|
663
619
|
{
|
|
664
620
|
address: depositAsset,
|
|
665
|
-
abi:
|
|
621
|
+
abi: chunkEHRZFLWL_js.erc2612Abi,
|
|
666
622
|
functionName: "name"
|
|
667
623
|
},
|
|
668
624
|
{
|
|
669
625
|
address: depositAsset,
|
|
670
|
-
abi:
|
|
626
|
+
abi: chunkEHRZFLWL_js.erc2612Abi,
|
|
671
627
|
functionName: "version"
|
|
672
628
|
},
|
|
673
629
|
{
|
|
674
630
|
address: depositAsset,
|
|
675
|
-
abi:
|
|
631
|
+
abi: chunkEHRZFLWL_js.erc2612Abi,
|
|
676
632
|
functionName: "nonces",
|
|
677
633
|
args: [to]
|
|
678
634
|
}
|
|
@@ -684,7 +640,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
684
640
|
} else if (nameResult.status === "success") {
|
|
685
641
|
resolvedTokenName = nameResult.result;
|
|
686
642
|
} else {
|
|
687
|
-
throw new
|
|
643
|
+
throw new chunkR5G6F7RP_js.APIError(`Failed to read token name from ${depositAsset}`, {
|
|
688
644
|
endpoint: "prepareDepositPermitSignature",
|
|
689
645
|
cause: nameResult.error
|
|
690
646
|
});
|
|
@@ -701,7 +657,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
701
657
|
} else if (nonceResult.status === "success") {
|
|
702
658
|
resolvedNonce = nonceResult.result;
|
|
703
659
|
} else {
|
|
704
|
-
throw new
|
|
660
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
705
661
|
`Token ${depositAsset} does not support EIP-2612 permit. Missing required function: nonces()`,
|
|
706
662
|
{
|
|
707
663
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -710,10 +666,10 @@ async function prepareDepositPermitSignature(params) {
|
|
|
710
666
|
);
|
|
711
667
|
}
|
|
712
668
|
} catch (error) {
|
|
713
|
-
if (error instanceof
|
|
669
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
714
670
|
throw error;
|
|
715
671
|
}
|
|
716
|
-
throw new
|
|
672
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
717
673
|
`Failed to read token metadata: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
718
674
|
{
|
|
719
675
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -727,7 +683,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
727
683
|
if (prefetchedDecimals !== void 0) {
|
|
728
684
|
resolvedDecimals = prefetchedDecimals;
|
|
729
685
|
} else {
|
|
730
|
-
resolvedDecimals = await
|
|
686
|
+
resolvedDecimals = await chunkEHRZFLWL_js.getErc20Decimals({
|
|
731
687
|
tokenAddress: depositAsset,
|
|
732
688
|
chainId: normalizedChainId
|
|
733
689
|
});
|
|
@@ -754,10 +710,10 @@ async function prepareDepositPermitSignature(params) {
|
|
|
754
710
|
message
|
|
755
711
|
};
|
|
756
712
|
} catch (error) {
|
|
757
|
-
if (error instanceof
|
|
713
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
758
714
|
throw error;
|
|
759
715
|
}
|
|
760
|
-
throw new
|
|
716
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
761
717
|
`Failed to prepare permit signature: ${error instanceof Error ? error.message : String(error)}`,
|
|
762
718
|
{
|
|
763
719
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -783,7 +739,7 @@ function parsePermitSignature(signature) {
|
|
|
783
739
|
s: parsed.s
|
|
784
740
|
};
|
|
785
741
|
} catch (error) {
|
|
786
|
-
throw new
|
|
742
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
787
743
|
`Invalid permit signature format. Expected hex string but received: ${signature}. ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
788
744
|
{
|
|
789
745
|
endpoint: "parsePermitSignature",
|
|
@@ -794,58 +750,40 @@ function parsePermitSignature(signature) {
|
|
|
794
750
|
}
|
|
795
751
|
async function prepareDepositWithPermitTxData(params) {
|
|
796
752
|
const {
|
|
797
|
-
|
|
753
|
+
vaultName,
|
|
798
754
|
depositAsset,
|
|
799
755
|
depositAmount,
|
|
800
756
|
chainId,
|
|
801
757
|
signature,
|
|
802
758
|
deadline,
|
|
803
|
-
slippage =
|
|
759
|
+
slippage = chunkR5G6F7RP_js.DEFAULT_SLIPPAGE_BPS,
|
|
804
760
|
to,
|
|
805
761
|
distributorCode
|
|
806
762
|
} = params;
|
|
807
763
|
try {
|
|
808
764
|
const { v, r, s } = parsePermitSignature(signature);
|
|
809
765
|
if (slippage < 0 || slippage > 1e4) {
|
|
810
|
-
throw new
|
|
766
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
811
767
|
`Invalid slippage value: ${slippage}. Slippage must be between 0 and 10000 basis points.`,
|
|
812
768
|
{
|
|
813
769
|
endpoint: "prepareDepositWithPermitTxData"
|
|
814
770
|
}
|
|
815
771
|
);
|
|
816
772
|
}
|
|
817
|
-
const normalizedChainId =
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
});
|
|
825
|
-
} catch (error) {
|
|
826
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
827
|
-
`Failed to resolve vault for token ${depositAsset} with yield type ${yieldType} on chain ${normalizedChainId}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
828
|
-
{
|
|
829
|
-
endpoint: "prepareDepositWithPermitTxData",
|
|
830
|
-
cause: error
|
|
831
|
-
}
|
|
832
|
-
);
|
|
833
|
-
}
|
|
834
|
-
if (!vault) {
|
|
835
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
836
|
-
`No vault found for token address ${depositAsset} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
837
|
-
{
|
|
838
|
-
endpoint: "prepareDepositWithPermitTxData"
|
|
839
|
-
}
|
|
840
|
-
);
|
|
841
|
-
}
|
|
773
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
774
|
+
const vault = await chunkE2HBXOZY_js.resolveVault({
|
|
775
|
+
vaultName,
|
|
776
|
+
assetAddress: depositAsset,
|
|
777
|
+
chainId: normalizedChainId,
|
|
778
|
+
callerEndpoint: "prepareDepositWithPermitTxData"
|
|
779
|
+
});
|
|
842
780
|
let asset = null;
|
|
843
|
-
const assets = await
|
|
781
|
+
const assets = await chunkR5G6F7RP_js.getAssetsFromCache({ address: depositAsset });
|
|
844
782
|
if (assets.length > 0) {
|
|
845
783
|
asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets[0] || null;
|
|
846
784
|
}
|
|
847
785
|
if (!asset) {
|
|
848
|
-
throw new
|
|
786
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
849
787
|
`Asset metadata not found for token ${depositAsset} on chain ${normalizedChainId}`,
|
|
850
788
|
{
|
|
851
789
|
endpoint: "prepareDepositWithPermitTxData"
|
|
@@ -853,7 +791,7 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
853
791
|
);
|
|
854
792
|
}
|
|
855
793
|
if (!asset.chains || !asset.chains.includes(normalizedChainId)) {
|
|
856
|
-
throw new
|
|
794
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
857
795
|
`Token ${asset.symbol || depositAsset} not supported on chain ${normalizedChainId}`,
|
|
858
796
|
{
|
|
859
797
|
endpoint: "prepareDepositWithPermitTxData"
|
|
@@ -864,19 +802,25 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
864
802
|
const accountantAddress = vault.vault.accountantAddress;
|
|
865
803
|
const depositAssetAddress = depositAsset;
|
|
866
804
|
if (!communityCodeDepositorAddress) {
|
|
867
|
-
throw new
|
|
805
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
868
806
|
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
869
807
|
{ endpoint: "prepareDepositWithPermitTxData" }
|
|
870
808
|
);
|
|
871
809
|
}
|
|
872
|
-
|
|
810
|
+
if (!accountantAddress) {
|
|
811
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
812
|
+
`Accountant contract address not found for vault ${vault.id}`,
|
|
813
|
+
{ endpoint: "prepareDepositWithPermitTxData" }
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
const rateAndDecimalResults = await chunkEHRZFLWL_js.getRateInQuoteWithAssetDecimals({
|
|
873
817
|
assetAddress: depositAssetAddress,
|
|
874
818
|
accountantAddress,
|
|
875
819
|
chainId: normalizedChainId
|
|
876
820
|
});
|
|
877
821
|
const [depositAssetDecimalsResult, rateInQuoteResult] = rateAndDecimalResults;
|
|
878
822
|
if (depositAssetDecimalsResult.status === "failure") {
|
|
879
|
-
throw new
|
|
823
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
880
824
|
`Failed to get asset decimals: ${depositAssetDecimalsResult.error?.message || "Unknown error"}`,
|
|
881
825
|
{
|
|
882
826
|
endpoint: "prepareDepositWithPermitTxData",
|
|
@@ -885,7 +829,7 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
885
829
|
);
|
|
886
830
|
}
|
|
887
831
|
if (rateInQuoteResult.status === "failure") {
|
|
888
|
-
throw new
|
|
832
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
889
833
|
`Failed to get exchange rate: ${rateInQuoteResult.error?.message || "Unknown error"}`,
|
|
890
834
|
{
|
|
891
835
|
endpoint: "prepareDepositWithPermitTxData",
|
|
@@ -924,10 +868,10 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
924
868
|
chainId: normalizedChainId
|
|
925
869
|
};
|
|
926
870
|
} catch (error) {
|
|
927
|
-
if (error instanceof
|
|
871
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
928
872
|
throw error;
|
|
929
873
|
}
|
|
930
|
-
throw new
|
|
874
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
931
875
|
`Failed to prepare deposit with permit transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
932
876
|
{
|
|
933
877
|
endpoint: "prepareDepositWithPermitTxData",
|
|
@@ -939,7 +883,7 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
939
883
|
|
|
940
884
|
// src/utils/wallet.ts
|
|
941
885
|
async function isSmartContractWallet(address, chainId) {
|
|
942
|
-
const client = await
|
|
886
|
+
const client = await chunkR5G6F7RP_js.getClient(chainId);
|
|
943
887
|
const code = await client.getCode({ address });
|
|
944
888
|
return !!code && code !== "0x";
|
|
945
889
|
}
|
|
@@ -961,7 +905,7 @@ function isAlreadyApprovedAuth(result) {
|
|
|
961
905
|
}
|
|
962
906
|
async function prepareDepositAuthorization(params) {
|
|
963
907
|
const {
|
|
964
|
-
|
|
908
|
+
vaultName,
|
|
965
909
|
depositAsset,
|
|
966
910
|
depositAmount,
|
|
967
911
|
to,
|
|
@@ -970,21 +914,16 @@ async function prepareDepositAuthorization(params) {
|
|
|
970
914
|
forceMethod
|
|
971
915
|
} = params;
|
|
972
916
|
try {
|
|
973
|
-
const normalizedChainId =
|
|
974
|
-
const vault = await
|
|
917
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
918
|
+
const vault = await chunkE2HBXOZY_js.resolveVault({
|
|
919
|
+
vaultName,
|
|
975
920
|
assetAddress: depositAsset,
|
|
976
|
-
|
|
977
|
-
|
|
921
|
+
chainId: normalizedChainId,
|
|
922
|
+
callerEndpoint: "prepareDepositAuthorization"
|
|
978
923
|
});
|
|
979
|
-
if (!vault) {
|
|
980
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
981
|
-
`No vault found for token ${depositAsset} with yield type '${yieldType}' on chain ${normalizedChainId}`,
|
|
982
|
-
{ endpoint: "prepareDepositAuthorization" }
|
|
983
|
-
);
|
|
984
|
-
}
|
|
985
924
|
if (forceMethod === "approval") {
|
|
986
925
|
const txData2 = await prepareApproveDepositTokenTxData({
|
|
987
|
-
|
|
926
|
+
vaultName,
|
|
988
927
|
depositAsset,
|
|
989
928
|
approvalAmount: depositAmount,
|
|
990
929
|
chainId: normalizedChainId
|
|
@@ -996,19 +935,18 @@ async function prepareDepositAuthorization(params) {
|
|
|
996
935
|
}
|
|
997
936
|
if (forceMethod === "permit") {
|
|
998
937
|
const tokenInfo2 = await isDepositSpendApproved({
|
|
999
|
-
|
|
938
|
+
vaultName: vault.name,
|
|
1000
939
|
chainId: normalizedChainId,
|
|
1001
940
|
depositAssetAddress: depositAsset,
|
|
1002
941
|
recipientAddress: to
|
|
1003
942
|
});
|
|
1004
943
|
const permitData = await prepareDepositPermitSignature({
|
|
1005
|
-
|
|
944
|
+
vaultName,
|
|
1006
945
|
depositAsset,
|
|
1007
946
|
depositAmount,
|
|
1008
947
|
to,
|
|
1009
948
|
chainId: normalizedChainId,
|
|
1010
949
|
deadline,
|
|
1011
|
-
// Pass pre-fetched data to avoid redundant RPC calls
|
|
1012
950
|
nonce: tokenInfo2.nonce ?? void 0,
|
|
1013
951
|
decimals: tokenInfo2.decimals,
|
|
1014
952
|
tokenName: tokenInfo2.tokenName,
|
|
@@ -1025,7 +963,7 @@ async function prepareDepositAuthorization(params) {
|
|
|
1025
963
|
);
|
|
1026
964
|
if (smartWallet) {
|
|
1027
965
|
const txData2 = await prepareApproveDepositTokenTxData({
|
|
1028
|
-
|
|
966
|
+
vaultName,
|
|
1029
967
|
depositAsset,
|
|
1030
968
|
approvalAmount: depositAmount,
|
|
1031
969
|
chainId: normalizedChainId
|
|
@@ -1036,20 +974,19 @@ async function prepareDepositAuthorization(params) {
|
|
|
1036
974
|
};
|
|
1037
975
|
}
|
|
1038
976
|
const tokenInfo = await isDepositSpendApproved({
|
|
1039
|
-
|
|
977
|
+
vaultName: vault.name,
|
|
1040
978
|
chainId: normalizedChainId,
|
|
1041
979
|
depositAssetAddress: depositAsset,
|
|
1042
980
|
recipientAddress: to
|
|
1043
981
|
});
|
|
1044
982
|
if (tokenInfo.supportsPermit) {
|
|
1045
983
|
const permitData = await prepareDepositPermitSignature({
|
|
1046
|
-
|
|
984
|
+
vaultName,
|
|
1047
985
|
depositAsset,
|
|
1048
986
|
depositAmount,
|
|
1049
987
|
to,
|
|
1050
988
|
chainId: normalizedChainId,
|
|
1051
989
|
deadline,
|
|
1052
|
-
// Pass pre-fetched data to avoid redundant RPC calls
|
|
1053
990
|
nonce: tokenInfo.nonce ?? void 0,
|
|
1054
991
|
decimals: tokenInfo.decimals,
|
|
1055
992
|
tokenName: tokenInfo.tokenName,
|
|
@@ -1070,7 +1007,7 @@ async function prepareDepositAuthorization(params) {
|
|
|
1070
1007
|
};
|
|
1071
1008
|
}
|
|
1072
1009
|
const txData = await prepareApproveDepositTokenTxData({
|
|
1073
|
-
|
|
1010
|
+
vaultName,
|
|
1074
1011
|
depositAsset,
|
|
1075
1012
|
approvalAmount: depositAmount,
|
|
1076
1013
|
chainId: normalizedChainId
|
|
@@ -1080,10 +1017,10 @@ async function prepareDepositAuthorization(params) {
|
|
|
1080
1017
|
txData
|
|
1081
1018
|
};
|
|
1082
1019
|
} catch (error) {
|
|
1083
|
-
if (error instanceof
|
|
1020
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
1084
1021
|
throw error;
|
|
1085
1022
|
}
|
|
1086
|
-
throw new
|
|
1023
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1087
1024
|
`Failed to prepare deposit authorization: ${error instanceof Error ? error.message : String(error)}`,
|
|
1088
1025
|
{
|
|
1089
1026
|
endpoint: "prepareDepositAuthorization",
|
|
@@ -1094,7 +1031,7 @@ async function prepareDepositAuthorization(params) {
|
|
|
1094
1031
|
}
|
|
1095
1032
|
async function prepareDeposit(params) {
|
|
1096
1033
|
const {
|
|
1097
|
-
|
|
1034
|
+
vaultName,
|
|
1098
1035
|
depositAsset,
|
|
1099
1036
|
depositAmount,
|
|
1100
1037
|
to,
|
|
@@ -1107,7 +1044,7 @@ async function prepareDeposit(params) {
|
|
|
1107
1044
|
} = params;
|
|
1108
1045
|
try {
|
|
1109
1046
|
if (forceMethod === "permit" && (!signature || deadline === void 0)) {
|
|
1110
|
-
throw new
|
|
1047
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1111
1048
|
"Permit deposit requires both signature and deadline parameters when forceMethod is 'permit'",
|
|
1112
1049
|
{ endpoint: "prepareDeposit" }
|
|
1113
1050
|
);
|
|
@@ -1115,13 +1052,13 @@ async function prepareDeposit(params) {
|
|
|
1115
1052
|
const usePermit = forceMethod === "permit" || forceMethod !== "approval" && signature !== void 0 && deadline !== void 0;
|
|
1116
1053
|
if (usePermit) {
|
|
1117
1054
|
if (!signature || deadline === void 0) {
|
|
1118
|
-
throw new
|
|
1055
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1119
1056
|
"Permit deposit requires both signature and deadline parameters",
|
|
1120
1057
|
{ endpoint: "prepareDeposit" }
|
|
1121
1058
|
);
|
|
1122
1059
|
}
|
|
1123
1060
|
const txData2 = await prepareDepositWithPermitTxData({
|
|
1124
|
-
|
|
1061
|
+
vaultName,
|
|
1125
1062
|
depositAsset,
|
|
1126
1063
|
depositAmount,
|
|
1127
1064
|
to,
|
|
@@ -1137,7 +1074,7 @@ async function prepareDeposit(params) {
|
|
|
1137
1074
|
};
|
|
1138
1075
|
}
|
|
1139
1076
|
const txData = await prepareDepositTxData({
|
|
1140
|
-
|
|
1077
|
+
vaultName,
|
|
1141
1078
|
depositAsset,
|
|
1142
1079
|
depositAmount,
|
|
1143
1080
|
to,
|
|
@@ -1150,10 +1087,10 @@ async function prepareDeposit(params) {
|
|
|
1150
1087
|
txData
|
|
1151
1088
|
};
|
|
1152
1089
|
} catch (error) {
|
|
1153
|
-
if (error instanceof
|
|
1090
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
1154
1091
|
throw error;
|
|
1155
1092
|
}
|
|
1156
|
-
throw new
|
|
1093
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1157
1094
|
`Failed to prepare deposit: ${error instanceof Error ? error.message : String(error)}`,
|
|
1158
1095
|
{
|
|
1159
1096
|
endpoint: "prepareDeposit",
|
|
@@ -1163,55 +1100,50 @@ async function prepareDeposit(params) {
|
|
|
1163
1100
|
}
|
|
1164
1101
|
}
|
|
1165
1102
|
async function prepareApproveWithdrawOrderTxData({
|
|
1166
|
-
|
|
1103
|
+
vaultName,
|
|
1167
1104
|
wantAssetAddress,
|
|
1168
1105
|
withdrawAmount,
|
|
1169
1106
|
chainId,
|
|
1170
1107
|
shareDecimals
|
|
1171
1108
|
}) {
|
|
1172
1109
|
try {
|
|
1173
|
-
const normalizedChainId =
|
|
1174
|
-
const config = await
|
|
1110
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
1111
|
+
const config = await chunkE2HBXOZY_js.resolveVault({
|
|
1112
|
+
vaultName,
|
|
1175
1113
|
assetAddress: wantAssetAddress,
|
|
1176
|
-
|
|
1177
|
-
|
|
1114
|
+
chainId: normalizedChainId,
|
|
1115
|
+
callerEndpoint: "prepareApproveWithdrawOrderTxData"
|
|
1178
1116
|
});
|
|
1179
|
-
if (!config || config.chainId !== normalizedChainId) {
|
|
1180
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
1181
|
-
`Vault chain mismatch: vault is on chain ${config?.chainId}, requested chain ${normalizedChainId}`,
|
|
1182
|
-
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1183
|
-
);
|
|
1184
|
-
}
|
|
1185
1117
|
if (!config.vault.boringVaultAddress) {
|
|
1186
|
-
throw new
|
|
1118
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1187
1119
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
1188
1120
|
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1189
1121
|
);
|
|
1190
1122
|
}
|
|
1191
1123
|
if (!config.vault.withdrawQueueAddress) {
|
|
1192
|
-
throw new
|
|
1124
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1193
1125
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1194
1126
|
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1195
1127
|
);
|
|
1196
1128
|
}
|
|
1197
1129
|
const boringVaultAddress = config.vault.boringVaultAddress;
|
|
1198
1130
|
const withdrawQueueAddress = config.vault.withdrawQueueAddress;
|
|
1199
|
-
const decimals = shareDecimals ?? await
|
|
1131
|
+
const decimals = shareDecimals ?? await chunkEHRZFLWL_js.getErc20Decimals({
|
|
1200
1132
|
tokenAddress: boringVaultAddress,
|
|
1201
1133
|
chainId: normalizedChainId
|
|
1202
1134
|
});
|
|
1203
|
-
const withdrawAmountAsBigInt = withdrawAmount ? viem.parseUnits(withdrawAmount, decimals) :
|
|
1135
|
+
const withdrawAmountAsBigInt = withdrawAmount ? viem.parseUnits(withdrawAmount, decimals) : chunkR5G6F7RP_js.DEFAULT_APPROVAL_AMOUNT;
|
|
1204
1136
|
return {
|
|
1205
|
-
abi:
|
|
1137
|
+
abi: chunkEHRZFLWL_js.BoringVaultAbi,
|
|
1206
1138
|
address: boringVaultAddress,
|
|
1207
1139
|
functionName: "approve",
|
|
1208
1140
|
args: [withdrawQueueAddress, withdrawAmountAsBigInt]
|
|
1209
1141
|
};
|
|
1210
1142
|
} catch (error) {
|
|
1211
|
-
if (error instanceof
|
|
1143
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
1212
1144
|
throw error;
|
|
1213
1145
|
}
|
|
1214
|
-
throw new
|
|
1146
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1215
1147
|
`Failed to prepare approval transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1216
1148
|
{
|
|
1217
1149
|
endpoint: "prepareApproveWithdrawOrderTxData",
|
|
@@ -1223,48 +1155,43 @@ async function prepareApproveWithdrawOrderTxData({
|
|
|
1223
1155
|
|
|
1224
1156
|
// src/vaults/withdraw/cancel-withdraw.ts
|
|
1225
1157
|
var prepareCancelWithdrawOrderTxData = async ({
|
|
1226
|
-
|
|
1158
|
+
vaultName,
|
|
1227
1159
|
wantAsset,
|
|
1228
1160
|
chainId,
|
|
1229
1161
|
orderIndex
|
|
1230
1162
|
}) => {
|
|
1231
1163
|
try {
|
|
1232
|
-
const normalizedChainId =
|
|
1233
|
-
const config = await
|
|
1164
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
1165
|
+
const config = await chunkE2HBXOZY_js.resolveVault({
|
|
1166
|
+
vaultName,
|
|
1234
1167
|
assetAddress: wantAsset,
|
|
1235
|
-
|
|
1236
|
-
|
|
1168
|
+
chainId: normalizedChainId,
|
|
1169
|
+
callerEndpoint: "prepareCancelWithdrawOrderTxData"
|
|
1237
1170
|
});
|
|
1238
|
-
if (!config) {
|
|
1239
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
1240
|
-
`No vault found for asset ${wantAsset} with yield type '${yieldType}' on chain ${normalizedChainId}`,
|
|
1241
|
-
{ endpoint: "prepareCancelWithdrawOrderTxData" }
|
|
1242
|
-
);
|
|
1243
|
-
}
|
|
1244
1171
|
if (config.chainId !== normalizedChainId) {
|
|
1245
|
-
throw new
|
|
1172
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1246
1173
|
`Vault chain mismatch: vault is on chain ${config.chainId}, requested chain ${normalizedChainId}`,
|
|
1247
1174
|
{ endpoint: "prepareCancelWithdrawOrderTxData" }
|
|
1248
1175
|
);
|
|
1249
1176
|
}
|
|
1250
1177
|
if (!config.vault.withdrawQueueAddress) {
|
|
1251
|
-
throw new
|
|
1178
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1252
1179
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1253
1180
|
{ endpoint: "prepareCancelWithdrawOrderTxData" }
|
|
1254
1181
|
);
|
|
1255
1182
|
}
|
|
1256
1183
|
return {
|
|
1257
|
-
abi:
|
|
1184
|
+
abi: chunkE2HBXOZY_js.WithdrawQueueAbi,
|
|
1258
1185
|
address: config.vault.withdrawQueueAddress,
|
|
1259
1186
|
functionName: "cancelOrder",
|
|
1260
1187
|
args: [orderIndex],
|
|
1261
1188
|
chainId: normalizedChainId
|
|
1262
1189
|
};
|
|
1263
1190
|
} catch (error) {
|
|
1264
|
-
if (error instanceof
|
|
1191
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
1265
1192
|
throw error;
|
|
1266
1193
|
}
|
|
1267
|
-
throw new
|
|
1194
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1268
1195
|
`Failed to prepare cancel order transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1269
1196
|
{
|
|
1270
1197
|
endpoint: "prepareCancelWithdrawOrderTxData",
|
|
@@ -1286,50 +1213,45 @@ var EMPTY_SIGNATURE_PARAMS = {
|
|
|
1286
1213
|
eip2612Signature: "0x"
|
|
1287
1214
|
};
|
|
1288
1215
|
var prepareWithdrawOrderTxData = async ({
|
|
1289
|
-
|
|
1216
|
+
vaultName,
|
|
1290
1217
|
wantAsset,
|
|
1291
1218
|
userAddress,
|
|
1292
1219
|
chainId,
|
|
1293
1220
|
amountOffer
|
|
1294
1221
|
}) => {
|
|
1295
1222
|
try {
|
|
1296
|
-
const normalizedChainId =
|
|
1297
|
-
const config = await
|
|
1223
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
1224
|
+
const config = await chunkE2HBXOZY_js.resolveVault({
|
|
1225
|
+
vaultName,
|
|
1298
1226
|
assetAddress: wantAsset,
|
|
1299
|
-
|
|
1300
|
-
|
|
1227
|
+
chainId: normalizedChainId,
|
|
1228
|
+
callerEndpoint: "prepareWithdrawOrderTxData"
|
|
1301
1229
|
});
|
|
1302
|
-
if (!config) {
|
|
1303
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
1304
|
-
`No vault found for asset ${wantAsset} with yield type '${yieldType}' on chain ${normalizedChainId}`,
|
|
1305
|
-
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1306
|
-
);
|
|
1307
|
-
}
|
|
1308
1230
|
if (config.chainId !== normalizedChainId) {
|
|
1309
|
-
throw new
|
|
1231
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1310
1232
|
`Vault chain mismatch: vault is on chain ${config.chainId}, requested chain ${normalizedChainId}`,
|
|
1311
1233
|
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1312
1234
|
);
|
|
1313
1235
|
}
|
|
1314
1236
|
if (!config.vault.withdrawQueueAddress) {
|
|
1315
|
-
throw new
|
|
1237
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1316
1238
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1317
1239
|
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1318
1240
|
);
|
|
1319
1241
|
}
|
|
1320
1242
|
if (!config.vault.boringVaultAddress) {
|
|
1321
|
-
throw new
|
|
1243
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1322
1244
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
1323
1245
|
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1324
1246
|
);
|
|
1325
1247
|
}
|
|
1326
|
-
const sharesDecimals = await
|
|
1248
|
+
const sharesDecimals = await chunkEHRZFLWL_js.getErc20Decimals({
|
|
1327
1249
|
tokenAddress: config.vault.boringVaultAddress,
|
|
1328
1250
|
chainId: normalizedChainId
|
|
1329
1251
|
});
|
|
1330
1252
|
const formattedAmountOffer = viem.parseUnits(amountOffer, sharesDecimals);
|
|
1331
1253
|
return {
|
|
1332
|
-
abi:
|
|
1254
|
+
abi: chunkE2HBXOZY_js.WithdrawQueueAbi,
|
|
1333
1255
|
address: config.vault.withdrawQueueAddress,
|
|
1334
1256
|
functionName: "submitOrder",
|
|
1335
1257
|
args: [
|
|
@@ -1345,10 +1267,10 @@ var prepareWithdrawOrderTxData = async ({
|
|
|
1345
1267
|
chainId: normalizedChainId
|
|
1346
1268
|
};
|
|
1347
1269
|
} catch (error) {
|
|
1348
|
-
if (error instanceof
|
|
1270
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
1349
1271
|
throw error;
|
|
1350
1272
|
}
|
|
1351
|
-
throw new
|
|
1273
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1352
1274
|
`Failed to prepare withdraw order transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1353
1275
|
{
|
|
1354
1276
|
endpoint: "prepareWithdrawOrderTxData",
|
|
@@ -1368,20 +1290,20 @@ function isWithdrawAlreadyApprovedAuth(result) {
|
|
|
1368
1290
|
return result.method === WithdrawAuthMethod.ALREADY_APPROVED;
|
|
1369
1291
|
}
|
|
1370
1292
|
async function prepareWithdrawal(params) {
|
|
1371
|
-
const {
|
|
1293
|
+
const { vaultName, wantAsset, withdrawAmount, userAddress, chainId } = params;
|
|
1372
1294
|
try {
|
|
1373
1295
|
return await prepareWithdrawOrderTxData({
|
|
1374
|
-
|
|
1296
|
+
vaultName,
|
|
1375
1297
|
wantAsset,
|
|
1376
1298
|
userAddress,
|
|
1377
1299
|
chainId,
|
|
1378
1300
|
amountOffer: withdrawAmount
|
|
1379
1301
|
});
|
|
1380
1302
|
} catch (error) {
|
|
1381
|
-
if (error instanceof
|
|
1303
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
1382
1304
|
throw error;
|
|
1383
1305
|
}
|
|
1384
|
-
throw new
|
|
1306
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1385
1307
|
`Failed to prepare withdrawal: ${error instanceof Error ? error.message : String(error)}`,
|
|
1386
1308
|
{
|
|
1387
1309
|
endpoint: "prepareWithdrawal",
|
|
@@ -1392,7 +1314,7 @@ async function prepareWithdrawal(params) {
|
|
|
1392
1314
|
}
|
|
1393
1315
|
async function prepareWithdrawalAuthorization(params) {
|
|
1394
1316
|
const {
|
|
1395
|
-
|
|
1317
|
+
vaultName,
|
|
1396
1318
|
wantAsset,
|
|
1397
1319
|
withdrawAmount,
|
|
1398
1320
|
userAddress,
|
|
@@ -1400,21 +1322,16 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1400
1322
|
forceMethod
|
|
1401
1323
|
} = params;
|
|
1402
1324
|
try {
|
|
1403
|
-
const normalizedChainId =
|
|
1404
|
-
const vault = await
|
|
1325
|
+
const normalizedChainId = chunkR5G6F7RP_js.toChainId(chainId);
|
|
1326
|
+
const vault = await chunkE2HBXOZY_js.resolveVault({
|
|
1327
|
+
vaultName,
|
|
1405
1328
|
assetAddress: wantAsset,
|
|
1406
|
-
|
|
1407
|
-
|
|
1329
|
+
chainId: normalizedChainId,
|
|
1330
|
+
callerEndpoint: "prepareWithdrawalAuthorization"
|
|
1408
1331
|
});
|
|
1409
|
-
if (!vault) {
|
|
1410
|
-
throw new chunkBQG3XKTU_js.APIError(
|
|
1411
|
-
`No vault found for asset ${wantAsset} with yield type '${yieldType}' on chain ${normalizedChainId}`,
|
|
1412
|
-
{ endpoint: "prepareWithdrawalAuthorization" }
|
|
1413
|
-
);
|
|
1414
|
-
}
|
|
1415
1332
|
if (forceMethod === "approval") {
|
|
1416
1333
|
const txData2 = await prepareApproveWithdrawOrderTxData({
|
|
1417
|
-
|
|
1334
|
+
vaultName,
|
|
1418
1335
|
wantAssetAddress: wantAsset,
|
|
1419
1336
|
withdrawAmount,
|
|
1420
1337
|
chainId: normalizedChainId
|
|
@@ -1431,7 +1348,7 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1431
1348
|
);
|
|
1432
1349
|
if (smartWallet) {
|
|
1433
1350
|
const txData2 = await prepareApproveWithdrawOrderTxData({
|
|
1434
|
-
|
|
1351
|
+
vaultName,
|
|
1435
1352
|
wantAssetAddress: wantAsset,
|
|
1436
1353
|
withdrawAmount,
|
|
1437
1354
|
chainId: normalizedChainId
|
|
@@ -1443,13 +1360,13 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1443
1360
|
}
|
|
1444
1361
|
}
|
|
1445
1362
|
const approvalInfo = await isWithdrawalSpendApproved({
|
|
1446
|
-
|
|
1363
|
+
vaultName: vault.name,
|
|
1447
1364
|
chainId: normalizedChainId,
|
|
1448
1365
|
wantAssetAddress: wantAsset,
|
|
1449
1366
|
recipientAddress: userAddress
|
|
1450
1367
|
});
|
|
1451
1368
|
if (approvalInfo.error) {
|
|
1452
|
-
throw new
|
|
1369
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1453
1370
|
`Failed to check withdrawal approval: ${approvalInfo.error}`,
|
|
1454
1371
|
{ endpoint: "prepareWithdrawalAuthorization" }
|
|
1455
1372
|
);
|
|
@@ -1467,7 +1384,7 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1467
1384
|
};
|
|
1468
1385
|
}
|
|
1469
1386
|
const txData = await prepareApproveWithdrawOrderTxData({
|
|
1470
|
-
|
|
1387
|
+
vaultName,
|
|
1471
1388
|
wantAssetAddress: wantAsset,
|
|
1472
1389
|
withdrawAmount,
|
|
1473
1390
|
chainId: normalizedChainId,
|
|
@@ -1478,10 +1395,10 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1478
1395
|
txData
|
|
1479
1396
|
};
|
|
1480
1397
|
} catch (error) {
|
|
1481
|
-
if (error instanceof
|
|
1398
|
+
if (error instanceof chunkR5G6F7RP_js.APIError) {
|
|
1482
1399
|
throw error;
|
|
1483
1400
|
}
|
|
1484
|
-
throw new
|
|
1401
|
+
throw new chunkR5G6F7RP_js.APIError(
|
|
1485
1402
|
`Failed to prepare withdrawal authorization: ${error instanceof Error ? error.message : String(error)}`,
|
|
1486
1403
|
{
|
|
1487
1404
|
endpoint: "prepareWithdrawalAuthorization",
|
|
@@ -1514,5 +1431,5 @@ exports.prepareWithdrawOrderTxData = prepareWithdrawOrderTxData;
|
|
|
1514
1431
|
exports.prepareWithdrawal = prepareWithdrawal;
|
|
1515
1432
|
exports.prepareWithdrawalAuthorization = prepareWithdrawalAuthorization;
|
|
1516
1433
|
exports.toEthSignTypedDataV4 = toEthSignTypedDataV4;
|
|
1517
|
-
//# sourceMappingURL=chunk-
|
|
1518
|
-
//# sourceMappingURL=chunk-
|
|
1434
|
+
//# sourceMappingURL=chunk-ZJBJFFBQ.js.map
|
|
1435
|
+
//# sourceMappingURL=chunk-ZJBJFFBQ.js.map
|