@galacticcouncil/sdk 0.0.1-beta.9 → 0.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/README.md +27 -24
- package/dist/index.esm.js +3 -2
- package/dist/index.js +3 -2
- package/dist/types/api/router.d.ts +17 -16
- package/dist/types/api/tradeRouter.d.ts +58 -17
- package/dist/types/client/{capi.d.ts → cApi.d.ts} +0 -0
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/{polkadot.d.ts → polkadotApi.d.ts} +15 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pool/index.d.ts +3 -1
- package/dist/types/pool/lbp/lbpMath.d.ts +13 -0
- package/dist/types/pool/lbp/lbpPolkadotApiClient.d.ts +25 -0
- package/dist/types/pool/lbp/lbpPool.d.ts +43 -0
- package/dist/types/pool/omni/omniMath.d.ts +11 -0
- package/dist/types/pool/omni/omniPolkadotApiClient.d.ts +13 -0
- package/dist/types/pool/omni/omniPool.d.ts +34 -0
- package/dist/types/pool/polkadotApiPoolService.d.ts +17 -0
- package/dist/types/pool/xyk/xykMath.d.ts +2 -0
- package/dist/types/pool/xyk/xykPolkadotApiClient.d.ts +10 -0
- package/dist/types/pool/xyk/xykPool.d.ts +11 -5
- package/dist/types/route/bfs.d.ts +2 -2
- package/dist/types/types.d.ts +67 -31
- package/dist/types/utils/mapper.d.ts +5 -0
- package/dist/types/utils/math.d.ts +24 -7
- package/package.json +5 -3
- package/dist/index.esm.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/types/client/types.d.ts +0 -7
- package/dist/types/pool/polkadotPoolService.d.ts +0 -7
- package/dist/types/pool/xyk/xykPolkadotClient.d.ts +0 -8
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/@galacticcouncil/sdk)
|
|
5
5
|

|
|
6
|
-
[](https://www.codefactor.io/repository/github/galacticcouncil/sdk)
|
|
7
6
|
|
|
8
7
|
</p>
|
|
9
8
|
Galactic SDK is collection of components crafted to ease Basilisk & HydraDX chains integration.
|
|
@@ -27,9 +26,9 @@ Install with [npm](https://www.npmjs.com/):
|
|
|
27
26
|
|
|
28
27
|
## Components
|
|
29
28
|
|
|
30
|
-
###
|
|
29
|
+
### Router
|
|
31
30
|
|
|
32
|
-
Off-chain
|
|
31
|
+
Off-chain routing, build to find the most suitable routes across the the pools. Building block for TradeRouter.
|
|
33
32
|
|
|
34
33
|
#### API
|
|
35
34
|
|
|
@@ -38,6 +37,16 @@ getPools(): PoolBase[]
|
|
|
38
37
|
getAllAssets(): PoolAsset[]
|
|
39
38
|
getAssetPairs(token: string): PoolAsset[]
|
|
40
39
|
getAllPaths(tokenIn: string, tokenOut: string): Hop[][]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### TradeRouter
|
|
43
|
+
|
|
44
|
+
Off-chain optimization of orders across pools for best price execution. TradeRouter does not perform any on-chain transations.
|
|
45
|
+
|
|
46
|
+
#### API
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
getBestSpotPrice(tokenIn: string, tokenOut: string): Amount
|
|
41
50
|
getBestSell(tokenIn: string, tokenOut: string, amountIn: BigNumber | number | string): Trade
|
|
42
51
|
getBestBuy(tokenIn: string, tokenOut: string, amountOut: BigNumber | number | string): Trade
|
|
43
52
|
```
|
|
@@ -49,27 +58,21 @@ For type signature visit [types.ts](src/types.ts)<br />
|
|
|
49
58
|
```typescript
|
|
50
59
|
// Import
|
|
51
60
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
52
|
-
import { TradeRouter,
|
|
61
|
+
import { TradeRouter, PolkadotApiPoolService } from '@galacticcouncil/sdk';
|
|
53
62
|
|
|
54
63
|
// Initialize Polkadot API
|
|
55
64
|
const wsProvider = new WsProvider('wss://rpc.basilisk.cloud');
|
|
56
65
|
const api = await ApiPromise.create({ provider: wsProvider });
|
|
57
66
|
|
|
58
|
-
// Initialize Router
|
|
59
|
-
const poolService = new
|
|
60
|
-
const tradeRouter = new TradeRouter(poolService);
|
|
67
|
+
// Initialize Trade Router
|
|
68
|
+
const poolService = new PolkadotApiPoolService(api);
|
|
69
|
+
const tradeRouter = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
|
|
61
70
|
|
|
62
71
|
// Do something
|
|
63
72
|
const result = await tradeRouter.getAllAssets();
|
|
64
73
|
console.log(result);
|
|
65
74
|
```
|
|
66
75
|
|
|
67
|
-
### TradeExecutor
|
|
68
|
-
|
|
69
|
-
On-chain transaction executor using data from router to perform best possible trade.
|
|
70
|
-
|
|
71
|
-
Not supported yet. 🛠
|
|
72
|
-
|
|
73
76
|
## Examples
|
|
74
77
|
|
|
75
78
|
SDK Examples and testing helpers.
|
|
@@ -88,17 +91,17 @@ Component list and current status ⬇️
|
|
|
88
91
|
- 🛠 Work in progress
|
|
89
92
|
- ⏳ Planning to build
|
|
90
93
|
|
|
91
|
-
| Name
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
| Polkadot
|
|
96
|
-
| Capi
|
|
97
|
-
| XYK
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
94
|
+
| Name | Type | |
|
|
95
|
+
| ----------- | :----: | --: |
|
|
96
|
+
| Router | API | 🧪 |
|
|
97
|
+
| TradeRouter | API | 🧪 |
|
|
98
|
+
| Polkadot | Client | 🧪 |
|
|
99
|
+
| Capi | Client | ⏳ |
|
|
100
|
+
| XYK | Pool | 🧪 |
|
|
101
|
+
| Omni | Pool | 🧪 |
|
|
102
|
+
| LBP | Pool | 🛠 |
|
|
103
|
+
| Stable | Pool | ⏳ |
|
|
101
104
|
|
|
102
105
|
## Issue reporting
|
|
103
106
|
|
|
104
|
-
In case of unexpected sdk behaviour, please create well-written issue [here](https://https://github.com/
|
|
107
|
+
In case of unexpected sdk behaviour, please create well-written issue [here](https://https://github.com/galacticcouncil/sdk/issues/new). It makes it easier to find & fix the problem accordingly.
|