Giter VIP home page Giter VIP logo

sdk's Introduction

Galactic SDK

npm version

Galactic SDK is collection of components crafted to ease Basilisk & HydraDX chains integration.

Table of content:

Installation

Install with npm:

npm install @galacticcouncil/sdk

Components

Router

Off-chain routing, build to find the most suitable routes across the pools. Building block for TradeRouter.

API

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

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

Usage

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

Issue reporting

In case of unexpected sdk behaviour, please create well-written issue here. It makes it easier to find & fix the problem accordingly.

sdk's People

Contributors

mrq1911 avatar nohaapav avatar robiquet avatar xrash avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.