Force route

This commit is contained in:
Aleksandr Kraiz
2022-05-25 18:09:48 +04:00
parent 244bd5e51b
commit 69b579b6ed
2 changed files with 6 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.10.1",
"version": "0.10.2",
"description": "Orion Protocol SDK",
"main": "./lib/esm/index.js",
"module": "./lib/esm/index.js",

View File

@@ -23,6 +23,9 @@ export type SwapMarketParams = {
options?: {
logger?: (message: string) => void,
autoApprove?: boolean,
developer: {
route: 'aggregator' | 'pool',
}
}
}
@@ -49,6 +52,7 @@ export default async function swapMarket({
orionUnit,
options,
}: SwapMarketParams): Promise<Swap> {
if (options?.developer) options?.logger?.('YOU SPECIFIED A DEVELOPER OPTIONS. BE CAREFUL!');
if (amount === '') throw new Error('Amount can not be empty');
if (assetIn === '') throw new Error('AssetIn can not be empty');
if (assetOut === '') throw new Error('AssetOut can not be empty');
@@ -125,7 +129,7 @@ export default async function swapMarket({
const percent = new BigNumber(slippagePercent).div(100);
const { isThroughPoolOptimal } = swapInfo;
const isThroughPoolOptimal = options?.developer.route === 'pool' ?? swapInfo.isThroughPoolOptimal;
if (isThroughPoolOptimal) {
options?.logger?.('Swap through pool');