This commit is contained in:
Aleksandr Kraiz
2022-05-28 11:17:18 +04:00
parent 1b660c9ada
commit fd212d2366
7 changed files with 30 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ export type SwapMarketParams = {
signer: ethers.Signer,
orionUnit: OrionUnit,
options?: {
poolOnly?: boolean,
logger?: (message: string) => void,
autoApprove?: boolean,
developer?: {
@@ -115,7 +116,17 @@ export default async function swapMarket({
signer,
);
const swapInfo = await simpleFetch(orionAggregator.getSwapInfo)(type, assetIn, assetOut, amount.toString());
const swapInfo = await simpleFetch(orionAggregator.getSwapInfo)(
type,
assetIn,
assetOut,
amount.toString(),
options?.poolOnly ? ['ORION_POOL'] : undefined,
);
if (options?.poolOnly === true && options.poolOnly !== swapInfo.isThroughPoolOptimal) {
throw new Error(`Unexpected Orion Aggregator response. Please, contact support. Report swap request id: ${swapInfo.id}`);
}
if (swapInfo.type === 'exactReceive' && amountBN.lt(swapInfo.minAmountOut)) {
throw new Error(`Amount is too low. Min amountOut is ${swapInfo.minAmountOut} ${assetOut}`);