Skip to content

Commit

Permalink
update READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Dec 25, 2023
1 parent ff2dd93 commit 4d25519
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 105 deletions.
122 changes: 17 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,24 @@
# Galactic SDK

[![npm version](https://img.shields.io/npm/v/@galacticcouncil/sdk.svg)](https://www.npmjs.com/package/@galacticcouncil/sdk)

</p>
Galactic SDK is collection of components crafted to ease Basilisk & HydraDX chains integration.
<br />
<br />
Table of content:

- [Installation](#installation)
- [Components](#components)
- [Router](#router)
- [TradeRouter](#traderouter)
- [Examples](#examples)
- [Roadmap](#roadmap)
- [Issue reporting](#issue-reporting)

## 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, {
includeOnly: [PoolType.XYK],
});

// 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 | 🧪 |

## Development and Build

### Requirements
## Project Structure

<pre>
<a href=".">SDK</a>: Galactic SDK monorepo.
├──<a href="./packages/math-ema/">Math EMA</a>: Exponential moving average utils.
├──<a href="./packages/math-lbp/">Math LBP</a>: Liquidity bootstrapping pool utils.
├──<a href="./packages/math-liquidity-mining/">Math LM</a>: Liquidity mining utils.
├──<a href="./packages/math-omnipool/">Math Omnipool</a>: Omnipool utils.
├──<a href="./packages/math-stableswap/">Math Stableswap</a>: Stableswap pool utils.
├──<a href="./packages/math-staking/">Math Staking</a>: Staking utils.
├──<a href="./packages/math-xyk/">Math XYK</a>: XYK pool utils.
├──<a href="./packages/sdk">SDK</a>: HydraDX trade router & pool utilities.
├──<a href="./packages/xcm-cfg">XCM Config</a>: HydraDX cross-chain configuration.
├──<a href="./packages/xcm-sdk">XCM SDK</a>: HydraDX cross-chain sdk.
</pre>

## Requirements

- [Node.js](https://nodejs.org/) (**version 18 or higher**)

Expand Down
11 changes: 11 additions & 0 deletions packages/math-ema/README.md
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`
11 changes: 11 additions & 0 deletions packages/math-lbp/README.md
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`
11 changes: 11 additions & 0 deletions packages/math-liquidity-mining/README.md
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`
11 changes: 11 additions & 0 deletions packages/math-omnipool/README.md
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`
11 changes: 11 additions & 0 deletions packages/math-stableswap/README.md
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`
11 changes: 11 additions & 0 deletions packages/math-staking/README.md
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`
11 changes: 11 additions & 0 deletions packages/math-xyk/README.md
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`
102 changes: 102 additions & 0 deletions packages/sdk/README.md
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 | 🧪 |
16 changes: 16 additions & 0 deletions packages/xcm-cfg/README.md
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`
16 changes: 16 additions & 0 deletions packages/xcm-sdk/README.md
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`

0 comments on commit 4d25519

Please sign in to comment.