@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.
- package/LICENSE +1 -1
- package/README.md +113 -91
- package/dist/index.d.mts +3081 -759
- package/dist/index.d.ts +3081 -759
- package/dist/index.js +14775 -186
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14834 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -86
- package/CHANGELOG.md +0 -320
- package/dist/chain-utils-5r2UnCDS.d.mts +0 -380
- package/dist/chain-utils-5r2UnCDS.d.ts +0 -380
- package/dist/chunk-4NQPS3JC.js +0 -2101
- package/dist/chunk-4NQPS3JC.js.map +0 -1
- package/dist/chunk-6CU533DM.mjs +0 -39
- package/dist/chunk-6CU533DM.mjs.map +0 -1
- package/dist/chunk-6JLKHV6O.js +0 -128
- package/dist/chunk-6JLKHV6O.js.map +0 -1
- package/dist/chunk-FHE43NKY.js +0 -1143
- package/dist/chunk-FHE43NKY.js.map +0 -1
- package/dist/chunk-GOJQYEJQ.js +0 -3212
- package/dist/chunk-GOJQYEJQ.js.map +0 -1
- package/dist/chunk-LMNADWTH.mjs +0 -2073
- package/dist/chunk-LMNADWTH.mjs.map +0 -1
- package/dist/chunk-ODXJYXUH.mjs +0 -3168
- package/dist/chunk-ODXJYXUH.mjs.map +0 -1
- package/dist/chunk-QMFYPHX5.mjs +0 -690
- package/dist/chunk-QMFYPHX5.mjs.map +0 -1
- package/dist/chunk-TNL23CO2.js +0 -45
- package/dist/chunk-TNL23CO2.js.map +0 -1
- package/dist/chunk-UY2WD7MF.mjs +0 -1133
- package/dist/chunk-UY2WD7MF.mjs.map +0 -1
- package/dist/chunk-WD6QFSXZ.js +0 -701
- package/dist/chunk-WD6QFSXZ.js.map +0 -1
- package/dist/chunk-Y5LBT2WT.mjs +0 -118
- package/dist/chunk-Y5LBT2WT.mjs.map +0 -1
- package/dist/core.d.mts +0 -195
- package/dist/core.d.ts +0 -195
- package/dist/core.js +0 -1236
- package/dist/core.js.map +0 -1
- package/dist/core.mjs +0 -1194
- package/dist/core.mjs.map +0 -1
- package/dist/display.d.mts +0 -472
- package/dist/display.d.ts +0 -472
- package/dist/display.js +0 -52
- package/dist/display.js.map +0 -1
- package/dist/display.mjs +0 -7
- package/dist/display.mjs.map +0 -1
- package/dist/index-D8RtV9cB.d.mts +0 -5114
- package/dist/index-ev_V5sjt.d.ts +0 -5114
- package/dist/utils.d.mts +0 -112
- package/dist/utils.d.ts +0 -112
- package/dist/utils.js +0 -67
- package/dist/utils.js.map +0 -1
- package/dist/utils.mjs +0 -25
- package/dist/utils.mjs.map +0 -1
- package/dist/vaults.d.mts +0 -4
- package/dist/vaults.d.ts +0 -4
- package/dist/vaults.js +0 -96
- package/dist/vaults.js.map +0 -1
- package/dist/vaults.mjs +0 -7
- 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
|
-
|
|
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)
|
|
13
11
|
|
|
14
|
-
[
|
|
15
|
-
[](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
|
-
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
35
|
-
yarn add @paxoslabs/amplify-sdk viem
|
|
41
|
+
## Quickstart
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
```ts
|
|
44
|
+
import { AmplifyClient } from '@paxoslabs/amplify-sdk'
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
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
|
-
##
|
|
127
|
+
## Types
|
|
106
128
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
## License
|
|
129
|
+
Generated request and response types are available under the `Amplify` namespace:
|
|
110
130
|
|
|
111
|
-
|
|
131
|
+
```ts
|
|
132
|
+
import { Amplify } from '@paxoslabs/amplify-sdk'
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
const request: Amplify.PrepareDepositRequest = {
|
|
135
|
+
/* ... */
|
|
136
|
+
}
|
|
137
|
+
```
|
|
114
138
|
|
|
115
|
-
|
|
139
|
+
## License
|
|
116
140
|
|
|
117
|
-
-
|
|
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
|