@galacticcouncil/sdk 0.0.1-beta.8 → 0.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.
Files changed (36) hide show
  1. package/README.md +23 -27
  2. package/dist/index.esm.js +3 -2
  3. package/dist/index.js +3 -2
  4. package/dist/types/api/index.d.ts +2 -1
  5. package/dist/types/api/router.d.ts +102 -0
  6. package/dist/types/api/tradeRouter.d.ts +85 -0
  7. package/dist/types/{api/trade/executor.d.ts → client/cApi.d.ts} +0 -0
  8. package/dist/types/client/index.d.ts +1 -1
  9. package/dist/types/client/{polkadot.d.ts → polkadotApi.d.ts} +15 -1
  10. package/dist/types/index.d.ts +2 -2
  11. package/dist/types/pool/index.d.ts +3 -1
  12. package/dist/types/pool/lbp/lbpMath.d.ts +13 -0
  13. package/dist/types/pool/lbp/lbpPolkadotApiClient.d.ts +25 -0
  14. package/dist/types/pool/lbp/lbpPool.d.ts +43 -0
  15. package/dist/types/pool/omni/omniMath.d.ts +11 -0
  16. package/dist/types/pool/omni/omniPolkadotApiClient.d.ts +13 -0
  17. package/dist/types/pool/omni/omniPool.d.ts +34 -0
  18. package/dist/types/pool/polkadotApiPoolService.d.ts +17 -0
  19. package/dist/types/pool/xyk/xykMath.d.ts +2 -0
  20. package/dist/types/pool/xyk/xykPolkadotApiClient.d.ts +10 -0
  21. package/dist/types/pool/xyk/xykPool.d.ts +11 -5
  22. package/dist/types/{suggester → route}/bfs.d.ts +2 -2
  23. package/dist/types/{suggester → route}/graph.d.ts +0 -0
  24. package/dist/types/{suggester → route}/index.d.ts +0 -0
  25. package/dist/types/{suggester → route}/suggester.d.ts +0 -0
  26. package/dist/types/types.d.ts +84 -22
  27. package/dist/types/utils/mapper.d.ts +5 -0
  28. package/dist/types/utils/math.d.ts +32 -3
  29. package/package.json +5 -3
  30. package/dist/index.esm.js.map +0 -7
  31. package/dist/index.js.map +0 -7
  32. package/dist/types/api/trade/router.d.ts +0 -129
  33. package/dist/types/client/capi.d.ts +0 -0
  34. package/dist/types/client/types.d.ts +0 -7
  35. package/dist/types/pool/polkadotPoolService.d.ts +0 -7
  36. package/dist/types/pool/xyk/xykPolkadotClient.d.ts +0 -8
package/README.md CHANGED
@@ -3,9 +3,6 @@
3
3
 
4
4
  [![npm version](https://img.shields.io/npm/v/@galacticcouncil/sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/sdk)
5
5
  ![Coverage](./badges/coverage-jest%20coverage.svg)
6
- ![npm bundle size](https://img.shields.io/bundlephobia/min/sdk)
7
- [![npm downloads](https://img.shields.io/npm/dw/@galacticcouncil/sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/sdk)
8
- ![Last commit](https://img.shields.io/github/last-commit/galacticcouncil/sdk?logo=git)
9
6
 
10
7
  </p>
11
8
  Galactic SDK is collection of components crafted to ease Basilisk & HydraDX chains integration.
@@ -29,9 +26,13 @@ Install with [npm](https://www.npmjs.com/):
29
26
 
30
27
  ## Components
31
28
 
29
+ ## Router
30
+
31
+ Off-chain routing, build to find the all possible trading routes across the the pools. Building block for TradeRouter.
32
+
32
33
  ### TradeRouter
33
34
 
34
- Off-chain optimization of orders across pools for best price execution. Router does not perform any on-chain transations.
35
+ Off-chain optimization of orders across pools for best price execution. TradeRouter does not perform any on-chain transations.
35
36
 
36
37
  #### API
37
38
 
@@ -40,8 +41,9 @@ getPools(): PoolBase[]
40
41
  getAllAssets(): PoolAsset[]
41
42
  getAssetPairs(token: string): PoolAsset[]
42
43
  getAllPaths(tokenIn: string, tokenOut: string): Hop[][]
43
- getBestSellPrice(tokenIn: string, tokenOut: string, amountIn: BigNumber): Swap[]
44
- getBestBuyPrice(tokenIn: string, tokenOut: string, amountOut: BigNumber): Swap[]
44
+ getBestSpotPrice(tokenIn: string, tokenOut: string): Amount
45
+ getBestSell(tokenIn: string, tokenOut: string, amountIn: BigNumber | number | string): Trade
46
+ getBestBuy(tokenIn: string, tokenOut: string, amountOut: BigNumber | number | string): Trade
45
47
  ```
46
48
 
47
49
  For type signature visit [types.ts](src/types.ts)<br />
@@ -51,27 +53,21 @@ For type signature visit [types.ts](src/types.ts)<br />
51
53
  ```typescript
52
54
  // Import
53
55
  import { ApiPromise, WsProvider } from '@polkadot/api';
54
- import { TradeRouter, PolkadotPoolService } from '@galacticcouncil/sdk';
56
+ import { TradeRouter, PolkadotApiPoolService } from '@galacticcouncil/sdk';
55
57
 
56
58
  // Initialize Polkadot API
57
59
  const wsProvider = new WsProvider('wss://rpc.basilisk.cloud');
58
60
  const api = await ApiPromise.create({ provider: wsProvider });
59
61
 
60
- // Initialize Router
61
- const poolService = new PolkadotPoolService(api);
62
- const tradeRouter = new TradeRouter(poolService);
62
+ // Initialize Trade Router
63
+ const poolService = new PolkadotApiPoolService(api);
64
+ const tradeRouter = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
63
65
 
64
66
  // Do something
65
67
  const result = await tradeRouter.getAllAssets();
66
68
  console.log(result);
67
69
  ```
68
70
 
69
- ### TradeExecutor
70
-
71
- On-chain transaction executor using data from router to perform best possible trade.
72
-
73
- Not supported yet. 🛠
74
-
75
71
  ## Examples
76
72
 
77
73
  SDK Examples and testing helpers.
@@ -90,17 +86,17 @@ Component list and current status ⬇️
90
86
  - 🛠 Work in progress
91
87
  - ⏳ Planning to build
92
88
 
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 | ⏳ |
89
+ | Name | Type | |
90
+ | ----------- | :----: | --: |
91
+ | Router | API | 🧪 |
92
+ | TradeRouter | API | 🧪 |
93
+ | Polkadot | Client | 🧪 |
94
+ | Capi | Client | ⏳ |
95
+ | XYK | Pool | 🧪 |
96
+ | Omni | Pool | 🧪 |
97
+ | LBP | Pool | 🛠 |
98
+ | Stable | Pool | ⏳ |
103
99
 
104
100
  ## Issue reporting
105
101
 
106
- In case of unexpected sdk behaviour, please create well-written issue [here](https://https://github.com/nohaapav/router-sdk/issues/new). It makes it easier to find & fix the problem accordingly.
102
+ 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.