@gluwa/creditcoin-dex-router-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

creditcoin-dex-router-sdk

Introduction

This repository adapts the smart-order-router to be used in Gluwa's Creditcoin ecosystem.

Getting Started

1. Installation process

The package can be found at @gluwa/creditcoin-dex-router-sdk. Run the following command to install it in your project:

npm install @gluwa/creditcoin-dex-router-sdk

2. Software dependencies

It is recommended that you install ethers v5.7 in your project.

DexRouter (client side) Example

Here is are the basic steps to initialize the DexRouter:

import { DexRouter, DexRouterConfiguration, DexRouterParams } from '@gluwa/creditcoin-dex-router-sdk';
import { Token } from "@uniswap/sdk-core";
import { ethers } from 'ethers';

// Initialize the DexRouterConfiguration with all required fields
const chainId = 102031;
const config: DexRouterConfiguration = {
    chainId,
    indexerGraphqlUrl: 'http://localhost:8080/graphql',
    blockedTokenServiceUrl: 'http://localhost:5243/',
    factoryAddress: '0x0000000000000000000000000000000000000000',
    multicallAddress: '0x0000000000000000000000000000000000000000',
    quoterAddress: '0x0000000000000000000000000000000000000000',
    wrappedNativeToken: new Token(chainId, '0x0000000000000000000000000000000000000000', 18, 'WCTC', 'Wrapped Native Token')
};

// Initialize the provider to communicate with the block chain.
const baseProvider = new ethers.providers.JsonRpcProvider('https://rpc.cc3-testnet.creditcoin.network');

// Initialize DexRouterParams with config and base provider
const dexRouterParams: DexRouterParams = {
    config,
    baseProvider,
};

// Construct a new instance of DexRouter using the above params.
const dexRouter = new DexRouter(dexRouterParams);

ServerSideRouter (server side version of DexRouter) Example

Here is are the basic steps to initialize the ServerSideRouter:

import { ServerSideRouter, ServerSideRouterParams } from '@gluwa/creditcoin-dex-router-sdk';
import { ethers } from 'ethers';

// Initialize the provider to communicate with the block chain.
const baseProvider = new ethers.providers.JsonRpcProvider('https://rpc.cc3-testnet.creditcoin.network');

// Initialize ServerSideRouterParams with config and base provider
const serverSideRouterParams: ServerSideRouterParams = {
    baseProvider,
    config: {
        routerServiceUrl: 'https://dex-dev.creditcoin.org/router-service', // <--- This is the important piece that differs from standard DexRouter
    }
};

// Construct a new instance of ServerSideRouter using the above params.
const serverSideRouter = new ServerSideRouter(serverSideRouterParams);

Development environment setup

To install git hooks, which will stop you from committing common mistakes, from the root directory of this repository execute:

ln -s ../../.github/hooks/pre-commit .git/hooks/pre-commit

Readme

Keywords

none

Package Sidebar

Install

npm i @gluwa/creditcoin-dex-router-sdk

Weekly Downloads

8

Version

1.0.0

License

ISC

Unpacked Size

364 kB

Total Files

303

Last publish

Collaborators

  • taelimoh
  • kevinnguyen17
  • hyeonggook.lee
  • jlafleurgluwa
  • dsylebee
  • gluwa-bot