-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
228 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# EMA math | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/math-ema.svg)](https://www.npmjs.com/package/@galacticcouncil/math-ema) | ||
|
||
Exponential moving average wasm utils. | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/math-ema` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# LBP math | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/math-lbp.svg)](https://www.npmjs.com/package/@galacticcouncil/math-lbp) | ||
|
||
Liquidity bootstrapping pool wasm utils. | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/math-lbp` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Liquidity mining math | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/math-liquidity-mining.svg)](https://www.npmjs.com/package/@galacticcouncil/math-liquidity-mining) | ||
|
||
Liquidity mining wasm utils. | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/math-liquidity-mining` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Omnipool math | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/math-omnipool.svg)](https://www.npmjs.com/package/@galacticcouncil/math-omnipool) | ||
|
||
Omnipool wasm utils. | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/math-omnipool` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Stableswap math | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/math-stableswap.svg)](https://www.npmjs.com/package/@galacticcouncil/math-stableswap) | ||
|
||
Stableswap wasm utils. | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/math-stableswap` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Staking math | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/math-staking.svg)](https://www.npmjs.com/package/@galacticcouncil/math-staking) | ||
|
||
Staking wasm utils. | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/math-staking` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# XYK math | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/math-xyk.svg)](https://www.npmjs.com/package/@galacticcouncil/math-xyk) | ||
|
||
XYK wasm utils. | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/math-xyk` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Galactic SDK | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/sdk) | ||
|
||
</p> | ||
HydraDX trade router & pool utilities. | ||
<br /> | ||
<br /> | ||
Table of content: | ||
|
||
- [Installation](#installation) | ||
- [Components](#components) | ||
- [Router](#router) | ||
- [TradeRouter](#traderouter) | ||
- [Examples](#examples) | ||
- [Roadmap](#roadmap) | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/sdk` | ||
|
||
## Components | ||
|
||
### Router | ||
|
||
Off-chain routing, build to find the most suitable routes across the pools. Building block for TradeRouter. | ||
|
||
#### API | ||
|
||
```typescript | ||
getPools(): PoolBase[] | ||
getAllAssets(): Asset[] | ||
getAssetPairs(token: string): Asset[] | ||
getAllPaths(tokenIn: string, tokenOut: string): Hop[][] | ||
``` | ||
|
||
### TradeRouter | ||
|
||
Off-chain optimization of orders across pools for best price execution. TradeRouter does not perform any on-chain transations. | ||
|
||
#### API | ||
|
||
```typescript | ||
getBestSpotPrice(tokenIn: string, tokenOut: string): Amount | ||
getBestSell(tokenIn: string, tokenOut: string, amountIn: BigNumber | number | string): Trade | ||
getBestBuy(tokenIn: string, tokenOut: string, amountOut: BigNumber | number | string): Trade | ||
``` | ||
|
||
For type signature visit [types.ts](src/types.ts)<br /> | ||
|
||
#### Usage | ||
|
||
```typescript | ||
// Import | ||
import { ApiPromise, WsProvider } from '@polkadot/api'; | ||
import { TradeRouter, PoolService, PoolType } from '@galacticcouncil/sdk'; | ||
|
||
// Initialize Polkadot API | ||
const wsProvider = new WsProvider('wss://rpc.hydradx.cloud'); | ||
const api = await ApiPromise.create({ provider: wsProvider }); | ||
|
||
// Initialize Trade Router | ||
const poolService = new PoolService(api); | ||
const tradeRouter = new TradeRouter(poolService); | ||
|
||
// Do something | ||
const result = await tradeRouter.getAllAssets(); | ||
console.log(result); | ||
``` | ||
|
||
## Examples | ||
|
||
SDK Examples and testing helpers. | ||
|
||
### Run | ||
|
||
Run: `$ npx tsx ./test/script/examples/<examplePackage>/<exampleName>.ts` with valid example package & name. | ||
|
||
To demonstrate full working examples on real chain see [script](test/script/examples) section. | ||
|
||
## Roadmap | ||
|
||
Component list and current status ⬇️ | ||
|
||
- 🧪 Done | ||
- 🛠 Work in progress | ||
- ⏳ Planning to build | ||
|
||
| Name | Type | | | ||
| ----------- | :--: | --: | | ||
| Router | API | 🧪 | | ||
| TradeRouter | API | 🧪 | | ||
| XYK | Math | 🧪 | | ||
| XYK | Pool | 🧪 | | ||
| Omni | Math | 🧪 | | ||
| Omni | Pool | 🧪 | | ||
| LBP | Math | 🧪 | | ||
| LBP | Pool | 🧪 | | ||
| Stable | Math | 🧪 | | ||
| Stable | Pool | 🧪 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Galactic XCM config | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/xcm-cfg.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-cfg) | ||
|
||
Cross-chain configuration for HydraDX & Basilisk dapps. | ||
|
||
## Disclaimer | ||
|
||
The existing setup is constructed based on the Moonbeam xcm-sdk. | ||
For more details visit: https://github.com/PureStake/xcm-sdk/ | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/xcm-cfg` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Galactic XCM SDK | ||
|
||
[![npm version](https://img.shields.io/npm/v/@galacticcouncil/xcm-sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/xcm-sdk) | ||
|
||
Wallet interface for cross-chain interactions in the Polkadot/Kusama ecosystem. | ||
|
||
## Disclaimer | ||
|
||
The existing code is a tailored implementation of the Moonbeam xcm-sdk. | ||
For more details visit: https://github.com/PureStake/xcm-sdk/ | ||
|
||
## Installation | ||
|
||
Install with [npm](https://www.npmjs.com/): | ||
|
||
`npm install @galacticcouncil/xcm-sdk` |