1.0.0 • Published 8 months ago

@gluwa/creditcoin-dex-router-sdk v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

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
1.0.0

8 months ago

1.0.0-rc.5

8 months ago

1.0.0-rc.3

9 months ago

0.9.0

11 months ago

0.8.1

11 months ago

1.0.0-rc.4

9 months ago

0.8.0

11 months ago

1.0.0-rc.1

10 months ago

0.7.4

11 months ago

1.0.0-rc.2

10 months ago

0.9.1

10 months ago

0.7.3

11 months ago

0.7.2

1 year ago

0.7.1

1 year ago

0.6.5

1 year ago

0.6.4

1 year ago

0.7.0

1 year ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago