@paxoslabs/amplify-sdk 1.0.0 → 1.0.2
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/LICENSE +28 -0
- package/README.md +145 -0
- package/dist/index.d.mts +280 -306
- package/dist/index.d.ts +280 -306
- package/dist/index.js +554 -518
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +554 -518
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, PaxosLabs
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Paxos Labs Amplify SDK
|
|
4
|
+
|
|
5
|
+
**Official TypeScript SDK for the Paxos Labs Amplify API** — vault discovery, deposits, withdrawals, and user positions.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@paxoslabs/amplify-sdk)
|
|
8
|
+
[](https://www.npmjs.com/package/@paxoslabs/amplify-sdk)
|
|
9
|
+
[](https://www.typescriptlang.org)
|
|
10
|
+
[](./LICENSE)
|
|
11
|
+
|
|
12
|
+
[Documentation](https://developers.paxoslabs.com) · [API Reference](https://developers.paxoslabs.com) · [Changelog](./CHANGELOG.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
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)
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
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**.
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { AmplifyClient } from '@paxoslabs/amplify-sdk'
|
|
45
|
+
|
|
46
|
+
const client = new AmplifyClient({ apiKey: process.env.PAXOS_LABS_API_KEY! })
|
|
47
|
+
|
|
48
|
+
const { vaults } = await client.amplify.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
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
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.amplify.vaults` | List vaults and assets; fetch APYs, TVLs, compositions, supply caps, and liquidity shortfalls |
|
|
78
|
+
| `client.amplify.deposit` | Prepare deposit transactions |
|
|
79
|
+
| `client.amplify.smartDeposits` | Create a smart deposit address for a user |
|
|
80
|
+
| `client.amplify.withdraw` | Prepare (`prepare`) and cancel (`cancel`) withdrawals; calculate fees (`calculateFee`); list requests (`listRequests`) and volumes (`getVolumes`) |
|
|
81
|
+
| `client.amplify.users` | Fetch user positions |
|
|
82
|
+
| `client.core.authorization` | Detect (`detect`) token authorization requirements (permit, approval, or already approved) |
|
|
83
|
+
|
|
84
|
+
### Example: prepare a deposit
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const prepared = await client.amplify.deposit.prepare({
|
|
88
|
+
vaultAddress,
|
|
89
|
+
depositAsset,
|
|
90
|
+
depositAmount,
|
|
91
|
+
userAddress,
|
|
92
|
+
chainId,
|
|
93
|
+
})
|
|
94
|
+
|
|
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.amplify.smartDeposits.getAddress({
|
|
103
|
+
userDestinationAddress,
|
|
104
|
+
vaultAddress,
|
|
105
|
+
inputToken,
|
|
106
|
+
chainId,
|
|
107
|
+
})
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Error handling
|
|
111
|
+
|
|
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.amplify.deposit.prepare(request)
|
|
119
|
+
} catch (err) {
|
|
120
|
+
if (err instanceof AmplifyError) {
|
|
121
|
+
console.error(err.statusCode, err.message)
|
|
122
|
+
}
|
|
123
|
+
throw err
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Types
|
|
128
|
+
|
|
129
|
+
Generated types are available under the `Amplify` namespace:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { Amplify } from '@paxoslabs/amplify-sdk'
|
|
133
|
+
|
|
134
|
+
// Response types are at the top level
|
|
135
|
+
type DepositResponse = Amplify.PrepareDepositResponseDto
|
|
136
|
+
type AuthResponse = Amplify.AuthorizationResponseDto
|
|
137
|
+
|
|
138
|
+
// Request types are nested under resource namespaces
|
|
139
|
+
type DepositRequest = Amplify.amplify.deposit.PrepareDepositRequest
|
|
140
|
+
type AuthRequest = Amplify.core.authorization.DetectAuthorizationRequest
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
[BSD-3-Clause](./LICENSE) © Paxos Labs
|