@gluwa/creditcoin-dex-router-sdk
v0.7.2
Published
Creditcoin DEX Router SDK
Downloads
79
Keywords
Readme
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.
Example
Here is are the basic steps to initialize the DexRouter:
import { DexRouter, DexRouterConfiguration, DexRouterParams } from "@gluwa/creditcoin-dex-router-sdk";
import { ethers } from "ethers";
const CC3_DEX_FACTORY_ADDRESS = '0x62C10aaE28a6e9447413Dc5586484a397DBa10d8';
// Initialize the DexRouterConfiguration with URLs of backend services, chain ID, and factory address of CC3 DEX
// There are several optional properties that will fallback to defaults. See technical reference doc for more info on these.
const config: DexRouterConfiguration = {
chainId: 102031,
factoryAddress: CC3_DEX_FACTORY_ADDRESS,
indexerGraphqlUrl: "http://localhost:8080/graphql",
blockedTokenServiceUrl: "http://localhost:5243/"
};
// 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);