@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.
Files changed (55) hide show
  1. package/README.md +105 -0
  2. package/dist/index.esm.js +4 -0
  3. package/dist/index.esm.js.map +7 -0
  4. package/dist/index.js +4 -0
  5. package/dist/index.js.map +7 -0
  6. package/dist/types/api/index.d.ts +2 -0
  7. package/dist/types/api/router.d.ts +102 -0
  8. package/dist/types/api/tradeRouter.d.ts +85 -0
  9. package/{types/api/trader.d.ts → dist/types/client/cApi.d.ts} +0 -0
  10. package/dist/types/client/index.d.ts +1 -0
  11. package/{types/client/polkadot.d.ts → dist/types/client/polkadotApi.d.ts} +15 -1
  12. package/dist/types/index.d.ts +4 -0
  13. package/dist/types/pool/index.d.ts +5 -0
  14. package/dist/types/pool/lbp/lbpMath.d.ts +13 -0
  15. package/dist/types/pool/lbp/lbpPolkadotApiClient.d.ts +25 -0
  16. package/dist/types/pool/lbp/lbpPool.d.ts +43 -0
  17. package/dist/types/pool/omni/omniMath.d.ts +9 -0
  18. package/dist/types/pool/omni/omniPolkadotApiClient.d.ts +13 -0
  19. package/dist/types/pool/omni/omniPool.d.ts +34 -0
  20. package/dist/types/pool/polkadotApiPoolService.d.ts +17 -0
  21. package/{types → dist/types}/pool/poolFactory.d.ts +0 -0
  22. package/{types/pool/xyk/math/bundler.d.ts → dist/types/pool/xyk/xykMath.d.ts} +2 -0
  23. package/dist/types/pool/xyk/xykPolkadotApiClient.d.ts +10 -0
  24. package/dist/types/pool/xyk/xykPool.d.ts +22 -0
  25. package/{types/suggester → dist/types/route}/bfs.d.ts +2 -2
  26. package/{types/suggester → dist/types/route}/graph.d.ts +0 -0
  27. package/{types/suggester → dist/types/route}/index.d.ts +0 -0
  28. package/{types/suggester → dist/types/route}/suggester.d.ts +0 -0
  29. package/dist/types/types.d.ts +117 -0
  30. package/{types → dist/types}/utils/bignumber.d.ts +0 -0
  31. package/dist/types/utils/mapper.d.ts +5 -0
  32. package/dist/types/utils/math.d.ts +33 -0
  33. package/{types → dist/types}/utils/queue.d.ts +0 -0
  34. package/{types → dist/types}/utils/stack.d.ts +0 -0
  35. package/{types → dist/types}/utils/traversal/bfs.d.ts +0 -0
  36. package/package.json +8 -7
  37. package/cjs/hydra_dx_wasm_bg-ZX7K4FM7.wasm +0 -0
  38. package/cjs/index.js +0 -2
  39. package/cjs/index.js.map +0 -7
  40. package/esm/hydra_dx_wasm_bg-ZX7K4FM7.wasm +0 -0
  41. package/esm/index.js +0 -2
  42. package/esm/index.js.map +0 -7
  43. package/types/api/index.d.ts +0 -1
  44. package/types/api/router.d.ts +0 -129
  45. package/types/client/capi.d.ts +0 -0
  46. package/types/client/index.d.ts +0 -1
  47. package/types/client/types.d.ts +0 -7
  48. package/types/index.d.ts +0 -4
  49. package/types/pool/index.d.ts +0 -3
  50. package/types/pool/polkadotPoolService.d.ts +0 -7
  51. package/types/pool/xyk/math/nodejs.d.ts +0 -9
  52. package/types/pool/xyk/xykPolkadotClient.d.ts +0 -8
  53. package/types/pool/xyk/xykPool.d.ts +0 -16
  54. package/types/types.d.ts +0 -55
  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
+ [![npm version](https://img.shields.io/npm/v/@galacticcouncil/sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/sdk)
5
+ ![Coverage](./badges/coverage-jest%20coverage.svg)
6
+ [![CodeFactor](https://www.codefactor.io/repository/github/galacticcouncil/sdk/badge)](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.