@paxoslabs/amplify-sdk 0.0.1 → 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/README.md +5 -480
- package/dist/{amplify-sdk-api-DPrRhynk.d.mts → amplify-sdk-api-Biol0OIp.d.mts} +1 -1
- package/dist/{amplify-sdk-api-B5hBTGrB.d.ts → amplify-sdk-api-DGRgEybp.d.ts} +1 -1
- package/dist/{chunk-IBNTWZ4S.js → chunk-B2QCI6ET.js} +13 -35
- package/dist/chunk-B2QCI6ET.js.map +1 -0
- package/dist/{chunk-WFCHKDDG.mjs → chunk-CUGK4ZBJ.mjs} +13 -35
- package/dist/chunk-CUGK4ZBJ.mjs.map +1 -0
- package/dist/{chunk-BXUG3WDV.js → chunk-DTFLXAZJ.js} +27 -52
- package/dist/chunk-DTFLXAZJ.js.map +1 -0
- package/dist/{chunk-AIBI7ZQM.js → chunk-GS7TDQXA.js} +8 -8
- package/dist/{chunk-AIBI7ZQM.js.map → chunk-GS7TDQXA.js.map} +1 -1
- package/dist/{chunk-GBWBO6ZF.mjs → chunk-HI44AMLC.mjs} +8 -8
- package/dist/chunk-HI44AMLC.mjs.map +1 -0
- package/dist/{chunk-ZCVMGIMV.js → chunk-KYR6BFAE.js} +24 -24
- package/dist/chunk-KYR6BFAE.js.map +1 -0
- package/dist/{chunk-K4DL2AII.js → chunk-LSNRG5Z2.js} +4 -4
- package/dist/{chunk-K4DL2AII.js.map → chunk-LSNRG5Z2.js.map} +1 -1
- package/dist/{chunk-OPOYGPSS.mjs → chunk-REKEQLQA.mjs} +3 -3
- package/dist/{chunk-OPOYGPSS.mjs.map → chunk-REKEQLQA.mjs.map} +1 -1
- package/dist/{chunk-ZLS2AAMI.mjs → chunk-VIULRHK6.mjs} +3 -3
- package/dist/{chunk-ZLS2AAMI.mjs.map → chunk-VIULRHK6.mjs.map} +1 -1
- package/dist/{chunk-YP2TR5RP.mjs → chunk-ZILA73XN.mjs} +25 -50
- package/dist/chunk-ZILA73XN.mjs.map +1 -0
- package/dist/core.d.mts +6 -6
- package/dist/core.d.ts +6 -6
- package/dist/core.js +16 -16
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +6 -6
- package/dist/core.mjs.map +1 -1
- package/dist/display.d.mts +3 -3
- package/dist/display.d.ts +3 -3
- package/dist/display.js +16 -16
- package/dist/display.js.map +1 -1
- package/dist/display.mjs +8 -8
- package/dist/display.mjs.map +1 -1
- package/dist/{exchange-rate-CRA_CMaX.d.mts → exchange-rate-BfPH_fQt.d.mts} +4 -4
- package/dist/{exchange-rate-D3_FVgqa.d.ts → exchange-rate-Cp1ddpw4.d.ts} +4 -4
- package/dist/index.d.mts +245 -15
- package/dist/index.d.ts +245 -15
- package/dist/index.js +341 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +249 -53
- package/dist/index.mjs.map +1 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +5 -5
- package/dist/utils.mjs +2 -2
- package/package.json +7 -7
- package/dist/chunk-BXUG3WDV.js.map +0 -1
- package/dist/chunk-GBWBO6ZF.mjs.map +0 -1
- package/dist/chunk-IBNTWZ4S.js.map +0 -1
- package/dist/chunk-WFCHKDDG.mjs.map +0 -1
- package/dist/chunk-YP2TR5RP.mjs.map +0 -1
- package/dist/chunk-ZCVMGIMV.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,27 @@ 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.1.0-alpha.0](https://github.com/Ion-Protocol/amplify-sdk/compare/v0.0.2...v0.1.0-alpha.0) (2025-12-08)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **deposit:** export CommunityCodeDepositTxData type and fix cache check ([426f711](https://github.com/Ion-Protocol/amplify-sdk/commit/426f7116ddd72309aca2e77117a622d6a6a1e0dd))
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **deposit:** update CommunityCodeDepositor support for partner code deposits ([c8c281e](https://github.com/Ion-Protocol/amplify-sdk/commit/c8c281efcbc69b9ce3fd887c5ece6a19688004f3))
|
|
20
|
+
* **lint:** remove unused variables and useless try-catch ([5d1ed6d](https://github.com/Ion-Protocol/amplify-sdk/commit/5d1ed6dc73693714127d6ea79afff781b34c1bab))
|
|
21
|
+
* **types:** improve type safety and chain cache initialization ([03bcf41](https://github.com/Ion-Protocol/amplify-sdk/commit/03bcf4171fd72fc1bd55d84301cd78f55f2d57b2))
|
|
22
|
+
|
|
23
|
+
### Styles
|
|
24
|
+
|
|
25
|
+
* apply formatting and update branding to Amplify SDK ([c9f4d19](https://github.com/Ion-Protocol/amplify-sdk/commit/c9f4d193286b6b5fdfdf18a26ce9f6e2704f719f))
|
|
26
|
+
|
|
27
|
+
### Code Refactoring
|
|
28
|
+
|
|
29
|
+
* **chain-utils:** remove redundant optional chaining after null check ([22f1181](https://github.com/Ion-Protocol/amplify-sdk/commit/22f1181e9e670436a2eda1d6ef7e6921a4c61188))
|
|
30
|
+
|
|
10
31
|
## [Unreleased]
|
|
11
32
|
|
|
12
33
|
### BREAKING CHANGES
|
|
@@ -109,4 +130,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
109
130
|
- Configured semantic versioning with alpha/beta/rc support
|
|
110
131
|
- Implemented comprehensive CI/CD pipeline with quality gates
|
|
111
132
|
- Added security auditing and dependency scanning
|
|
112
|
-
- Configured automated NPM publishing with provenance
|
|
133
|
+
- Configured automated NPM publishing with provenance
|
package/README.md
CHANGED
|
@@ -12,29 +12,7 @@
|
|
|
12
12
|
A TypeScript SDK for interacting with Paxos Labs Amplify Vaults, providing type-safe functions for discovering vaults, depositing assets, and withdrawing across multiple blockchain networks.
|
|
13
13
|
|
|
14
14
|
[](https://www.npmjs.com/package/@paxoslabs/amplify-sdk)
|
|
15
|
-
[
|
|
20
|
-
- [Quick Start (5 Minutes)](#quick-start-5-minutes)
|
|
21
|
-
- [Documentation](#documentation)
|
|
22
|
-
- [Complete Guides](#-complete-guides)
|
|
23
|
-
- [Example Projects](#-example-projects)
|
|
24
|
-
- [Core API Overview](#core-api-overview)
|
|
25
|
-
- [Vault Discovery](#vault-discovery)
|
|
26
|
-
- [Cache Management](#cache-management)
|
|
27
|
-
- [Deposits](#deposits)
|
|
28
|
-
- [Permit Deposits (Gas-Optimized)](#permit-deposits-gas-optimized)
|
|
29
|
-
- [Withdrawals](#withdrawals)
|
|
30
|
-
- [TypeScript Support](#typescript-support)
|
|
31
|
-
- [Error Handling](#error-handling)
|
|
32
|
-
- [Supported Networks](#supported-networks)
|
|
33
|
-
- [Requirements](#requirements)
|
|
34
|
-
- [API Configuration](#api-configuration)
|
|
35
|
-
- [Available Vault Keys](#available-vault-keys)
|
|
36
|
-
- [Contributing](#contributing)
|
|
37
|
-
- [License](#license)
|
|
15
|
+
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
38
16
|
|
|
39
17
|
## Features
|
|
40
18
|
|
|
@@ -47,9 +25,7 @@ A TypeScript SDK for interacting with Paxos Labs Amplify Vaults, providing type-
|
|
|
47
25
|
- **Full TypeScript Support** - Complete type definitions and autocomplete
|
|
48
26
|
- **React Ready** - Works with viem (vanilla) and wagmi (React hooks)
|
|
49
27
|
|
|
50
|
-
##
|
|
51
|
-
|
|
52
|
-
### 1. Installation
|
|
28
|
+
## Installation
|
|
53
29
|
|
|
54
30
|
```bash
|
|
55
31
|
# npm
|
|
@@ -65,469 +41,18 @@ pnpm add @paxoslabs/amplify-sdk viem
|
|
|
65
41
|
pnpm add wagmi @tanstack/react-query
|
|
66
42
|
```
|
|
67
43
|
|
|
68
|
-
### 2. Initialize the SDK
|
|
69
|
-
|
|
70
|
-
**⚠️ Required**: Initialize the SDK with your API key before using any functions.
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
import { initAmplifySDK } from "@paxoslabs/amplify-sdk";
|
|
74
|
-
|
|
75
|
-
// Initialize SDK with your API key
|
|
76
|
-
await initAmplifySDK("pxl_your_api_key_here");
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Get Your API Key**: Contact Paxos Labs to request an API key for access.
|
|
80
|
-
|
|
81
|
-
**Environment Variables** (Recommended):
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
# .env file
|
|
85
|
-
PAXOS_API_KEY=pxl_your_api_key_here
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
// In your app
|
|
90
|
-
await initAmplifySDK(process.env.PAXOS_API_KEY!);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Features**:
|
|
94
|
-
|
|
95
|
-
- ✅ **Automatic Authentication**: All API calls include authentication headers
|
|
96
|
-
- ✅ **Cache Pre-population**: Vaults and assets cached during initialization
|
|
97
|
-
- ✅ **Idempotent**: Multiple calls with same key are safe (no-op)
|
|
98
|
-
- ✅ **Re-initialization**: Switch API keys at runtime for environment changes
|
|
99
|
-
|
|
100
|
-
### 3. Discover Available Vaults
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
import { fetchVaults } from "@paxoslabs/amplify-sdk";
|
|
104
|
-
|
|
105
|
-
// Fetch all available vaults
|
|
106
|
-
const allVaults = await fetchVaults();
|
|
107
|
-
|
|
108
|
-
// Or filter by chain and yield type
|
|
109
|
-
const primeVaults = await fetchVaults({
|
|
110
|
-
chainId: 1, // Ethereum mainnet
|
|
111
|
-
yieldType: "PRIME",
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
console.log(`Found ${primeVaults.length} PRIME vaults on Ethereum`);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 4. Find Supported Deposit Assets
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
import { fetchSupportedAssets } from "@paxoslabs/amplify-sdk";
|
|
121
|
-
|
|
122
|
-
// Fetch assets supported for deposits
|
|
123
|
-
const assets = await fetchSupportedAssets({
|
|
124
|
-
chainId: 1, // Ethereum mainnet
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// Find USDC
|
|
128
|
-
const usdc = assets.find((asset) => asset.symbol === "USDC");
|
|
129
|
-
console.log(`USDC address: ${usdc?.address}`);
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### 5. Deposit into a Vault (Viem)
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
import { createWalletClient, http } from "viem";
|
|
136
|
-
import { mainnet } from "viem/chains";
|
|
137
|
-
import { privateKeyToAccount } from "viem/accounts";
|
|
138
|
-
import {
|
|
139
|
-
prepareApproveDepositToken,
|
|
140
|
-
prepareDepositTransactionData,
|
|
141
|
-
isDepositSpendApproved,
|
|
142
|
-
} from "@paxoslabs/amplify-sdk";
|
|
143
|
-
|
|
144
|
-
// Setup viem client
|
|
145
|
-
const account = privateKeyToAccount("0x...");
|
|
146
|
-
const client = createWalletClient({
|
|
147
|
-
account,
|
|
148
|
-
chain: mainnet,
|
|
149
|
-
transport: http(),
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
async function deposit() {
|
|
153
|
-
const vaultKey = "op-nTBILL"; // T-Bill vault
|
|
154
|
-
const tokenSymbol = "USDC";
|
|
155
|
-
const amount = "1000.0"; // $1000 USDC
|
|
156
|
-
const chainId = 1;
|
|
157
|
-
|
|
158
|
-
// 1. Check if approval needed
|
|
159
|
-
const isApproved = await isDepositSpendApproved({
|
|
160
|
-
vaultKey,
|
|
161
|
-
userAddress: account.address,
|
|
162
|
-
depositTokenSymbol: tokenSymbol,
|
|
163
|
-
depositAmount: amount,
|
|
164
|
-
chainId,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// 2. Approve if needed
|
|
168
|
-
if (!isApproved) {
|
|
169
|
-
const approvalTx = await prepareApproveDepositToken({
|
|
170
|
-
vaultKey,
|
|
171
|
-
depositTokenSymbol: tokenSymbol,
|
|
172
|
-
depositAmount: amount,
|
|
173
|
-
chainId,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const approvalHash = await client.writeContract(approvalTx);
|
|
177
|
-
console.log(`Approval tx: ${approvalHash}`);
|
|
178
|
-
// Wait for approval confirmation...
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// 3. Prepare and execute deposit
|
|
182
|
-
const depositTx = await prepareDepositTransactionData({
|
|
183
|
-
vaultKey,
|
|
184
|
-
userAddress: account.address,
|
|
185
|
-
depositTokenSymbol: tokenSymbol,
|
|
186
|
-
depositAmount: amount,
|
|
187
|
-
chainId,
|
|
188
|
-
slippage: 100, // 1% slippage (100 basis points)
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const depositHash = await client.writeContract(depositTx);
|
|
192
|
-
console.log(`Deposit tx: ${depositHash}`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
deposit();
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### 5. Deposit into a Vault (Wagmi + React)
|
|
199
|
-
|
|
200
|
-
```tsx
|
|
201
|
-
import { useAccount, useWriteContract } from "wagmi";
|
|
202
|
-
import {
|
|
203
|
-
prepareApproveDepositToken,
|
|
204
|
-
prepareDepositTransactionData,
|
|
205
|
-
isDepositSpendApproved,
|
|
206
|
-
} from "@paxoslabs/amplify-sdk";
|
|
207
|
-
|
|
208
|
-
function DepositComponent() {
|
|
209
|
-
const { address } = useAccount();
|
|
210
|
-
const { writeContract } = useWriteContract();
|
|
211
|
-
|
|
212
|
-
const handleDeposit = async () => {
|
|
213
|
-
if (!address) return;
|
|
214
|
-
|
|
215
|
-
const vaultKey = "op-nTBILL";
|
|
216
|
-
const tokenSymbol = "USDC";
|
|
217
|
-
const amount = "1000.0";
|
|
218
|
-
const chainId = 1;
|
|
219
|
-
|
|
220
|
-
try {
|
|
221
|
-
// Check approval
|
|
222
|
-
const isApproved = await isDepositSpendApproved({
|
|
223
|
-
vaultKey,
|
|
224
|
-
userAddress: address,
|
|
225
|
-
depositTokenSymbol: tokenSymbol,
|
|
226
|
-
depositAmount: amount,
|
|
227
|
-
chainId,
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
// Approve if needed
|
|
231
|
-
if (!isApproved) {
|
|
232
|
-
const approvalTx = await prepareApproveDepositToken({
|
|
233
|
-
vaultKey,
|
|
234
|
-
depositTokenSymbol: tokenSymbol,
|
|
235
|
-
depositAmount: amount,
|
|
236
|
-
chainId,
|
|
237
|
-
});
|
|
238
|
-
await writeContract(approvalTx);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Execute deposit
|
|
242
|
-
const depositTx = await prepareDepositTransactionData({
|
|
243
|
-
vaultKey,
|
|
244
|
-
userAddress: address,
|
|
245
|
-
depositTokenSymbol: tokenSymbol,
|
|
246
|
-
depositAmount: amount,
|
|
247
|
-
chainId,
|
|
248
|
-
slippage: 100, // 1%
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
await writeContract(depositTx);
|
|
252
|
-
} catch (error) {
|
|
253
|
-
console.error("Deposit failed:", error);
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
return <button onClick={handleDeposit}>Deposit $1000 USDC</button>;
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
**That's it!** You've discovered vaults and executed your first deposit. ✨
|
|
262
|
-
|
|
263
44
|
## Documentation
|
|
264
45
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
- **[Getting Started Guide](./docs/getting-started.md)** - Detailed setup and first API call
|
|
268
|
-
- **[API Reference: Vault Discovery](./docs/api-reference/vault-discovery.md)** - Fetch vaults and assets
|
|
269
|
-
- **[API Reference: Deposits](./docs/api-reference/deposits.md)** - Standard deposit flows
|
|
270
|
-
- **[API Reference: Permit Deposits](./docs/api-reference/deposits-permit.md)** - Gas-optimized deposits
|
|
271
|
-
- **[API Reference: Withdrawals](./docs/api-reference/withdrawals.md)** - Withdrawal flows
|
|
272
|
-
- **[API Reference: Caching](./docs/api-reference/caching.md)** - Performance optimization
|
|
273
|
-
- **[API Reference: Types](./docs/api-reference/types.md)** - TypeScript type definitions
|
|
274
|
-
- **[Guide: Error Handling](./docs/guides/error-handling.md)** - Error patterns and recovery
|
|
275
|
-
- **[Guide: React Integration](./docs/guides/react-integration.md)** - React patterns and hooks
|
|
276
|
-
- **[Guide: Multi-Chain Operations](./docs/guides/multi-chain.md)** - Cross-chain deposits/withdrawals
|
|
277
|
-
|
|
278
|
-
### 💻 Example Projects
|
|
279
|
-
|
|
280
|
-
- **[Viem Deposit Example](./docs/examples/viem-deposit/)** - Executable viem deposit example
|
|
281
|
-
- **[Wagmi Deposit Example](./docs/examples/wagmi-deposit/)** - React wagmi deposit component
|
|
282
|
-
- **[Wagmi Withdrawal Example](./docs/examples/wagmi-withdraw/)** - React wagmi withdrawal component
|
|
283
|
-
|
|
284
|
-
## Core API Overview
|
|
285
|
-
|
|
286
|
-
### Vault Discovery
|
|
287
|
-
|
|
288
|
-
```typescript
|
|
289
|
-
import {
|
|
290
|
-
fetchVaults,
|
|
291
|
-
fetchSupportedAssets,
|
|
292
|
-
getWithdrawSupportedAssets,
|
|
293
|
-
} from "@paxoslabs/amplify-sdk";
|
|
294
|
-
|
|
295
|
-
// Discover vaults
|
|
296
|
-
const vaults = await fetchVaults({
|
|
297
|
-
chainId: 1,
|
|
298
|
-
yieldType: "PRIME", // or "TBILL", "LENDING"
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// Discover deposit assets
|
|
302
|
-
const depositAssets = await fetchSupportedAssets({
|
|
303
|
-
chainId: 1,
|
|
304
|
-
symbol: "USDC",
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
// Discover withdrawal assets
|
|
308
|
-
const withdrawAssets = await getWithdrawSupportedAssets();
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Cache Management
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
|
-
import {
|
|
315
|
-
initializeCache,
|
|
316
|
-
getVaultsFromCache,
|
|
317
|
-
getAssetsFromCache,
|
|
318
|
-
refreshVaultCache,
|
|
319
|
-
} from "@paxoslabs/amplify-sdk";
|
|
320
|
-
|
|
321
|
-
// Initialize cache (recommended at app startup)
|
|
322
|
-
await initializeCache();
|
|
323
|
-
|
|
324
|
-
// Use cached data (80% faster than API calls)
|
|
325
|
-
const cachedVaults = await getVaultsFromCache({ chainId: 1 });
|
|
326
|
-
const cachedAssets = await getAssetsFromCache({ symbol: "USDC" });
|
|
327
|
-
|
|
328
|
-
// Refresh cache periodically
|
|
329
|
-
await refreshVaultCache();
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
### Deposits
|
|
333
|
-
|
|
334
|
-
```typescript
|
|
335
|
-
import {
|
|
336
|
-
prepareDepositTransactionData,
|
|
337
|
-
prepareApproveDepositToken,
|
|
338
|
-
isDepositSpendApproved,
|
|
339
|
-
} from "@paxoslabs/amplify-sdk";
|
|
340
|
-
|
|
341
|
-
// Check approval status
|
|
342
|
-
const isApproved = await isDepositSpendApproved({
|
|
343
|
-
vaultKey: "op-nTBILL",
|
|
344
|
-
userAddress: "0x...",
|
|
345
|
-
depositTokenSymbol: "USDC",
|
|
346
|
-
depositAmount: "1000.0",
|
|
347
|
-
chainId: 1,
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
// Prepare approval transaction
|
|
351
|
-
const approvalTx = await prepareApproveDepositToken({
|
|
352
|
-
vaultKey: "op-nTBILL",
|
|
353
|
-
depositTokenSymbol: "USDC",
|
|
354
|
-
depositAmount: "1000.0",
|
|
355
|
-
chainId: 1,
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// Prepare deposit transaction
|
|
359
|
-
const depositTx = await prepareDepositTransactionData({
|
|
360
|
-
vaultKey: "op-nTBILL",
|
|
361
|
-
userAddress: "0x...",
|
|
362
|
-
depositTokenSymbol: "USDC",
|
|
363
|
-
depositAmount: "1000.0",
|
|
364
|
-
chainId: 1,
|
|
365
|
-
slippage: 100, // 1% (100 basis points)
|
|
366
|
-
});
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### Permit Deposits (Gas-Optimized)
|
|
370
|
-
|
|
371
|
-
```typescript
|
|
372
|
-
import {
|
|
373
|
-
prepareDepositWithPermitTransactionData,
|
|
374
|
-
type PrepareDepositWithPermitTransactionDataParams,
|
|
375
|
-
} from "@paxoslabs/amplify-sdk";
|
|
376
|
-
|
|
377
|
-
// Sign permit message off-chain (using viem or wagmi)
|
|
378
|
-
const signature = await signTypedData({
|
|
379
|
-
/* permit EIP-2612 typed data */
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
// Execute deposit with permit in single transaction
|
|
383
|
-
const permitDepositTx = await prepareDepositWithPermitTransactionData({
|
|
384
|
-
vaultKey: "op-nTBILL",
|
|
385
|
-
userAddress: "0x...",
|
|
386
|
-
depositTokenSymbol: "USDC",
|
|
387
|
-
depositAmount: "1000.0",
|
|
388
|
-
chainId: 1,
|
|
389
|
-
permitSignature: signature,
|
|
390
|
-
deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour
|
|
391
|
-
});
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
### Withdrawals
|
|
395
|
-
|
|
396
|
-
```typescript
|
|
397
|
-
import {
|
|
398
|
-
prepareWithdrawTransactionData,
|
|
399
|
-
prepareApproveWithdrawToken,
|
|
400
|
-
isWithdrawalSpendApproved,
|
|
401
|
-
} from "@paxoslabs/amplify-sdk";
|
|
402
|
-
|
|
403
|
-
// Check if vault shares are approved
|
|
404
|
-
const isApproved = await isWithdrawalSpendApproved({
|
|
405
|
-
vaultKey: "op-nTBILL",
|
|
406
|
-
userAddress: "0x...",
|
|
407
|
-
withdrawAmount: "100.0", // vault shares
|
|
408
|
-
chainId: 1,
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
// Approve vault shares
|
|
412
|
-
const approvalTx = await prepareApproveWithdrawToken({
|
|
413
|
-
vaultKey: "op-nTBILL",
|
|
414
|
-
withdrawAmount: "100.0",
|
|
415
|
-
chainId: 1,
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
// Withdraw assets
|
|
419
|
-
const withdrawTx = await prepareWithdrawTransactionData({
|
|
420
|
-
vaultKey: "op-nTBILL",
|
|
421
|
-
chainId: 1,
|
|
422
|
-
userAddress: "0x...",
|
|
423
|
-
wantTokenSymbol: "USDC",
|
|
424
|
-
offerAmount: "100.0", // vault shares to redeem
|
|
425
|
-
deadline: Math.floor(Date.now() / 1000) + 3600, // 1 hour
|
|
426
|
-
slippage: 100, // 1%
|
|
427
|
-
});
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
## TypeScript Support
|
|
431
|
-
|
|
432
|
-
Full type definitions with autocomplete:
|
|
433
|
-
|
|
434
|
-
```typescript
|
|
435
|
-
import type {
|
|
436
|
-
AmplifyVault,
|
|
437
|
-
SupportedAsset,
|
|
438
|
-
VaultFilterOptions,
|
|
439
|
-
VaultKey,
|
|
440
|
-
ChainId,
|
|
441
|
-
DepositTransactionData,
|
|
442
|
-
WithdrawTransactionData,
|
|
443
|
-
PrepareDepositTransactionDataParams,
|
|
444
|
-
} from "@paxoslabs/amplify-sdk";
|
|
445
|
-
|
|
446
|
-
// All functions have full TypeScript support
|
|
447
|
-
const depositData: DepositTransactionData = await prepareDepositTransactionData(
|
|
448
|
-
{
|
|
449
|
-
// TypeScript provides autocomplete and validation
|
|
450
|
-
}
|
|
451
|
-
);
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
## Error Handling
|
|
455
|
-
|
|
456
|
-
```typescript
|
|
457
|
-
import { APIError } from "@paxoslabs/amplify-sdk";
|
|
458
|
-
|
|
459
|
-
try {
|
|
460
|
-
const vaults = await fetchVaults({ chainId: 1 });
|
|
461
|
-
} catch (error) {
|
|
462
|
-
if (error instanceof APIError) {
|
|
463
|
-
console.error(`API Error: ${error.message}`);
|
|
464
|
-
console.error(`Endpoint: ${error.context?.endpoint}`);
|
|
465
|
-
console.error(`Status: ${error.context?.status}`);
|
|
466
|
-
} else {
|
|
467
|
-
console.error("Unexpected error:", error);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
## Supported Networks
|
|
473
|
-
|
|
474
|
-
| Network | Chain ID | Status |
|
|
475
|
-
| ---------------- | ---------- | ------ |
|
|
476
|
-
| Ethereum Mainnet | 1 | ✅ |
|
|
477
|
-
| HyperEVM | 999 | ✅ |
|
|
478
|
-
| Boba Network | 288 | ✅ |
|
|
479
|
-
| Sei Network | 713715 | ✅ |
|
|
480
|
-
| Plume Mainnet | 98866 | ✅ |
|
|
481
|
-
| Form Network | 478 | ✅ |
|
|
482
|
-
| Swell Mainnet | 1923 | ✅ |
|
|
483
|
-
| Rari Chain | 1380012617 | ✅ |
|
|
484
|
-
|
|
485
|
-
## Requirements
|
|
486
|
-
|
|
487
|
-
- **Node.js** >= 20
|
|
488
|
-
- **TypeScript** >= 4.9.0 (optional but recommended)
|
|
489
|
-
- **viem** >= 2.0.0 (required)
|
|
490
|
-
- **wagmi** >= 2.0.0 (for React applications)
|
|
491
|
-
- **@tanstack/react-query** >= 5.0.0 (for React applications)
|
|
492
|
-
|
|
493
|
-
## API Configuration
|
|
494
|
-
|
|
495
|
-
The SDK connects to the Amplify API at `http://localhost:8500` by default. This is suitable for development environments. For production deployments, you'll need to configure the API endpoint according to your backend setup.
|
|
496
|
-
|
|
497
|
-
**Note**: All API calls have a 10-second timeout. Network requests that exceed this timeout will throw an `APIError`.
|
|
498
|
-
|
|
499
|
-
## Available Vault Keys
|
|
500
|
-
|
|
501
|
-
```typescript
|
|
502
|
-
import { VaultKeys } from "@paxoslabs/amplify-sdk";
|
|
503
|
-
|
|
504
|
-
console.log(VaultKeys);
|
|
505
|
-
// {
|
|
506
|
-
// OPNALPHA: "op-nALPHA",
|
|
507
|
-
// OPNBASIS: "op-nBASIS",
|
|
508
|
-
// OPNETF: "op-nETF",
|
|
509
|
-
// OPNPAYFI: "op-nPAYFI",
|
|
510
|
-
// OPNPLUME: "op-PLUME",
|
|
511
|
-
// OPNRWA: "op-nRWA",
|
|
512
|
-
// OPNTBILL: "op-nTBILL",
|
|
513
|
-
// OPPUSD: "op-pUSD",
|
|
514
|
-
// XLHYPE: "XLHYPE",
|
|
515
|
-
// CAMPUSD: "campUSD"
|
|
516
|
-
// }
|
|
517
|
-
```
|
|
518
|
-
|
|
519
|
-
## Contributing
|
|
520
|
-
|
|
521
|
-
Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
46
|
+
Full documentation at https://developers.paxoslabs.com/
|
|
522
47
|
|
|
523
48
|
## License
|
|
524
49
|
|
|
525
|
-
|
|
50
|
+
BSD © Paxos Labs
|
|
526
51
|
|
|
527
52
|
---
|
|
528
53
|
|
|
529
54
|
**Need Help?**
|
|
530
55
|
|
|
531
|
-
- 📖 [Full Documentation](./docs/getting-started.
|
|
56
|
+
- 📖 [Full Documentation](./docs/getting-started.mdx)
|
|
532
57
|
- 🐛 [Report Issues](https://github.com/Ion-Protocol/amplify-sdk/issues)
|
|
533
58
|
- 💬 [GitHub Discussions](https://github.com/Ion-Protocol/amplify-sdk/discussions)
|
|
@@ -144,7 +144,7 @@ interface VaultFilterOptions {
|
|
|
144
144
|
/** Filter by yield type */
|
|
145
145
|
yieldType?: YieldType;
|
|
146
146
|
/** Filter by deposit token address */
|
|
147
|
-
depositTokenAddress?:
|
|
147
|
+
depositTokenAddress?: Address;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* Filter options for asset queries
|
|
@@ -144,7 +144,7 @@ interface VaultFilterOptions {
|
|
|
144
144
|
/** Filter by yield type */
|
|
145
145
|
yieldType?: YieldType;
|
|
146
146
|
/** Filter by deposit token address */
|
|
147
|
-
depositTokenAddress?:
|
|
147
|
+
depositTokenAddress?: Address;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* Filter options for asset queries
|
|
@@ -551,7 +551,7 @@ async function findVaultByConfig(params) {
|
|
|
551
551
|
);
|
|
552
552
|
}
|
|
553
553
|
const cache = getCache();
|
|
554
|
-
if (cache.isExpired()) {
|
|
554
|
+
if (cache.isEmpty() || cache.isExpired()) {
|
|
555
555
|
await cache.refresh();
|
|
556
556
|
}
|
|
557
557
|
const normalizedAddress = params.assetAddress.toLowerCase();
|
|
@@ -765,15 +765,9 @@ var CHAIN_ID_TO_CHAIN_MAP = {
|
|
|
765
765
|
// src/utils/chain-utils.ts
|
|
766
766
|
var chainsCache = null;
|
|
767
767
|
async function getChainFromConfig(chainId, config) {
|
|
768
|
-
console.log("[Amplify SDK] getChainFromConfig called for chainId:", chainId);
|
|
769
768
|
if (chainsCache && !config) {
|
|
770
769
|
const chain2 = chainsCache.get(Number(chainId));
|
|
771
770
|
if (chain2) {
|
|
772
|
-
console.log("[Amplify SDK] Returning cached chain:", {
|
|
773
|
-
chainId: chain2.id,
|
|
774
|
-
name: chain2.name,
|
|
775
|
-
hasMulticall3: !!chain2.contracts?.multicall3
|
|
776
|
-
});
|
|
777
771
|
return chain2;
|
|
778
772
|
}
|
|
779
773
|
}
|
|
@@ -782,30 +776,20 @@ async function getChainFromConfig(chainId, config) {
|
|
|
782
776
|
if (!vault) {
|
|
783
777
|
throw new Error(`Vault not found for ID: ${chainId}`);
|
|
784
778
|
}
|
|
785
|
-
const sourceChain = CHAIN_ID_TO_CHAIN_MAP[chainId];
|
|
786
|
-
console.log("[Amplify SDK] Source chain from CHAIN_ID_TO_CHAIN_MAP:", {
|
|
787
|
-
chainId,
|
|
788
|
-
found: !!sourceChain,
|
|
789
|
-
hasMulticall3: !!sourceChain?.contracts?.multicall3,
|
|
790
|
-
multicall3Address: sourceChain?.contracts?.multicall3?.address
|
|
791
|
-
});
|
|
792
779
|
if (config && !chainsCache) {
|
|
793
780
|
const cache = /* @__PURE__ */ new Map();
|
|
794
781
|
for (const v of vaults) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
id: v.chainId,
|
|
799
|
-
name: chainConfig?.name,
|
|
800
|
-
nativeCurrency: chainConfig?.nativeCurrency,
|
|
801
|
-
rpcUrls: chainConfig?.rpcUrls,
|
|
802
|
-
contracts: chainConfig?.contracts
|
|
803
|
-
});
|
|
804
|
-
console.log("[Amplify SDK] Cached chain config:", {
|
|
805
|
-
chainId: v.chainId,
|
|
806
|
-
hasMulticall3: !!chainConfig?.contracts?.multicall3
|
|
807
|
-
});
|
|
782
|
+
const chainConfig = CHAIN_ID_TO_CHAIN_MAP[v.chainId];
|
|
783
|
+
if (!chainConfig) {
|
|
784
|
+
throw new Error(`Chain config not found for ID: ${v.chainId}`);
|
|
808
785
|
}
|
|
786
|
+
cache.set(v.chainId, {
|
|
787
|
+
id: v.chainId,
|
|
788
|
+
name: chainConfig.name,
|
|
789
|
+
nativeCurrency: chainConfig.nativeCurrency,
|
|
790
|
+
rpcUrls: chainConfig.rpcUrls,
|
|
791
|
+
contracts: chainConfig.contracts
|
|
792
|
+
});
|
|
809
793
|
}
|
|
810
794
|
chainsCache = cache;
|
|
811
795
|
}
|
|
@@ -813,12 +797,6 @@ async function getChainFromConfig(chainId, config) {
|
|
|
813
797
|
if (!chain) {
|
|
814
798
|
throw new Error(`Chain not found for ID: ${chainId}`);
|
|
815
799
|
}
|
|
816
|
-
console.log("[Amplify SDK] Returning chain:", {
|
|
817
|
-
chainId: chain.id,
|
|
818
|
-
name: chain.name,
|
|
819
|
-
hasMulticall3: !!chain.contracts?.multicall3,
|
|
820
|
-
multicall3Address: chain.contracts?.multicall3?.address
|
|
821
|
-
});
|
|
822
800
|
return chain;
|
|
823
801
|
}
|
|
824
802
|
function clearChainsCache() {
|
|
@@ -851,5 +829,5 @@ exports.getWithdrawSupportedAssets = getWithdrawSupportedAssets;
|
|
|
851
829
|
exports.initAmplifySDK = initAmplifySDK;
|
|
852
830
|
exports.initializeCache = initializeCache;
|
|
853
831
|
exports.refreshVaultCache = refreshVaultCache;
|
|
854
|
-
//# sourceMappingURL=chunk-
|
|
855
|
-
//# sourceMappingURL=chunk-
|
|
832
|
+
//# sourceMappingURL=chunk-B2QCI6ET.js.map
|
|
833
|
+
//# sourceMappingURL=chunk-B2QCI6ET.js.map
|