@paxoslabs/amplify-sdk 0.5.1 → 0.5.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/CHANGELOG.md +7 -45
- package/README.md +22 -22
- package/dist/{chain-utils-D_b2LEEi.d.mts → chain-utils-5r2UnCDS.d.mts} +57 -1
- package/dist/{chain-utils-D_b2LEEi.d.ts → chain-utils-5r2UnCDS.d.ts} +57 -1
- package/dist/{chunk-L5XT67QZ.js → chunk-4NQPS3JC.js} +813 -147
- package/dist/chunk-4NQPS3JC.js.map +1 -0
- package/dist/{chunk-7RWWVUHP.mjs → chunk-6CU533DM.mjs} +2 -2
- package/dist/chunk-6CU533DM.mjs.map +1 -0
- package/dist/chunk-6JLKHV6O.js +128 -0
- package/dist/chunk-6JLKHV6O.js.map +1 -0
- package/dist/{chunk-YAYUSBC6.js → chunk-FHE43NKY.js} +12 -12
- package/dist/chunk-FHE43NKY.js.map +1 -0
- package/dist/chunk-GOJQYEJQ.js +3212 -0
- package/dist/chunk-GOJQYEJQ.js.map +1 -0
- package/dist/{chunk-3D6EDR3Z.mjs → chunk-LMNADWTH.mjs} +703 -41
- package/dist/chunk-LMNADWTH.mjs.map +1 -0
- package/dist/chunk-ODXJYXUH.mjs +3168 -0
- package/dist/chunk-ODXJYXUH.mjs.map +1 -0
- package/dist/{chunk-WJGSTAPB.mjs → chunk-QMFYPHX5.mjs} +300 -87
- package/dist/chunk-QMFYPHX5.mjs.map +1 -0
- package/dist/{chunk-3I3PYX2F.js → chunk-TNL23CO2.js} +2 -2
- package/dist/chunk-TNL23CO2.js.map +1 -0
- package/dist/{chunk-E6SBQNDA.mjs → chunk-UY2WD7MF.mjs} +3 -3
- package/dist/chunk-UY2WD7MF.mjs.map +1 -0
- package/dist/chunk-WD6QFSXZ.js +701 -0
- package/dist/chunk-WD6QFSXZ.js.map +1 -0
- package/dist/chunk-Y5LBT2WT.mjs +118 -0
- package/dist/chunk-Y5LBT2WT.mjs.map +1 -0
- package/dist/core.d.mts +50 -7
- package/dist/core.d.ts +50 -7
- package/dist/core.js +32 -16
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +4 -4
- package/dist/core.mjs.map +1 -1
- package/dist/display.d.mts +212 -3
- package/dist/display.d.ts +212 -3
- package/dist/display.js +27 -11
- package/dist/display.mjs +5 -5
- package/dist/index-D8RtV9cB.d.mts +5114 -0
- package/dist/index-ev_V5sjt.d.ts +5114 -0
- package/dist/index.d.mts +41 -6
- package/dist/index.d.ts +41 -6
- package/dist/index.js +90 -58
- package/dist/index.mjs +6 -6
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +13 -13
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +3 -3
- package/dist/utils.mjs.map +1 -1
- package/dist/vaults.d.mts +3 -3817
- package/dist/vaults.d.ts +3 -3817
- package/dist/vaults.js +26 -26
- package/dist/vaults.mjs +5 -5
- package/package.json +30 -65
- package/dist/chunk-3D6EDR3Z.mjs.map +0 -1
- package/dist/chunk-3I3PYX2F.js.map +0 -1
- package/dist/chunk-7RWWVUHP.mjs.map +0 -1
- package/dist/chunk-AUDMOT6F.js +0 -1230
- package/dist/chunk-AUDMOT6F.js.map +0 -1
- package/dist/chunk-E5DH5YEE.js +0 -1485
- package/dist/chunk-E5DH5YEE.js.map +0 -1
- package/dist/chunk-E6SBQNDA.mjs.map +0 -1
- package/dist/chunk-JLZL25CY.mjs +0 -1450
- package/dist/chunk-JLZL25CY.mjs.map +0 -1
- package/dist/chunk-L5XT67QZ.js.map +0 -1
- package/dist/chunk-WJGSTAPB.mjs.map +0 -1
- package/dist/chunk-XVDK6J72.js +0 -484
- package/dist/chunk-XVDK6J72.js.map +0 -1
- package/dist/chunk-Y6RXVDQN.mjs +0 -1222
- package/dist/chunk-Y6RXVDQN.mjs.map +0 -1
- package/dist/chunk-YAYUSBC6.js.map +0 -1
|
@@ -1,11 +1,113 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunk6JLKHV6O_js = require('./chunk-6JLKHV6O.js');
|
|
4
|
+
var chunkFHE43NKY_js = require('./chunk-FHE43NKY.js');
|
|
5
|
+
var chunkTNL23CO2_js = require('./chunk-TNL23CO2.js');
|
|
6
|
+
var chunkGOJQYEJQ_js = require('./chunk-GOJQYEJQ.js');
|
|
7
7
|
var viem = require('viem');
|
|
8
8
|
|
|
9
|
+
// src/client/kyt-client.ts
|
|
10
|
+
var CHAIN_ID_TO_PREDICATE_CHAIN = {
|
|
11
|
+
1: "ethereum",
|
|
12
|
+
11155111: "sepolia",
|
|
13
|
+
8453: "base",
|
|
14
|
+
84532: "base-sepolia",
|
|
15
|
+
999: "hyperevm",
|
|
16
|
+
2201: "stable-testnet"
|
|
17
|
+
};
|
|
18
|
+
async function fetchKytAttestation(params) {
|
|
19
|
+
const { to, from, chainId } = params;
|
|
20
|
+
const logger = chunkGOJQYEJQ_js.getLogger();
|
|
21
|
+
const chain = CHAIN_ID_TO_PREDICATE_CHAIN[chainId];
|
|
22
|
+
if (!chain) {
|
|
23
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
24
|
+
`KYT attestation not supported for chain ID ${chainId}. Supported chains: ${Object.keys(CHAIN_ID_TO_PREDICATE_CHAIN).join(", ")}`,
|
|
25
|
+
{ endpoint: "kytAttestation" }
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const url = `${chunkGOJQYEJQ_js.getRestV2BaseURL()}/kytAttestation`;
|
|
29
|
+
const headers = chunkGOJQYEJQ_js.getRequestHeaders();
|
|
30
|
+
logger.debug("Fetching KYT attestation", { to, from, chain });
|
|
31
|
+
let response;
|
|
32
|
+
try {
|
|
33
|
+
response = await fetch(url, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
headers,
|
|
36
|
+
body: JSON.stringify({ to, from, chain }),
|
|
37
|
+
signal: chunkGOJQYEJQ_js.createTimeoutSignal(chunkGOJQYEJQ_js.DEFAULT_TIMEOUT)
|
|
38
|
+
});
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
41
|
+
throw new chunkGOJQYEJQ_js.APIError("KYT attestation request timed out", {
|
|
42
|
+
endpoint: "kytAttestation",
|
|
43
|
+
cause: error
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
47
|
+
`KYT attestation request failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
48
|
+
{ endpoint: "kytAttestation", cause: error }
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
let serverMessage;
|
|
53
|
+
try {
|
|
54
|
+
const errorBody = await response.json();
|
|
55
|
+
serverMessage = errorBody?.error?.message;
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
if (response.status === 403) {
|
|
59
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
60
|
+
serverMessage ?? "Deposit blocked: transaction is not compliant with KYT policy",
|
|
61
|
+
{ endpoint: "kytAttestation", statusCode: 403 }
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (response.status === 400) {
|
|
65
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
66
|
+
serverMessage ?? "KYT attestation request was rejected: invalid parameters",
|
|
67
|
+
{ endpoint: "kytAttestation", statusCode: 400 }
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
71
|
+
serverMessage ?? `KYT attestation request failed (HTTP ${response.status})`,
|
|
72
|
+
{ endpoint: "kytAttestation", statusCode: response.status }
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
let body;
|
|
76
|
+
try {
|
|
77
|
+
body = await response.json();
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new chunkGOJQYEJQ_js.APIError("KYT attestation response contained invalid JSON", {
|
|
80
|
+
endpoint: "kytAttestation",
|
|
81
|
+
cause: error
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (!body.attestation) {
|
|
85
|
+
throw new chunkGOJQYEJQ_js.APIError("KYT attestation response missing attestation field", {
|
|
86
|
+
endpoint: "kytAttestation"
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const { attestation } = body;
|
|
90
|
+
const missingFields = ["uuid", "attester", "signature", "expiration"].filter((f) => attestation[f] == null);
|
|
91
|
+
if (missingFields.length > 0) {
|
|
92
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
93
|
+
`KYT attestation response missing required fields: ${missingFields.join(", ")}`,
|
|
94
|
+
{ endpoint: "kytAttestation" }
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (typeof attestation.expiration !== "number" && typeof attestation.expiration !== "string") {
|
|
98
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
99
|
+
"KYT attestation response has invalid expiration value",
|
|
100
|
+
{ endpoint: "kytAttestation" }
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const sig = attestation.signature.startsWith("0x") ? attestation.signature : `0x${attestation.signature}`;
|
|
104
|
+
return {
|
|
105
|
+
uuid: attestation.uuid,
|
|
106
|
+
expiration: BigInt(attestation.expiration),
|
|
107
|
+
attester: attestation.attester,
|
|
108
|
+
signature: sig
|
|
109
|
+
};
|
|
110
|
+
}
|
|
9
111
|
var isDepositSpendApproved = async ({
|
|
10
112
|
vaultName,
|
|
11
113
|
chainId,
|
|
@@ -13,8 +115,8 @@ var isDepositSpendApproved = async ({
|
|
|
13
115
|
recipientAddress
|
|
14
116
|
}) => {
|
|
15
117
|
try {
|
|
16
|
-
const normalizedChainId =
|
|
17
|
-
const config = await
|
|
118
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
119
|
+
const config = await chunk6JLKHV6O_js.resolveVault({
|
|
18
120
|
vaultName,
|
|
19
121
|
chainId: normalizedChainId,
|
|
20
122
|
assetAddress: depositAssetAddress,
|
|
@@ -22,7 +124,7 @@ var isDepositSpendApproved = async ({
|
|
|
22
124
|
});
|
|
23
125
|
const communityCodeDepositorAddress = config.vault.communityCodeDepositorAddress;
|
|
24
126
|
if (!communityCodeDepositorAddress) {
|
|
25
|
-
throw new
|
|
127
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
26
128
|
`Community code depositor contract address not configured for vault ${config.id}`,
|
|
27
129
|
{
|
|
28
130
|
endpoint: "isDepositSpendApproved"
|
|
@@ -37,7 +139,7 @@ var isDepositSpendApproved = async ({
|
|
|
37
139
|
domainSeparator,
|
|
38
140
|
tokenName,
|
|
39
141
|
tokenVersion
|
|
40
|
-
} = await
|
|
142
|
+
} = await chunkFHE43NKY_js.getTokenPermitInfoWithAllowance({
|
|
41
143
|
chainId: normalizedChainId,
|
|
42
144
|
tokenAddress: depositAssetAddress,
|
|
43
145
|
owner: recipientAddress,
|
|
@@ -56,10 +158,10 @@ var isDepositSpendApproved = async ({
|
|
|
56
158
|
error: null
|
|
57
159
|
};
|
|
58
160
|
} catch (error) {
|
|
59
|
-
if (error instanceof
|
|
161
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
60
162
|
throw error;
|
|
61
163
|
}
|
|
62
|
-
throw new
|
|
164
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
63
165
|
`Failed to check deposit approval: ${error instanceof Error ? error.message : String(error)}`,
|
|
64
166
|
{
|
|
65
167
|
endpoint: "isDepositSpendApproved",
|
|
@@ -75,8 +177,8 @@ var isWithdrawalSpendApproved = async ({
|
|
|
75
177
|
recipientAddress
|
|
76
178
|
}) => {
|
|
77
179
|
try {
|
|
78
|
-
const normalizedChainId =
|
|
79
|
-
const config = await
|
|
180
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
181
|
+
const config = await chunk6JLKHV6O_js.resolveVault({
|
|
80
182
|
vaultName,
|
|
81
183
|
chainId: normalizedChainId,
|
|
82
184
|
assetAddress: wantAssetAddress,
|
|
@@ -84,7 +186,7 @@ var isWithdrawalSpendApproved = async ({
|
|
|
84
186
|
});
|
|
85
187
|
const boringVaultAddress = config.vault.boringVaultAddress;
|
|
86
188
|
if (!boringVaultAddress) {
|
|
87
|
-
throw new
|
|
189
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
88
190
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
89
191
|
{
|
|
90
192
|
endpoint: "isWithdrawalSpendApproved"
|
|
@@ -93,14 +195,14 @@ var isWithdrawalSpendApproved = async ({
|
|
|
93
195
|
}
|
|
94
196
|
const withdrawQueueAddress = config.vault.withdrawQueueAddress;
|
|
95
197
|
if (!withdrawQueueAddress) {
|
|
96
|
-
throw new
|
|
198
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
97
199
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
98
200
|
{
|
|
99
201
|
endpoint: "isWithdrawalSpendApproved"
|
|
100
202
|
}
|
|
101
203
|
);
|
|
102
204
|
}
|
|
103
|
-
const [allowance, decimals] = await
|
|
205
|
+
const [allowance, decimals] = await chunkFHE43NKY_js.getErc20AllowanceWithDecimals({
|
|
104
206
|
chainId: normalizedChainId,
|
|
105
207
|
tokenAddress: boringVaultAddress,
|
|
106
208
|
recipientAddress,
|
|
@@ -123,10 +225,10 @@ var isWithdrawalSpendApproved = async ({
|
|
|
123
225
|
error: null
|
|
124
226
|
};
|
|
125
227
|
} catch (error) {
|
|
126
|
-
if (error instanceof
|
|
228
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
127
229
|
throw error;
|
|
128
230
|
}
|
|
129
|
-
throw new
|
|
231
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
130
232
|
`Failed to check withdrawal approval: ${error instanceof Error ? error.message : String(error)}`,
|
|
131
233
|
{ endpoint: "isWithdrawalSpendApproved", cause: error }
|
|
132
234
|
);
|
|
@@ -138,9 +240,9 @@ async function prepareApproveDepositTokenTxData({
|
|
|
138
240
|
approvalAmount,
|
|
139
241
|
chainId
|
|
140
242
|
}) {
|
|
141
|
-
const normalizedChainId =
|
|
243
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
142
244
|
try {
|
|
143
|
-
const config = await
|
|
245
|
+
const config = await chunk6JLKHV6O_js.resolveVault({
|
|
144
246
|
vaultName,
|
|
145
247
|
assetAddress: depositAsset,
|
|
146
248
|
chainId: normalizedChainId,
|
|
@@ -148,14 +250,14 @@ async function prepareApproveDepositTokenTxData({
|
|
|
148
250
|
});
|
|
149
251
|
const communityCodeDepositorAddress = config.vault.communityCodeDepositorAddress;
|
|
150
252
|
if (!communityCodeDepositorAddress) {
|
|
151
|
-
throw new
|
|
253
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
152
254
|
`Community Code Depositor contract address not configured for vault ${config.id}`,
|
|
153
255
|
{ endpoint: "prepareApproveDepositToken" }
|
|
154
256
|
);
|
|
155
257
|
}
|
|
156
|
-
const assets = await
|
|
258
|
+
const assets = await chunkGOJQYEJQ_js.getSupportedAssets({ address: depositAsset });
|
|
157
259
|
if (assets.length === 0) {
|
|
158
|
-
throw new
|
|
260
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
159
261
|
`Asset metadata not found for token ${depositAsset} on chain ${normalizedChainId}`,
|
|
160
262
|
{ endpoint: "prepareApproveDepositToken" }
|
|
161
263
|
);
|
|
@@ -164,13 +266,13 @@ async function prepareApproveDepositTokenTxData({
|
|
|
164
266
|
(asset) => asset.address.toLowerCase() === depositAsset.toLowerCase() && asset.chains.includes(normalizedChainId)
|
|
165
267
|
);
|
|
166
268
|
if (!verifiedAsset) {
|
|
167
|
-
throw new
|
|
269
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
168
270
|
`Asset ${depositAsset} not verified on chain ${normalizedChainId}`,
|
|
169
271
|
{ endpoint: "prepareApproveDepositToken" }
|
|
170
272
|
);
|
|
171
273
|
}
|
|
172
274
|
const decimals = verifiedAsset.decimals;
|
|
173
|
-
const amount = approvalAmount ? viem.parseUnits(approvalAmount, decimals) :
|
|
275
|
+
const amount = approvalAmount ? viem.parseUnits(approvalAmount, decimals) : chunkGOJQYEJQ_js.DEFAULT_APPROVAL_AMOUNT;
|
|
174
276
|
return {
|
|
175
277
|
abi: viem.erc20Abi,
|
|
176
278
|
address: depositAsset,
|
|
@@ -178,10 +280,10 @@ async function prepareApproveDepositTokenTxData({
|
|
|
178
280
|
args: [communityCodeDepositorAddress, amount]
|
|
179
281
|
};
|
|
180
282
|
} catch (error) {
|
|
181
|
-
if (error instanceof
|
|
283
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
182
284
|
throw error;
|
|
183
285
|
}
|
|
184
|
-
throw new
|
|
286
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
185
287
|
`Failed to prepare approval transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
186
288
|
{
|
|
187
289
|
endpoint: "prepareApproveDepositToken",
|
|
@@ -191,8 +293,8 @@ async function prepareApproveDepositTokenTxData({
|
|
|
191
293
|
}
|
|
192
294
|
}
|
|
193
295
|
|
|
194
|
-
// src/abi/
|
|
195
|
-
var
|
|
296
|
+
// src/abi/distributor-code-depositor-abi-v1.ts
|
|
297
|
+
var DistributorCodeDepositorAbiV1 = [
|
|
196
298
|
{
|
|
197
299
|
inputs: [
|
|
198
300
|
{
|
|
@@ -211,19 +313,53 @@ var CommunityCodeDepositorAbi = [
|
|
|
211
313
|
type: "address"
|
|
212
314
|
},
|
|
213
315
|
{ internalType: "bool", name: "_isNativeDepositSupported", type: "bool" },
|
|
316
|
+
{ internalType: "uint256", name: "_supplyCap", type: "uint256" },
|
|
317
|
+
{
|
|
318
|
+
internalType: "contract IFeeModule",
|
|
319
|
+
name: "_feeModule",
|
|
320
|
+
type: "address"
|
|
321
|
+
},
|
|
322
|
+
{ internalType: "address", name: "_feeRecipient", type: "address" },
|
|
323
|
+
{ internalType: "address", name: "_registry", type: "address" },
|
|
324
|
+
{ internalType: "string", name: "_policyID", type: "string" },
|
|
214
325
|
{ internalType: "address", name: "_owner", type: "address" }
|
|
215
326
|
],
|
|
216
327
|
stateMutability: "nonpayable",
|
|
217
328
|
type: "constructor"
|
|
218
329
|
},
|
|
330
|
+
{ inputs: [], name: "FeesExceedOrEqualAmount", type: "error" },
|
|
219
331
|
{ inputs: [], name: "IncorrectNativeDepositAmount", type: "error" },
|
|
332
|
+
{
|
|
333
|
+
inputs: [
|
|
334
|
+
{ internalType: "uint256", name: "actual", type: "uint256" },
|
|
335
|
+
{ internalType: "uint256", name: "minimum", type: "uint256" }
|
|
336
|
+
],
|
|
337
|
+
name: "InsufficientSharesAfterFees",
|
|
338
|
+
type: "error"
|
|
339
|
+
},
|
|
220
340
|
{ inputs: [], name: "NativeDepositNotSupported", type: "error" },
|
|
221
341
|
{
|
|
222
342
|
inputs: [],
|
|
223
343
|
name: "NativeWrapperAccountantDecimalsMismatch",
|
|
224
344
|
type: "error"
|
|
225
345
|
},
|
|
346
|
+
{
|
|
347
|
+
inputs: [
|
|
348
|
+
{ internalType: "address", name: "addressEmptyCode", type: "address" }
|
|
349
|
+
],
|
|
350
|
+
name: "NoCode",
|
|
351
|
+
type: "error"
|
|
352
|
+
},
|
|
226
353
|
{ inputs: [], name: "PermitFailedAndAllowanceTooLow", type: "error" },
|
|
354
|
+
{
|
|
355
|
+
inputs: [
|
|
356
|
+
{ internalType: "uint256", name: "resultingValue", type: "uint256" },
|
|
357
|
+
{ internalType: "uint256", name: "supplyCapInBase", type: "uint256" }
|
|
358
|
+
],
|
|
359
|
+
name: "SupplyCapInBaseError",
|
|
360
|
+
type: "error"
|
|
361
|
+
},
|
|
362
|
+
{ inputs: [], name: "UnauthorizedTransaction", type: "error" },
|
|
227
363
|
{ inputs: [], name: "ZeroAddress", type: "error" },
|
|
228
364
|
{
|
|
229
365
|
anonymous: false,
|
|
@@ -283,6 +419,46 @@ var CommunityCodeDepositorAbi = [
|
|
|
283
419
|
name: "DepositWithDistributorCode",
|
|
284
420
|
type: "event"
|
|
285
421
|
},
|
|
422
|
+
{
|
|
423
|
+
anonymous: false,
|
|
424
|
+
inputs: [
|
|
425
|
+
{
|
|
426
|
+
indexed: true,
|
|
427
|
+
internalType: "contract IFeeModule",
|
|
428
|
+
name: "newFeeModule",
|
|
429
|
+
type: "address"
|
|
430
|
+
}
|
|
431
|
+
],
|
|
432
|
+
name: "FeeModuleUpdated",
|
|
433
|
+
type: "event"
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
anonymous: false,
|
|
437
|
+
inputs: [
|
|
438
|
+
{
|
|
439
|
+
indexed: true,
|
|
440
|
+
internalType: "address",
|
|
441
|
+
name: "newFeeRecipient",
|
|
442
|
+
type: "address"
|
|
443
|
+
}
|
|
444
|
+
],
|
|
445
|
+
name: "FeeRecipientUpdated",
|
|
446
|
+
type: "event"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
anonymous: false,
|
|
450
|
+
inputs: [
|
|
451
|
+
{
|
|
452
|
+
indexed: true,
|
|
453
|
+
internalType: "contract ERC20",
|
|
454
|
+
name: "depositAsset",
|
|
455
|
+
type: "address"
|
|
456
|
+
},
|
|
457
|
+
{ indexed: true, internalType: "bool", name: "enabled", type: "bool" }
|
|
458
|
+
],
|
|
459
|
+
name: "KytStatusUpdated",
|
|
460
|
+
type: "event"
|
|
461
|
+
},
|
|
286
462
|
{
|
|
287
463
|
anonymous: false,
|
|
288
464
|
inputs: [
|
|
@@ -297,6 +473,64 @@ var CommunityCodeDepositorAbi = [
|
|
|
297
473
|
name: "OwnershipTransferred",
|
|
298
474
|
type: "event"
|
|
299
475
|
},
|
|
476
|
+
{
|
|
477
|
+
anonymous: false,
|
|
478
|
+
inputs: [
|
|
479
|
+
{
|
|
480
|
+
indexed: false,
|
|
481
|
+
internalType: "string",
|
|
482
|
+
name: "oldPolicyID",
|
|
483
|
+
type: "string"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
indexed: false,
|
|
487
|
+
internalType: "string",
|
|
488
|
+
name: "newPolicyID",
|
|
489
|
+
type: "string"
|
|
490
|
+
}
|
|
491
|
+
],
|
|
492
|
+
name: "PredicatePolicyIDUpdated",
|
|
493
|
+
type: "event"
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
anonymous: false,
|
|
497
|
+
inputs: [
|
|
498
|
+
{
|
|
499
|
+
indexed: true,
|
|
500
|
+
internalType: "address",
|
|
501
|
+
name: "oldRegistry",
|
|
502
|
+
type: "address"
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
indexed: true,
|
|
506
|
+
internalType: "address",
|
|
507
|
+
name: "newRegistry",
|
|
508
|
+
type: "address"
|
|
509
|
+
}
|
|
510
|
+
],
|
|
511
|
+
name: "PredicateRegistryUpdated",
|
|
512
|
+
type: "event"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
anonymous: false,
|
|
516
|
+
inputs: [
|
|
517
|
+
{
|
|
518
|
+
indexed: false,
|
|
519
|
+
internalType: "uint256",
|
|
520
|
+
name: "newSupplyCapInBase",
|
|
521
|
+
type: "uint256"
|
|
522
|
+
}
|
|
523
|
+
],
|
|
524
|
+
name: "SupplyCapInBaseUpdated",
|
|
525
|
+
type: "event"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
inputs: [],
|
|
529
|
+
name: "PREDICATE_DEPOSIT_SIGNATURE",
|
|
530
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
531
|
+
stateMutability: "view",
|
|
532
|
+
type: "function"
|
|
533
|
+
},
|
|
300
534
|
{
|
|
301
535
|
inputs: [],
|
|
302
536
|
name: "authority",
|
|
@@ -319,7 +553,18 @@ var CommunityCodeDepositorAbi = [
|
|
|
319
553
|
{ internalType: "uint256", name: "depositAmount", type: "uint256" },
|
|
320
554
|
{ internalType: "uint256", name: "minimumMint", type: "uint256" },
|
|
321
555
|
{ internalType: "address", name: "to", type: "address" },
|
|
322
|
-
{ internalType: "bytes", name: "distributorCode", type: "bytes" }
|
|
556
|
+
{ internalType: "bytes", name: "distributorCode", type: "bytes" },
|
|
557
|
+
{
|
|
558
|
+
components: [
|
|
559
|
+
{ internalType: "string", name: "uuid", type: "string" },
|
|
560
|
+
{ internalType: "uint256", name: "expiration", type: "uint256" },
|
|
561
|
+
{ internalType: "address", name: "attester", type: "address" },
|
|
562
|
+
{ internalType: "bytes", name: "signature", type: "bytes" }
|
|
563
|
+
],
|
|
564
|
+
internalType: "struct Attestation",
|
|
565
|
+
name: "_attestation",
|
|
566
|
+
type: "tuple"
|
|
567
|
+
}
|
|
323
568
|
],
|
|
324
569
|
name: "deposit",
|
|
325
570
|
outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }],
|
|
@@ -331,7 +576,18 @@ var CommunityCodeDepositorAbi = [
|
|
|
331
576
|
{ internalType: "uint256", name: "depositAmount", type: "uint256" },
|
|
332
577
|
{ internalType: "uint256", name: "minimumMint", type: "uint256" },
|
|
333
578
|
{ internalType: "address", name: "to", type: "address" },
|
|
334
|
-
{ internalType: "bytes", name: "distributorCode", type: "bytes" }
|
|
579
|
+
{ internalType: "bytes", name: "distributorCode", type: "bytes" },
|
|
580
|
+
{
|
|
581
|
+
components: [
|
|
582
|
+
{ internalType: "string", name: "uuid", type: "string" },
|
|
583
|
+
{ internalType: "uint256", name: "expiration", type: "uint256" },
|
|
584
|
+
{ internalType: "address", name: "attester", type: "address" },
|
|
585
|
+
{ internalType: "bytes", name: "signature", type: "bytes" }
|
|
586
|
+
],
|
|
587
|
+
internalType: "struct Attestation",
|
|
588
|
+
name: "_attestation",
|
|
589
|
+
type: "tuple"
|
|
590
|
+
}
|
|
335
591
|
],
|
|
336
592
|
name: "depositNative",
|
|
337
593
|
outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }],
|
|
@@ -352,6 +608,17 @@ var CommunityCodeDepositorAbi = [
|
|
|
352
608
|
{ internalType: "uint256", name: "minimumMint", type: "uint256" },
|
|
353
609
|
{ internalType: "address", name: "to", type: "address" },
|
|
354
610
|
{ internalType: "bytes", name: "distributorCode", type: "bytes" },
|
|
611
|
+
{
|
|
612
|
+
components: [
|
|
613
|
+
{ internalType: "string", name: "uuid", type: "string" },
|
|
614
|
+
{ internalType: "uint256", name: "expiration", type: "uint256" },
|
|
615
|
+
{ internalType: "address", name: "attester", type: "address" },
|
|
616
|
+
{ internalType: "bytes", name: "signature", type: "bytes" }
|
|
617
|
+
],
|
|
618
|
+
internalType: "struct Attestation",
|
|
619
|
+
name: "_attestation",
|
|
620
|
+
type: "tuple"
|
|
621
|
+
},
|
|
355
622
|
{ internalType: "uint256", name: "deadline", type: "uint256" },
|
|
356
623
|
{ internalType: "uint8", name: "v", type: "uint8" },
|
|
357
624
|
{ internalType: "bytes32", name: "r", type: "bytes32" },
|
|
@@ -362,6 +629,36 @@ var CommunityCodeDepositorAbi = [
|
|
|
362
629
|
stateMutability: "nonpayable",
|
|
363
630
|
type: "function"
|
|
364
631
|
},
|
|
632
|
+
{
|
|
633
|
+
inputs: [],
|
|
634
|
+
name: "feeModule",
|
|
635
|
+
outputs: [
|
|
636
|
+
{ internalType: "contract IFeeModule", name: "", type: "address" }
|
|
637
|
+
],
|
|
638
|
+
stateMutability: "view",
|
|
639
|
+
type: "function"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
inputs: [],
|
|
643
|
+
name: "feeRecipient",
|
|
644
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
645
|
+
stateMutability: "view",
|
|
646
|
+
type: "function"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
inputs: [],
|
|
650
|
+
name: "getPolicyID",
|
|
651
|
+
outputs: [{ internalType: "string", name: "policyID", type: "string" }],
|
|
652
|
+
stateMutability: "view",
|
|
653
|
+
type: "function"
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
inputs: [],
|
|
657
|
+
name: "getRegistry",
|
|
658
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
659
|
+
stateMutability: "view",
|
|
660
|
+
type: "function"
|
|
661
|
+
},
|
|
365
662
|
{
|
|
366
663
|
inputs: [],
|
|
367
664
|
name: "isNativeDepositSupported",
|
|
@@ -369,6 +666,13 @@ var CommunityCodeDepositorAbi = [
|
|
|
369
666
|
stateMutability: "view",
|
|
370
667
|
type: "function"
|
|
371
668
|
},
|
|
669
|
+
{
|
|
670
|
+
inputs: [{ internalType: "contract ERC20", name: "", type: "address" }],
|
|
671
|
+
name: "kytEnabled",
|
|
672
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
673
|
+
stateMutability: "view",
|
|
674
|
+
type: "function"
|
|
675
|
+
},
|
|
372
676
|
{
|
|
373
677
|
inputs: [],
|
|
374
678
|
name: "nativeWrapper",
|
|
@@ -398,6 +702,27 @@ var CommunityCodeDepositorAbi = [
|
|
|
398
702
|
stateMutability: "nonpayable",
|
|
399
703
|
type: "function"
|
|
400
704
|
},
|
|
705
|
+
{
|
|
706
|
+
inputs: [{ internalType: "string", name: "_policyID", type: "string" }],
|
|
707
|
+
name: "setPolicyID",
|
|
708
|
+
outputs: [],
|
|
709
|
+
stateMutability: "nonpayable",
|
|
710
|
+
type: "function"
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
inputs: [{ internalType: "address", name: "_registry", type: "address" }],
|
|
714
|
+
name: "setRegistry",
|
|
715
|
+
outputs: [],
|
|
716
|
+
stateMutability: "nonpayable",
|
|
717
|
+
type: "function"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
inputs: [],
|
|
721
|
+
name: "supplyCapInBase",
|
|
722
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
723
|
+
stateMutability: "view",
|
|
724
|
+
type: "function"
|
|
725
|
+
},
|
|
401
726
|
{
|
|
402
727
|
inputs: [],
|
|
403
728
|
name: "teller",
|
|
@@ -417,44 +742,167 @@ var CommunityCodeDepositorAbi = [
|
|
|
417
742
|
outputs: [],
|
|
418
743
|
stateMutability: "nonpayable",
|
|
419
744
|
type: "function"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
inputs: [
|
|
748
|
+
{
|
|
749
|
+
internalType: "contract IFeeModule",
|
|
750
|
+
name: "newFeeModule",
|
|
751
|
+
type: "address"
|
|
752
|
+
}
|
|
753
|
+
],
|
|
754
|
+
name: "updateFeeModule",
|
|
755
|
+
outputs: [],
|
|
756
|
+
stateMutability: "nonpayable",
|
|
757
|
+
type: "function"
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
inputs: [
|
|
761
|
+
{ internalType: "address", name: "newFeeRecipient", type: "address" }
|
|
762
|
+
],
|
|
763
|
+
name: "updateFeeRecipient",
|
|
764
|
+
outputs: [],
|
|
765
|
+
stateMutability: "nonpayable",
|
|
766
|
+
type: "function"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
inputs: [
|
|
770
|
+
{ internalType: "contract ERC20", name: "depositAsset", type: "address" },
|
|
771
|
+
{ internalType: "bool", name: "enabled", type: "bool" }
|
|
772
|
+
],
|
|
773
|
+
name: "updateKytStatus",
|
|
774
|
+
outputs: [],
|
|
775
|
+
stateMutability: "nonpayable",
|
|
776
|
+
type: "function"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
inputs: [
|
|
780
|
+
{ internalType: "uint256", name: "newSupplyCapInBase", type: "uint256" }
|
|
781
|
+
],
|
|
782
|
+
name: "updateSupplyCapInBase",
|
|
783
|
+
outputs: [],
|
|
784
|
+
stateMutability: "nonpayable",
|
|
785
|
+
type: "function"
|
|
420
786
|
}
|
|
421
787
|
];
|
|
422
|
-
|
|
423
|
-
// src/vaults/deposit/utils.ts
|
|
424
788
|
var calculateMinimumMint = (depositAmount, rate, vaultTokenDecimals, slippage) => {
|
|
425
|
-
const slippageValue = slippage ??
|
|
426
|
-
const slippageAsBigInt = BigInt(slippageValue) *
|
|
427
|
-
const minimumMint = depositAmount *
|
|
428
|
-
const slippageAmount = minimumMint * slippageAsBigInt /
|
|
789
|
+
const slippageValue = slippage ?? chunkGOJQYEJQ_js.DEFAULT_SLIPPAGE_BPS;
|
|
790
|
+
const slippageAsBigInt = BigInt(slippageValue) * chunkTNL23CO2_js.WAD.bigint / BigInt(1e4);
|
|
791
|
+
const minimumMint = depositAmount * chunkTNL23CO2_js.WAD.bigint / rate;
|
|
792
|
+
const slippageAmount = minimumMint * slippageAsBigInt / chunkTNL23CO2_js.WAD.bigint;
|
|
429
793
|
if (vaultTokenDecimals > 18) {
|
|
430
794
|
return (minimumMint - slippageAmount) * BigInt(10) ** (BigInt(vaultTokenDecimals) - BigInt(18));
|
|
431
795
|
}
|
|
432
796
|
return (minimumMint - slippageAmount) / BigInt(10) ** (BigInt(18) - BigInt(vaultTokenDecimals));
|
|
433
797
|
};
|
|
798
|
+
async function getDepositFeeForAmount(depositFeeModuleAddress, depositAsset, depositAmount, chainId) {
|
|
799
|
+
if (!depositFeeModuleAddress || depositFeeModuleAddress === viem.zeroAddress) {
|
|
800
|
+
return 0n;
|
|
801
|
+
}
|
|
802
|
+
const { feePercentage, flatFee, oneHundredPercent } = await chunkGOJQYEJQ_js.readDepositFeeStructure(
|
|
803
|
+
depositFeeModuleAddress,
|
|
804
|
+
depositAsset,
|
|
805
|
+
chainId
|
|
806
|
+
);
|
|
807
|
+
const variableFee = oneHundredPercent > 0n ? depositAmount * feePercentage / oneHundredPercent : 0n;
|
|
808
|
+
return variableFee + flatFee;
|
|
809
|
+
}
|
|
810
|
+
async function assertDepositWithinCap(vault, depositAmountRaw, depositAssetAddress, chainId, callerEndpoint) {
|
|
811
|
+
let supplyCapInBase = null;
|
|
812
|
+
let hasDepositCap = false;
|
|
813
|
+
if (vault.depositCap) {
|
|
814
|
+
supplyCapInBase = vault.depositCap.supplyCapInBase;
|
|
815
|
+
hasDepositCap = vault.depositCap.hasDepositCap;
|
|
816
|
+
} else if (vault.vault.communityCodeDepositorAddress && vault.vault.depositFeeModuleAddress) {
|
|
817
|
+
const onChainCap = await chunkGOJQYEJQ_js.readSupplyCapInBase(
|
|
818
|
+
vault.vault.communityCodeDepositorAddress,
|
|
819
|
+
chainId
|
|
820
|
+
);
|
|
821
|
+
supplyCapInBase = onChainCap;
|
|
822
|
+
hasDepositCap = onChainCap !== 0n && onChainCap !== viem.maxUint256;
|
|
823
|
+
}
|
|
824
|
+
if (!hasDepositCap || supplyCapInBase == null) return;
|
|
825
|
+
const client = await chunkGOJQYEJQ_js.getClient(chainId);
|
|
826
|
+
const [supplyResult, baseRateResult, quoteRateResult, decResult] = await client.multicall({
|
|
827
|
+
contracts: [
|
|
828
|
+
{
|
|
829
|
+
abi: chunkFHE43NKY_js.BoringVaultAbi,
|
|
830
|
+
address: vault.vault.boringVaultAddress,
|
|
831
|
+
functionName: "totalSupply"
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
abi: chunkFHE43NKY_js.AccountantAbi,
|
|
835
|
+
address: vault.vault.accountantAddress,
|
|
836
|
+
functionName: "getRate"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
abi: chunkFHE43NKY_js.AccountantAbi,
|
|
840
|
+
address: vault.vault.accountantAddress,
|
|
841
|
+
functionName: "getRateInQuote",
|
|
842
|
+
args: [depositAssetAddress]
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
abi: chunkFHE43NKY_js.AccountantAbi,
|
|
846
|
+
address: vault.vault.accountantAddress,
|
|
847
|
+
functionName: "decimals"
|
|
848
|
+
}
|
|
849
|
+
]
|
|
850
|
+
});
|
|
851
|
+
if (supplyResult.status !== "success" || baseRateResult.status !== "success" || quoteRateResult.status !== "success" || decResult.status !== "success") {
|
|
852
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
853
|
+
"Unable to verify deposit against supply cap: on-chain read failed",
|
|
854
|
+
{ endpoint: callerEndpoint }
|
|
855
|
+
);
|
|
856
|
+
}
|
|
857
|
+
const currentValueInBase = supplyResult.result * baseRateResult.result / 10n ** BigInt(decResult.result);
|
|
858
|
+
const depositAmountInBase = quoteRateResult.result > 0n ? depositAmountRaw * baseRateResult.result / quoteRateResult.result : depositAmountRaw;
|
|
859
|
+
const remaining = supplyCapInBase > currentValueInBase ? supplyCapInBase - currentValueInBase : 0n;
|
|
860
|
+
if (depositAmountInBase > remaining) {
|
|
861
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
862
|
+
`Deposit would exceed vault supply cap. Remaining capacity: ${remaining}, deposit amount (in base): ${depositAmountInBase}`,
|
|
863
|
+
{ endpoint: callerEndpoint }
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
434
867
|
|
|
435
868
|
// src/vaults/deposit/deposit.ts
|
|
869
|
+
var DepositType = {
|
|
870
|
+
STANDARD: "standard",
|
|
871
|
+
KYT: "kyt"
|
|
872
|
+
};
|
|
873
|
+
function isKytDeposit(data) {
|
|
874
|
+
return data.depositType === DepositType.KYT;
|
|
875
|
+
}
|
|
876
|
+
function isStandardDeposit(data) {
|
|
877
|
+
return data.depositType === DepositType.STANDARD;
|
|
878
|
+
}
|
|
436
879
|
async function prepareDepositTxData(params) {
|
|
437
880
|
const {
|
|
438
881
|
vaultName,
|
|
439
882
|
depositAsset,
|
|
440
883
|
depositAmount,
|
|
441
884
|
chainId,
|
|
442
|
-
slippage =
|
|
885
|
+
slippage = chunkGOJQYEJQ_js.DEFAULT_SLIPPAGE_BPS,
|
|
443
886
|
to,
|
|
444
887
|
distributorCode
|
|
445
888
|
} = params;
|
|
446
889
|
try {
|
|
447
|
-
const normalizedChainId =
|
|
448
|
-
const vault = await
|
|
890
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
891
|
+
const vault = await chunk6JLKHV6O_js.resolveVault({
|
|
449
892
|
vaultName,
|
|
450
893
|
assetAddress: depositAsset,
|
|
451
894
|
chainId: normalizedChainId,
|
|
452
895
|
callerEndpoint: "prepareDepositTransactionData"
|
|
453
896
|
});
|
|
454
|
-
|
|
897
|
+
if (vault.inDeprecation) {
|
|
898
|
+
chunkGOJQYEJQ_js.getLogger().warn(
|
|
899
|
+
`Vault "${vault.name}" is being deprecated. Please contact the Paxos Labs team for migration guidance.`
|
|
900
|
+
);
|
|
901
|
+
}
|
|
902
|
+
const assets = await chunkGOJQYEJQ_js.getSupportedAssets({ address: depositAsset });
|
|
455
903
|
const asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets.find((a) => a.address.toLowerCase() === depositAsset.toLowerCase());
|
|
456
904
|
if (!asset) {
|
|
457
|
-
throw new
|
|
905
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
458
906
|
`Asset metadata not found for token ${depositAsset} on chain ${normalizedChainId}`,
|
|
459
907
|
{
|
|
460
908
|
endpoint: "prepareDepositTransactionData"
|
|
@@ -463,26 +911,26 @@ async function prepareDepositTxData(params) {
|
|
|
463
911
|
}
|
|
464
912
|
const communityCodeDepositorAddress = vault.vault.communityCodeDepositorAddress;
|
|
465
913
|
if (!communityCodeDepositorAddress) {
|
|
466
|
-
throw new
|
|
914
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
467
915
|
`Community Code Depositor contract address not found for vault ${vault.id}`,
|
|
468
916
|
{ endpoint: "prepareDepositTransactionData" }
|
|
469
917
|
);
|
|
470
918
|
}
|
|
471
919
|
const accountantAddress = vault.vault.accountantAddress;
|
|
472
920
|
if (!accountantAddress) {
|
|
473
|
-
throw new
|
|
921
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
474
922
|
`Accountant contract address not found for vault ${vault.id}`,
|
|
475
923
|
{ endpoint: "prepareDepositTransactionData" }
|
|
476
924
|
);
|
|
477
925
|
}
|
|
478
926
|
const depositAssetAddress = asset.address;
|
|
479
|
-
const [depositAssetDecimalsResult, rateInQuoteResult] = await
|
|
927
|
+
const [depositAssetDecimalsResult, rateInQuoteResult] = await chunkFHE43NKY_js.getRateInQuoteWithAssetDecimals({
|
|
480
928
|
assetAddress: depositAssetAddress,
|
|
481
929
|
accountantAddress,
|
|
482
930
|
chainId: normalizedChainId
|
|
483
931
|
});
|
|
484
932
|
if (depositAssetDecimalsResult.status === "failure") {
|
|
485
|
-
throw new
|
|
933
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
486
934
|
`Failed to get asset decimals: ${depositAssetDecimalsResult.error?.message || "Unknown error"}`,
|
|
487
935
|
{
|
|
488
936
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -491,7 +939,7 @@ async function prepareDepositTxData(params) {
|
|
|
491
939
|
);
|
|
492
940
|
}
|
|
493
941
|
if (rateInQuoteResult.status === "failure") {
|
|
494
|
-
throw new
|
|
942
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
495
943
|
`Failed to get exchange rate: ${rateInQuoteResult.error?.message || "Unknown error"}`,
|
|
496
944
|
{
|
|
497
945
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -503,36 +951,98 @@ async function prepareDepositTxData(params) {
|
|
|
503
951
|
depositAmount,
|
|
504
952
|
depositAssetDecimalsResult.result
|
|
505
953
|
);
|
|
506
|
-
const
|
|
954
|
+
const totalFee = await getDepositFeeForAmount(
|
|
955
|
+
vault.vault.depositFeeModuleAddress,
|
|
956
|
+
depositAssetAddress,
|
|
507
957
|
depositAmountAsBigInt,
|
|
958
|
+
normalizedChainId
|
|
959
|
+
);
|
|
960
|
+
if (totalFee >= depositAmountAsBigInt) {
|
|
961
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
962
|
+
"Deposit amount is entirely consumed by fees. Increase the deposit amount.",
|
|
963
|
+
{ endpoint: "prepareDepositTransactionData" }
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
const depositAmountAfterFees = depositAmountAsBigInt - totalFee;
|
|
967
|
+
await assertDepositWithinCap(
|
|
968
|
+
vault,
|
|
969
|
+
depositAmountAfterFees,
|
|
970
|
+
depositAssetAddress,
|
|
971
|
+
normalizedChainId,
|
|
972
|
+
"prepareDepositTransactionData"
|
|
973
|
+
);
|
|
974
|
+
const minimumMint = calculateMinimumMint(
|
|
975
|
+
depositAmountAfterFees,
|
|
508
976
|
rateInQuoteResult.result,
|
|
509
977
|
depositAssetDecimalsResult.result,
|
|
510
978
|
slippage
|
|
511
979
|
);
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
980
|
+
const distributorCodeHex = viem.stringToHex(distributorCode || "");
|
|
981
|
+
const policyId = vault.enterpriseConfig?.predicatePolicyId;
|
|
982
|
+
if (policyId === void 0) {
|
|
983
|
+
return {
|
|
984
|
+
depositType: DepositType.STANDARD,
|
|
985
|
+
abi: chunkGOJQYEJQ_js.DistributorCodeDepositorAbiV0,
|
|
986
|
+
address: communityCodeDepositorAddress,
|
|
987
|
+
functionName: "deposit",
|
|
988
|
+
args: [
|
|
989
|
+
depositAssetAddress,
|
|
990
|
+
depositAmountAsBigInt,
|
|
991
|
+
minimumMint,
|
|
992
|
+
to,
|
|
993
|
+
distributorCodeHex
|
|
994
|
+
],
|
|
995
|
+
chainId: normalizedChainId
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
if (policyId === null) {
|
|
999
|
+
const emptyAttestation = {
|
|
1000
|
+
uuid: "",
|
|
1001
|
+
expiration: 0n,
|
|
1002
|
+
attester: viem.zeroAddress,
|
|
1003
|
+
signature: "0x"
|
|
1004
|
+
};
|
|
1005
|
+
return {
|
|
1006
|
+
depositType: DepositType.KYT,
|
|
1007
|
+
address: communityCodeDepositorAddress,
|
|
1008
|
+
abi: DistributorCodeDepositorAbiV1,
|
|
1009
|
+
functionName: "deposit",
|
|
1010
|
+
args: [
|
|
1011
|
+
depositAssetAddress,
|
|
1012
|
+
depositAmountAsBigInt,
|
|
1013
|
+
minimumMint,
|
|
1014
|
+
to,
|
|
1015
|
+
distributorCodeHex,
|
|
1016
|
+
emptyAttestation
|
|
1017
|
+
],
|
|
1018
|
+
chainId: normalizedChainId
|
|
1019
|
+
};
|
|
517
1020
|
}
|
|
1021
|
+
const attestation = await fetchKytAttestation({
|
|
1022
|
+
to: communityCodeDepositorAddress,
|
|
1023
|
+
from: to,
|
|
1024
|
+
chainId: normalizedChainId
|
|
1025
|
+
});
|
|
518
1026
|
return {
|
|
519
|
-
|
|
1027
|
+
depositType: DepositType.KYT,
|
|
520
1028
|
address: communityCodeDepositorAddress,
|
|
1029
|
+
abi: DistributorCodeDepositorAbiV1,
|
|
521
1030
|
functionName: "deposit",
|
|
522
1031
|
args: [
|
|
523
1032
|
depositAssetAddress,
|
|
524
1033
|
depositAmountAsBigInt,
|
|
525
1034
|
minimumMint,
|
|
526
1035
|
to,
|
|
527
|
-
|
|
1036
|
+
distributorCodeHex,
|
|
1037
|
+
attestation
|
|
528
1038
|
],
|
|
529
1039
|
chainId: normalizedChainId
|
|
530
1040
|
};
|
|
531
1041
|
} catch (error) {
|
|
532
|
-
if (error instanceof
|
|
1042
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
533
1043
|
throw error;
|
|
534
1044
|
}
|
|
535
|
-
throw new
|
|
1045
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
536
1046
|
`Failed to prepare deposit transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
537
1047
|
{
|
|
538
1048
|
endpoint: "prepareDepositTransactionData",
|
|
@@ -588,8 +1098,8 @@ async function prepareDepositPermitSignature(params) {
|
|
|
588
1098
|
tokenVersion: prefetchedTokenVersion
|
|
589
1099
|
} = params;
|
|
590
1100
|
try {
|
|
591
|
-
const normalizedChainId =
|
|
592
|
-
const vault = await
|
|
1101
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1102
|
+
const vault = await chunk6JLKHV6O_js.resolveVault({
|
|
593
1103
|
vaultName,
|
|
594
1104
|
assetAddress: depositAsset,
|
|
595
1105
|
chainId: normalizedChainId,
|
|
@@ -597,7 +1107,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
597
1107
|
});
|
|
598
1108
|
const communityCodeDepositorAddress = vault.vault.communityCodeDepositorAddress;
|
|
599
1109
|
if (!communityCodeDepositorAddress) {
|
|
600
|
-
throw new
|
|
1110
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
601
1111
|
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
602
1112
|
{ endpoint: "prepareDepositPermitSignature" }
|
|
603
1113
|
);
|
|
@@ -611,24 +1121,24 @@ async function prepareDepositPermitSignature(params) {
|
|
|
611
1121
|
resolvedTokenVersion = prefetchedTokenVersion;
|
|
612
1122
|
resolvedNonce = prefetchedNonce;
|
|
613
1123
|
} else {
|
|
614
|
-
const client = await
|
|
1124
|
+
const client = await chunkGOJQYEJQ_js.getClient(normalizedChainId);
|
|
615
1125
|
try {
|
|
616
1126
|
const [nameResult, versionResult, nonceResult] = await client.multicall(
|
|
617
1127
|
{
|
|
618
1128
|
contracts: [
|
|
619
1129
|
{
|
|
620
1130
|
address: depositAsset,
|
|
621
|
-
abi:
|
|
1131
|
+
abi: chunkFHE43NKY_js.erc2612Abi,
|
|
622
1132
|
functionName: "name"
|
|
623
1133
|
},
|
|
624
1134
|
{
|
|
625
1135
|
address: depositAsset,
|
|
626
|
-
abi:
|
|
1136
|
+
abi: chunkFHE43NKY_js.erc2612Abi,
|
|
627
1137
|
functionName: "version"
|
|
628
1138
|
},
|
|
629
1139
|
{
|
|
630
1140
|
address: depositAsset,
|
|
631
|
-
abi:
|
|
1141
|
+
abi: chunkFHE43NKY_js.erc2612Abi,
|
|
632
1142
|
functionName: "nonces",
|
|
633
1143
|
args: [to]
|
|
634
1144
|
}
|
|
@@ -640,7 +1150,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
640
1150
|
} else if (nameResult.status === "success") {
|
|
641
1151
|
resolvedTokenName = nameResult.result;
|
|
642
1152
|
} else {
|
|
643
|
-
throw new
|
|
1153
|
+
throw new chunkGOJQYEJQ_js.APIError(`Failed to read token name from ${depositAsset}`, {
|
|
644
1154
|
endpoint: "prepareDepositPermitSignature",
|
|
645
1155
|
cause: nameResult.error
|
|
646
1156
|
});
|
|
@@ -657,7 +1167,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
657
1167
|
} else if (nonceResult.status === "success") {
|
|
658
1168
|
resolvedNonce = nonceResult.result;
|
|
659
1169
|
} else {
|
|
660
|
-
throw new
|
|
1170
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
661
1171
|
`Token ${depositAsset} does not support EIP-2612 permit. Missing required function: nonces()`,
|
|
662
1172
|
{
|
|
663
1173
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -666,10 +1176,10 @@ async function prepareDepositPermitSignature(params) {
|
|
|
666
1176
|
);
|
|
667
1177
|
}
|
|
668
1178
|
} catch (error) {
|
|
669
|
-
if (error instanceof
|
|
1179
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
670
1180
|
throw error;
|
|
671
1181
|
}
|
|
672
|
-
throw new
|
|
1182
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
673
1183
|
`Failed to read token metadata: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
674
1184
|
{
|
|
675
1185
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -683,7 +1193,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
683
1193
|
if (prefetchedDecimals !== void 0) {
|
|
684
1194
|
resolvedDecimals = prefetchedDecimals;
|
|
685
1195
|
} else {
|
|
686
|
-
resolvedDecimals = await
|
|
1196
|
+
resolvedDecimals = await chunkFHE43NKY_js.getErc20Decimals({
|
|
687
1197
|
tokenAddress: depositAsset,
|
|
688
1198
|
chainId: normalizedChainId
|
|
689
1199
|
});
|
|
@@ -710,10 +1220,10 @@ async function prepareDepositPermitSignature(params) {
|
|
|
710
1220
|
message
|
|
711
1221
|
};
|
|
712
1222
|
} catch (error) {
|
|
713
|
-
if (error instanceof
|
|
1223
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
714
1224
|
throw error;
|
|
715
1225
|
}
|
|
716
|
-
throw new
|
|
1226
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
717
1227
|
`Failed to prepare permit signature: ${error instanceof Error ? error.message : String(error)}`,
|
|
718
1228
|
{
|
|
719
1229
|
endpoint: "prepareDepositPermitSignature",
|
|
@@ -739,7 +1249,7 @@ function parsePermitSignature(signature) {
|
|
|
739
1249
|
s: parsed.s
|
|
740
1250
|
};
|
|
741
1251
|
} catch (error) {
|
|
742
|
-
throw new
|
|
1252
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
743
1253
|
`Invalid permit signature format. Expected hex string but received: ${signature}. ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
744
1254
|
{
|
|
745
1255
|
endpoint: "parsePermitSignature",
|
|
@@ -756,34 +1266,39 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
756
1266
|
chainId,
|
|
757
1267
|
signature,
|
|
758
1268
|
deadline,
|
|
759
|
-
slippage =
|
|
1269
|
+
slippage = chunkGOJQYEJQ_js.DEFAULT_SLIPPAGE_BPS,
|
|
760
1270
|
to,
|
|
761
1271
|
distributorCode
|
|
762
1272
|
} = params;
|
|
763
1273
|
try {
|
|
764
1274
|
const { v, r, s } = parsePermitSignature(signature);
|
|
765
1275
|
if (slippage < 0 || slippage > 1e4) {
|
|
766
|
-
throw new
|
|
1276
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
767
1277
|
`Invalid slippage value: ${slippage}. Slippage must be between 0 and 10000 basis points.`,
|
|
768
1278
|
{
|
|
769
1279
|
endpoint: "prepareDepositWithPermitTxData"
|
|
770
1280
|
}
|
|
771
1281
|
);
|
|
772
1282
|
}
|
|
773
|
-
const normalizedChainId =
|
|
774
|
-
const vault = await
|
|
1283
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1284
|
+
const vault = await chunk6JLKHV6O_js.resolveVault({
|
|
775
1285
|
vaultName,
|
|
776
1286
|
assetAddress: depositAsset,
|
|
777
1287
|
chainId: normalizedChainId,
|
|
778
1288
|
callerEndpoint: "prepareDepositWithPermitTxData"
|
|
779
1289
|
});
|
|
1290
|
+
if (vault.inDeprecation) {
|
|
1291
|
+
chunkGOJQYEJQ_js.getLogger().warn(
|
|
1292
|
+
`Vault "${vault.name}" is being deprecated. Please contact the Paxos Labs team for migration guidance.`
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
780
1295
|
let asset = null;
|
|
781
|
-
const assets = await
|
|
1296
|
+
const assets = await chunkGOJQYEJQ_js.getSupportedAssets({ address: depositAsset });
|
|
782
1297
|
if (assets.length > 0) {
|
|
783
1298
|
asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets[0] || null;
|
|
784
1299
|
}
|
|
785
1300
|
if (!asset) {
|
|
786
|
-
throw new
|
|
1301
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
787
1302
|
`Asset metadata not found for token ${depositAsset} on chain ${normalizedChainId}`,
|
|
788
1303
|
{
|
|
789
1304
|
endpoint: "prepareDepositWithPermitTxData"
|
|
@@ -791,7 +1306,7 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
791
1306
|
);
|
|
792
1307
|
}
|
|
793
1308
|
if (!asset.chains || !asset.chains.includes(normalizedChainId)) {
|
|
794
|
-
throw new
|
|
1309
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
795
1310
|
`Token ${asset.symbol || depositAsset} not supported on chain ${normalizedChainId}`,
|
|
796
1311
|
{
|
|
797
1312
|
endpoint: "prepareDepositWithPermitTxData"
|
|
@@ -802,25 +1317,25 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
802
1317
|
const accountantAddress = vault.vault.accountantAddress;
|
|
803
1318
|
const depositAssetAddress = depositAsset;
|
|
804
1319
|
if (!communityCodeDepositorAddress) {
|
|
805
|
-
throw new
|
|
1320
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
806
1321
|
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
807
1322
|
{ endpoint: "prepareDepositWithPermitTxData" }
|
|
808
1323
|
);
|
|
809
1324
|
}
|
|
810
1325
|
if (!accountantAddress) {
|
|
811
|
-
throw new
|
|
1326
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
812
1327
|
`Accountant contract address not found for vault ${vault.id}`,
|
|
813
1328
|
{ endpoint: "prepareDepositWithPermitTxData" }
|
|
814
1329
|
);
|
|
815
1330
|
}
|
|
816
|
-
const rateAndDecimalResults = await
|
|
1331
|
+
const rateAndDecimalResults = await chunkFHE43NKY_js.getRateInQuoteWithAssetDecimals({
|
|
817
1332
|
assetAddress: depositAssetAddress,
|
|
818
1333
|
accountantAddress,
|
|
819
1334
|
chainId: normalizedChainId
|
|
820
1335
|
});
|
|
821
1336
|
const [depositAssetDecimalsResult, rateInQuoteResult] = rateAndDecimalResults;
|
|
822
1337
|
if (depositAssetDecimalsResult.status === "failure") {
|
|
823
|
-
throw new
|
|
1338
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
824
1339
|
`Failed to get asset decimals: ${depositAssetDecimalsResult.error?.message || "Unknown error"}`,
|
|
825
1340
|
{
|
|
826
1341
|
endpoint: "prepareDepositWithPermitTxData",
|
|
@@ -829,7 +1344,7 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
829
1344
|
);
|
|
830
1345
|
}
|
|
831
1346
|
if (rateInQuoteResult.status === "failure") {
|
|
832
|
-
throw new
|
|
1347
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
833
1348
|
`Failed to get exchange rate: ${rateInQuoteResult.error?.message || "Unknown error"}`,
|
|
834
1349
|
{
|
|
835
1350
|
endpoint: "prepareDepositWithPermitTxData",
|
|
@@ -838,40 +1353,111 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
838
1353
|
);
|
|
839
1354
|
}
|
|
840
1355
|
const onChainDecimals = depositAssetDecimalsResult.result;
|
|
841
|
-
const depositAmountAsBigInt = viem.parseUnits(
|
|
842
|
-
|
|
843
|
-
|
|
1356
|
+
const depositAmountAsBigInt = viem.parseUnits(depositAmount, onChainDecimals);
|
|
1357
|
+
const totalFee = await getDepositFeeForAmount(
|
|
1358
|
+
vault.vault.depositFeeModuleAddress,
|
|
1359
|
+
depositAssetAddress,
|
|
1360
|
+
depositAmountAsBigInt,
|
|
1361
|
+
normalizedChainId
|
|
1362
|
+
);
|
|
1363
|
+
if (totalFee >= depositAmountAsBigInt) {
|
|
1364
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1365
|
+
"Deposit amount is entirely consumed by fees. Increase the deposit amount.",
|
|
1366
|
+
{ endpoint: "prepareDepositWithPermitTxData" }
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
const depositAmountAfterFees = depositAmountAsBigInt - totalFee;
|
|
1370
|
+
await assertDepositWithinCap(
|
|
1371
|
+
vault,
|
|
1372
|
+
depositAmountAfterFees,
|
|
1373
|
+
depositAssetAddress,
|
|
1374
|
+
normalizedChainId,
|
|
1375
|
+
"prepareDepositWithPermitTxData"
|
|
844
1376
|
);
|
|
845
1377
|
const minimumMint = calculateMinimumMint(
|
|
846
|
-
|
|
1378
|
+
depositAmountAfterFees,
|
|
847
1379
|
rateInQuoteResult.result,
|
|
848
1380
|
onChainDecimals,
|
|
849
1381
|
slippage
|
|
850
1382
|
);
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1383
|
+
const distributorCodeHex = viem.stringToHex(distributorCode || "");
|
|
1384
|
+
const policyId = vault.enterpriseConfig?.predicatePolicyId;
|
|
1385
|
+
if (policyId === void 0) {
|
|
1386
|
+
return {
|
|
1387
|
+
depositType: DepositType.STANDARD,
|
|
1388
|
+
abi: chunkGOJQYEJQ_js.DistributorCodeDepositorAbiV0,
|
|
1389
|
+
address: communityCodeDepositorAddress,
|
|
854
1390
|
functionName: "depositWithPermit",
|
|
855
1391
|
args: [
|
|
856
1392
|
depositAssetAddress,
|
|
857
1393
|
depositAmountAsBigInt,
|
|
858
1394
|
minimumMint,
|
|
859
1395
|
to,
|
|
860
|
-
|
|
1396
|
+
distributorCodeHex,
|
|
861
1397
|
deadline,
|
|
862
1398
|
v,
|
|
863
1399
|
r,
|
|
864
1400
|
s
|
|
865
|
-
]
|
|
866
|
-
|
|
1401
|
+
],
|
|
1402
|
+
chainId: normalizedChainId
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
if (policyId === null) {
|
|
1406
|
+
const emptyAttestation = {
|
|
1407
|
+
uuid: "",
|
|
1408
|
+
expiration: 0n,
|
|
1409
|
+
attester: viem.zeroAddress,
|
|
1410
|
+
signature: "0x"
|
|
1411
|
+
};
|
|
1412
|
+
return {
|
|
1413
|
+
depositType: DepositType.KYT,
|
|
1414
|
+
abi: DistributorCodeDepositorAbiV1,
|
|
1415
|
+
address: communityCodeDepositorAddress,
|
|
1416
|
+
functionName: "depositWithPermit",
|
|
1417
|
+
args: [
|
|
1418
|
+
depositAssetAddress,
|
|
1419
|
+
depositAmountAsBigInt,
|
|
1420
|
+
minimumMint,
|
|
1421
|
+
to,
|
|
1422
|
+
distributorCodeHex,
|
|
1423
|
+
emptyAttestation,
|
|
1424
|
+
deadline,
|
|
1425
|
+
v,
|
|
1426
|
+
r,
|
|
1427
|
+
s
|
|
1428
|
+
],
|
|
1429
|
+
chainId: normalizedChainId
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
const attestation = await fetchKytAttestation({
|
|
1433
|
+
to: communityCodeDepositorAddress,
|
|
1434
|
+
from: to,
|
|
1435
|
+
chainId: normalizedChainId
|
|
1436
|
+
});
|
|
1437
|
+
return {
|
|
1438
|
+
depositType: DepositType.KYT,
|
|
1439
|
+
abi: DistributorCodeDepositorAbiV1,
|
|
867
1440
|
address: communityCodeDepositorAddress,
|
|
1441
|
+
functionName: "depositWithPermit",
|
|
1442
|
+
args: [
|
|
1443
|
+
depositAssetAddress,
|
|
1444
|
+
depositAmountAsBigInt,
|
|
1445
|
+
minimumMint,
|
|
1446
|
+
to,
|
|
1447
|
+
distributorCodeHex,
|
|
1448
|
+
attestation,
|
|
1449
|
+
deadline,
|
|
1450
|
+
v,
|
|
1451
|
+
r,
|
|
1452
|
+
s
|
|
1453
|
+
],
|
|
868
1454
|
chainId: normalizedChainId
|
|
869
1455
|
};
|
|
870
1456
|
} catch (error) {
|
|
871
|
-
if (error instanceof
|
|
1457
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
872
1458
|
throw error;
|
|
873
1459
|
}
|
|
874
|
-
throw new
|
|
1460
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
875
1461
|
`Failed to prepare deposit with permit transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
876
1462
|
{
|
|
877
1463
|
endpoint: "prepareDepositWithPermitTxData",
|
|
@@ -883,7 +1469,7 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
883
1469
|
|
|
884
1470
|
// src/utils/wallet.ts
|
|
885
1471
|
async function isSmartContractWallet(address, chainId) {
|
|
886
|
-
const client = await
|
|
1472
|
+
const client = await chunkGOJQYEJQ_js.getClient(chainId);
|
|
887
1473
|
const code = await client.getCode({ address });
|
|
888
1474
|
return !!code && code !== "0x";
|
|
889
1475
|
}
|
|
@@ -914,8 +1500,8 @@ async function prepareDepositAuthorization(params) {
|
|
|
914
1500
|
forceMethod
|
|
915
1501
|
} = params;
|
|
916
1502
|
try {
|
|
917
|
-
const normalizedChainId =
|
|
918
|
-
const vault = await
|
|
1503
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1504
|
+
const vault = await chunk6JLKHV6O_js.resolveVault({
|
|
919
1505
|
vaultName,
|
|
920
1506
|
assetAddress: depositAsset,
|
|
921
1507
|
chainId: normalizedChainId,
|
|
@@ -957,10 +1543,7 @@ async function prepareDepositAuthorization(params) {
|
|
|
957
1543
|
permitData
|
|
958
1544
|
};
|
|
959
1545
|
}
|
|
960
|
-
const smartWallet = await isSmartContractWallet(
|
|
961
|
-
to,
|
|
962
|
-
normalizedChainId
|
|
963
|
-
);
|
|
1546
|
+
const smartWallet = await isSmartContractWallet(to, normalizedChainId);
|
|
964
1547
|
if (smartWallet) {
|
|
965
1548
|
const txData2 = await prepareApproveDepositTokenTxData({
|
|
966
1549
|
vaultName,
|
|
@@ -1017,10 +1600,10 @@ async function prepareDepositAuthorization(params) {
|
|
|
1017
1600
|
txData
|
|
1018
1601
|
};
|
|
1019
1602
|
} catch (error) {
|
|
1020
|
-
if (error instanceof
|
|
1603
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
1021
1604
|
throw error;
|
|
1022
1605
|
}
|
|
1023
|
-
throw new
|
|
1606
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1024
1607
|
`Failed to prepare deposit authorization: ${error instanceof Error ? error.message : String(error)}`,
|
|
1025
1608
|
{
|
|
1026
1609
|
endpoint: "prepareDepositAuthorization",
|
|
@@ -1044,7 +1627,7 @@ async function prepareDeposit(params) {
|
|
|
1044
1627
|
} = params;
|
|
1045
1628
|
try {
|
|
1046
1629
|
if (forceMethod === "permit" && (!signature || deadline === void 0)) {
|
|
1047
|
-
throw new
|
|
1630
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1048
1631
|
"Permit deposit requires both signature and deadline parameters when forceMethod is 'permit'",
|
|
1049
1632
|
{ endpoint: "prepareDeposit" }
|
|
1050
1633
|
);
|
|
@@ -1052,7 +1635,7 @@ async function prepareDeposit(params) {
|
|
|
1052
1635
|
const usePermit = forceMethod === "permit" || forceMethod !== "approval" && signature !== void 0 && deadline !== void 0;
|
|
1053
1636
|
if (usePermit) {
|
|
1054
1637
|
if (!signature || deadline === void 0) {
|
|
1055
|
-
throw new
|
|
1638
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1056
1639
|
"Permit deposit requires both signature and deadline parameters",
|
|
1057
1640
|
{ endpoint: "prepareDeposit" }
|
|
1058
1641
|
);
|
|
@@ -1087,10 +1670,10 @@ async function prepareDeposit(params) {
|
|
|
1087
1670
|
txData
|
|
1088
1671
|
};
|
|
1089
1672
|
} catch (error) {
|
|
1090
|
-
if (error instanceof
|
|
1673
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
1091
1674
|
throw error;
|
|
1092
1675
|
}
|
|
1093
|
-
throw new
|
|
1676
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1094
1677
|
`Failed to prepare deposit: ${error instanceof Error ? error.message : String(error)}`,
|
|
1095
1678
|
{
|
|
1096
1679
|
endpoint: "prepareDeposit",
|
|
@@ -1107,43 +1690,43 @@ async function prepareApproveWithdrawOrderTxData({
|
|
|
1107
1690
|
shareDecimals
|
|
1108
1691
|
}) {
|
|
1109
1692
|
try {
|
|
1110
|
-
const normalizedChainId =
|
|
1111
|
-
const config = await
|
|
1693
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1694
|
+
const config = await chunk6JLKHV6O_js.resolveVault({
|
|
1112
1695
|
vaultName,
|
|
1113
1696
|
assetAddress: wantAssetAddress,
|
|
1114
1697
|
chainId: normalizedChainId,
|
|
1115
1698
|
callerEndpoint: "prepareApproveWithdrawOrderTxData"
|
|
1116
1699
|
});
|
|
1117
1700
|
if (!config.vault.boringVaultAddress) {
|
|
1118
|
-
throw new
|
|
1701
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1119
1702
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
1120
1703
|
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1121
1704
|
);
|
|
1122
1705
|
}
|
|
1123
1706
|
if (!config.vault.withdrawQueueAddress) {
|
|
1124
|
-
throw new
|
|
1707
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1125
1708
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1126
1709
|
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1127
1710
|
);
|
|
1128
1711
|
}
|
|
1129
1712
|
const boringVaultAddress = config.vault.boringVaultAddress;
|
|
1130
1713
|
const withdrawQueueAddress = config.vault.withdrawQueueAddress;
|
|
1131
|
-
const decimals = shareDecimals ?? await
|
|
1714
|
+
const decimals = shareDecimals ?? await chunkFHE43NKY_js.getErc20Decimals({
|
|
1132
1715
|
tokenAddress: boringVaultAddress,
|
|
1133
1716
|
chainId: normalizedChainId
|
|
1134
1717
|
});
|
|
1135
|
-
const withdrawAmountAsBigInt = withdrawAmount ? viem.parseUnits(withdrawAmount, decimals) :
|
|
1718
|
+
const withdrawAmountAsBigInt = withdrawAmount ? viem.parseUnits(withdrawAmount, decimals) : chunkGOJQYEJQ_js.DEFAULT_APPROVAL_AMOUNT;
|
|
1136
1719
|
return {
|
|
1137
|
-
abi:
|
|
1720
|
+
abi: chunkFHE43NKY_js.BoringVaultAbi,
|
|
1138
1721
|
address: boringVaultAddress,
|
|
1139
1722
|
functionName: "approve",
|
|
1140
1723
|
args: [withdrawQueueAddress, withdrawAmountAsBigInt]
|
|
1141
1724
|
};
|
|
1142
1725
|
} catch (error) {
|
|
1143
|
-
if (error instanceof
|
|
1726
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
1144
1727
|
throw error;
|
|
1145
1728
|
}
|
|
1146
|
-
throw new
|
|
1729
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1147
1730
|
`Failed to prepare approval transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1148
1731
|
{
|
|
1149
1732
|
endpoint: "prepareApproveWithdrawOrderTxData",
|
|
@@ -1161,37 +1744,37 @@ var prepareCancelWithdrawOrderTxData = async ({
|
|
|
1161
1744
|
orderIndex
|
|
1162
1745
|
}) => {
|
|
1163
1746
|
try {
|
|
1164
|
-
const normalizedChainId =
|
|
1165
|
-
const config = await
|
|
1747
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1748
|
+
const config = await chunk6JLKHV6O_js.resolveVault({
|
|
1166
1749
|
vaultName,
|
|
1167
1750
|
assetAddress: wantAsset,
|
|
1168
1751
|
chainId: normalizedChainId,
|
|
1169
1752
|
callerEndpoint: "prepareCancelWithdrawOrderTxData"
|
|
1170
1753
|
});
|
|
1171
1754
|
if (config.chainId !== normalizedChainId) {
|
|
1172
|
-
throw new
|
|
1755
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1173
1756
|
`Vault chain mismatch: vault is on chain ${config.chainId}, requested chain ${normalizedChainId}`,
|
|
1174
1757
|
{ endpoint: "prepareCancelWithdrawOrderTxData" }
|
|
1175
1758
|
);
|
|
1176
1759
|
}
|
|
1177
1760
|
if (!config.vault.withdrawQueueAddress) {
|
|
1178
|
-
throw new
|
|
1761
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1179
1762
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1180
1763
|
{ endpoint: "prepareCancelWithdrawOrderTxData" }
|
|
1181
1764
|
);
|
|
1182
1765
|
}
|
|
1183
1766
|
return {
|
|
1184
|
-
abi:
|
|
1767
|
+
abi: chunkGOJQYEJQ_js.WithdrawQueueAbi,
|
|
1185
1768
|
address: config.vault.withdrawQueueAddress,
|
|
1186
1769
|
functionName: "cancelOrder",
|
|
1187
1770
|
args: [orderIndex],
|
|
1188
1771
|
chainId: normalizedChainId
|
|
1189
1772
|
};
|
|
1190
1773
|
} catch (error) {
|
|
1191
|
-
if (error instanceof
|
|
1774
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
1192
1775
|
throw error;
|
|
1193
1776
|
}
|
|
1194
|
-
throw new
|
|
1777
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1195
1778
|
`Failed to prepare cancel order transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1196
1779
|
{
|
|
1197
1780
|
endpoint: "prepareCancelWithdrawOrderTxData",
|
|
@@ -1220,38 +1803,38 @@ var prepareWithdrawOrderTxData = async ({
|
|
|
1220
1803
|
amountOffer
|
|
1221
1804
|
}) => {
|
|
1222
1805
|
try {
|
|
1223
|
-
const normalizedChainId =
|
|
1224
|
-
const config = await
|
|
1806
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1807
|
+
const config = await chunk6JLKHV6O_js.resolveVault({
|
|
1225
1808
|
vaultName,
|
|
1226
1809
|
assetAddress: wantAsset,
|
|
1227
1810
|
chainId: normalizedChainId,
|
|
1228
1811
|
callerEndpoint: "prepareWithdrawOrderTxData"
|
|
1229
1812
|
});
|
|
1230
1813
|
if (config.chainId !== normalizedChainId) {
|
|
1231
|
-
throw new
|
|
1814
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1232
1815
|
`Vault chain mismatch: vault is on chain ${config.chainId}, requested chain ${normalizedChainId}`,
|
|
1233
1816
|
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1234
1817
|
);
|
|
1235
1818
|
}
|
|
1236
1819
|
if (!config.vault.withdrawQueueAddress) {
|
|
1237
|
-
throw new
|
|
1820
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1238
1821
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1239
1822
|
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1240
1823
|
);
|
|
1241
1824
|
}
|
|
1242
1825
|
if (!config.vault.boringVaultAddress) {
|
|
1243
|
-
throw new
|
|
1826
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1244
1827
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
1245
1828
|
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1246
1829
|
);
|
|
1247
1830
|
}
|
|
1248
|
-
const sharesDecimals = await
|
|
1831
|
+
const sharesDecimals = await chunkFHE43NKY_js.getErc20Decimals({
|
|
1249
1832
|
tokenAddress: config.vault.boringVaultAddress,
|
|
1250
1833
|
chainId: normalizedChainId
|
|
1251
1834
|
});
|
|
1252
1835
|
const formattedAmountOffer = viem.parseUnits(amountOffer, sharesDecimals);
|
|
1253
1836
|
return {
|
|
1254
|
-
abi:
|
|
1837
|
+
abi: chunkGOJQYEJQ_js.WithdrawQueueAbi,
|
|
1255
1838
|
address: config.vault.withdrawQueueAddress,
|
|
1256
1839
|
functionName: "submitOrder",
|
|
1257
1840
|
args: [
|
|
@@ -1267,10 +1850,10 @@ var prepareWithdrawOrderTxData = async ({
|
|
|
1267
1850
|
chainId: normalizedChainId
|
|
1268
1851
|
};
|
|
1269
1852
|
} catch (error) {
|
|
1270
|
-
if (error instanceof
|
|
1853
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
1271
1854
|
throw error;
|
|
1272
1855
|
}
|
|
1273
|
-
throw new
|
|
1856
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1274
1857
|
`Failed to prepare withdraw order transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1275
1858
|
{
|
|
1276
1859
|
endpoint: "prepareWithdrawOrderTxData",
|
|
@@ -1279,6 +1862,79 @@ var prepareWithdrawOrderTxData = async ({
|
|
|
1279
1862
|
);
|
|
1280
1863
|
}
|
|
1281
1864
|
};
|
|
1865
|
+
var prepareAtomicWithdrawOrderTxData = async ({
|
|
1866
|
+
vaultName,
|
|
1867
|
+
wantAsset,
|
|
1868
|
+
userAddress,
|
|
1869
|
+
chainId,
|
|
1870
|
+
amountOffer
|
|
1871
|
+
}) => {
|
|
1872
|
+
try {
|
|
1873
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1874
|
+
const config = await chunk6JLKHV6O_js.resolveVault({
|
|
1875
|
+
vaultName,
|
|
1876
|
+
assetAddress: wantAsset,
|
|
1877
|
+
chainId: normalizedChainId,
|
|
1878
|
+
callerEndpoint: "prepareAtomicWithdrawOrderTxData"
|
|
1879
|
+
});
|
|
1880
|
+
if (config.chainId !== normalizedChainId) {
|
|
1881
|
+
throw new chunk6JLKHV6O_js.InvalidChainIdError(
|
|
1882
|
+
`Vault chain mismatch: vault is on chain ${config.chainId}, requested chain ${normalizedChainId}`,
|
|
1883
|
+
{
|
|
1884
|
+
vaultId: config.id,
|
|
1885
|
+
vaultChainId: config.chainId,
|
|
1886
|
+
requestedChainId: normalizedChainId
|
|
1887
|
+
}
|
|
1888
|
+
);
|
|
1889
|
+
}
|
|
1890
|
+
if (!config.vault.withdrawQueueAddress) {
|
|
1891
|
+
throw new chunk6JLKHV6O_js.TransactionDataError(
|
|
1892
|
+
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1893
|
+
{ vaultId: config.id, field: "withdrawQueueAddress" }
|
|
1894
|
+
);
|
|
1895
|
+
}
|
|
1896
|
+
if (!config.vault.boringVaultAddress) {
|
|
1897
|
+
throw new chunk6JLKHV6O_js.TransactionDataError(
|
|
1898
|
+
`BoringVault contract address not configured for vault ${config.id}`,
|
|
1899
|
+
{ vaultId: config.id, field: "boringVaultAddress" }
|
|
1900
|
+
);
|
|
1901
|
+
}
|
|
1902
|
+
const sharesDecimals = await chunkFHE43NKY_js.getErc20Decimals({
|
|
1903
|
+
tokenAddress: config.vault.boringVaultAddress,
|
|
1904
|
+
chainId: normalizedChainId
|
|
1905
|
+
});
|
|
1906
|
+
const formattedAmountOffer = viem.parseUnits(amountOffer, sharesDecimals);
|
|
1907
|
+
return {
|
|
1908
|
+
abi: chunkGOJQYEJQ_js.WithdrawQueueAbi,
|
|
1909
|
+
address: config.vault.withdrawQueueAddress,
|
|
1910
|
+
functionName: "submitOrderAndProcessAll",
|
|
1911
|
+
args: [
|
|
1912
|
+
{
|
|
1913
|
+
amountOffer: formattedAmountOffer,
|
|
1914
|
+
wantAsset,
|
|
1915
|
+
intendedDepositor: userAddress,
|
|
1916
|
+
receiver: userAddress,
|
|
1917
|
+
refundReceiver: userAddress,
|
|
1918
|
+
signatureParams: EMPTY_SIGNATURE_PARAMS
|
|
1919
|
+
}
|
|
1920
|
+
],
|
|
1921
|
+
chainId: normalizedChainId
|
|
1922
|
+
};
|
|
1923
|
+
} catch (error) {
|
|
1924
|
+
if (error instanceof chunk6JLKHV6O_js.WithdrawError) {
|
|
1925
|
+
throw error;
|
|
1926
|
+
}
|
|
1927
|
+
throw new chunk6JLKHV6O_js.TransactionDataError(
|
|
1928
|
+
`Failed to prepare atomic withdraw order transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1929
|
+
{
|
|
1930
|
+
endpoint: "prepareAtomicWithdrawOrderTxData",
|
|
1931
|
+
cause: error
|
|
1932
|
+
}
|
|
1933
|
+
);
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
|
|
1937
|
+
// src/vaults/withdraw/index.ts
|
|
1282
1938
|
var WithdrawAuthMethod = {
|
|
1283
1939
|
APPROVAL: "approval",
|
|
1284
1940
|
ALREADY_APPROVED: "already_approved"
|
|
@@ -1292,18 +1948,26 @@ function isWithdrawAlreadyApprovedAuth(result) {
|
|
|
1292
1948
|
async function prepareWithdrawal(params) {
|
|
1293
1949
|
const { vaultName, wantAsset, withdrawAmount, userAddress, chainId } = params;
|
|
1294
1950
|
try {
|
|
1295
|
-
|
|
1951
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1952
|
+
const vault = await chunk6JLKHV6O_js.resolveVault({
|
|
1953
|
+
vaultName,
|
|
1954
|
+
assetAddress: wantAsset,
|
|
1955
|
+
chainId: normalizedChainId,
|
|
1956
|
+
callerEndpoint: "prepareWithdrawal"
|
|
1957
|
+
});
|
|
1958
|
+
const builderParams = {
|
|
1296
1959
|
vaultName,
|
|
1297
1960
|
wantAsset,
|
|
1298
1961
|
userAddress,
|
|
1299
1962
|
chainId,
|
|
1300
1963
|
amountOffer: withdrawAmount
|
|
1301
|
-
}
|
|
1964
|
+
};
|
|
1965
|
+
return vault.atomicWithdrawal ? await prepareAtomicWithdrawOrderTxData(builderParams) : await prepareWithdrawOrderTxData(builderParams);
|
|
1302
1966
|
} catch (error) {
|
|
1303
|
-
if (error instanceof
|
|
1967
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
1304
1968
|
throw error;
|
|
1305
1969
|
}
|
|
1306
|
-
throw new
|
|
1970
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1307
1971
|
`Failed to prepare withdrawal: ${error instanceof Error ? error.message : String(error)}`,
|
|
1308
1972
|
{
|
|
1309
1973
|
endpoint: "prepareWithdrawal",
|
|
@@ -1322,8 +1986,8 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1322
1986
|
forceMethod
|
|
1323
1987
|
} = params;
|
|
1324
1988
|
try {
|
|
1325
|
-
const normalizedChainId =
|
|
1326
|
-
const vault = await
|
|
1989
|
+
const normalizedChainId = chunkGOJQYEJQ_js.toChainId(chainId);
|
|
1990
|
+
const vault = await chunk6JLKHV6O_js.resolveVault({
|
|
1327
1991
|
vaultName,
|
|
1328
1992
|
assetAddress: wantAsset,
|
|
1329
1993
|
chainId: normalizedChainId,
|
|
@@ -1366,16 +2030,14 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1366
2030
|
recipientAddress: userAddress
|
|
1367
2031
|
});
|
|
1368
2032
|
if (approvalInfo.error) {
|
|
1369
|
-
throw new
|
|
2033
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1370
2034
|
`Failed to check withdrawal approval: ${approvalInfo.error}`,
|
|
1371
2035
|
{ endpoint: "prepareWithdrawalAuthorization" }
|
|
1372
2036
|
);
|
|
1373
2037
|
}
|
|
1374
2038
|
const decimals = typeof approvalInfo.decimals === "string" ? Number(approvalInfo.decimals) : approvalInfo.decimals;
|
|
1375
2039
|
const withdrawAmountBigInt = viem.parseUnits(withdrawAmount, decimals);
|
|
1376
|
-
const currentAllowanceBigInt = BigInt(
|
|
1377
|
-
approvalInfo.allowanceAsBigInt
|
|
1378
|
-
);
|
|
2040
|
+
const currentAllowanceBigInt = BigInt(approvalInfo.allowanceAsBigInt);
|
|
1379
2041
|
if (approvalInfo.isApproved && currentAllowanceBigInt >= withdrawAmountBigInt) {
|
|
1380
2042
|
return {
|
|
1381
2043
|
method: WithdrawAuthMethod.ALREADY_APPROVED,
|
|
@@ -1395,10 +2057,10 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1395
2057
|
txData
|
|
1396
2058
|
};
|
|
1397
2059
|
} catch (error) {
|
|
1398
|
-
if (error instanceof
|
|
2060
|
+
if (error instanceof chunkGOJQYEJQ_js.APIError) {
|
|
1399
2061
|
throw error;
|
|
1400
2062
|
}
|
|
1401
|
-
throw new
|
|
2063
|
+
throw new chunkGOJQYEJQ_js.APIError(
|
|
1402
2064
|
`Failed to prepare withdrawal authorization: ${error instanceof Error ? error.message : String(error)}`,
|
|
1403
2065
|
{
|
|
1404
2066
|
endpoint: "prepareWithdrawalAuthorization",
|
|
@@ -1409,12 +2071,16 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1409
2071
|
}
|
|
1410
2072
|
|
|
1411
2073
|
exports.DepositAuthMethod = DepositAuthMethod;
|
|
2074
|
+
exports.DepositType = DepositType;
|
|
1412
2075
|
exports.PERMIT_TYPES = PERMIT_TYPES;
|
|
1413
2076
|
exports.WithdrawAuthMethod = WithdrawAuthMethod;
|
|
2077
|
+
exports.fetchKytAttestation = fetchKytAttestation;
|
|
1414
2078
|
exports.isAlreadyApprovedAuth = isAlreadyApprovedAuth;
|
|
1415
2079
|
exports.isApprovalAuth = isApprovalAuth;
|
|
1416
2080
|
exports.isDepositSpendApproved = isDepositSpendApproved;
|
|
2081
|
+
exports.isKytDeposit = isKytDeposit;
|
|
1417
2082
|
exports.isPermitAuth = isPermitAuth;
|
|
2083
|
+
exports.isStandardDeposit = isStandardDeposit;
|
|
1418
2084
|
exports.isWithdrawAlreadyApprovedAuth = isWithdrawAlreadyApprovedAuth;
|
|
1419
2085
|
exports.isWithdrawApprovalAuth = isWithdrawApprovalAuth;
|
|
1420
2086
|
exports.isWithdrawalSpendApproved = isWithdrawalSpendApproved;
|
|
@@ -1431,5 +2097,5 @@ exports.prepareWithdrawOrderTxData = prepareWithdrawOrderTxData;
|
|
|
1431
2097
|
exports.prepareWithdrawal = prepareWithdrawal;
|
|
1432
2098
|
exports.prepareWithdrawalAuthorization = prepareWithdrawalAuthorization;
|
|
1433
2099
|
exports.toEthSignTypedDataV4 = toEthSignTypedDataV4;
|
|
1434
|
-
//# sourceMappingURL=chunk-
|
|
1435
|
-
//# sourceMappingURL=chunk-
|
|
2100
|
+
//# sourceMappingURL=chunk-4NQPS3JC.js.map
|
|
2101
|
+
//# sourceMappingURL=chunk-4NQPS3JC.js.map
|