@galacticcouncil/sdk 0.0.1-beta.2 → 0.0.1-beta.20
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 +105 -0
- package/dist/index.esm.js +4 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +7 -0
- package/dist/types/api/index.d.ts +2 -0
- package/dist/types/api/router.d.ts +102 -0
- package/dist/types/api/tradeRouter.d.ts +85 -0
- package/{types/api/trader.d.ts → dist/types/client/cApi.d.ts} +0 -0
- package/dist/types/client/index.d.ts +1 -0
- package/{types/client/polkadot.d.ts → dist/types/client/polkadotApi.d.ts} +15 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/pool/index.d.ts +5 -0
- 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 +9 -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/{types → dist/types}/pool/poolFactory.d.ts +0 -0
- package/{types/pool/xyk/math/bundler.d.ts → 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 +22 -0
- package/{types/suggester → dist/types/route}/bfs.d.ts +2 -2
- package/{types/suggester → dist/types/route}/graph.d.ts +0 -0
- package/{types/suggester → dist/types/route}/index.d.ts +0 -0
- package/{types/suggester → dist/types/route}/suggester.d.ts +0 -0
- package/dist/types/types.d.ts +117 -0
- package/{types → dist/types}/utils/bignumber.d.ts +0 -0
- package/dist/types/utils/mapper.d.ts +5 -0
- package/dist/types/utils/math.d.ts +33 -0
- package/{types → dist/types}/utils/queue.d.ts +0 -0
- package/{types → dist/types}/utils/stack.d.ts +0 -0
- package/{types → dist/types}/utils/traversal/bfs.d.ts +0 -0
- package/package.json +8 -7
- package/cjs/hydra_dx_wasm_bg-ZX7K4FM7.wasm +0 -0
- package/cjs/index.js +0 -2
- package/cjs/index.js.map +0 -7
- package/esm/hydra_dx_wasm_bg-ZX7K4FM7.wasm +0 -0
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -7
- package/types/api/index.d.ts +0 -1
- package/types/api/router.d.ts +0 -129
- package/types/client/capi.d.ts +0 -0
- package/types/client/index.d.ts +0 -1
- package/types/client/types.d.ts +0 -7
- package/types/index.d.ts +0 -4
- package/types/pool/index.d.ts +0 -3
- package/types/pool/polkadotPoolService.d.ts +0 -7
- package/types/pool/xyk/math/nodejs.d.ts +0 -9
- package/types/pool/xyk/xykPolkadotClient.d.ts +0 -8
- package/types/pool/xyk/xykPool.d.ts +0 -16
- package/types/types.d.ts +0 -55
- package/types/utils/math.d.ts +0 -4
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<h1><code>Galactic SDK</code></h1>
|
|
2
|
+
<p>
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/@galacticcouncil/sdk)
|
|
5
|
+

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