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.
Installation
To install the rainbow-swap-sdk, use the following npm command:
npm install rainbow-swap-sdk
Integrate your dApp
import {getSwapMessages} from 'rainbow-swap-sdk';
const assetsRecord = await getAssetsRecord();
...
const userAddress = 'UQDGGjjuwhikx8ZPJsrLbKXGq7mx26D8pK_l8GqBejzB52Pa';
const isRainbowWalletActive = await getIsRainbowWalletActive(userAddress);
...
const params = {
inputAssetAmount: '1000000000',
inputAssetAddress: 'ton',
outputAssetAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'
};
const bestRouteResponse = getBestRoute(params);
...
const isActivationRequired = getIsActivationRequired(bestRouteResponse.bestRoute, isRainbowWalletActive);
if (isActivationRequired) {
const activationMessages = getRainbowWalletActivationMessages(userAddress);
} else {
const slippageTolerance = '2.5';
const swapMessages = await getSwapMessages(
userAddress,
bestRouteResponse.bestRoute,
slippageTolerance
);
}
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.