@paxoslabs/amplify-sdk 0.4.0-alpha.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -80
- package/README.md +4 -4
- package/dist/{chunk-NWMPT6GS.mjs → chunk-5VVP4RVO.mjs} +90 -82
- package/dist/chunk-5VVP4RVO.mjs.map +1 -0
- package/dist/{chunk-D7SOE6KR.js → chunk-DGUDYJGO.js} +15 -5
- package/dist/chunk-DGUDYJGO.js.map +1 -0
- package/dist/{chunk-JDIHKL5E.mjs → chunk-G5O3XKFN.mjs} +15 -5
- package/dist/chunk-G5O3XKFN.mjs.map +1 -0
- package/dist/{chunk-REYERXH2.js → chunk-NYRRIERP.js} +90 -81
- package/dist/chunk-NYRRIERP.js.map +1 -0
- package/dist/display.js +7 -7
- package/dist/display.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -30
- package/dist/index.mjs +2 -2
- package/dist/vaults.d.mts +49 -16
- package/dist/vaults.d.ts +49 -16
- package/dist/vaults.js +25 -21
- package/dist/vaults.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-D7SOE6KR.js.map +0 -1
- package/dist/chunk-JDIHKL5E.mjs.map +0 -1
- package/dist/chunk-NWMPT6GS.mjs.map +0 -1
- package/dist/chunk-REYERXH2.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,97 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
<!-- auto-changelog-above -->
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
## [0.4.0](///compare/v0.2.4...v0.4.0) (2026-02-18)
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
* **core:** Minimum Node.js version increased from 20 to 22.
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **client:** migrate vault data fetching from REST v1 to GraphQL b71bbd6
|
|
20
|
+
* **config:** add PRIME yield type support 7b7e60d
|
|
21
|
+
* **core:** bump minimum Node.js requirement from 20 to 22 d96f256
|
|
22
|
+
* **deposit:** improve TypeScript inference and add eth_signTypedData_v4 helper 7feb7b6
|
|
23
|
+
* **display:** add display module with UI helper functions 868d722
|
|
24
|
+
* **init:** make SDK initialization fully non-blocking 3cfb510
|
|
25
|
+
* **wallets:** add smart contract wallet detection for deposit and withdrawal flows 1547072
|
|
26
|
+
* **withdraw:** add prepareWithdrawal wrapper and forceMethod authorization overrides 1deef81
|
|
27
|
+
* **withdraw:** add prepareWithdrawalAuthorization and fix approval bugs 88baaaf
|
|
28
|
+
* **withdraw:** add WithdrawQueue contract integration 901bb5e
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* address CodeRabbit PR review findings 299cc64
|
|
33
|
+
* address CodeRabbit review findings across withdraw, deposit, and display modules 8b52868
|
|
34
|
+
* align stale API references with current naming (PR review) d2a2655
|
|
35
|
+
* **auth:** remove redundant allowance fields from approval authorization results f6236a4
|
|
36
|
+
* **ci:** restrict dry-run job permissions to read-only af546e1
|
|
37
|
+
* **ci:** separate dry-run job to skip environment approval 7c88088
|
|
38
|
+
* **deposit:** verify asset is supported on target chain d4a6eae
|
|
39
|
+
* **display:** add multicall error handling in getMinimumMint 2fe41d5
|
|
40
|
+
* **display:** use AND separator in v2 API filter query strings 46bdec5
|
|
41
|
+
* **errors:** ensure instanceof checks work in transpiled code 9167032
|
|
42
|
+
* reset version to 0.3.0 for release-it minor bump to 0.4.0 79d7b6d
|
|
43
|
+
* **withdraw:** remove legacy AtomicQueue utils and update tests 67f6703
|
|
44
|
+
|
|
45
|
+
## [0.4.0] - 2026-02-18
|
|
46
|
+
|
|
47
|
+
### BREAKING CHANGES
|
|
48
|
+
|
|
49
|
+
- **withdraw:** Replace AtomicQueue with WithdrawQueue contract ([7c521f4](https://github.com/Ion-Protocol/amplify-sdk/commit/7c521f4))
|
|
50
|
+
- `prepareWithdrawTransactionData()` → `prepareWithdrawOrderTxData()`
|
|
51
|
+
- `prepareApproveWithdrawToken()` → `prepareApproveWithdrawOrderTxData()`
|
|
52
|
+
- Added `prepareCancelWithdrawOrderTxData()` for order cancellation
|
|
53
|
+
- Slippage params no longer required for withdrawals
|
|
54
|
+
- **withdraw:** Rename WithdrawQueue functions for API clarity ([6b287de](https://github.com/Ion-Protocol/amplify-sdk/commit/6b287de))
|
|
55
|
+
- **auth:** Remove redundant allowance fields from approval authorization results ([f6236a4](https://github.com/Ion-Protocol/amplify-sdk/commit/f6236a4))
|
|
56
|
+
- **client:** Migrate vault data fetching from REST v1 to GraphQL ([b71bbd6](https://github.com/Ion-Protocol/amplify-sdk/commit/b71bbd6))
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
- **withdraw:** add `prepareWithdrawal` unified wrapper and `forceMethod` authorization overrides ([1deef81](https://github.com/Ion-Protocol/amplify-sdk/commit/1deef81))
|
|
61
|
+
- `prepareWithdrawal()` provides a stable high-level API wrapping `prepareWithdrawOrderTxData()`
|
|
62
|
+
- `forceMethod` parameter on both deposit and withdrawal authorization for explicit routing control
|
|
63
|
+
- Auth logic reordered: force override → smart wallet heuristic → auto-detect
|
|
64
|
+
- **withdraw:** add WithdrawQueue contract integration ([901bb5e](https://github.com/Ion-Protocol/amplify-sdk/commit/901bb5e))
|
|
65
|
+
- **withdraw:** add `prepareWithdrawalAuthorization` unified wrapper and fix approval bugs ([88baaaf](https://github.com/Ion-Protocol/amplify-sdk/commit/88baaaf))
|
|
66
|
+
- **display:** add display module with UI helper functions (`getVaultAPY`, `getVaultTVL`, `getMinimumMint`, `getMinimumWithdrawalOrderSize`, `getWithdrawalFee`, `getWithdrawalRequests`) ([868d722](https://github.com/Ion-Protocol/amplify-sdk/commit/868d722))
|
|
67
|
+
- **init:** make SDK initialization fully non-blocking ([3cfb510](https://github.com/Ion-Protocol/amplify-sdk/commit/3cfb510))
|
|
68
|
+
- **wallets:** add smart contract wallet detection for deposit and withdrawal flows ([1547072](https://github.com/Ion-Protocol/amplify-sdk/commit/1547072))
|
|
69
|
+
|
|
70
|
+
### Bug Fixes
|
|
71
|
+
|
|
72
|
+
- **withdraw:** remove legacy AtomicQueue utils and update tests ([67f6703](https://github.com/Ion-Protocol/amplify-sdk/commit/67f6703))
|
|
73
|
+
- **display:** use AND separator in v2 API filter query strings ([46bdec5](https://github.com/Ion-Protocol/amplify-sdk/commit/46bdec5))
|
|
74
|
+
- **display:** add multicall error handling in `getMinimumMint` ([2fe41d5](https://github.com/Ion-Protocol/amplify-sdk/commit/2fe41d5))
|
|
75
|
+
- **auth:** remove redundant allowance fields from approval authorization results ([f6236a4](https://github.com/Ion-Protocol/amplify-sdk/commit/f6236a4))
|
|
76
|
+
- address CodeRabbit review findings across withdraw, deposit, and display modules ([8b52868](https://github.com/Ion-Protocol/amplify-sdk/commit/8b52868))
|
|
77
|
+
|
|
78
|
+
### Code Refactoring
|
|
79
|
+
|
|
80
|
+
- **withdraw:** add ApprovalMethod enum for signature params ([21e0ae9](https://github.com/Ion-Protocol/amplify-sdk/commit/21e0ae9))
|
|
81
|
+
- **client:** make `fetchVaults` and `fetchSupportedAssets` cache-aware ([a50a345](https://github.com/Ion-Protocol/amplify-sdk/commit/a50a345))
|
|
82
|
+
- **client:** move API client from `api/` to `client/` folder ([a6523db](https://github.com/Ion-Protocol/amplify-sdk/commit/a6523db))
|
|
83
|
+
|
|
84
|
+
### Styles
|
|
85
|
+
|
|
86
|
+
- apply biome formatting to codebase ([d034237](https://github.com/Ion-Protocol/amplify-sdk/commit/d034237))
|
|
87
|
+
|
|
88
|
+
### Documentation
|
|
89
|
+
|
|
90
|
+
- update API reference and guides for new withdrawal API ([623fbf0](https://github.com/Ion-Protocol/amplify-sdk/commit/623fbf0))
|
|
91
|
+
- align Mintlify docs with current SDK state ([df67147](https://github.com/Ion-Protocol/amplify-sdk/commit/df67147))
|
|
92
|
+
- update withdrawal docs from AtomicQueue to WithdrawQueue terminology ([4ff639d](https://github.com/Ion-Protocol/amplify-sdk/commit/4ff639d))
|
|
93
|
+
- fix withdrawal examples and smart wallet guide per code review ([bacca7c](https://github.com/Ion-Protocol/amplify-sdk/commit/bacca7c))
|
|
94
|
+
|
|
95
|
+
### Chores
|
|
96
|
+
|
|
97
|
+
- **deps:** add version overrides for brace-expansion and lodash ([4dba204](https://github.com/Ion-Protocol/amplify-sdk/commit/4dba204))
|
|
98
|
+
- **test:** remove unused getMockAssets import ([b3e9bd0](https://github.com/Ion-Protocol/amplify-sdk/commit/b3e9bd0))
|
|
99
|
+
|
|
100
|
+
|
|
10
101
|
## [0.3.0-beta.0] - 2025-01-30
|
|
11
102
|
|
|
12
103
|
### BREAKING CHANGES
|
|
@@ -183,86 +274,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
183
274
|
|
|
184
275
|
* **chain-utils:** remove redundant optional chaining after null check ([22f1181](https://github.com/Ion-Protocol/amplify-sdk/commit/22f1181e9e670436a2eda1d6ef7e6921a4c61188))
|
|
185
276
|
|
|
186
|
-
## [Unreleased]
|
|
187
|
-
|
|
188
|
-
### BREAKING CHANGES
|
|
189
|
-
|
|
190
|
-
- **Product Rename**: Earn SDK renamed to Amplify SDK
|
|
191
|
-
- Package name: `@paxoslabs/earn-sdk` → `@paxoslabs/amplify-sdk`
|
|
192
|
-
- Function: `initEarnSDK()` → `initAmplifySDK()`
|
|
193
|
-
- Type: `AmplifyVault` → `AmplifyVault`
|
|
194
|
-
- Repository: `Ion-Protocol/earn-sdk` → `Ion-Protocol/amplify-sdk`
|
|
195
|
-
- 7 source files renamed (earn-* → amplify-*)
|
|
196
|
-
|
|
197
|
-
### Migration Guide
|
|
198
|
-
|
|
199
|
-
**For Existing Users**:
|
|
200
|
-
|
|
201
|
-
1. Update package in `package.json`:
|
|
202
|
-
```bash
|
|
203
|
-
npm uninstall @paxoslabs/earn-sdk
|
|
204
|
-
npm install @paxoslabs/amplify-sdk
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
2. Update import statements:
|
|
208
|
-
```typescript
|
|
209
|
-
// Old
|
|
210
|
-
import { initEarnSDK, type EarnVault } from "@paxoslabs/earn-sdk";
|
|
211
|
-
|
|
212
|
-
// New
|
|
213
|
-
import { initAmplifySDK, type AmplifyVault } from "@paxoslabs/amplify-sdk";
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
3. Update function calls:
|
|
217
|
-
```typescript
|
|
218
|
-
// Old
|
|
219
|
-
await initEarnSDK("pxl_internal_your_api_key");
|
|
220
|
-
|
|
221
|
-
// New
|
|
222
|
-
await initAmplifySDK("pxl_internal_your_api_key");
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
4. Update type references:
|
|
226
|
-
```typescript
|
|
227
|
-
// Old
|
|
228
|
-
const vault: EarnVault = ...;
|
|
229
|
-
|
|
230
|
-
// New
|
|
231
|
-
const vault: AmplifyVault = ...;
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Notes
|
|
235
|
-
- API endpoints continue to use `/v1/earn-sdk/*` for backwards compatibility
|
|
236
|
-
- No changes required to backend integration
|
|
237
|
-
- Old package `@paxoslabs/earn-sdk` will be deprecated but remain functional
|
|
238
|
-
- Endpoint migration to `/v1/amplify-sdk/*` planned for future release
|
|
239
|
-
|
|
240
|
-
### Documentation
|
|
241
|
-
- **Comprehensive SDK Documentation (Phase 008)**:
|
|
242
|
-
- Complete README.md overhaul with 5-minute quick start guide
|
|
243
|
-
- New documentation structure under `docs/`:
|
|
244
|
-
- `getting-started.md` - Detailed installation and first API call guide
|
|
245
|
-
- `api-reference/` - Complete API documentation for all SDK functions
|
|
246
|
-
- `vault-discovery.md` - Vault and asset discovery via Amplify API
|
|
247
|
-
- `deposits.md` - Standard deposit flows (viem + wagmi patterns)
|
|
248
|
-
- `deposits-permit.md` - Gas-optimized permit deposits (EIP-2612)
|
|
249
|
-
- `withdrawals.md` - Complete withdrawal flows with deadline protection
|
|
250
|
-
- `caching.md` - Performance optimization with vault caching
|
|
251
|
-
- `types.md` - TypeScript type definitions reference
|
|
252
|
-
- `guides/` - Tutorial-style integration guides
|
|
253
|
-
- `react-integration.md` - Three React patterns (direct, custom hooks, TanStack Query)
|
|
254
|
-
- `error-handling.md` - Error handling patterns for API and transactions
|
|
255
|
-
- `multi-chain.md` - Multi-chain deployment and chain selection
|
|
256
|
-
- `examples/` - Fully executable example projects
|
|
257
|
-
- `viem-deposit/` - Complete viem deposit example with tests
|
|
258
|
-
- `wagmi-deposit/` - Complete wagmi deposit example with React hooks
|
|
259
|
-
- `wagmi-withdraw/` - Complete wagmi withdrawal example
|
|
260
|
-
- 56 viem code examples and 33 wagmi code examples across all documentation
|
|
261
|
-
- 100% coverage of all 48 functional requirements
|
|
262
|
-
- All code examples are TypeScript with full type safety
|
|
263
|
-
- MSW (Mock Service Worker) integration for runnable examples
|
|
264
|
-
- Validation script for documentation quality assurance
|
|
265
|
-
|
|
266
277
|
## [0.0.1-alpha.1] - 2025-11-01
|
|
267
278
|
|
|
268
279
|
### Features
|
package/README.md
CHANGED
|
@@ -57,18 +57,18 @@ await initAmplifySDK("pxl_your_api_key");
|
|
|
57
57
|
// Prepare deposit authorization (auto-detects permit vs approval)
|
|
58
58
|
const auth = await prepareDepositAuthorization({
|
|
59
59
|
yieldType: "CORE",
|
|
60
|
-
|
|
60
|
+
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
|
61
61
|
depositAmount: "1000.0",
|
|
62
|
-
|
|
62
|
+
to: userAddress,
|
|
63
63
|
chainId: 1,
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
// Shared deposit parameters
|
|
67
67
|
const depositParams = {
|
|
68
68
|
yieldType: "CORE",
|
|
69
|
-
|
|
69
|
+
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
70
70
|
depositAmount: "1000.0",
|
|
71
|
-
|
|
71
|
+
to: userAddress,
|
|
72
72
|
chainId: 1,
|
|
73
73
|
};
|
|
74
74
|
|
|
@@ -462,22 +462,11 @@ async function prepareDepositTxData(params) {
|
|
|
462
462
|
} = params;
|
|
463
463
|
try {
|
|
464
464
|
const normalizedChainId = toChainId(chainId);
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
chainId: normalizedChainId
|
|
471
|
-
});
|
|
472
|
-
} catch (error) {
|
|
473
|
-
throw new APIError(
|
|
474
|
-
`Failed to resolve vault for token ${depositAsset} with yield type ${yieldType} on chain ${normalizedChainId}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
475
|
-
{
|
|
476
|
-
endpoint: "prepareDepositTransactionData",
|
|
477
|
-
cause: error
|
|
478
|
-
}
|
|
479
|
-
);
|
|
480
|
-
}
|
|
465
|
+
const vault = await findVaultByConfig({
|
|
466
|
+
assetAddress: depositAsset,
|
|
467
|
+
yieldType,
|
|
468
|
+
chainId: normalizedChainId
|
|
469
|
+
});
|
|
481
470
|
if (!vault) {
|
|
482
471
|
throw new APIError(
|
|
483
472
|
`No vault found for token address ${depositAsset} with yield type '${yieldType}' on chain ${normalizedChainId}. This combination may not be supported.`,
|
|
@@ -486,11 +475,8 @@ async function prepareDepositTxData(params) {
|
|
|
486
475
|
}
|
|
487
476
|
);
|
|
488
477
|
}
|
|
489
|
-
let asset = null;
|
|
490
478
|
const assets = await getAssetsFromCache({ address: depositAsset });
|
|
491
|
-
|
|
492
|
-
asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets[0] || null;
|
|
493
|
-
}
|
|
479
|
+
const asset = assets.find((a) => a.chains.includes(normalizedChainId)) || assets.find((a) => a.address.toLowerCase() === depositAsset.toLowerCase());
|
|
494
480
|
if (!asset) {
|
|
495
481
|
throw new APIError(
|
|
496
482
|
`Asset metadata not found for token ${depositAsset} on chain ${normalizedChainId}`,
|
|
@@ -994,11 +980,7 @@ async function prepareDepositAuthorization(params) {
|
|
|
994
980
|
{ endpoint: "prepareDepositAuthorization" }
|
|
995
981
|
);
|
|
996
982
|
}
|
|
997
|
-
|
|
998
|
-
to,
|
|
999
|
-
normalizedChainId
|
|
1000
|
-
);
|
|
1001
|
-
if (smartWallet && forceMethod !== "permit") {
|
|
983
|
+
if (forceMethod === "approval") {
|
|
1002
984
|
const txData2 = await prepareApproveDepositTokenTxData({
|
|
1003
985
|
yieldType,
|
|
1004
986
|
depositAsset,
|
|
@@ -1007,18 +989,16 @@ async function prepareDepositAuthorization(params) {
|
|
|
1007
989
|
});
|
|
1008
990
|
return {
|
|
1009
991
|
method: DepositAuthMethod.APPROVAL,
|
|
1010
|
-
txData: txData2
|
|
1011
|
-
allowance: "0",
|
|
1012
|
-
allowanceAsBigInt: "0"
|
|
992
|
+
txData: txData2
|
|
1013
993
|
};
|
|
1014
994
|
}
|
|
1015
|
-
const tokenInfo = await isDepositSpendApproved({
|
|
1016
|
-
yieldType,
|
|
1017
|
-
chainId: normalizedChainId,
|
|
1018
|
-
depositAssetAddress: depositAsset,
|
|
1019
|
-
recipientAddress: to
|
|
1020
|
-
});
|
|
1021
995
|
if (forceMethod === "permit") {
|
|
996
|
+
const tokenInfo2 = await isDepositSpendApproved({
|
|
997
|
+
yieldType,
|
|
998
|
+
chainId: normalizedChainId,
|
|
999
|
+
depositAssetAddress: depositAsset,
|
|
1000
|
+
recipientAddress: to
|
|
1001
|
+
});
|
|
1022
1002
|
const permitData = await prepareDepositPermitSignature({
|
|
1023
1003
|
yieldType,
|
|
1024
1004
|
depositAsset,
|
|
@@ -1027,17 +1007,21 @@ async function prepareDepositAuthorization(params) {
|
|
|
1027
1007
|
chainId: normalizedChainId,
|
|
1028
1008
|
deadline,
|
|
1029
1009
|
// Pass pre-fetched data to avoid redundant RPC calls
|
|
1030
|
-
nonce:
|
|
1031
|
-
decimals:
|
|
1032
|
-
tokenName:
|
|
1033
|
-
tokenVersion:
|
|
1010
|
+
nonce: tokenInfo2.nonce ?? void 0,
|
|
1011
|
+
decimals: tokenInfo2.decimals,
|
|
1012
|
+
tokenName: tokenInfo2.tokenName,
|
|
1013
|
+
tokenVersion: tokenInfo2.tokenVersion
|
|
1034
1014
|
});
|
|
1035
1015
|
return {
|
|
1036
1016
|
method: DepositAuthMethod.PERMIT,
|
|
1037
1017
|
permitData
|
|
1038
1018
|
};
|
|
1039
1019
|
}
|
|
1040
|
-
|
|
1020
|
+
const smartWallet = await isSmartContractWallet(
|
|
1021
|
+
to,
|
|
1022
|
+
normalizedChainId
|
|
1023
|
+
);
|
|
1024
|
+
if (smartWallet) {
|
|
1041
1025
|
const txData2 = await prepareApproveDepositTokenTxData({
|
|
1042
1026
|
yieldType,
|
|
1043
1027
|
depositAsset,
|
|
@@ -1046,11 +1030,15 @@ async function prepareDepositAuthorization(params) {
|
|
|
1046
1030
|
});
|
|
1047
1031
|
return {
|
|
1048
1032
|
method: DepositAuthMethod.APPROVAL,
|
|
1049
|
-
txData: txData2
|
|
1050
|
-
allowance: tokenInfo.allowance,
|
|
1051
|
-
allowanceAsBigInt: tokenInfo.allowanceAsBigInt
|
|
1033
|
+
txData: txData2
|
|
1052
1034
|
};
|
|
1053
1035
|
}
|
|
1036
|
+
const tokenInfo = await isDepositSpendApproved({
|
|
1037
|
+
yieldType,
|
|
1038
|
+
chainId: normalizedChainId,
|
|
1039
|
+
depositAssetAddress: depositAsset,
|
|
1040
|
+
recipientAddress: to
|
|
1041
|
+
});
|
|
1054
1042
|
if (tokenInfo.supportsPermit) {
|
|
1055
1043
|
const permitData = await prepareDepositPermitSignature({
|
|
1056
1044
|
yieldType,
|
|
@@ -1087,9 +1075,7 @@ async function prepareDepositAuthorization(params) {
|
|
|
1087
1075
|
});
|
|
1088
1076
|
return {
|
|
1089
1077
|
method: DepositAuthMethod.APPROVAL,
|
|
1090
|
-
txData
|
|
1091
|
-
allowance: tokenInfo.allowance,
|
|
1092
|
-
allowanceAsBigInt: tokenInfo.allowanceAsBigInt
|
|
1078
|
+
txData
|
|
1093
1079
|
};
|
|
1094
1080
|
} catch (error) {
|
|
1095
1081
|
if (error instanceof APIError) {
|
|
@@ -1191,19 +1177,19 @@ async function prepareApproveWithdrawOrderTxData({
|
|
|
1191
1177
|
if (!config || config.chainId !== normalizedChainId) {
|
|
1192
1178
|
throw new APIError(
|
|
1193
1179
|
`Vault chain mismatch: vault is on chain ${config?.chainId}, requested chain ${normalizedChainId}`,
|
|
1194
|
-
{ endpoint: "
|
|
1180
|
+
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1195
1181
|
);
|
|
1196
1182
|
}
|
|
1197
1183
|
if (!config.vault.boringVaultAddress) {
|
|
1198
1184
|
throw new APIError(
|
|
1199
1185
|
`BoringVault contract address not configured for vault ${config.id}`,
|
|
1200
|
-
{ endpoint: "
|
|
1186
|
+
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1201
1187
|
);
|
|
1202
1188
|
}
|
|
1203
1189
|
if (!config.vault.withdrawQueueAddress) {
|
|
1204
1190
|
throw new APIError(
|
|
1205
1191
|
`WithdrawQueue contract address not configured for vault ${config.id}`,
|
|
1206
|
-
{ endpoint: "
|
|
1192
|
+
{ endpoint: "prepareApproveWithdrawOrderTxData" }
|
|
1207
1193
|
);
|
|
1208
1194
|
}
|
|
1209
1195
|
const boringVaultAddress = config.vault.boringVaultAddress;
|
|
@@ -1226,7 +1212,7 @@ async function prepareApproveWithdrawOrderTxData({
|
|
|
1226
1212
|
throw new APIError(
|
|
1227
1213
|
`Failed to prepare approval transaction: ${error instanceof Error ? error.message : String(error)}`,
|
|
1228
1214
|
{
|
|
1229
|
-
endpoint: "
|
|
1215
|
+
endpoint: "prepareApproveWithdrawOrderTxData",
|
|
1230
1216
|
cause: error
|
|
1231
1217
|
}
|
|
1232
1218
|
);
|
|
@@ -1335,24 +1321,6 @@ var prepareWithdrawOrderTxData = async ({
|
|
|
1335
1321
|
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1336
1322
|
);
|
|
1337
1323
|
}
|
|
1338
|
-
const smartWallet = await isSmartContractWallet(
|
|
1339
|
-
userAddress,
|
|
1340
|
-
normalizedChainId
|
|
1341
|
-
);
|
|
1342
|
-
if (!smartWallet) {
|
|
1343
|
-
const approvalInfo = await isWithdrawalSpendApproved({
|
|
1344
|
-
yieldType,
|
|
1345
|
-
chainId: normalizedChainId,
|
|
1346
|
-
wantAssetAddress: wantAsset,
|
|
1347
|
-
recipientAddress: userAddress
|
|
1348
|
-
});
|
|
1349
|
-
if (!approvalInfo.isApproved) {
|
|
1350
|
-
throw new APIError(
|
|
1351
|
-
`Vault shares not approved for withdrawal`,
|
|
1352
|
-
{ endpoint: "prepareWithdrawOrderTxData" }
|
|
1353
|
-
);
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
1324
|
const sharesDecimals = await getErc20Decimals({
|
|
1357
1325
|
tokenAddress: config.vault.boringVaultAddress,
|
|
1358
1326
|
chainId: normalizedChainId
|
|
@@ -1397,8 +1365,38 @@ function isWithdrawApprovalAuth(result) {
|
|
|
1397
1365
|
function isWithdrawAlreadyApprovedAuth(result) {
|
|
1398
1366
|
return result.method === WithdrawAuthMethod.ALREADY_APPROVED;
|
|
1399
1367
|
}
|
|
1400
|
-
async function
|
|
1368
|
+
async function prepareWithdrawal(params) {
|
|
1401
1369
|
const { yieldType, wantAsset, withdrawAmount, userAddress, chainId } = params;
|
|
1370
|
+
try {
|
|
1371
|
+
return await prepareWithdrawOrderTxData({
|
|
1372
|
+
yieldType,
|
|
1373
|
+
wantAsset,
|
|
1374
|
+
userAddress,
|
|
1375
|
+
chainId,
|
|
1376
|
+
amountOffer: withdrawAmount
|
|
1377
|
+
});
|
|
1378
|
+
} catch (error) {
|
|
1379
|
+
if (error instanceof APIError) {
|
|
1380
|
+
throw error;
|
|
1381
|
+
}
|
|
1382
|
+
throw new APIError(
|
|
1383
|
+
`Failed to prepare withdrawal: ${error instanceof Error ? error.message : String(error)}`,
|
|
1384
|
+
{
|
|
1385
|
+
endpoint: "prepareWithdrawal",
|
|
1386
|
+
cause: error
|
|
1387
|
+
}
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
async function prepareWithdrawalAuthorization(params) {
|
|
1392
|
+
const {
|
|
1393
|
+
yieldType,
|
|
1394
|
+
wantAsset,
|
|
1395
|
+
withdrawAmount,
|
|
1396
|
+
userAddress,
|
|
1397
|
+
chainId,
|
|
1398
|
+
forceMethod
|
|
1399
|
+
} = params;
|
|
1402
1400
|
try {
|
|
1403
1401
|
const normalizedChainId = toChainId(chainId);
|
|
1404
1402
|
const vault = await findVaultByConfig({
|
|
@@ -1412,11 +1410,7 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1412
1410
|
{ endpoint: "prepareWithdrawalAuthorization" }
|
|
1413
1411
|
);
|
|
1414
1412
|
}
|
|
1415
|
-
|
|
1416
|
-
userAddress,
|
|
1417
|
-
normalizedChainId
|
|
1418
|
-
);
|
|
1419
|
-
if (smartWallet) {
|
|
1413
|
+
if (forceMethod === "approval") {
|
|
1420
1414
|
const txData2 = await prepareApproveWithdrawOrderTxData({
|
|
1421
1415
|
yieldType,
|
|
1422
1416
|
wantAssetAddress: wantAsset,
|
|
@@ -1425,11 +1419,27 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1425
1419
|
});
|
|
1426
1420
|
return {
|
|
1427
1421
|
method: WithdrawAuthMethod.APPROVAL,
|
|
1428
|
-
txData: txData2
|
|
1429
|
-
allowance: "0",
|
|
1430
|
-
allowanceAsBigInt: "0"
|
|
1422
|
+
txData: txData2
|
|
1431
1423
|
};
|
|
1432
1424
|
}
|
|
1425
|
+
if (forceMethod !== "allowance_check") {
|
|
1426
|
+
const smartWallet = await isSmartContractWallet(
|
|
1427
|
+
userAddress,
|
|
1428
|
+
normalizedChainId
|
|
1429
|
+
);
|
|
1430
|
+
if (smartWallet) {
|
|
1431
|
+
const txData2 = await prepareApproveWithdrawOrderTxData({
|
|
1432
|
+
yieldType,
|
|
1433
|
+
wantAssetAddress: wantAsset,
|
|
1434
|
+
withdrawAmount,
|
|
1435
|
+
chainId: normalizedChainId
|
|
1436
|
+
});
|
|
1437
|
+
return {
|
|
1438
|
+
method: WithdrawAuthMethod.APPROVAL,
|
|
1439
|
+
txData: txData2
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1433
1443
|
const approvalInfo = await isWithdrawalSpendApproved({
|
|
1434
1444
|
yieldType,
|
|
1435
1445
|
chainId: normalizedChainId,
|
|
@@ -1463,9 +1473,7 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1463
1473
|
});
|
|
1464
1474
|
return {
|
|
1465
1475
|
method: WithdrawAuthMethod.APPROVAL,
|
|
1466
|
-
txData
|
|
1467
|
-
allowance: approvalInfo.allowance,
|
|
1468
|
-
allowanceAsBigInt: approvalInfo.allowanceAsBigInt
|
|
1476
|
+
txData
|
|
1469
1477
|
};
|
|
1470
1478
|
} catch (error) {
|
|
1471
1479
|
if (error instanceof APIError) {
|
|
@@ -1481,6 +1489,6 @@ async function prepareWithdrawalAuthorization(params) {
|
|
|
1481
1489
|
}
|
|
1482
1490
|
}
|
|
1483
1491
|
|
|
1484
|
-
export { DepositAuthMethod, PERMIT_TYPES, WithdrawAuthMethod, isAlreadyApprovedAuth, isApprovalAuth, isDepositSpendApproved, isPermitAuth, isWithdrawAlreadyApprovedAuth, isWithdrawApprovalAuth, isWithdrawalSpendApproved, parsePermitSignature, prepareApproveDepositTokenTxData, prepareApproveWithdrawOrderTxData, prepareCancelWithdrawOrderTxData, prepareDeposit, prepareDepositAuthorization, prepareDepositPermitSignature, prepareDepositTxData, prepareDepositWithPermitTxData, prepareWithdrawOrderTxData, prepareWithdrawalAuthorization, toEthSignTypedDataV4 };
|
|
1485
|
-
//# sourceMappingURL=chunk-
|
|
1486
|
-
//# sourceMappingURL=chunk-
|
|
1492
|
+
export { DepositAuthMethod, PERMIT_TYPES, WithdrawAuthMethod, isAlreadyApprovedAuth, isApprovalAuth, isDepositSpendApproved, isPermitAuth, isWithdrawAlreadyApprovedAuth, isWithdrawApprovalAuth, isWithdrawalSpendApproved, parsePermitSignature, prepareApproveDepositTokenTxData, prepareApproveWithdrawOrderTxData, prepareCancelWithdrawOrderTxData, prepareDeposit, prepareDepositAuthorization, prepareDepositPermitSignature, prepareDepositTxData, prepareDepositWithPermitTxData, prepareWithdrawOrderTxData, prepareWithdrawal, prepareWithdrawalAuthorization, toEthSignTypedDataV4 };
|
|
1493
|
+
//# sourceMappingURL=chunk-5VVP4RVO.mjs.map
|
|
1494
|
+
//# sourceMappingURL=chunk-5VVP4RVO.mjs.map
|