Skip to content

Commit

Permalink
🩹Fix exact output quote using stellar classic assets
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPoblete committed Aug 23, 2024
1 parent 2161980 commit f6a59fd
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/functions/generateRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,42 +118,42 @@ export const useRouterSDK = () => {
amount,
tradeType,
};

const horizonPath = (await getHorizonBestPath(horizonProps, sorobanContext)) as BuildTradeRoute;

let horizonPath: BuildTradeRoute;
try {
horizonPath = (await getHorizonBestPath(horizonProps, sorobanContext)) as BuildTradeRoute;
} catch (error) {
console.error('Error getting horizon path');
}
let sorobanPath: BuildTradeRoute;
if (isAggregator) {
sorobanPath = (await router
.routeSplit(currencyAmount, quoteCurrency, tradeType)
.then((response) => {
if (!response) return undefined;
const result = {
...response,
platform: PlatformType.AGGREGATOR,
};
return result;
})) as BuildTradeRoute;
} else {
sorobanPath = (await router
.route(currencyAmount, quoteCurrency, tradeType, factory, sorobanContext as any)
.then((response) => {
if (!response) return undefined;
const result = {
...response,
platform: PlatformType.ROUTER,
};
return result;
})) as BuildTradeRoute;
try{
if (isAggregator) {
sorobanPath = (await router
.routeSplit(currencyAmount, quoteCurrency, tradeType)
.then((response) => {
if (!response) return undefined;
const result = {
...response,
platform: PlatformType.AGGREGATOR,
};
return result;
})) as BuildTradeRoute;
} else {
sorobanPath = (await router
.route(currencyAmount, quoteCurrency, tradeType, factory, sorobanContext as any)
.then((response) => {
if (!response) return undefined;
const result = {
...response,
platform: PlatformType.ROUTER,
};
return result;
})) as BuildTradeRoute;
}
} catch (error) {
console.error('Error getting soroban path', error);
}
const bestPath = getBestPath(horizonPath, sorobanPath, tradeType);
// .then((res) => {
// if (!res) return;
// const response = {
// ...res,
// platform: PlatformType.ROUTER,
// };
// return response;
// });

const bestPath = getBestPath(horizonPath!, sorobanPath!, tradeType);

return bestPath;
};
Expand Down

0 comments on commit f6a59fd

Please sign in to comment.