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

rainbow-swap-sdk

v1.2.5

Published

SDK for building applications on top of Rainbow Swap 🌈 - The Next Gen DEX Aggregator on TON πŸ’Ž.

Downloads

586

Readme

Rainbow Swap 🌈 SDK

This SDK is designed for building applications on top of Rainbow Swap 🌈 - The Next Gen DEX Aggregator on the TON blockchain πŸ’Ž.


We have plans to integrate commissions and share them with those who have integrated this SDK into their DApps.


npm version NPM License

Installation

To install the rainbow-swap-sdk, use the following npm command:

npm install rainbow-swap-sdk

Integrate your dApp

import {
    getAssetsRecord,
    getBestRoute,
    getSwapMessages
} from 'rainbow-swap-sdk';

// 1. On page load: fetch the list of available tokens
const assetsRecord = await getAssetsRecord();

...

// 2. On input asset amount, input asset, or output asset change: fetch a new swap route
const params = {
  inputAssetAmount: '1000000000', // 1 TON in nano
  inputAssetAddress: 'ton', // TON
  outputAssetAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs' // USDT jetton master address
};
const bestRouteResponse = await getBestRoute(params);

...

// 3. Generate sign request messages & send it via @tonconnect
const userAddress = 'UQDGGjjuwhikx8ZPJsrLbKXGq7mx26D8pK_l8GqBejzB52Pa'; // user wallet address
const slippageTolerance = 2.5; // 2.5%

const swapMessages = await getSwapMessages(
    userAddress,
    bestRouteResponse.bestRoute,
    slippageTolerance
);

Application status check

Additionally, you might want to check if everything is functioning correctly. For instance, you could temporarily disable swaps if block production on TON is disrupted due to the DOGS listing.

import { getAppStatus } from 'rainbow-swap-sdk';

const {
    isSwapsEnabled, // true - if everything works fine
    message // explanations why swaps are disabled
} = await getAppStatus();

Live example

For a live example of using the SDK, visit Rainbow Swap 🌈 repository.

Contact

For questions and suggestions, contact us at Blackbot.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.