npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jds-js-sdk

v5.1.5

Published

🛠 An SDK for building applications on top of router.

Downloads

5

Readme

RouterProtocol JS SDK

Getting started

Initailize

    import {RouterProtocol} from "@router/router-js-sdk"

    const routerprotocol=new RouterProtocol("SDK_ID_HERE","SOURCE_CHAIN_ID","PROVIDER_HERE")
    await routerprotocol.initailize()

Fetch Bridge Fee

    const fees = await routerprotocol.getBridgeFee("DESTINATION_CHAIN_ID");

Response Type

    {
        address: string, // address of fee token
        transferFee: BigNumber, // transfer fee amount
        exchangeFee: BigNumber // exchange fee amount
    }[]

Response Example(polygon to harmony)

   [
      {
        address: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
        transferFee: BigNumber { _hex: '0x30d400', _isBigNumber: true },
        exchangeFee: BigNumber { _hex: '0x30d400', _isBigNumber: true }
      },
      {
        address: '0x4c28f48448720e9000907BC2611F73022fdcE1fA',
        transferFee: BigNumber { _hex: '0x2c68af0bb1400000', _isBigNumber: true },
        exchangeFee: BigNumber { _hex: '0x2c68af0bb1400000', _isBigNumber: true }
      },
      {
        address: '0x16ECCfDbb4eE1A85A33f3A9B21175Cd7Ae753dB4',
        transferFee: BigNumber { _hex: '0x0b1a2bc2ec500000', _isBigNumber: true },
        exchangeFee: BigNumber { _hex: '0x0b1a2bc2ec500000', _isBigNumber: true }
      },
      {
        address: '0xC168E40227E4ebD8C1caE80F7a55a4F0e6D66C97',
        transferFee: BigNumber { _hex: '0x03e733628714200000', _isBigNumber: true },
        exchangeFee: BigNumber { _hex: '0x03e733628714200000', _isBigNumber: true }
      }
    ]

Getting Allowance

Source Token Allowance (one to be swapped)
    const allowance:BigNumber =await routerprotocol.getSourceTokenAllowance("TOKEN_ADDRESS","DESTINATION_CHAIN_ID","USER_ADDRESS")
Fee Token Allowance (bridge fee to be paid)
    const allowance:BigNumber =await routerprotocol.getFeeTokenAllowance("TOKEN_ADDRESS","DESTINATION_CHAIN_ID","USER_ADDRESS")

Getting Approved

Getting Source Token Approved (one to be swapped)
    await routerprotocol.approveSourceToken("TOKEN_ADDRESS","USER_ADDRESS","AMOUNT_TO_BE_APPROVED","DESTINATION_CHAIN_ID","SOURCE_SIGNER")
Getting fee Token Approved (bridge fee to be paid)
    await routerprotocol.approveFeeToken("TOKEN_ADDRESS","USER_ADDRESS","AMOUNT_TO_BE_APPROVED","SOURCE_SIGNER")

Getting Quote

    const quote =await routerprotocol.getQuote("AMOUNT","DESTINATION_CHAIN_ID","SOURCE_TOKEN_ADDRESS","DESTINATION_TOKEN_ADDRESS",""USER_ADDRESS"","FEE_TOKEN_ADDRESS","SLIPPAGE_TOLERANCE")

Response Type

interface Quote{ 
    source: {
    asset: {
      decimals: number,
      symbol: string,
      name: string,
      chainId: number,
      address: string,
      resourceID: string,
      isMintable: boolean,
      isWrappedAsset: boolean,
      tokenInstance: {
        decimals: number,
        symbol: string,
        name: string,
        chainId: number,
        address: string
      }
    },
    stableReserveAsset: {
      decimals: number,
      symbol: string,
      name: string,
      chainId: number,
      address: string,
      resourceID: string,
      isMintable: boolean,
      isWrappedAsset: boolean
    },
    tokenAmount: string,
    stableReserveAmount: string,
    path: any[],
    flags: string[],
    priceImpact: string,
    bridgeFee: number,
    tokenPath: string
  },
  destination: {
    asset: {
      decimals: number,
      symbolstring:string,
      name: string,
      chainId: number
      address: string,
      resourceID: string,
      isMintable: boolean,
      isWrappedAsset: boolean,
      tokenInstance: {
        decimals: number,
        symbolstring:string,
        name: string,
        chainId: number
        address: string
      }
    },
    stableReserveAsset: {
      decimals: number,
      symbol: string,
      name: string,
      chainId: number
      address: string,
      resourceID: string,
      isMintable: boolean,
      isWrappedAsset: boolean
    },
    tokenAmount: string,
    stableReserveAmount: string,
    priceImpact: string,
    tokenPath: string
  }
}

Response Example(polygon to harmony)

    {
      source: {
        asset: {
          decimals: 6,
          symbol: 'USDC',
          name: 'USDC',
          chainId: 137,
          address: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
          resourceID: '0x00000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa8417400',
          isMintable: false,
          isWrappedAsset: false,
          tokenInstance: [Object]
        },
        stableReserveAsset: {
          decimals: 6,
          symbol: 'USDC',
          name: 'USDC',
          chainId: 137,
          address: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
          resourceID: '0x00000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa8417400',
          isMintable: false,
          isWrappedAsset: false
        },
        tokenAmount: '100',
        stableReserveAmount: '100',
        path: [],
        flags: [ '17716742144' ],
        priceImpact: '0',
        bridgeFee: 0,
        tokenPath: ''
      },
      destination: {
        asset: {
          decimals: 6,
          symbol: 'USDC',
          name: 'USD Coin',
          chainId: 1666600000,
          address: '0x985458E523dB3d53125813eD68c274899e9DfAb4',
          resourceID: '0x00000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa8417400',
          isMintable: false,
          isWrappedAsset: false,
          tokenInstance: [Object]
        },
        stableReserveAsset: {
          decimals: 6,
          symbol: 'USDC',
          name: 'USD Coin',
          chainId: 1666600000,
          address: '0x985458E523dB3d53125813eD68c274899e9DfAb4',
          resourceID: '0x00000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa8417400',
          isMintable: false,
          isWrappedAsset: false
        },
        tokenAmount: '100',
        stableReserveAmount: '100',
        priceImpact: '0',
        tokenPath: ''
      }
    }

Swap

        const tx = await routerprotocol.swap("SOURCE_SIGNER")

Get transaction status

    const txStatus=await routerprotocol.getTransactionStatus("TXN_HASH")

Response Type

interface TransactionStatus{"tx_status":string,
"tx_status_code":number,
"src_chain_id":string,
"dest_chain_id":string,
"src_tx_hash":string,
"dest_tx_hash":string}

Response Example

{"tx_status":"Completed","tx_status_code":1,"src_chain_id":"1","dest_chain_id":"4","src_tx_hash":"0xde12f05b718b3407633d00fb5834ae48fb6ec5970b3252d3a6eb5e18222f33ee","dest_tx_hash":"0x437124f52c6efa61dccd8c1fa34206bdb7a079e64e368db6eda4bb6999843b23"}