rainbow-swap-sdk 1.1.19 → 1.2.0

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
@@ -44,7 +44,7 @@ const bestRouteResponse = await getBestRoute(params);
44
44
 
45
45
  // 3. Generate sign request messages & send it via @tonconnect
46
46
  const userAddress = 'UQDGGjjuwhikx8ZPJsrLbKXGq7mx26D8pK_l8GqBejzB52Pa'; // user wallet address
47
- const slippageTolerance = '2.5'; // 2.5%
47
+ const slippageTolerance = 2.5; // 2.5%
48
48
 
49
49
  const swapMessages = await getSwapMessages(
50
50
  userAddress,
@@ -1,6 +1,6 @@
1
1
  import { Address } from '@ton/core';
2
2
  import { RouteStepWithCalculation } from '../../interfaces/route-step-with-calculation.interface';
3
- export declare const dedust_getTransferParams: (route: RouteStepWithCalculation[], queryId: number, gasAmount: bigint, senderAddress: Address, receiverAddress: Address, responseDestination: Address, slippageTolerance: string) => Promise<{
3
+ export declare const dedust_getTransferParams: (route: RouteStepWithCalculation[], queryId: number, gasAmount: bigint, senderAddress: Address, receiverAddress: Address, responseDestination: Address, slippageTolerance: number) => Promise<{
4
4
  to: Address;
5
5
  value: bigint;
6
6
  body: import("@ton/core").Cell;
@@ -22,7 +22,7 @@ export declare const packJettonReceiveEffect: (params: {
22
22
  effectType: EffectType;
23
23
  fullBody: Cell;
24
24
  }) => Cell;
25
- export declare const getDexTransferParams: (route: RouteStepWithCalculation[], queryId: number, gasAmount: bigint, senderAddress: Address, receiverAddress: Address, responseDestination: Address, slippageTolerance: string) => Promise<{
25
+ export declare const getDexTransferParams: (route: RouteStepWithCalculation[], queryId: number, gasAmount: bigint, senderAddress: Address, receiverAddress: Address, responseDestination: Address, slippageTolerance: number) => Promise<{
26
26
  to: Address;
27
27
  value: bigint;
28
28
  body: Cell;
@@ -1,4 +1,4 @@
1
1
  import { Address } from '@ton/core';
2
2
  import { RouteStepWithCalculation } from '../../interfaces/route-step-with-calculation.interface';
3
3
  import { TransferParams } from '../../interfaces/transfer-params.interface';
4
- export declare const rainbow_getTransferParams: (firstChunk: RouteStepWithCalculation[], secondChunk: RouteStepWithCalculation[], queryId: number, gasAmount: bigint, senderAddress: Address, slippageTolerance: string) => Promise<TransferParams>;
4
+ export declare const rainbow_getTransferParams: (firstChunk: RouteStepWithCalculation[], secondChunk: RouteStepWithCalculation[], queryId: number, gasAmount: bigint, senderAddress: Address, slippageTolerance: number) => Promise<TransferParams>;
@@ -32,7 +32,7 @@ const rainbow_getTransferParams = async (firstChunk, secondChunk, queryId, gasAm
32
32
  });
33
33
  const tweakedSlippageTolerance = firstChunk[0].dexType === dex_type_enum_1.DexTypeEnum.Ston &&
34
34
  firstChunk[0].inputAssetAmount !== globals_1.TON
35
- ? '100' // We could not handle Ston.fi returned jettons
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);
38
38
  if (inputAssetAddress === globals_1.TON) {
@@ -1 +1 @@
1
- export declare const applySlippageTolerance: (amount: string, slippageTolerance: string) => bigint;
1
+ export declare const applySlippageTolerance: (amount: string, slippageTolerance: number) => bigint;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applySlippageTolerance = void 0;
4
+ const PRECISION = 10 ** 6;
4
5
  const applySlippageTolerance = (amount, slippageTolerance) => {
5
- const decimals = slippageTolerance.split('.')[1]?.length || 0;
6
- const multiplier = BigInt(10 ** decimals);
7
- return ((BigInt(amount) *
8
- BigInt(Math.floor((100 - parseFloat(slippageTolerance)) * Number(multiplier)))) /
9
- (BigInt(100) * multiplier));
6
+ const amountBigInt = BigInt(amount);
7
+ const slippageAmount = (amountBigInt * BigInt(Math.ceil(slippageTolerance * PRECISION))) /
8
+ BigInt(100 * PRECISION);
9
+ return amountBigInt - slippageAmount;
10
10
  };
11
11
  exports.applySlippageTolerance = applySlippageTolerance;
@@ -1,7 +1,7 @@
1
1
  import { Address } from '@ton/core';
2
2
  import { TransferParams } from '../../interfaces/transfer-params.interface';
3
3
  import { CalculatedSwapRoute } from '../../types/calculated-swap-route.type';
4
- export declare const getSwapRouteTransferParams: (swapRoute: CalculatedSwapRoute, senderAddress: Address, slippageTolerance: string) => Promise<{
4
+ export declare const getSwapRouteTransferParams: (swapRoute: CalculatedSwapRoute, senderAddress: Address, slippageTolerance: number) => Promise<{
5
5
  to: Address;
6
6
  value: bigint;
7
7
  body: import("@ton/core").Cell;
@@ -1,6 +1,6 @@
1
1
  import { Address } from '@ton/core';
2
2
  import { RouteStepWithCalculation } from '../../interfaces/route-step-with-calculation.interface';
3
- export declare const ston_getTransferParams: (routeStep: RouteStepWithCalculation, queryId: number, gasAmount: bigint, senderAddress: Address, receiverAddress: Address, responseDestination: Address, slippageTolerance: string) => Promise<{
3
+ export declare const ston_getTransferParams: (routeStep: RouteStepWithCalculation, queryId: number, gasAmount: bigint, senderAddress: Address, receiverAddress: Address, responseDestination: Address, slippageTolerance: number) => Promise<{
4
4
  to: Address;
5
5
  value: bigint;
6
6
  body: import("@ton/core").Cell;
@@ -1,4 +1,4 @@
1
1
  import { Message } from '../interfaces/message.interface';
2
2
  import { CalculatedSwapRoute } from '../types/calculated-swap-route.type';
3
- export declare const getSwapMessages: (senderAddress: string, bestRoute: CalculatedSwapRoute[], slippageTolerance: string) => Promise<Message[]>;
3
+ export declare const getSwapMessages: (senderAddress: string, bestRoute: CalculatedSwapRoute[], slippageTolerance: number) => Promise<Message[]>;
4
4
  export declare const getRainbowWalletActivationMessages: (senderAddress: string) => Message[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rainbow-swap-sdk",
3
- "version": "1.1.19",
3
+ "version": "1.2.0",
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",
@@ -16,10 +16,10 @@
16
16
  "release": "release-it patch --release-version"
17
17
  },
18
18
  "dependencies": {
19
- "@rnw-community/shared": "^0.73.0",
20
- "@ton/core": "^0.56.3",
19
+ "@rnw-community/shared": "^0.74.0",
20
+ "@ton/core": "^0.57.0",
21
21
  "@ton/crypto": "^3.3.0",
22
- "@ton/ton": "^14.0.0",
22
+ "@ton/ton": "^15.0.0",
23
23
  "axios": "^1.7.3",
24
24
  "buffer": "^6.0.3"
25
25
  },