@paxoslabs/amplify-sdk 0.5.3 → 1.0.1

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.
Files changed (62) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +113 -91
  3. package/dist/index.d.mts +3081 -759
  4. package/dist/index.d.ts +3081 -759
  5. package/dist/index.js +14775 -186
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +14834 -6
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +25 -86
  10. package/CHANGELOG.md +0 -320
  11. package/dist/chain-utils-5r2UnCDS.d.mts +0 -380
  12. package/dist/chain-utils-5r2UnCDS.d.ts +0 -380
  13. package/dist/chunk-4NQPS3JC.js +0 -2101
  14. package/dist/chunk-4NQPS3JC.js.map +0 -1
  15. package/dist/chunk-6CU533DM.mjs +0 -39
  16. package/dist/chunk-6CU533DM.mjs.map +0 -1
  17. package/dist/chunk-6JLKHV6O.js +0 -128
  18. package/dist/chunk-6JLKHV6O.js.map +0 -1
  19. package/dist/chunk-FHE43NKY.js +0 -1143
  20. package/dist/chunk-FHE43NKY.js.map +0 -1
  21. package/dist/chunk-GOJQYEJQ.js +0 -3212
  22. package/dist/chunk-GOJQYEJQ.js.map +0 -1
  23. package/dist/chunk-LMNADWTH.mjs +0 -2073
  24. package/dist/chunk-LMNADWTH.mjs.map +0 -1
  25. package/dist/chunk-ODXJYXUH.mjs +0 -3168
  26. package/dist/chunk-ODXJYXUH.mjs.map +0 -1
  27. package/dist/chunk-QMFYPHX5.mjs +0 -690
  28. package/dist/chunk-QMFYPHX5.mjs.map +0 -1
  29. package/dist/chunk-TNL23CO2.js +0 -45
  30. package/dist/chunk-TNL23CO2.js.map +0 -1
  31. package/dist/chunk-UY2WD7MF.mjs +0 -1133
  32. package/dist/chunk-UY2WD7MF.mjs.map +0 -1
  33. package/dist/chunk-WD6QFSXZ.js +0 -701
  34. package/dist/chunk-WD6QFSXZ.js.map +0 -1
  35. package/dist/chunk-Y5LBT2WT.mjs +0 -118
  36. package/dist/chunk-Y5LBT2WT.mjs.map +0 -1
  37. package/dist/core.d.mts +0 -195
  38. package/dist/core.d.ts +0 -195
  39. package/dist/core.js +0 -1236
  40. package/dist/core.js.map +0 -1
  41. package/dist/core.mjs +0 -1194
  42. package/dist/core.mjs.map +0 -1
  43. package/dist/display.d.mts +0 -472
  44. package/dist/display.d.ts +0 -472
  45. package/dist/display.js +0 -52
  46. package/dist/display.js.map +0 -1
  47. package/dist/display.mjs +0 -7
  48. package/dist/display.mjs.map +0 -1
  49. package/dist/index-D8RtV9cB.d.mts +0 -5114
  50. package/dist/index-ev_V5sjt.d.ts +0 -5114
  51. package/dist/utils.d.mts +0 -112
  52. package/dist/utils.d.ts +0 -112
  53. package/dist/utils.js +0 -67
  54. package/dist/utils.js.map +0 -1
  55. package/dist/utils.mjs +0 -25
  56. package/dist/utils.mjs.map +0 -1
  57. package/dist/vaults.d.mts +0 -4
  58. package/dist/vaults.d.ts +0 -4
  59. package/dist/vaults.js +0 -96
  60. package/dist/vaults.js.map +0 -1
  61. package/dist/vaults.mjs +0 -7
  62. package/dist/vaults.mjs.map +0 -1
package/LICENSE CHANGED
@@ -25,4 +25,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
25
  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
26
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
27
  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,119 +1,141 @@
1
- ```
2
- _____ .__ .__ _____ _________________ ____ __.
3
- / _ \ _____ ______ | | |__|/ ____\__.__. / _____/\______ \ | |/ _|
4
- / /_\ \ / \\____ \| | | \ __< | | \_____ \ | | \| <
5
- / | \ Y Y \ |_> > |_| || | \___ | / \ | ` \ | \
6
- \____|__ /__|_| / __/|____/__||__| / ____| /_______ //_______ /____|__ \
7
- \/ \/|__| \/ \/ \/ \/
8
- ```
1
+ <div align="center">
9
2
 
10
3
  # Paxos Labs Amplify SDK
11
4
 
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.
5
+ **Official TypeScript SDK for the Paxos Labs Amplify API** vault discovery, deposits, withdrawals, and user positions.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@paxoslabs/amplify-sdk.svg?color=2ea043&label=npm)](https://www.npmjs.com/package/@paxoslabs/amplify-sdk)
8
+ [![npm downloads](https://img.shields.io/npm/dm/@paxoslabs/amplify-sdk.svg?color=2ea043)](https://www.npmjs.com/package/@paxoslabs/amplify-sdk)
9
+ [![types](https://img.shields.io/npm/types/@paxoslabs/amplify-sdk.svg?color=3178c6)](https://www.typescriptlang.org)
10
+ [![license](https://img.shields.io/npm/l/@paxoslabs/amplify-sdk.svg?color=blue)](./LICENSE)
13
11
 
14
- [![npm version](https://img.shields.io/npm/v/@paxoslabs/amplify-sdk.svg)](https://www.npmjs.com/package/@paxoslabs/amplify-sdk)
15
- [![License: BSD 3-Clause](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
12
+ [Documentation](https://developers.paxoslabs.com) · [API Reference](https://developers.paxoslabs.com) · [Changelog](./CHANGELOG.md)
16
13
 
17
- ## Features
14
+ </div>
15
+
16
+ ---
18
17
 
19
- - **Vault Discovery** - Query available vaults and supported assets via API
20
- - **Deposits** - Deposit assets into vaults with slippage protection
21
- - **Withdrawals** - Withdraw assets from vaults with deadline protection
22
- - **Permit Deposits** - Gas-optimized deposits using EIP-2612 permit signatures
23
- - **Cache Management** - Optimize API calls with built-in caching
24
- - **Multi-Chain Support** - Seamless operations across 7+ blockchain networks
25
- - **Full TypeScript Support** - Complete type definitions and autocomplete
26
- - **React Ready** - Works with viem (vanilla) and wagmi (React hooks)
18
+ Generated from the Amplify OpenAPI specification, so every method, type, and error is fully typed and stays in lockstep with the API.
19
+
20
+ ## Table of contents
21
+
22
+ - [Installation](#installation)
23
+ - [Quickstart](#quickstart)
24
+ - [Configuration](#configuration)
25
+ - [Resources](#resources)
26
+ - [Error handling](#error-handling)
27
+ - [Types](#types)
28
+ - [License](#license)
27
29
 
28
30
  ## Installation
29
31
 
30
32
  ```bash
31
- # npm
32
- npm install @paxoslabs/amplify-sdk viem
33
+ npm install @paxoslabs/amplify-sdk
34
+ # pnpm add @paxoslabs/amplify-sdk
35
+ # yarn add @paxoslabs/amplify-sdk
36
+ # bun add @paxoslabs/amplify-sdk
37
+ ```
38
+
39
+ > Requires Node.js **>= 24**.
33
40
 
34
- # yarn
35
- yarn add @paxoslabs/amplify-sdk viem
41
+ ## Quickstart
36
42
 
37
- # pnpm
38
- pnpm add @paxoslabs/amplify-sdk viem
43
+ ```ts
44
+ import { AmplifyClient } from '@paxoslabs/amplify-sdk'
39
45
 
40
- # For React apps, also install wagmi
41
- pnpm add wagmi @tanstack/react-query
46
+ const client = new AmplifyClient({ apiKey: process.env.PAXOS_LABS_API_KEY! })
47
+
48
+ const { vaults } = await client.vaults.list({ filter: 'chainId=1' })
49
+ ```
50
+
51
+ The API key is sent as the `x-api-key` header and authenticates every request.
52
+
53
+ > [!IMPORTANT]
54
+ > **Keep your API key server-side.** It must never ship to the browser. Call the SDK from a backend (Route Handler, Server Action, or API server), return the prepared transaction payload, and sign it client-side with the user's wallet.
55
+
56
+ ## Configuration
57
+
58
+ ```ts
59
+ interface AmplifyClientOptions {
60
+ /** API key (required). Sent as the `x-api-key` header on every request. */
61
+ apiKey: string
62
+ /** Environment override. Defaults to production. */
63
+ environment?: string
64
+ /** Base URL override. Takes precedence over `environment`. */
65
+ baseUrl?: string
66
+ }
42
67
  ```
43
68
 
44
- ## Quick Start
45
-
46
- ```typescript
47
- import {
48
- initAmplifySDK,
49
- prepareDepositAuthorization,
50
- prepareDeposit,
51
- DepositAuthMethod,
52
- } from '@paxoslabs/amplify-sdk'
53
-
54
- // Initialize SDK with your API key
55
- await initAmplifySDK('pxl_your_api_key')
56
-
57
- // Or initialize with custom RPC URLs for better reliability
58
- await initAmplifySDK('pxl_your_api_key', {
59
- rpcUrls: {
60
- 1: 'https://my-eth-rpc.com', // Ethereum
61
- 999: 'https://my-hyperEVM-rpc.com', // HyperEVM
62
- },
69
+ The client targets the production API by default; pass `environment` or `baseUrl` only for non-production use.
70
+
71
+ ## Resources
72
+
73
+ Each API area is exposed as a subclient on the `AmplifyClient` instance.
74
+
75
+ | Accessor | Purpose |
76
+ | :--- | :--- |
77
+ | `client.vaults` | List vaults and assets; fetch APYs, TVLs, compositions, supply caps, and liquidity shortfalls |
78
+ | `client.deposit` | Prepare deposit transactions |
79
+ | `client.smartDeposits` | Create a smart deposit address for a user |
80
+ | `client.withdraw` | Prepare and cancel withdrawals; calculate fees; list requests and volumes |
81
+ | `client.users` | Fetch user positions |
82
+ | `client.permit` | ERC-20 permit / authorization detection |
83
+
84
+ ### Example: prepare a deposit
85
+
86
+ ```ts
87
+ const prepared = await client.deposit.prepareDeposit({
88
+ vaultAddress,
89
+ depositAsset,
90
+ depositAmount,
91
+ userAddress,
92
+ chainId,
63
93
  })
64
94
 
65
- // Prepare deposit authorization (auto-detects permit vs approval)
66
- const auth = await prepareDepositAuthorization({
67
- yieldType: 'CORE',
68
- depositAsset: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
69
- depositAmount: '1000.0',
70
- to: userAddress,
71
- chainId: 1,
95
+ // prepared.transaction { to, data, value }
96
+ // Sign and broadcast it with the user's wallet (viem / wagmi / Privy / Dynamic).
97
+ ```
98
+
99
+ ### Example: create a smart deposit address
100
+
101
+ ```ts
102
+ const { smartDepositAddress } = await client.smartDeposits.getAddress({
103
+ userDestinationAddress,
104
+ vaultAddress,
105
+ inputToken,
106
+ chainId,
72
107
  })
108
+ ```
73
109
 
74
- // Shared deposit parameters
75
- const depositParams = {
76
- yieldType: 'CORE',
77
- depositAsset: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
78
- depositAmount: '1000.0',
79
- to: userAddress,
80
- chainId: 1,
81
- }
110
+ ## Error handling
82
111
 
83
- // Handle based on authorization method
84
- if (auth.method === DepositAuthMethod.PERMIT) {
85
- // Token supports EIP-2612: sign permit and deposit in one transaction
86
- const signature = await signTypedData(auth.permitData)
87
- const tx = await prepareDeposit({
88
- ...depositParams,
89
- signature,
90
- deadline: auth.permitData.message.deadline,
91
- })
92
- await writeContract(tx.txData)
93
- } else if (auth.method === DepositAuthMethod.APPROVAL) {
94
- // Token requires ERC20 approval: approve first, then deposit
95
- await writeContract(auth.txData)
96
- const tx = await prepareDeposit(depositParams)
97
- await writeContract(tx.txData)
98
- } else if (auth.method === DepositAuthMethod.ALREADY_APPROVED) {
99
- // Sufficient allowance exists: proceed directly to deposit
100
- const tx = await prepareDeposit(depositParams)
101
- await writeContract(tx.txData)
112
+ Requests reject with `AmplifyError` (carrying `statusCode` and `message`); requests that exceed the timeout reject with `AmplifyTimeoutError`.
113
+
114
+ ```ts
115
+ import { AmplifyError } from '@paxoslabs/amplify-sdk'
116
+
117
+ try {
118
+ await client.deposit.prepareDeposit(request)
119
+ } catch (err) {
120
+ if (err instanceof AmplifyError) {
121
+ console.error(err.statusCode, err.message)
122
+ }
123
+ throw err
102
124
  }
103
125
  ```
104
126
 
105
- ## Documentation
127
+ ## Types
106
128
 
107
- Full documentation at https://developers.paxoslabs.com/
108
-
109
- ## License
129
+ Generated request and response types are available under the `Amplify` namespace:
110
130
 
111
- BSD © Paxos Labs
131
+ ```ts
132
+ import { Amplify } from '@paxoslabs/amplify-sdk'
112
133
 
113
- ---
134
+ const request: Amplify.PrepareDepositRequest = {
135
+ /* ... */
136
+ }
137
+ ```
114
138
 
115
- **Need Help?**
139
+ ## License
116
140
 
117
- - 📖 [Full Documentation](./docs/getting-started.mdx)
118
- - 🐛 [Report Issues](https://github.com/Ion-Protocol/amplify-sdk/issues)
119
- - 💬 [GitHub Discussions](https://github.com/Ion-Protocol/amplify-sdk/discussions)
141
+ [BSD-3-Clause](./LICENSE) © Paxos Labs