rainbow-swap-sdk
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -34,3 +34,3 @@ "use strict"; | ||
const tweakedSlippageTolerance = firstChunk[0].dexPair.dexType === dex_type_enum_1.DexTypeEnum.Ston && | ||
firstChunk[0].inputAssetAmount !== globals_1.TON | ||
firstChunk[0].inputAssetAddress !== globals_1.TON | ||
? 100 // We could not handle Ston.fi returned jettons | ||
@@ -37,0 +37,0 @@ : slippageTolerance; |
import { CalculatedSwapRoute } from './calculated-swap-route.type'; | ||
import { Message } from '../interfaces/message.interface'; | ||
export type BestRouteResponse = { | ||
bestRoute: CalculatedSwapRoute[]; | ||
priceImprovement: number; | ||
swapMessages: Message[]; | ||
}; |
@@ -10,3 +10,5 @@ import { AppStatus } from '../types/app-status.type'; | ||
maxDepth?: number; | ||
senderAddress?: string; | ||
maxSlippage?: number; | ||
}) => Promise<BestRouteResponse>; | ||
export declare const getAppStatus: () => Promise<AppStatus>; |
{ | ||
"name": "rainbow-swap-sdk", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "SDK for building applications on top of Rainbow Swap 🌈 - The Next Gen DEX Aggregator on TON 💎.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/0xblackbot/rainbow-swap-sdk.git", |
@@ -26,7 +26,6 @@ # Rainbow Swap 🌈 SDK | ||
getAssetsRecord, | ||
getBestRoute, | ||
getSwapMessages | ||
getBestRoute | ||
} from 'rainbow-swap-sdk'; | ||
// 1. On page load: fetch the list of available tokens | ||
// 1. Load the list of available tokens | ||
const assetsRecord = await getAssetsRecord(); | ||
@@ -36,21 +35,16 @@ | ||
// 2. On input asset amount, input asset, or output asset change: fetch a new swap route | ||
// 2. Load the best swap route & swap messages | ||
const params = { | ||
inputAssetAmount: '1000000000', // 1 TON in nano | ||
inputAssetAddress: 'ton', // TON | ||
outputAssetAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs' // USDT jetton master address | ||
outputAssetAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs', // USDT jetton master address | ||
maxDepth: 2, // optional number of maximum route length (should be in range from 1 to 3) | ||
userAddress: 'UQDGGjjuwhikx8ZPJsrLbKXGq7mx26D8pK_l8GqBejzB52Pa', // optional user wallet address, if set - swapMessages will return | ||
slippageTolerance: 5 // optional max slippage value (should be in range ) | ||
}; | ||
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 | ||
); | ||
const bestRoute = bestRouteResponse.bestRoute; // Route of the best possible swap route | ||
const swapMessages = bestRouteResponse.swapMessages; // Array of messages that should be sent to @tonconnect | ||
``` | ||
@@ -57,0 +51,0 @@ |
77134
1216
74