Fix poolOnly

This commit is contained in:
Aleksandr Kraiz
2022-05-30 16:59:29 +04:00
parent 1bae893719
commit b17bc611cf
2 changed files with 7 additions and 3 deletions

View File

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

View File

@@ -126,7 +126,7 @@ export default async function swapMarket({
options?.poolOnly ? ['ORION_POOL'] : undefined,
);
if (options?.poolOnly === true && options.poolOnly !== swapInfo.isThroughPoolOptimal) {
if (swapInfo.orderInfo !== null && options?.poolOnly === true && options.poolOnly !== swapInfo.isThroughPoolOptimal) {
throw new Error(`Unexpected Orion Aggregator response. Please, contact support. Report swap request id: ${swapInfo.id}`);
}
@@ -142,7 +142,11 @@ export default async function swapMarket({
const percent = new BigNumber(slippagePercent).div(100);
const isThroughPoolOptimal = options?.developer?.route === 'pool' ?? swapInfo.isThroughPoolOptimal;
let isThroughPoolOptimal: boolean;
if (options?.developer?.route !== undefined) {
isThroughPoolOptimal = options.developer.route === 'pool';
} else if (options?.poolOnly) isThroughPoolOptimal = true;
else isThroughPoolOptimal = swapInfo.isThroughPoolOptimal;
if (isThroughPoolOptimal) {
options?.logger?.('Swap through pool');