@galacticcouncil/sdk 0.0.1-beta.3 → 0.0.1-beta.6
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/README.md +34 -29
- package/dist/index.esm.js +2127 -1
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/{trader.d.ts → trade/executor.d.ts} +0 -0
- package/dist/types/api/{router.d.ts → trade/router.d.ts} +3 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/pool/xyk/{math/bundler.d.ts → xykMath.d.ts} +0 -0
- package/package.json +3 -3
- package/wasm-loader.ts +39 -0
- package/dist/hydra_dx_wasm_bg-ZX7K4FM7.wasm +0 -0
- package/dist/types/pool/xyk/math/nodejs.d.ts +0 -9
package/README.md
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
<h1><code>Galactic SDK</code></h1>
|
|
2
|
+
<p>
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/@galacticcouncil/sdk)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
[](https://www.npmjs.com/package/@galacticcouncil/sdk)
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
</p>
|
|
2
11
|
Galactic SDK is collection of components crafted to ease Basilisk & HydraDX chains integration.
|
|
3
12
|
<br />
|
|
4
13
|
<br />
|
|
5
14
|
Table of content:
|
|
6
15
|
|
|
16
|
+
- [Installation](#installation)
|
|
7
17
|
- [Components](#components)
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
18
|
+
- [TradeRouter](#traderouter)
|
|
19
|
+
- [TradeExecutor](#tradeexecutor)
|
|
10
20
|
- [Examples](#examples)
|
|
11
|
-
- [Packaging](#packaging)
|
|
12
21
|
- [Roadmap](#roadmap)
|
|
13
22
|
- [Issue reporting](#issue-reporting)
|
|
14
23
|
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Install with [npm](https://www.npmjs.com/):
|
|
27
|
+
|
|
28
|
+
`npm install @galacticcouncil/sdk`
|
|
29
|
+
|
|
15
30
|
## Components
|
|
16
31
|
|
|
17
|
-
###
|
|
32
|
+
### TradeRouter
|
|
18
33
|
|
|
19
34
|
Off-chain optimization of orders across pools for best price execution. Router does not perform any on-chain transations.
|
|
20
35
|
|
|
@@ -30,15 +45,13 @@ getBestBuyPrice(tokenIn: string, tokenOut: string, amountOut: BigNumber): Swap[]
|
|
|
30
45
|
```
|
|
31
46
|
|
|
32
47
|
For type signature visit [types.ts](src/types.ts)<br />
|
|
33
|
-
**Note:** All amount args are formatted as bignumber 1^12!!!
|
|
34
48
|
|
|
35
49
|
#### Usage
|
|
36
50
|
|
|
37
51
|
```typescript
|
|
38
52
|
// Import
|
|
39
53
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
40
|
-
import { PolkadotPoolService } from '@
|
|
41
|
-
import { Router } from '@galactic/api';
|
|
54
|
+
import { TradeRouter, PolkadotPoolService } from '@galacticcouncil/sdk';
|
|
42
55
|
|
|
43
56
|
// Initialize Polkadot API
|
|
44
57
|
const wsProvider = new WsProvider('wss://rpc.basilisk.cloud');
|
|
@@ -46,14 +59,14 @@ const api = await ApiPromise.create({ provider: wsProvider });
|
|
|
46
59
|
|
|
47
60
|
// Initialize Router
|
|
48
61
|
const poolService = new PolkadotPoolService(api);
|
|
49
|
-
const
|
|
62
|
+
const tradeRouter = new TradeRouter(poolService);
|
|
50
63
|
|
|
51
64
|
// Do something
|
|
52
|
-
const result = await
|
|
65
|
+
const result = await tradeRouter.getAllAssets();
|
|
53
66
|
console.log(result);
|
|
54
67
|
```
|
|
55
68
|
|
|
56
|
-
###
|
|
69
|
+
### TradeExecutor
|
|
57
70
|
|
|
58
71
|
On-chain transaction executor using data from router to perform best possible trade.
|
|
59
72
|
|
|
@@ -65,18 +78,10 @@ SDK Examples and testing helpers.
|
|
|
65
78
|
|
|
66
79
|
### Run
|
|
67
80
|
|
|
68
|
-
Run: `$ npx tsx ./test/script/examples
|
|
81
|
+
Run: `$ npx tsx ./test/script/examples/<examplePackage>/<exampleName>.ts` with valid example package & name.
|
|
69
82
|
|
|
70
83
|
To demonstrate full working examples on real chain see [script](test/script/examples) section.
|
|
71
84
|
|
|
72
|
-
## Packaging
|
|
73
|
-
|
|
74
|
-
- api - Router & Trader impl
|
|
75
|
-
- client - Substrate chain based clients
|
|
76
|
-
- pool - Pool specific logic, math, clients
|
|
77
|
-
- suggester - Route proposing, graph utils, BFS, DFS
|
|
78
|
-
- utils - bignumber, math, collections
|
|
79
|
-
|
|
80
85
|
## Roadmap
|
|
81
86
|
|
|
82
87
|
Component list and current status ⬇️
|
|
@@ -85,16 +90,16 @@ Component list and current status ⬇️
|
|
|
85
90
|
- 🛠 Work in progress
|
|
86
91
|
- ⏳ Planning to build
|
|
87
92
|
|
|
88
|
-
| Name
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
| Polkadot
|
|
93
|
-
| Capi
|
|
94
|
-
| XYK
|
|
95
|
-
| LBP
|
|
96
|
-
| Stable
|
|
97
|
-
| Omni
|
|
93
|
+
| Name | Type | |
|
|
94
|
+
| ------------- | :----: | --: |
|
|
95
|
+
| TradeRouter | API | 🧪 |
|
|
96
|
+
| TradeExecutor | API | 🛠 |
|
|
97
|
+
| Polkadot | Client | 🧪 |
|
|
98
|
+
| Capi | Client | ⏳ |
|
|
99
|
+
| XYK | Pool | 🧪 |
|
|
100
|
+
| LBP | Pool | ⏳ |
|
|
101
|
+
| Stable | Pool | ⏳ |
|
|
102
|
+
| Omni | Pool | ⏳ |
|
|
98
103
|
|
|
99
104
|
## Issue reporting
|
|
100
105
|
|