@olympex-io/olympex-sdk 0.1.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/LICENSE +11 -0
- package/README.md +157 -0
- package/dist/index.d.mts +824 -0
- package/dist/index.d.ts +824 -0
- package/dist/index.js +863 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +817 -0
- package/dist/index.mjs.map +1 -0
- package/docs/authentication.md +166 -0
- package/docs/contributing-jsdoc.md +184 -0
- package/docs/errors.md +61 -0
- package/docs/fees.md +64 -0
- package/docs/getting-started.md +107 -0
- package/docs/logging.md +85 -0
- package/docs/methods/README.md +25 -0
- package/docs/methods/create-account.md +62 -0
- package/docs/methods/quote.md +84 -0
- package/docs/methods/swap.md +69 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Olympex
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Olympex SDK
|
|
2
|
+
|
|
3
|
+
> **Server-side SDK — not for direct browser usage.**
|
|
4
|
+
> Run in your backend or BFF with signed API credentials (`apiKey`, `apiSecret`, `passphrase`).
|
|
5
|
+
> Browser clients must proxy through your own server. See [`docs/authentication.md`](./docs/authentication.md).
|
|
6
|
+
|
|
7
|
+
Official TypeScript SDK for Olympex partner integrations — package scope **`@olympex-io/olympex-sdk`**.
|
|
8
|
+
|
|
9
|
+
The SDK is a thin GraphQL/REST client over the Olympex backend. It does not duplicate quote, swap, routing, fee, or cross-chain business logic locally.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @olympex-io/olympex-sdk
|
|
15
|
+
# or
|
|
16
|
+
npm install @olympex-io/olympex-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires **Node.js 22.15.0+** (server-side only). Never bundle `apiSecret` or `passphrase` in browser code.
|
|
20
|
+
|
|
21
|
+
## Quickstart
|
|
22
|
+
|
|
23
|
+
### 1. Bootstrap credentials (once)
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createAccount } from '@olympex-io/olympex-sdk';
|
|
27
|
+
|
|
28
|
+
const { apiKey, secretKey } = await createAccount({
|
|
29
|
+
name: 'My App',
|
|
30
|
+
password: process.env.OLYMPEX_ACCOUNT_PASSWORD!,
|
|
31
|
+
});
|
|
32
|
+
// Persist apiKey, secretKey, and password in your secret store
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
See [`docs/methods/create-account.md`](./docs/methods/create-account.md).
|
|
36
|
+
|
|
37
|
+
### 2. Initialize client
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { initialize } from '@olympex-io/olympex-sdk';
|
|
41
|
+
|
|
42
|
+
const olympex = initialize({
|
|
43
|
+
apiKey: process.env.OLYMPEX_API_KEY!,
|
|
44
|
+
apiSecret: process.env.OLYMPEX_API_SECRET!,
|
|
45
|
+
passphrase: process.env.OLYMPEX_PASSPHRASE!,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Optional defaults for integrator margin:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const olympex = initialize({
|
|
53
|
+
apiKey: process.env.OLYMPEX_API_KEY!,
|
|
54
|
+
apiSecret: process.env.OLYMPEX_API_SECRET!,
|
|
55
|
+
passphrase: process.env.OLYMPEX_PASSPHRASE!,
|
|
56
|
+
defaultFees: {
|
|
57
|
+
feeBps: 15,
|
|
58
|
+
feeRecipient: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. Quote and swap
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const quote = await olympex.quote({
|
|
67
|
+
mode: 'single-chain',
|
|
68
|
+
params: {
|
|
69
|
+
chainId: 1,
|
|
70
|
+
inTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
71
|
+
outTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
72
|
+
amount: '1',
|
|
73
|
+
slippage: '1',
|
|
74
|
+
gasPrice: '30',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const swap = await olympex.swap({
|
|
79
|
+
mode: 'single-chain',
|
|
80
|
+
params: {
|
|
81
|
+
chainId: 1,
|
|
82
|
+
inTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
83
|
+
outTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
84
|
+
amount: '1',
|
|
85
|
+
slippage: '1',
|
|
86
|
+
gasPrice: '30',
|
|
87
|
+
account: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
|
|
88
|
+
aggregatorId: 'olympex',
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Method contracts: [`docs/methods/`](./docs/methods/README.md).
|
|
94
|
+
|
|
95
|
+
## Fees
|
|
96
|
+
|
|
97
|
+
`feeBps` (0–100) + `feeRecipient` are **integrator margin** inputs. The SDK validates and forwards them; the backend resolves your channel from signed auth and applies `platformFeeIntegrator` plus partner policy. See [`docs/fees.md`](./docs/fees.md).
|
|
98
|
+
|
|
99
|
+
## Errors
|
|
100
|
+
|
|
101
|
+
Typed errors extend `OlympexSdkError`:
|
|
102
|
+
|
|
103
|
+
| Class | When |
|
|
104
|
+
| --------------------- | ------------------------------------------- |
|
|
105
|
+
| `OlympexConfigError` | Invalid local input before any network call |
|
|
106
|
+
| `OlympexDomainError` | Backend `success: false` |
|
|
107
|
+
| `OlympexGraphQLError` | GraphQL `errors[]` on HTTP 200 |
|
|
108
|
+
| `OlympexNetworkError` | Timeouts, HTTP failures, auth 401/403 |
|
|
109
|
+
|
|
110
|
+
Full matrix: [`docs/errors.md`](./docs/errors.md).
|
|
111
|
+
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
| Variable | Description | Default |
|
|
115
|
+
| --------------------- | ---------------------------------------------- | ------------------------- |
|
|
116
|
+
| `OLYMPEX_BACKEND_URL` | Backend origin (scheme + host + optional port) | `https://back.olympex.io` |
|
|
117
|
+
|
|
118
|
+
## Documentation
|
|
119
|
+
|
|
120
|
+
| Topic | Doc |
|
|
121
|
+
| --------------- | ------------------------------------------------------ |
|
|
122
|
+
| Getting started | [`docs/getting-started.md`](./docs/getting-started.md) |
|
|
123
|
+
| Authentication | [`docs/authentication.md`](./docs/authentication.md) |
|
|
124
|
+
| Fees | [`docs/fees.md`](./docs/fees.md) |
|
|
125
|
+
| Errors | [`docs/errors.md`](./docs/errors.md) |
|
|
126
|
+
| Methods | [`docs/methods/`](./docs/methods/README.md) |
|
|
127
|
+
| Logging | [`docs/logging.md`](./docs/logging.md) |
|
|
128
|
+
|
|
129
|
+
## Development scripts
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
yarn install --immutable
|
|
133
|
+
yarn typecheck
|
|
134
|
+
yarn lint
|
|
135
|
+
yarn lint:jsdoc
|
|
136
|
+
yarn test
|
|
137
|
+
yarn test:packaging
|
|
138
|
+
yarn test:coverage
|
|
139
|
+
yarn build
|
|
140
|
+
npm pack --dry-run
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Local smoke test
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
OLYMPEX_API_KEY=... OLYMPEX_API_SECRET=... OLYMPEX_PASSPHRASE=... yarn debugging
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Uses `scripts/sdk-instance.ts` — see [`docs/authentication.md`](./docs/authentication.md).
|
|
150
|
+
|
|
151
|
+
## Release
|
|
152
|
+
|
|
153
|
+
See [RELEASE.md](./RELEASE.md) for Changesets workflow, Trusted Publishing (OIDC), and pre-release checks.
|
|
154
|
+
|
|
155
|
+
## SemVer
|
|
156
|
+
|
|
157
|
+
Public API follows SemVer from `0.1.0` onward. Pre-1.0 minors may include breaking changes — review changelog entries on each upgrade.
|