rainbow-swap-sdk 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,34 +23,28 @@ npm install rainbow-swap-sdk
23
23
  ```typescript
24
24
  import {
25
25
  getAssetsRecord,
26
- getBestRoute,
27
- getSwapMessages
26
+ getBestRoute
28
27
  } from 'rainbow-swap-sdk';
29
28
 
30
- // 1. On page load: fetch the list of available tokens
29
+ // 1. Load the list of available tokens
31
30
  const assetsRecord = await getAssetsRecord();
32
31
 
33
32
  ...
34
33
 
35
- // 2. On input asset amount, input asset, or output asset change: fetch a new swap route
34
+ // 2. Load the best swap route & swap messages
36
35
  const params = {
37
36
  inputAssetAmount: '1000000000', // 1 TON in nano
38
37
  inputAssetAddress: 'ton', // TON
39
- outputAssetAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs' // USDT jetton master address
38
+ outputAssetAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs', // USDT jetton master address
39
+ maxDepth: 2, // optional number of maximum route length (should be in range from 1 to 3)
40
+ userAddress: 'UQDGGjjuwhikx8ZPJsrLbKXGq7mx26D8pK_l8GqBejzB52Pa', // optional user wallet address, if set - swapMessages will return
41
+ slippageTolerance: 5 // optional max slippage value (should be in range )
40
42
  };
41
- const bestRouteResponse = await getBestRoute(params);
42
-
43
- ...
44
43
 
45
- // 3. Generate sign request messages & send it via @tonconnect
46
- const userAddress = 'UQDGGjjuwhikx8ZPJsrLbKXGq7mx26D8pK_l8GqBejzB52Pa'; // user wallet address
47
- const slippageTolerance = 2.5; // 2.5%
44
+ const bestRouteResponse = await getBestRoute(params);
48
45
 
49
- const swapMessages = await getSwapMessages(
50
- userAddress,
51
- bestRouteResponse.bestRoute,
52
- slippageTolerance
53
- );
46
+ const bestRoute = bestRouteResponse.bestRoute; // Route of the best possible swap route
47
+ const swapMessages = bestRouteResponse.swapMessages; // Array of messages that should be sent to @tonconnect
54
48
  ```
55
49
 
56
50
  ### Application status check
@@ -31,7 +31,7 @@ const rainbow_getTransferParams = async (firstChunk, secondChunk, queryId, gasAm
31
31
  fullBody: secondChunk_transferParams.body
32
32
  });
33
33
  const tweakedSlippageTolerance = firstChunk[0].dexPair.dexType === dex_type_enum_1.DexTypeEnum.Ston &&
34
- firstChunk[0].inputAssetAmount !== globals_1.TON
34
+ firstChunk[0].inputAssetAddress !== globals_1.TON
35
35
  ? 100 // We could not handle Ston.fi returned jettons
36
36
  : slippageTolerance;
37
37
  const firstChunk_transferParams = await (0, transfer_params_pack_utils_1.getDexTransferParams)(firstChunk, queryId, gasAmount + jettonReceiveEffectGasAmount, rainbowWallet.address, rainbowWallet.address, senderAddress, tweakedSlippageTolerance);
@@ -1,5 +1,7 @@
1
1
  import { CalculatedSwapRoute } from './calculated-swap-route.type';
2
+ import { Message } from '../interfaces/message.interface';
2
3
  export type BestRouteResponse = {
3
4
  bestRoute: CalculatedSwapRoute[];
4
5
  priceImprovement: number;
6
+ swapMessages: Message[];
5
7
  };
@@ -7,5 +7,7 @@ export declare const getBestRoute: (params: {
7
7
  inputAssetAddress: string;
8
8
  outputAssetAddress: string;
9
9
  maxDepth?: number;
10
+ senderAddress?: string;
11
+ maxSlippage?: number;
10
12
  }) => Promise<BestRouteResponse>;
11
13
  export declare const getAppStatus: () => Promise<AppStatus>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rainbow-swap-sdk",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "SDK for building applications on top of Rainbow Swap 🌈 - The Next Gen DEX Aggregator on TON 💎.",
5
5
  "repository": "https://github.com/0xblackbot/rainbow-swap-sdk.git",
6
6
  "license": "Apache-2.0",