@paxoslabs/amplify-sdk 0.0.1-alpha.1 → 0.0.1-alpha.3
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/dist/{chunk-ZSFIOWWT.js → chunk-AIBI7ZQM.js} +8 -8
- package/dist/{chunk-ZSFIOWWT.js.map → chunk-AIBI7ZQM.js.map} +1 -1
- package/dist/{chunk-JLXNOGZB.js → chunk-BXUG3WDV.js} +46 -21
- package/dist/chunk-BXUG3WDV.js.map +1 -0
- package/dist/{chunk-GE2VQUPP.mjs → chunk-GBWBO6ZF.mjs} +4 -4
- package/dist/{chunk-GE2VQUPP.mjs.map → chunk-GBWBO6ZF.mjs.map} +1 -1
- package/dist/{chunk-BDXS57YH.js → chunk-IBNTWZ4S.js} +33 -6
- package/dist/chunk-IBNTWZ4S.js.map +1 -0
- package/dist/{chunk-AFWUOS3M.js → chunk-K4DL2AII.js} +4 -4
- package/dist/{chunk-AFWUOS3M.js.map → chunk-K4DL2AII.js.map} +1 -1
- package/dist/{chunk-SIR2TCAR.mjs → chunk-OPOYGPSS.mjs} +3 -3
- package/dist/{chunk-SIR2TCAR.mjs.map → chunk-OPOYGPSS.mjs.map} +1 -1
- package/dist/{chunk-ISO6Z7LD.mjs → chunk-WFCHKDDG.mjs} +33 -6
- package/dist/chunk-WFCHKDDG.mjs.map +1 -0
- package/dist/{chunk-ZZBZIDZP.mjs → chunk-YP2TR5RP.mjs} +44 -19
- package/dist/chunk-YP2TR5RP.mjs.map +1 -0
- package/dist/{chunk-O5P6SP2O.js → chunk-ZCVMGIMV.js} +20 -20
- package/dist/{chunk-O5P6SP2O.js.map → chunk-ZCVMGIMV.js.map} +1 -1
- package/dist/{chunk-FYNPQXCR.mjs → chunk-ZLS2AAMI.mjs} +3 -3
- package/dist/{chunk-FYNPQXCR.mjs.map → chunk-ZLS2AAMI.mjs.map} +1 -1
- package/dist/core.js +14 -14
- package/dist/core.mjs +4 -4
- package/dist/display.js +12 -12
- package/dist/display.mjs +4 -4
- package/dist/index.js +131 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -5
- package/dist/index.mjs.map +1 -1
- package/dist/utils.js +5 -5
- package/dist/utils.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-BDXS57YH.js.map +0 -1
- package/dist/chunk-ISO6Z7LD.mjs.map +0 -1
- package/dist/chunk-JLXNOGZB.js.map +0 -1
- package/dist/chunk-ZZBZIDZP.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkITB7FXG4_js = require('./chunk-ITB7FXG4.js');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkZCVMGIMV_js = require('./chunk-ZCVMGIMV.js');
|
|
5
|
+
var chunkBXUG3WDV_js = require('./chunk-BXUG3WDV.js');
|
|
6
6
|
require('./chunk-ICKDAKVS.js');
|
|
7
7
|
var chunkRUIAH5HY_js = require('./chunk-RUIAH5HY.js');
|
|
8
|
-
var
|
|
8
|
+
var chunkK4DL2AII_js = require('./chunk-K4DL2AII.js');
|
|
9
9
|
var chunk3I3PYX2F_js = require('./chunk-3I3PYX2F.js');
|
|
10
|
-
var
|
|
10
|
+
var chunkIBNTWZ4S_js = require('./chunk-IBNTWZ4S.js');
|
|
11
11
|
var viem = require('viem');
|
|
12
12
|
|
|
13
13
|
async function prepareApproveDepositTokenTxData({
|
|
@@ -18,33 +18,33 @@ async function prepareApproveDepositTokenTxData({
|
|
|
18
18
|
}) {
|
|
19
19
|
const normalizedChainId = chunkRUIAH5HY_js.toChainId(chainId);
|
|
20
20
|
try {
|
|
21
|
-
const config = await
|
|
21
|
+
const config = await chunkIBNTWZ4S_js.findVaultByConfig({
|
|
22
22
|
assetAddress: depositToken,
|
|
23
23
|
yieldType,
|
|
24
24
|
chainId: normalizedChainId
|
|
25
25
|
});
|
|
26
26
|
if (!config) {
|
|
27
|
-
throw new
|
|
27
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
28
28
|
`No vault found for token address ${depositToken} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
29
29
|
{ endpoint: "prepareApproveDepositToken" }
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
const boringVaultAddress = config.vault.boringVaultAddress;
|
|
33
33
|
if (!boringVaultAddress) {
|
|
34
|
-
throw new
|
|
34
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
35
35
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
36
36
|
{ endpoint: "prepareApproveDepositToken" }
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
const assets = await
|
|
39
|
+
const assets = await chunkIBNTWZ4S_js.getAssetsFromCache({ address: depositToken });
|
|
40
40
|
if (assets.length === 0) {
|
|
41
|
-
throw new
|
|
41
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
42
42
|
`Asset metadata not found for token ${depositToken} on chain ${normalizedChainId}`,
|
|
43
43
|
{ endpoint: "prepareApproveDepositToken" }
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
const decimals = assets[0].decimals;
|
|
47
|
-
const amount = approvalAmount ? viem.parseUnits(approvalAmount, decimals) :
|
|
47
|
+
const amount = approvalAmount ? viem.parseUnits(approvalAmount, decimals) : chunkIBNTWZ4S_js.DEFAULT_APPROVAL_AMOUNT;
|
|
48
48
|
return {
|
|
49
49
|
abi: viem.erc20Abi,
|
|
50
50
|
address: depositToken,
|
|
@@ -52,10 +52,10 @@ async function prepareApproveDepositTokenTxData({
|
|
|
52
52
|
args: [boringVaultAddress, amount]
|
|
53
53
|
};
|
|
54
54
|
} catch (error) {
|
|
55
|
-
if (error instanceof
|
|
55
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
56
56
|
throw error;
|
|
57
57
|
}
|
|
58
|
-
throw new
|
|
58
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
59
59
|
`Failed to prepare approval transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
60
60
|
{
|
|
61
61
|
endpoint: "prepareApproveDepositToken",
|
|
@@ -90,13 +90,13 @@ async function prepareDepositTxData(params) {
|
|
|
90
90
|
const normalizedChainId = chunkRUIAH5HY_js.toChainId(chainId);
|
|
91
91
|
let vault;
|
|
92
92
|
try {
|
|
93
|
-
vault = await
|
|
93
|
+
vault = await chunkIBNTWZ4S_js.findVaultByConfig({
|
|
94
94
|
assetAddress: depositToken,
|
|
95
95
|
yieldType,
|
|
96
96
|
chainId: normalizedChainId
|
|
97
97
|
});
|
|
98
98
|
} catch (error) {
|
|
99
|
-
throw new
|
|
99
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
100
100
|
`Failed to resolve vault for token ${depositToken} with yield type ${yieldType} on chain ${normalizedChainId}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
101
101
|
{
|
|
102
102
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -105,7 +105,7 @@ async function prepareDepositTxData(params) {
|
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
if (!vault) {
|
|
108
|
-
throw new
|
|
108
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
109
109
|
`No vault found for token address ${depositToken} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
110
110
|
{
|
|
111
111
|
endpoint: "prepareDepositTransactionData"
|
|
@@ -113,12 +113,12 @@ async function prepareDepositTxData(params) {
|
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
let asset = null;
|
|
116
|
-
const assets = await
|
|
116
|
+
const assets = await chunkIBNTWZ4S_js.getAssetsFromCache({ address: depositToken });
|
|
117
117
|
if (assets.length > 0) {
|
|
118
118
|
asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets[0] || null;
|
|
119
119
|
}
|
|
120
120
|
if (!asset) {
|
|
121
|
-
throw new
|
|
121
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
122
122
|
`Asset metadata not found for token ${depositToken} on chain ${normalizedChainId}`,
|
|
123
123
|
{
|
|
124
124
|
endpoint: "prepareDepositTransactionData"
|
|
@@ -128,13 +128,13 @@ async function prepareDepositTxData(params) {
|
|
|
128
128
|
const tellerAddress = vault.vault.tellerAddress;
|
|
129
129
|
const accountantAddress = vault.vault.accountantAddress;
|
|
130
130
|
const depositAssetAddress = asset.address;
|
|
131
|
-
const [depositAssetDecimalsResult, rateInQuoteResult] = await
|
|
131
|
+
const [depositAssetDecimalsResult, rateInQuoteResult] = await chunkBXUG3WDV_js.getRateInQuoteWithAssetDecimals({
|
|
132
132
|
assetAddress: depositAssetAddress,
|
|
133
133
|
accountantAddress,
|
|
134
134
|
chainId: normalizedChainId
|
|
135
135
|
});
|
|
136
136
|
if (depositAssetDecimalsResult.status === "failure") {
|
|
137
|
-
throw new
|
|
137
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
138
138
|
`Failed to get asset decimals: ${depositAssetDecimalsResult.error?.message || "Unknown error"}`,
|
|
139
139
|
{
|
|
140
140
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -143,7 +143,7 @@ async function prepareDepositTxData(params) {
|
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
if (rateInQuoteResult.status === "failure") {
|
|
146
|
-
throw new
|
|
146
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
147
147
|
`Failed to get exchange rate: ${rateInQuoteResult.error?.message || "Unknown error"}`,
|
|
148
148
|
{
|
|
149
149
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -155,11 +155,11 @@ async function prepareDepositTxData(params) {
|
|
|
155
155
|
depositAmount,
|
|
156
156
|
depositAssetDecimalsResult.result
|
|
157
157
|
);
|
|
158
|
-
const vaultSharesAssets = await
|
|
158
|
+
const vaultSharesAssets = await chunkIBNTWZ4S_js.fetchSupportedAssets({
|
|
159
159
|
address: vault.vault.boringVaultAddress
|
|
160
160
|
});
|
|
161
161
|
if (vaultSharesAssets.length === 0) {
|
|
162
|
-
throw new
|
|
162
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
163
163
|
`Vault shares token not found in supported assets: ${vault.vault.boringVaultAddress}`,
|
|
164
164
|
{ endpoint: "prepareDepositTransactionData" }
|
|
165
165
|
);
|
|
@@ -171,17 +171,17 @@ async function prepareDepositTxData(params) {
|
|
|
171
171
|
slippage
|
|
172
172
|
);
|
|
173
173
|
return {
|
|
174
|
-
abi:
|
|
174
|
+
abi: chunkBXUG3WDV_js.TellerAbi,
|
|
175
175
|
address: tellerAddress,
|
|
176
176
|
functionName: "deposit",
|
|
177
177
|
args: [depositAssetAddress, depositAmountAsBigInt, minimumMint],
|
|
178
178
|
chainId: normalizedChainId
|
|
179
179
|
};
|
|
180
180
|
} catch (error) {
|
|
181
|
-
if (error instanceof
|
|
181
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
182
182
|
throw error;
|
|
183
183
|
}
|
|
184
|
-
throw new
|
|
184
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
185
185
|
`Failed to prepare deposit transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
186
186
|
{
|
|
187
187
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -262,13 +262,13 @@ async function prepareDepositPermitSignature(params) {
|
|
|
262
262
|
const normalizedChainId = chunkRUIAH5HY_js.toChainId(chainId);
|
|
263
263
|
let vault;
|
|
264
264
|
try {
|
|
265
|
-
vault = await
|
|
265
|
+
vault = await chunkIBNTWZ4S_js.findVaultByConfig({
|
|
266
266
|
assetAddress: depositToken,
|
|
267
267
|
yieldType,
|
|
268
268
|
chainId: normalizedChainId
|
|
269
269
|
});
|
|
270
270
|
} catch (error) {
|
|
271
|
-
throw new
|
|
271
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
272
272
|
`Failed to resolve vault for token ${depositToken} with yield type ${yieldType} on chain ${normalizedChainId}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
273
273
|
{
|
|
274
274
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -277,7 +277,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
277
277
|
);
|
|
278
278
|
}
|
|
279
279
|
if (!vault) {
|
|
280
|
-
throw new
|
|
280
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
281
281
|
`No vault found for token address ${depositToken} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
282
282
|
{
|
|
283
283
|
endpoint: "prepareDepositPermitSignature"
|
|
@@ -285,7 +285,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
285
285
|
);
|
|
286
286
|
}
|
|
287
287
|
const tellerAddress = vault.vault.tellerAddress;
|
|
288
|
-
const client = await
|
|
288
|
+
const client = await chunkBXUG3WDV_js.getClient(normalizedChainId);
|
|
289
289
|
let tokenName;
|
|
290
290
|
let tokenVersion;
|
|
291
291
|
let nonce;
|
|
@@ -313,7 +313,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
313
313
|
if (nameResult.status === "fulfilled") {
|
|
314
314
|
tokenName = nameResult.value;
|
|
315
315
|
} else {
|
|
316
|
-
throw new
|
|
316
|
+
throw new chunkIBNTWZ4S_js.APIError(`Failed to read token name from ${depositToken}`, {
|
|
317
317
|
endpoint: "prepareDepositPermitSignature",
|
|
318
318
|
cause: nameResult.reason
|
|
319
319
|
});
|
|
@@ -326,7 +326,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
326
326
|
if (nonceResult.status === "fulfilled") {
|
|
327
327
|
nonce = nonceResult.value;
|
|
328
328
|
} else {
|
|
329
|
-
throw new
|
|
329
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
330
330
|
`Token ${depositToken} does not support EIP-2612 permit. Missing required function: nonces()`,
|
|
331
331
|
{
|
|
332
332
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -335,10 +335,10 @@ async function prepareDepositPermitSignature(params) {
|
|
|
335
335
|
);
|
|
336
336
|
}
|
|
337
337
|
} catch (error) {
|
|
338
|
-
if (error instanceof
|
|
338
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
339
339
|
throw error;
|
|
340
340
|
}
|
|
341
|
-
throw new
|
|
341
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
342
342
|
`Failed to read token metadata: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
343
343
|
{
|
|
344
344
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -347,9 +347,9 @@ async function prepareDepositPermitSignature(params) {
|
|
|
347
347
|
);
|
|
348
348
|
}
|
|
349
349
|
const permitDeadline = deadline ?? BigInt(Math.floor(Date.now() / 1e3) + 3600);
|
|
350
|
-
const assets = await
|
|
350
|
+
const assets = await chunkIBNTWZ4S_js.fetchSupportedAssets({ address: depositToken });
|
|
351
351
|
if (assets.length === 0) {
|
|
352
|
-
throw new
|
|
352
|
+
throw new chunkIBNTWZ4S_js.APIError(`Asset metadata not found for token ${depositToken}`, {
|
|
353
353
|
endpoint: "prepareDepositPermitSignature"
|
|
354
354
|
});
|
|
355
355
|
}
|
|
@@ -375,10 +375,10 @@ async function prepareDepositPermitSignature(params) {
|
|
|
375
375
|
types: PERMIT_TYPES
|
|
376
376
|
};
|
|
377
377
|
} catch (error) {
|
|
378
|
-
if (error instanceof
|
|
378
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
379
379
|
throw error;
|
|
380
380
|
}
|
|
381
|
-
throw new
|
|
381
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
382
382
|
`Failed to prepare permit signature: ${error instanceof Error ? error.message : String(error)}`,
|
|
383
383
|
{
|
|
384
384
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -404,7 +404,7 @@ function parsePermitSignature(signature) {
|
|
|
404
404
|
s: parsed.s
|
|
405
405
|
};
|
|
406
406
|
} catch (error) {
|
|
407
|
-
throw new
|
|
407
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
408
408
|
`Invalid permit signature format. Expected hex string but received: ${signature}. ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
409
409
|
{
|
|
410
410
|
endpoint: "parsePermitSignature",
|
|
@@ -423,10 +423,18 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
423
423
|
deadline,
|
|
424
424
|
slippage = chunkITB7FXG4_js.DEFAULT_SLIPPAGE_BPS
|
|
425
425
|
} = params;
|
|
426
|
+
console.log("[Amplify SDK] prepareDepositWithPermitTransactionData called", {
|
|
427
|
+
yieldType,
|
|
428
|
+
depositToken,
|
|
429
|
+
depositAmount,
|
|
430
|
+
chainId,
|
|
431
|
+
deadline: deadline.toString(),
|
|
432
|
+
slippage
|
|
433
|
+
});
|
|
426
434
|
try {
|
|
427
435
|
const { v, r, s } = parsePermitSignature(signature);
|
|
428
436
|
if (slippage < 0 || slippage > 1e4) {
|
|
429
|
-
throw new
|
|
437
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
430
438
|
`Invalid slippage value: ${slippage}. Slippage must be between 0 and 10000 basis points.`,
|
|
431
439
|
{
|
|
432
440
|
endpoint: "prepareDepositWithPermitTransactionData"
|
|
@@ -434,15 +442,18 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
434
442
|
);
|
|
435
443
|
}
|
|
436
444
|
const normalizedChainId = chunkRUIAH5HY_js.toChainId(chainId);
|
|
445
|
+
console.log("[Amplify SDK] Normalized chainId:", normalizedChainId);
|
|
437
446
|
let vault;
|
|
438
447
|
try {
|
|
439
|
-
vault
|
|
448
|
+
console.log("[Amplify SDK] Resolving vault with findVaultByConfig...");
|
|
449
|
+
vault = await chunkIBNTWZ4S_js.findVaultByConfig({
|
|
440
450
|
assetAddress: depositToken,
|
|
441
451
|
yieldType,
|
|
442
452
|
chainId: normalizedChainId
|
|
443
453
|
});
|
|
454
|
+
console.log("[Amplify SDK] Vault resolved:", vault ? "Found" : "Not found");
|
|
444
455
|
} catch (error) {
|
|
445
|
-
throw new
|
|
456
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
446
457
|
`Failed to resolve vault for token ${depositToken} with yield type ${yieldType} on chain ${normalizedChainId}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
447
458
|
{
|
|
448
459
|
endpoint: "prepareDepositWithPermitTransactionData",
|
|
@@ -451,20 +462,22 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
451
462
|
);
|
|
452
463
|
}
|
|
453
464
|
if (!vault) {
|
|
454
|
-
throw new
|
|
465
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
455
466
|
`No vault found for token address ${depositToken} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
456
467
|
{
|
|
457
468
|
endpoint: "prepareDepositWithPermitTransactionData"
|
|
458
469
|
}
|
|
459
470
|
);
|
|
460
471
|
}
|
|
472
|
+
console.log("[Amplify SDK] Fetching supported assets for depositToken:", depositToken);
|
|
461
473
|
let asset = null;
|
|
462
|
-
const assets = await
|
|
474
|
+
const assets = await chunkIBNTWZ4S_js.fetchSupportedAssets({ address: depositToken });
|
|
475
|
+
console.log("[Amplify SDK] Supported assets found:", assets.length);
|
|
463
476
|
if (assets.length > 0) {
|
|
464
477
|
asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets[0] || null;
|
|
465
478
|
}
|
|
466
479
|
if (!asset) {
|
|
467
|
-
throw new
|
|
480
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
468
481
|
`Asset metadata not found for token ${depositToken} on chain ${normalizedChainId}`,
|
|
469
482
|
{
|
|
470
483
|
endpoint: "prepareDepositWithPermitTransactionData"
|
|
@@ -472,7 +485,7 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
472
485
|
);
|
|
473
486
|
}
|
|
474
487
|
if (!asset.chains || !asset.chains.includes(normalizedChainId)) {
|
|
475
|
-
throw new
|
|
488
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
476
489
|
`Token ${asset.symbol || depositToken} not supported on chain ${normalizedChainId}`,
|
|
477
490
|
{
|
|
478
491
|
endpoint: "prepareDepositWithPermitTransactionData"
|
|
@@ -482,13 +495,23 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
482
495
|
const tellerAddress = vault.vault.tellerAddress;
|
|
483
496
|
const accountantAddress = vault.vault.accountantAddress;
|
|
484
497
|
const depositAssetAddress = asset.address;
|
|
485
|
-
|
|
498
|
+
console.log("[Amplify SDK] Contract addresses:", {
|
|
499
|
+
tellerAddress,
|
|
500
|
+
accountantAddress,
|
|
501
|
+
depositAssetAddress
|
|
502
|
+
});
|
|
503
|
+
console.log("[Amplify SDK] Calling getRateInQuoteWithAssetDecimals...");
|
|
504
|
+
const [depositAssetDecimalsResult, rateInQuoteResult] = await chunkBXUG3WDV_js.getRateInQuoteWithAssetDecimals({
|
|
486
505
|
assetAddress: depositAssetAddress,
|
|
487
506
|
accountantAddress,
|
|
488
507
|
chainId: normalizedChainId
|
|
489
508
|
});
|
|
509
|
+
console.log("[Amplify SDK] getRateInQuoteWithAssetDecimals completed", {
|
|
510
|
+
decimalsStatus: depositAssetDecimalsResult.status,
|
|
511
|
+
rateStatus: rateInQuoteResult.status
|
|
512
|
+
});
|
|
490
513
|
if (depositAssetDecimalsResult.status === "failure") {
|
|
491
|
-
throw new
|
|
514
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
492
515
|
`Failed to get asset decimals: ${depositAssetDecimalsResult.error?.message || "Unknown error"}`,
|
|
493
516
|
{
|
|
494
517
|
endpoint: "prepareDepositWithPermitTransactionData",
|
|
@@ -497,7 +520,7 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
497
520
|
);
|
|
498
521
|
}
|
|
499
522
|
if (rateInQuoteResult.status === "failure") {
|
|
500
|
-
throw new
|
|
523
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
501
524
|
`Failed to get exchange rate: ${rateInQuoteResult.error?.message || "Unknown error"}`,
|
|
502
525
|
{
|
|
503
526
|
endpoint: "prepareDepositWithPermitTransactionData",
|
|
@@ -506,24 +529,34 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
506
529
|
);
|
|
507
530
|
}
|
|
508
531
|
const depositAmountAsBigInt = viem.parseUnits(depositAmount, asset.decimals);
|
|
509
|
-
|
|
532
|
+
console.log("[Amplify SDK] Fetching vault shares asset:", vault.vault.boringVaultAddress);
|
|
533
|
+
const vaultSharesAssets = await chunkIBNTWZ4S_js.fetchSupportedAssets({
|
|
510
534
|
address: vault.vault.boringVaultAddress
|
|
511
535
|
});
|
|
536
|
+
console.log("[Amplify SDK] Vault shares assets found:", vaultSharesAssets.length);
|
|
512
537
|
if (vaultSharesAssets.length === 0) {
|
|
513
|
-
throw new
|
|
538
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
514
539
|
`Vault shares token not found in supported assets: ${vault.vault.boringVaultAddress}`,
|
|
515
540
|
{ endpoint: "prepareDepositWithPermitTransactionData" }
|
|
516
541
|
);
|
|
517
542
|
}
|
|
543
|
+
console.log("[Amplify SDK] Calculating minimumMint...", {
|
|
544
|
+
depositAmountAsBigInt: depositAmountAsBigInt.toString(),
|
|
545
|
+
rateInQuote: rateInQuoteResult.result.toString(),
|
|
546
|
+
vaultSharesDecimals: vaultSharesAssets[0].decimals,
|
|
547
|
+
slippage
|
|
548
|
+
});
|
|
518
549
|
const minimumMint = calculateMinimumMint(
|
|
519
550
|
depositAmountAsBigInt,
|
|
520
551
|
rateInQuoteResult.result,
|
|
521
552
|
vaultSharesAssets[0].decimals,
|
|
522
553
|
slippage
|
|
523
554
|
);
|
|
555
|
+
console.log("[Amplify SDK] minimumMint calculated:", minimumMint.toString());
|
|
556
|
+
console.log("[Amplify SDK] Returning transaction data successfully");
|
|
524
557
|
return {
|
|
525
558
|
data: {
|
|
526
|
-
abi:
|
|
559
|
+
abi: chunkBXUG3WDV_js.TellerAbi,
|
|
527
560
|
functionName: "depositWithPermit",
|
|
528
561
|
args: [
|
|
529
562
|
depositAssetAddress,
|
|
@@ -539,10 +572,10 @@ async function prepareDepositWithPermitTransactionData(params) {
|
|
|
539
572
|
chainId: normalizedChainId
|
|
540
573
|
};
|
|
541
574
|
} catch (error) {
|
|
542
|
-
if (error instanceof
|
|
575
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
543
576
|
throw error;
|
|
544
577
|
}
|
|
545
|
-
throw new
|
|
578
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
546
579
|
`Failed to prepare deposit with permit transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
547
580
|
{
|
|
548
581
|
endpoint: "prepareDepositWithPermitTransactionData",
|
|
@@ -559,45 +592,45 @@ async function prepareApproveWithdrawTxData({
|
|
|
559
592
|
}) {
|
|
560
593
|
try {
|
|
561
594
|
const normalizedChainId = chunkRUIAH5HY_js.toChainId(chainId);
|
|
562
|
-
const config = await
|
|
595
|
+
const config = await chunkIBNTWZ4S_js.findVaultByConfig({
|
|
563
596
|
assetAddress: wantAssetAddress,
|
|
564
597
|
yieldType,
|
|
565
598
|
chainId: normalizedChainId
|
|
566
599
|
});
|
|
567
600
|
if (!config || config.chainId !== normalizedChainId) {
|
|
568
|
-
throw new
|
|
601
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
569
602
|
`Vault chain mismatch: vault is on chain ${config?.chainId}, requested chain ${normalizedChainId}`,
|
|
570
603
|
{ endpoint: "prepareApproveWithdrawToken" }
|
|
571
604
|
);
|
|
572
605
|
}
|
|
573
606
|
if (!config.vault.boringVaultAddress) {
|
|
574
|
-
throw new
|
|
607
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
575
608
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
576
609
|
{ endpoint: "prepareApproveWithdrawToken" }
|
|
577
610
|
);
|
|
578
611
|
}
|
|
579
612
|
const boringVaultAddress = config.vault.boringVaultAddress;
|
|
580
|
-
const vaultSharesAssets = await
|
|
613
|
+
const vaultSharesAssets = await chunkIBNTWZ4S_js.getAssetsFromCache({
|
|
581
614
|
address: boringVaultAddress
|
|
582
615
|
});
|
|
583
616
|
if (vaultSharesAssets.length === 0) {
|
|
584
|
-
throw new
|
|
617
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
585
618
|
`Vault shares token not found in supported assets: ${boringVaultAddress}`,
|
|
586
619
|
{ endpoint: "prepareApproveWithdrawToken" }
|
|
587
620
|
);
|
|
588
621
|
}
|
|
589
|
-
const withdrawAmountAsBigInt = withdrawAmount ? viem.parseUnits(withdrawAmount, vaultSharesAssets[0].decimals) :
|
|
622
|
+
const withdrawAmountAsBigInt = withdrawAmount ? viem.parseUnits(withdrawAmount, vaultSharesAssets[0].decimals) : chunkIBNTWZ4S_js.DEFAULT_APPROVAL_AMOUNT;
|
|
590
623
|
return {
|
|
591
|
-
abi:
|
|
624
|
+
abi: chunkBXUG3WDV_js.BoringVaultAbi,
|
|
592
625
|
address: boringVaultAddress,
|
|
593
626
|
functionName: "approve",
|
|
594
|
-
args: [
|
|
627
|
+
args: [chunkIBNTWZ4S_js.ATOMIC_QUEUE_CONTRACT_ADDRESS, withdrawAmountAsBigInt]
|
|
595
628
|
};
|
|
596
629
|
} catch (error) {
|
|
597
|
-
if (error instanceof
|
|
630
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
598
631
|
throw error;
|
|
599
632
|
}
|
|
600
|
-
throw new
|
|
633
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
601
634
|
`Failed to prepare approval transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
602
635
|
{
|
|
603
636
|
endpoint: "prepareApproveWithdrawToken",
|
|
@@ -609,7 +642,7 @@ async function prepareApproveWithdrawTxData({
|
|
|
609
642
|
|
|
610
643
|
// src/vaults/withdraw/utils.ts
|
|
611
644
|
var prepareUserRequest = (offerAmount, atomicPrice, deadline) => {
|
|
612
|
-
const deadlineTimeStamp =
|
|
645
|
+
const deadlineTimeStamp = chunkK4DL2AII_js.calculateDeadline(deadline);
|
|
613
646
|
return {
|
|
614
647
|
deadline: deadlineTimeStamp,
|
|
615
648
|
atomicPrice,
|
|
@@ -635,30 +668,30 @@ async function prepareBulkWithdrawTxData(params) {
|
|
|
635
668
|
} = params;
|
|
636
669
|
try {
|
|
637
670
|
const normalizedChainId = chunkRUIAH5HY_js.toChainId(chainId);
|
|
638
|
-
const vault = await
|
|
671
|
+
const vault = await chunkIBNTWZ4S_js.findVaultByConfig({
|
|
639
672
|
assetAddress: wantAssetAddress,
|
|
640
673
|
yieldType,
|
|
641
674
|
chainId: normalizedChainId
|
|
642
675
|
});
|
|
643
676
|
if (vault && vault.chainId !== normalizedChainId) {
|
|
644
|
-
throw new
|
|
677
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
645
678
|
`Vault chain mismatch: vault is on chain ${vault.chainId}, requested chain ${normalizedChainId}`,
|
|
646
679
|
{ endpoint: "prepareBulkWithdrawTransactionData" }
|
|
647
680
|
);
|
|
648
681
|
}
|
|
649
682
|
if (!vault || !vault.vault.boringVaultAddress) {
|
|
650
|
-
throw new
|
|
683
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
651
684
|
`BoringVault contract address not configured for vault ${vault?.vault.boringVaultAddress}`,
|
|
652
685
|
{ endpoint: "prepareBulkWithdrawTransactionData" }
|
|
653
686
|
);
|
|
654
687
|
}
|
|
655
688
|
const boringVaultAddress = vault.vault.boringVaultAddress;
|
|
656
689
|
const accountantAddress = vault.vault.accountantAddress;
|
|
657
|
-
const wantAsset = await
|
|
690
|
+
const wantAsset = await chunkIBNTWZ4S_js.getAssetsFromCache({
|
|
658
691
|
address: wantAssetAddress
|
|
659
692
|
});
|
|
660
693
|
if (wantAsset.length === 0) {
|
|
661
|
-
throw new
|
|
694
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
662
695
|
`Vault shares token not found in supported assets: ${boringVaultAddress}`,
|
|
663
696
|
{ endpoint: "prepareBulkWithdrawTransactionData" }
|
|
664
697
|
);
|
|
@@ -667,14 +700,14 @@ async function prepareBulkWithdrawTxData(params) {
|
|
|
667
700
|
wantAssetDecimalsResult,
|
|
668
701
|
sharesAssetDecimalsResult,
|
|
669
702
|
rateInQuoteResult
|
|
670
|
-
] = await
|
|
703
|
+
] = await chunkBXUG3WDV_js.getRateInQuoteAndSharesAndWantAssetDecimals({
|
|
671
704
|
sharesAssetAddress: boringVaultAddress,
|
|
672
705
|
wantAssetAddress,
|
|
673
706
|
accountantAddress,
|
|
674
707
|
chainId: normalizedChainId
|
|
675
708
|
});
|
|
676
709
|
if (rateInQuoteResult.status === "failure" || wantAssetDecimalsResult.status === "failure" || sharesAssetDecimalsResult.status === "failure") {
|
|
677
|
-
throw new
|
|
710
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
678
711
|
`Failed to get exchange rate: ${rateInQuoteResult?.error?.message || wantAssetDecimalsResult?.error?.message || sharesAssetDecimalsResult?.error?.message}`,
|
|
679
712
|
{
|
|
680
713
|
endpoint: "prepareBulkWithdrawTransactionData",
|
|
@@ -695,17 +728,17 @@ async function prepareBulkWithdrawTxData(params) {
|
|
|
695
728
|
);
|
|
696
729
|
const minimumAssets = atomicPrice * offerAmountAsBigInt / BigInt(10 ** sharesAssetDecimalsResult.result);
|
|
697
730
|
return {
|
|
698
|
-
abi:
|
|
731
|
+
abi: chunkBXUG3WDV_js.TellerAbi,
|
|
699
732
|
address: vault.vault.tellerAddress,
|
|
700
733
|
functionName: "bulkWithdraw",
|
|
701
734
|
args: [wantAssetAddress, offerAmountAsBigInt, minimumAssets, userAddress],
|
|
702
735
|
chainId: normalizedChainId
|
|
703
736
|
};
|
|
704
737
|
} catch (error) {
|
|
705
|
-
if (error instanceof
|
|
738
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
706
739
|
throw error;
|
|
707
740
|
}
|
|
708
|
-
throw new
|
|
741
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
709
742
|
`Failed to prepare withdrawal transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
710
743
|
{
|
|
711
744
|
endpoint: "prepareBulkWithdrawTransactionData",
|
|
@@ -956,30 +989,30 @@ var prepareWithdrawTxData = async ({
|
|
|
956
989
|
wantAssetAddress,
|
|
957
990
|
chainId,
|
|
958
991
|
offerAmount,
|
|
959
|
-
deadline =
|
|
992
|
+
deadline = chunkIBNTWZ4S_js.DEFAULT_DEADLINE,
|
|
960
993
|
slippage = chunkITB7FXG4_js.DEFAULT_SLIPPAGE_BPS
|
|
961
994
|
}) => {
|
|
962
995
|
try {
|
|
963
996
|
const normalizedChainId = chunkRUIAH5HY_js.toChainId(chainId);
|
|
964
|
-
const config = await
|
|
997
|
+
const config = await chunkIBNTWZ4S_js.findVaultByConfig({
|
|
965
998
|
assetAddress: wantAssetAddress,
|
|
966
999
|
yieldType,
|
|
967
1000
|
chainId: normalizedChainId
|
|
968
1001
|
});
|
|
969
1002
|
if (config && config.chainId !== normalizedChainId) {
|
|
970
|
-
throw new
|
|
1003
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
971
1004
|
`Vault chain mismatch: vault is on chain ${config.chainId}, requested chain ${normalizedChainId}`,
|
|
972
1005
|
{ endpoint: "prepareWithdrawTransactionData" }
|
|
973
1006
|
);
|
|
974
1007
|
}
|
|
975
1008
|
if (!config || !config.vault.boringVaultAddress) {
|
|
976
|
-
throw new
|
|
1009
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
977
1010
|
`BoringVault contract address not configured for vault ${config?.id}`,
|
|
978
1011
|
{ endpoint: "prepareWithdrawTransactionData" }
|
|
979
1012
|
);
|
|
980
1013
|
}
|
|
981
1014
|
if (!config.vault.accountantAddress) {
|
|
982
|
-
throw new
|
|
1015
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
983
1016
|
`Accountant contract address not configured for vault ${config.id}`,
|
|
984
1017
|
{ endpoint: "prepareWithdrawTransactionData" }
|
|
985
1018
|
);
|
|
@@ -990,14 +1023,14 @@ var prepareWithdrawTxData = async ({
|
|
|
990
1023
|
wantAssetDecimalsResult,
|
|
991
1024
|
sharesAssetDecimalsResult,
|
|
992
1025
|
rateInQuoteResult
|
|
993
|
-
] = await
|
|
1026
|
+
] = await chunkBXUG3WDV_js.getRateInQuoteAndSharesAndWantAssetDecimals({
|
|
994
1027
|
sharesAssetAddress: boringVaultAddress,
|
|
995
1028
|
wantAssetAddress,
|
|
996
1029
|
accountantAddress,
|
|
997
1030
|
chainId: normalizedChainId
|
|
998
1031
|
});
|
|
999
1032
|
if (rateInQuoteResult?.status === "failure" || wantAssetDecimalsResult?.status === "failure" || sharesAssetDecimalsResult?.status === "failure") {
|
|
1000
|
-
throw new
|
|
1033
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
1001
1034
|
`Failed to get exchange rate: ${rateInQuoteResult?.error?.message || wantAssetDecimalsResult?.error?.message || sharesAssetDecimalsResult?.error?.message}`,
|
|
1002
1035
|
{
|
|
1003
1036
|
endpoint: "prepareWithdrawTransactionData",
|
|
@@ -1023,16 +1056,16 @@ var prepareWithdrawTxData = async ({
|
|
|
1023
1056
|
);
|
|
1024
1057
|
return {
|
|
1025
1058
|
abi: AtomicQueueAbi,
|
|
1026
|
-
address:
|
|
1059
|
+
address: chunkIBNTWZ4S_js.ATOMIC_QUEUE_CONTRACT_ADDRESS,
|
|
1027
1060
|
functionName: "updateAtomicRequest",
|
|
1028
1061
|
args: [boringVaultAddress, wantAssetAddress, userRequest],
|
|
1029
1062
|
chainId: normalizedChainId
|
|
1030
1063
|
};
|
|
1031
1064
|
} catch (error) {
|
|
1032
|
-
if (error instanceof
|
|
1065
|
+
if (error instanceof chunkIBNTWZ4S_js.APIError) {
|
|
1033
1066
|
throw error;
|
|
1034
1067
|
}
|
|
1035
|
-
throw new
|
|
1068
|
+
throw new chunkIBNTWZ4S_js.APIError(
|
|
1036
1069
|
`Failed to prepare withdrawal transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1037
1070
|
{
|
|
1038
1071
|
endpoint: "prepareWithdrawTransactionData",
|
|
@@ -1048,59 +1081,59 @@ Object.defineProperty(exports, "YieldType", {
|
|
|
1048
1081
|
});
|
|
1049
1082
|
Object.defineProperty(exports, "getDepositExchangeRate", {
|
|
1050
1083
|
enumerable: true,
|
|
1051
|
-
get: function () { return
|
|
1084
|
+
get: function () { return chunkZCVMGIMV_js.getDepositExchangeRate; }
|
|
1052
1085
|
});
|
|
1053
1086
|
Object.defineProperty(exports, "getWithdrawExchangeRate", {
|
|
1054
1087
|
enumerable: true,
|
|
1055
|
-
get: function () { return
|
|
1088
|
+
get: function () { return chunkZCVMGIMV_js.getWithdrawExchangeRate; }
|
|
1056
1089
|
});
|
|
1057
1090
|
Object.defineProperty(exports, "isDepositSpendApproved", {
|
|
1058
1091
|
enumerable: true,
|
|
1059
|
-
get: function () { return
|
|
1092
|
+
get: function () { return chunkZCVMGIMV_js.isDepositSpendApproved; }
|
|
1060
1093
|
});
|
|
1061
1094
|
Object.defineProperty(exports, "isWithdrawalSpendApproved", {
|
|
1062
1095
|
enumerable: true,
|
|
1063
|
-
get: function () { return
|
|
1096
|
+
get: function () { return chunkZCVMGIMV_js.isWithdrawalSpendApproved; }
|
|
1064
1097
|
});
|
|
1065
1098
|
Object.defineProperty(exports, "APIError", {
|
|
1066
1099
|
enumerable: true,
|
|
1067
|
-
get: function () { return
|
|
1100
|
+
get: function () { return chunkIBNTWZ4S_js.APIError; }
|
|
1068
1101
|
});
|
|
1069
1102
|
Object.defineProperty(exports, "fetchSupportedAssets", {
|
|
1070
1103
|
enumerable: true,
|
|
1071
|
-
get: function () { return
|
|
1104
|
+
get: function () { return chunkIBNTWZ4S_js.fetchSupportedAssets; }
|
|
1072
1105
|
});
|
|
1073
1106
|
Object.defineProperty(exports, "fetchVaults", {
|
|
1074
1107
|
enumerable: true,
|
|
1075
|
-
get: function () { return
|
|
1108
|
+
get: function () { return chunkIBNTWZ4S_js.fetchVaults; }
|
|
1076
1109
|
});
|
|
1077
1110
|
Object.defineProperty(exports, "findVaultByConfig", {
|
|
1078
1111
|
enumerable: true,
|
|
1079
|
-
get: function () { return
|
|
1112
|
+
get: function () { return chunkIBNTWZ4S_js.findVaultByConfig; }
|
|
1080
1113
|
});
|
|
1081
1114
|
Object.defineProperty(exports, "getAssetsFromCache", {
|
|
1082
1115
|
enumerable: true,
|
|
1083
|
-
get: function () { return
|
|
1116
|
+
get: function () { return chunkIBNTWZ4S_js.getAssetsFromCache; }
|
|
1084
1117
|
});
|
|
1085
1118
|
Object.defineProperty(exports, "getCache", {
|
|
1086
1119
|
enumerable: true,
|
|
1087
|
-
get: function () { return
|
|
1120
|
+
get: function () { return chunkIBNTWZ4S_js.getCache; }
|
|
1088
1121
|
});
|
|
1089
1122
|
Object.defineProperty(exports, "getWithdrawSupportedAssets", {
|
|
1090
1123
|
enumerable: true,
|
|
1091
|
-
get: function () { return
|
|
1124
|
+
get: function () { return chunkIBNTWZ4S_js.getWithdrawSupportedAssets; }
|
|
1092
1125
|
});
|
|
1093
1126
|
Object.defineProperty(exports, "initAmplifySDK", {
|
|
1094
1127
|
enumerable: true,
|
|
1095
|
-
get: function () { return
|
|
1128
|
+
get: function () { return chunkIBNTWZ4S_js.initAmplifySDK; }
|
|
1096
1129
|
});
|
|
1097
1130
|
Object.defineProperty(exports, "initializeCache", {
|
|
1098
1131
|
enumerable: true,
|
|
1099
|
-
get: function () { return
|
|
1132
|
+
get: function () { return chunkIBNTWZ4S_js.initializeCache; }
|
|
1100
1133
|
});
|
|
1101
1134
|
Object.defineProperty(exports, "refreshVaultCache", {
|
|
1102
1135
|
enumerable: true,
|
|
1103
|
-
get: function () { return
|
|
1136
|
+
get: function () { return chunkIBNTWZ4S_js.refreshVaultCache; }
|
|
1104
1137
|
});
|
|
1105
1138
|
exports.PERMIT_TYPES = PERMIT_TYPES;
|
|
1106
1139
|
exports.parsePermitSignature = parsePermitSignature;
|