Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@
"typescript": "5.3.2",
"vitest": "^2.0.2"
},
"resolution": {
"axios-extensions": "3.1.7",
"axios": "1.7.2"
},
"version": "1.0.1",
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
2 changes: 0 additions & 2 deletions packages/oraidex-common-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
},
"license": "MIT",
"dependencies": {
"axios-extensions": "3.1.7",
"axios": "1.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-use": "17.4.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
import { PeriodParams } from "../charting_library";
import { Bar } from "./types";
import Axios, { AxiosAdapter } from "axios";
import { throttleAdapterEnhancer, retryAdapterEnhancer } from "axios-extensions";

const AXIOS_TIMEOUT = 10000;
const AXIOS_THROTTLE_THRESHOLD = 2000;
const axios = Axios.create({
timeout: AXIOS_TIMEOUT,
retryTimes: 3,
// cache will be enabled by default in 2 seconds
adapter: retryAdapterEnhancer(
throttleAdapterEnhancer(Axios.defaults.adapter as AxiosAdapter, {
threshold: AXIOS_THROTTLE_THRESHOLD
})
),
baseURL: "https://api.oraidex.io"
});

export const getTokenChartPrice = async (
pair: string,
periodParams: PeriodParams,
resolution: string
): Promise<Bar[]> => {
try {
const res = await axios.get("/v1/candles", {
params: {
pair,
startTime: periodParams.from,
endTime: periodParams.to,
tf: +resolution * 60
}
const baseUrl = `https://api.oraidex.io/v1`
const response = await fetch(`${baseUrl}/candles?pair=${pair}&startTime=${periodParams.from}&endTime=${periodParams.to}&tf=${+resolution * 60}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
return res.data;

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

const data = await response.json();
return data;
} catch (e) {
console.error("GetTokenChartPrice", e);
return [];
Expand Down
4 changes: 1 addition & 3 deletions packages/oraidex-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-common",
"version": "2.0.12",
"version": "2.0.13",
"main": "./build/index.js",
"module": "./build/index.js",
"types": "./build/index.d.ts",
Expand All @@ -13,8 +13,6 @@
},
"license": "MIT",
"dependencies": {
"axios-extensions": "3.1.7",
"axios": "1.7.2",
"@ethersproject/providers": "^5.0.10",
"ethers": "^5.0.15",
"@keplr-wallet/types": "^0.11.38",
Expand Down
20 changes: 0 additions & 20 deletions packages/oraidex-common/src/axios-request.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/oraidex-common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./axios-request";
export * from "./bigdecimal";
export * from "./config/chainInfosWithIcon";
export * from "./constant";
Expand Down
25 changes: 17 additions & 8 deletions packages/universal-swap/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
oraib2oraichainTest,
getSubAmountDetails,
// evmChains,
getAxios,
// parseAssetInfoFromContractAddrOrDenom,
parseAssetInfo,
calculateTimeoutTimestamp,
Expand Down Expand Up @@ -704,7 +703,6 @@ export class UniversalSwapHelper {
offerAmount: string,
routerConfig: RouterConfigSmartRoute
): Promise<SmartRouterResponse> => {
const { axios } = await getAxios(routerConfig.url);
const data = {
sourceAsset: parseAssetInfo(offerInfo),
sourceChainId: offerChainId,
Expand All @@ -720,13 +718,24 @@ export class UniversalSwapHelper {
ignoreFee: routerConfig.ignoreFee
}
};
const res: {
data: SmartRouterResponse;
} = await axios.post(routerConfig.path, data);

const response = await fetch(routerConfig.url + routerConfig.path, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

const res = await response.json();
return {
swapAmount: res.data.swapAmount,
returnAmount: res.data.returnAmount,
routes: res.data.routes
swapAmount: res.swapAmount,
returnAmount: res.returnAmount,
routes: res.routes
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const simulate = async () => {
const oraidexCommon = await OraidexCommon.load();
const flattenTokens = oraidexCommon.flattenTokens;

let originalFromToken = flattenTokens.find((t) => t.chainId === "0x38" && t.coinGeckoId === "oraichain-token");
let originalFromToken = flattenTokens.find((t) => t.chainId === "Oraichain" && t.coinGeckoId === "tether");
let originalToToken = flattenTokens.find((t) => t.chainId === "Oraichain" && t.coinGeckoId === "oraichain-token");

if (!originalFromToken) throw generateError("Could not find original from token");
Expand All @@ -31,6 +31,8 @@ const simulate = async () => {
protocols: ["Oraidex", "OraidexV3", "Osmosis"]
}
});
console.log({ res });

} catch (error) {
console.log("error: ", error);
}
Expand Down
11 changes: 10 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7002,7 +7002,7 @@ axios@0.21.4, axios@^0.21.1, axios@^0.21.2:
dependencies:
follow-redirects "^1.14.0"

axios@1.7.2, axios@^1.6.0, axios@^1.6.2, axios@^1.6.8:
axios@1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621"
integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==
Expand All @@ -7026,6 +7026,15 @@ axios@^0.27.2:
follow-redirects "^1.14.9"
form-data "^4.0.0"

axios@^1.6.0, axios@^1.6.2, axios@^1.6.8:
version "1.9.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.9.0.tgz#25534e3b72b54540077d33046f77e3b8d7081901"
integrity sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^1.6.7, axios@^1.7.4:
version "1.7.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.7.tgz#2f554296f9892a72ac8d8e4c5b79c14a91d0a47f"
Expand Down
Loading