npm.io
10.8.0 • Published 3 months ago

@galacticcouncil/sdk

Licence
Version
10.8.0
Deps
11
Size
336 kB
Vulns
0
Weekly
0
Stars
26

Galactic SDK

Build SDK License

Collection of SDK(s) crafted to ease Hydration chain integration. This monorepo contains everything you need to build on Hydration — from low-level pool math to high-level trading SDKs and cross-chain transfer tooling.

Note: The previous @polkadot/api-based toolkit (sdk, xcm-core, xcm-cfg, xcm-sdk) has been moved to galacticcouncil/sdk-legacy.

Table of Contents

Overview

┌────────────────────────────────────────────────────────────┐
│                         Your dApp                          │
├────────────────────────────────┬───────────────────────────┤
│         « sdk-next »           │         « xc »            │
│         ··············         │         ·······           │
│         Trade routing          │         Cross-chain       │
│         Pool queries           │         Transfers         │
│               │                │                           │
│          ┌────┴──────┐         │                           │
│          │  math-*   │         │                           │
│          │ Pool math │         │                           │
│          │ (WASM)    │         │                           │
│          └───────────┘         │                           │
├───────────────────┬────────────┴───────────────────────────┤
│  « common »       │  « descriptors »                       │
│  ···········      │  ················                      │
│  Shared utils     │  Chain metadata                        │
├───────────────────┴────────────────────────────────────────┤
│                      polkadot-api                          │
│                    Substrate SDK                           │
└────────────────────────────────────────────────────────────┘

All packages are built on the modern Polkadot API (papi).

Getting Started

Prerequisites
  • Node.js 25+
  • npm 11+
Installation

Pick the packages you need:

# Trading SDK
npm i @galacticcouncil/sdk-next

# Cross-chain transfers
npm i @galacticcouncil/xc

Quick Start

Solo Trading (sdk-next)
import { api, createSdkContext } from '@galacticcouncil/sdk-next';
import { createClient } from 'polkadot-api';

const provider = api.getWs('wss://hydradx-rpc.dwellir.com');
const client = createClient(provider);
const sdk = await createSdkContext(client);

Full docs & API reference →

Solo Cross-Chain (xc)
import { createXcContext } from '@galacticcouncil/xc';

const xc = await createXcContext();

Full docs & API reference →

Combo (sdk-next + xc)
import { api, createSdkContext } from '@galacticcouncil/sdk-next';
import { createXcContext } from '@galacticcouncil/xc';
import { createClient } from 'polkadot-api';

const provider = api.getWs('wss://hydradx-rpc.dwellir.com');
const client = createClient(provider);
const sdk = await createSdkContext(client);
// Shared pool context
const xc = await createXcContext(sdk.ctx.pool);

General

Core packages providing shared utilities, chain metadata, and trading functionality.

Package Version Changelog Description
@galacticcouncil/common common_v changelog Shared utilities (helpers, evm, xcm)
@galacticcouncil/descriptors descriptors_v changelog Hydration papi type-safe metadata descriptors
@galacticcouncil/sdk-next sdk-next_v changelog Trade router & pool utilities (polkadot-api)

XC (Cross-Chain)

Cross-chain transfer toolkit built on polkadot-api. Modular architecture with clean separation between core types, configuration, and wallet interface.

Package Version Changelog Description
@galacticcouncil/xc xc_v changelog High-level context factory (batteries-included)
@galacticcouncil/xc-core xc-core_v changelog Core types, asset & chain definitions
@galacticcouncil/xc-cfg xc-cfg_v changelog Pre-built route configs & DEX integrations
@galacticcouncil/xc-sdk xc-sdk_v changelog Wallet interface for multi-platform transfers
@galacticcouncil/xc-scan xc-scan_v changelog Cross-chain transaction scanning
Architecture
@galacticcouncil/xc          <- Start here (context factory, DEX factory)
├── @galacticcouncil/xc-sdk  <- Wallet, transfers, fee swaps
├── @galacticcouncil/xc-cfg  <- Route configs, DEX implementations
└── @galacticcouncil/xc-core <- Core types, chain & asset definitions

Math

WebAssembly math modules compiled from Rust. Each module provides high-performance, deterministic calculations for a specific Hydration pool type. These are standalone packages with zero JS dependencies.

Package Version Changelog Pool Type
@galacticcouncil/math-omnipool math-omni_v changelog Omnipool — single-sided unified liquidity
@galacticcouncil/math-stableswap math-stable_v changelog Stableswap — low-slippage stable asset trading
@galacticcouncil/math-xyk math-xyk_v changelog XYK — constant product AMM
@galacticcouncil/math-lbp math-lbp_v changelog LBP — liquidity bootstrapping pool
@galacticcouncil/math-hsm math-hsm_v changelog HSM — isolated multi-pool
@galacticcouncil/math-ema math-ema_v changelog EMA — exponential moving average oracle
@galacticcouncil/math-staking math-stake_v changelog Staking reward calculations
@galacticcouncil/math-liquidity-mining math-lm_v changelog Liquidity mining reward calculations

Note: You typically don't need to install math packages directly — they are dependencies of sdk-next.

Examples

Ready-to-run examples are available in the examples/ directory:

Example Description
sdk-next-cjs SDK-Next usage with CommonJS
sdk-next-esm SDK-Next usage with ES Modules
xc-transfer XC cross-chain transfer

Contributing

Everything about building, setting up development environment & releasing can be found in CONTRIBUTING.md.

Issue Reporting

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

This file is part of https://github.com/galacticcouncil/*

               $$$$      Licensed under the Apache License, Version 2.0 (the "License")
            $$$$$$$        you may only use this file in compliance with the License
         $$$$$$$$$$
                     $$$$$       Copyright (C) 2021-2024  Intergalactic, Limited (GIB)
        $$$$$$   $$$$$                       SPDX-License-Identifier: Apache-2.0
     $$$$$$$$$$$$$
  $$$$$$$$$$$$        $                      Built with <3 for decentralisation
 $$$$$$$$$$        $$$$
 $$$$         $$$$$$$$$      Unless required by applicable law or agreed to in
  $       $$$$$$$$$$$$       writing, software distributed under the License is
     $$$$$$$$$$$$$        distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
     $$$$$   $$$$$$         OR CONDITIONS OF ANY KIND, either express or implied.
       $$$$
         $$$$$$$$$            See the License for the specific language governing
            $$$$$$$                   permissions and limitations under the License.
               $$$$
                                                                $
 $$$   $$$                    $                      $
  $$     $$  $$     $   $$$ $  $$ $$  $$$$  $$  $$    $$$   $ $$$
  $$     $$   $$   $  $$    $$   $$  $  $     $  $    $  $     $$  $$   $$
  $$$$$$    $  $   $$     $   $        $$$$  $    $  $     $$  $     $
  $$     $$     $$    $$     $   $     $$     $  $    $  $$     $  $     $
 $$$   $$$     $      $$   $$   $     $$   $$  $    $   $$   $   $    $$
                  $         $$$               $$$     $          $$
                $$

For more details read LICENSE.md

Keywords