rainbow-swap-sdk
Advanced tools
Comparing version 1.2.5 to 1.3.0
@@ -15,3 +15,3 @@ "use strict"; | ||
const routeStep = remainingRoute[0]; | ||
const poolAddress = core_1.Address.parse(routeStep.dexPairAddress); | ||
const poolAddress = core_1.Address.parse(routeStep.dexPair.dexPairAddress); | ||
const limit = (0, slippage_tolerance_utils_1.applySlippageTolerance)(routeStep.outputAssetAmount, slippageTolerance); | ||
@@ -31,3 +31,3 @@ const next = createNextSwapStepPayload(remainingRoute.slice(1), slippageTolerance); | ||
const vaultAddress = await (0, vault_utils_1.dedust_getVaultAddress)(firstRouteStep.inputAssetAddress); | ||
const poolAddress = core_1.Address.parse(firstRouteStep.dexPairAddress); | ||
const poolAddress = core_1.Address.parse(firstRouteStep.dexPair.dexPairAddress); | ||
const minOutputAmount = (0, slippage_tolerance_utils_1.applySlippageTolerance)(firstRouteStep.outputAssetAmount, slippageTolerance); | ||
@@ -34,0 +34,0 @@ const nextSwapStep = createNextSwapStepPayload(route.slice(1), slippageTolerance); |
@@ -43,3 +43,3 @@ "use strict"; | ||
const getDexTransferParams = (route, queryId, gasAmount, senderAddress, receiverAddress, responseDestination, slippageTolerance) => { | ||
const dexType = route[0].dexType; | ||
const dexType = route[0].dexPair.dexType; | ||
if (dexType === dex_type_enum_1.DexTypeEnum.DeDust) { | ||
@@ -46,0 +46,0 @@ return (0, transfer_params_utils_1.dedust_getTransferParams)(route, queryId, gasAmount, senderAddress, receiverAddress, responseDestination, slippageTolerance); |
@@ -18,6 +18,6 @@ "use strict"; | ||
const secondChunk_transferParams = await (0, transfer_params_pack_utils_1.getDexTransferParams)(secondChunk, queryId, gasAmount, rainbowWallet.address, senderAddress, senderAddress, slippageTolerance); | ||
const jettonSenderAddressToListen = firstChunk[0].dexType === dex_type_enum_1.DexTypeEnum.Ston | ||
const jettonSenderAddressToListen = firstChunk[0].dexPair.dexType === dex_type_enum_1.DexTypeEnum.Ston | ||
? sdk_1.STON_ROUTER_ADDRESS | ||
: await (0, vault_utils_1.dedust_getVaultAddress)(firstChunk[firstChunk.length - 1].outputAssetAddress); | ||
const jettonReceiveEffectType = secondChunk[0].dexType === dex_type_enum_1.DexTypeEnum.DeDust && | ||
const jettonReceiveEffectType = secondChunk[0].dexPair.dexType === dex_type_enum_1.DexTypeEnum.DeDust && | ||
secondChunk[0].inputAssetAddress === globals_1.TON | ||
@@ -34,3 +34,3 @@ ? transfer_params_pack_utils_1.EffectType.DedustTonSwap | ||
}); | ||
const tweakedSlippageTolerance = firstChunk[0].dexType === dex_type_enum_1.DexTypeEnum.Ston && | ||
const tweakedSlippageTolerance = firstChunk[0].dexPair.dexType === dex_type_enum_1.DexTypeEnum.Ston && | ||
firstChunk[0].inputAssetAmount !== globals_1.TON | ||
@@ -37,0 +37,0 @@ ? 100 // We could not handle Ston.fi returned jettons |
@@ -8,11 +8,13 @@ "use strict"; | ||
const calculated_swap_route_utils_3 = require("../ston/calculated-swap-route.utils"); | ||
const calculated_swap_route_utils_4 = require("../ston-v2/calculated-swap-route.utils"); | ||
const FnRecord = { | ||
[swap_route_type_enum_1.SwapRouteType.DeDust]: calculated_swap_route_utils_1.dedust_mapSwapRouteToRoute, | ||
[swap_route_type_enum_1.SwapRouteType.Ston]: calculated_swap_route_utils_3.ston_mapSwapRouteToRoute, | ||
[swap_route_type_enum_1.SwapRouteType.Ston_v2]: calculated_swap_route_utils_4.stonV2_mapSwapRouteToRoute, | ||
[swap_route_type_enum_1.SwapRouteType.Rainbow]: calculated_swap_route_utils_2.rainbow_mapSwapRouteToRoute | ||
}; | ||
const mapSwapRouteToRoute = (swapRoute) => { | ||
if (swapRoute.type === swap_route_type_enum_1.SwapRouteType.DeDust) { | ||
return (0, calculated_swap_route_utils_1.dedust_mapSwapRouteToRoute)(swapRoute); | ||
} | ||
if (swapRoute.type === swap_route_type_enum_1.SwapRouteType.Ston) { | ||
return (0, calculated_swap_route_utils_3.ston_mapSwapRouteToRoute)(swapRoute); | ||
} | ||
return (0, calculated_swap_route_utils_2.rainbow_mapSwapRouteToRoute)(swapRoute); | ||
const fn = FnRecord[swapRoute.type]; | ||
return fn(swapRoute); | ||
}; | ||
exports.mapSwapRouteToRoute = mapSwapRouteToRoute; |
@@ -12,2 +12,3 @@ "use strict"; | ||
const transfer_params_utils_4 = require("../ston/transfer-params.utils"); | ||
const transfer_params_utils_5 = require("../ston-v2/transfer-params.utils"); | ||
const getSwapRouteTransferParams = (swapRoute, senderAddress, slippageTolerance) => { | ||
@@ -21,2 +22,5 @@ const queryId = (0, transfer_params_utils_1.getQueryId)(); | ||
} | ||
if (swapRoute.type === swap_route_type_enum_1.SwapRouteType.Ston_v2) { | ||
return (0, transfer_params_utils_5.stonV2_getTransferParams)(swapRoute.route, queryId, globals_1.GAS_AMOUNT, senderAddress, senderAddress, senderAddress, slippageTolerance); | ||
} | ||
return (0, transfer_params_utils_3.rainbow_getTransferParams)(swapRoute.firstChunk, swapRoute.secondChunk, queryId, globals_1.GAS_AMOUNT, senderAddress, slippageTolerance); | ||
@@ -23,0 +27,0 @@ }; |
export declare enum DexTypeEnum { | ||
DeDust = "DeDust", | ||
DeDustStable = "DeDustStable", | ||
Ston = "Ston", | ||
DeDustStable = "DeDustStable" | ||
Ston_v2 = "Ston_v2" | ||
} |
@@ -7,4 +7,5 @@ "use strict"; | ||
DexTypeEnum["DeDust"] = "DeDust"; | ||
DexTypeEnum["DeDustStable"] = "DeDustStable"; | ||
DexTypeEnum["Ston"] = "Ston"; | ||
DexTypeEnum["DeDustStable"] = "DeDustStable"; | ||
DexTypeEnum["Ston_v2"] = "Ston_v2"; | ||
})(DexTypeEnum || (exports.DexTypeEnum = DexTypeEnum = {})); |
export declare enum SwapRouteType { | ||
DeDust = "DeDust", | ||
Ston = "Ston", | ||
Ston_v2 = "Ston_v2", | ||
Rainbow = "Rainbow" | ||
} |
@@ -8,3 +8,4 @@ "use strict"; | ||
SwapRouteType["Ston"] = "Ston"; | ||
SwapRouteType["Ston_v2"] = "Ston_v2"; | ||
SwapRouteType["Rainbow"] = "Rainbow"; | ||
})(SwapRouteType || (exports.SwapRouteType = SwapRouteType = {})); |
@@ -10,1 +10,2 @@ import { Address } from '@ton/core'; | ||
export declare const REFERRAL_ADDRESS: Address; | ||
export declare const REFERRAL_VALUE = 0n; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.REFERRAL_ADDRESS = exports.JETTON_TRANSFER_GAS_AMOUNT = exports.GAS_AMOUNT = exports.TON_CLIENT = exports.API = exports.WORKCHAIN = exports.TON = void 0; | ||
exports.REFERRAL_VALUE = exports.REFERRAL_ADDRESS = exports.JETTON_TRANSFER_GAS_AMOUNT = exports.GAS_AMOUNT = exports.TON_CLIENT = exports.API = exports.WORKCHAIN = exports.TON = void 0; | ||
const core_1 = require("@ton/core"); | ||
@@ -22,1 +22,2 @@ const ton_1 = require("@ton/ton"); | ||
exports.REFERRAL_ADDRESS = core_1.Address.parse('UQBBPVrn4Y6F0Fci4j0mXuSAXmRDeE-nZCRIInQsNC9__8vG'); | ||
exports.REFERRAL_VALUE = 0n; |
@@ -1,6 +0,5 @@ | ||
import { DexTypeEnum } from '../enums/dex-type.enum'; | ||
import { RouteDirectionEnum } from '../enums/route-direction.enum'; | ||
import { DexPair } from '../types/dex-pair.type'; | ||
export interface RouteStep { | ||
dexType: DexTypeEnum; | ||
dexPairAddress: string; | ||
dexPair: DexPair; | ||
inputAssetAddress: string; | ||
@@ -7,0 +6,0 @@ outputAssetAddress: string; |
import { DeDustCalculatedSwapRoute } from '../dexes/dedust/calculated-swap-route.interface'; | ||
import { RainbowCalculatedSwapRoute } from '../dexes/rainbow/calculated-swap-route.interface'; | ||
import { StonCalculatedSwapRoute } from '../dexes/ston/calculated-swap-route.interface'; | ||
export type CalculatedSwapRoute = DeDustCalculatedSwapRoute | StonCalculatedSwapRoute | RainbowCalculatedSwapRoute; | ||
import { StonV2CalculatedSwapRoute } from '../dexes/ston-v2/calculated-swap-route.interface'; | ||
export type CalculatedSwapRoute = DeDustCalculatedSwapRoute | StonCalculatedSwapRoute | StonV2CalculatedSwapRoute | RainbowCalculatedSwapRoute; |
{ | ||
"name": "rainbow-swap-sdk", | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"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", |
74817
105
1185