Skip to content

Commit

Permalink
update params smart route (#324)
Browse files Browse the repository at this point in the history
* update params smart route

* update params smart route
  • Loading branch information
haunv3 authored Aug 28, 2024
1 parent 02f5447 commit 303fe90
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/oraidex-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-common",
"version": "1.1.3",
"version": "1.1.6",
"main": "build/index.js",
"files": [
"build/"
Expand Down
4 changes: 2 additions & 2 deletions packages/oraidex-common/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,8 @@ export const chainInfos: CustomChainInfo[] = [
{
...OsmoToken,
bridgeTo: ["Oraichain"]
}
// ...listOsmosisToken
},
...listOsmosisToken
]
},
/// popular networks already included
Expand Down
2 changes: 1 addition & 1 deletion packages/universal-swap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-universal-swap",
"version": "1.1.1",
"version": "1.1.2",
"main": "build/index.js",
"files": [
"build/"
Expand Down
22 changes: 9 additions & 13 deletions packages/universal-swap/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
ConvertReverse,
ConvertType,
OraiBridgeRouteData,
RouterConfigSmartRoute,
RouterResponse,
SimulateResponse,
SmartRouterResponse,
Expand Down Expand Up @@ -528,11 +529,7 @@ export class UniversalSwapHelper {
askInfo: AssetInfo,
askChainId: string,
offerAmount: string,
routerConfig: {
url: string;
path?: string;
protocols?: string[];
}
routerConfig: RouterConfigSmartRoute
): Promise<SmartRouterResponseAPI> => {
const { axios } = await getAxios(routerConfig.url);
const data = {
Expand All @@ -542,7 +539,8 @@ export class UniversalSwapHelper {
destChainId: askChainId,
offerAmount: offerAmount,
swapOptions: {
protocols: routerConfig.protocols
protocols: routerConfig.protocols,
dontAlowSwapAfter: routerConfig.dontAllowSwapAfter
}
};
const res: {
Expand All @@ -561,10 +559,11 @@ export class UniversalSwapHelper {
askInfo: AssetInfo,
askChainId: string,
offerAmount: string,
routerConfig: { url: string; path?: string; protocols?: string[] } = {
routerConfig: RouterConfigSmartRoute = {
url: "https://osor.oraidex.io",
path: "/smart-router",
protocols: ["Oraidex", "OraidexV3", "Osmosis"]
protocols: ["Oraidex", "OraidexV3", "Osmosis"],
dontAllowSwapAfter: [""]
}
): Promise<SmartRouterResponse> => {
const { returnAmount, routes } = await UniversalSwapHelper.querySmartRoute(
Expand Down Expand Up @@ -621,11 +620,7 @@ export class UniversalSwapHelper {
fromInfo: TokenItemType;
toInfo: TokenItemType;
amount: string;
routerConfig?: {
url: string;
path?: string;
protocols?: string[];
};
routerConfig?: RouterConfigSmartRoute;
}): Promise<SmartRouterResponse> => {
const { amount, fromInfo, toInfo, routerConfig } = query;
// check for universal-swap 2 tokens that have same coingeckoId, should return simulate data with average ratio 1-1.
Expand Down Expand Up @@ -720,6 +715,7 @@ export class UniversalSwapHelper {
url: string;
path?: string;
protocols?: string[];
dontAlowSwapAfter?: string[];
};
}): Promise<SimulateResponse> => {
// if the from token info is on bsc or eth, then we simulate using uniswap / pancake router
Expand Down
7 changes: 7 additions & 0 deletions packages/universal-swap/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,10 @@ export interface Routes extends RouteBase {
bridgeInfo?: BridgeInfo;
swapInfo?: SwapInfo[];
}

export interface RouterConfigSmartRoute {
url: string;
path?: string;
protocols?: string[];
dontAllowSwapAfter?: string[];
}

0 comments on commit 303fe90

Please sign in to comment.