Skip to content

Commit

Permalink
fix catch error
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Apr 13, 2024
1 parent 928ea40 commit a3593af
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions dexs/orderly-network/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BreakdownAdapter } from "../../adapters/types";
import type { BreakdownAdapter, FetchOptions } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import { httpGet } from "../../utils/fetchURL";
Expand All @@ -12,22 +12,30 @@ const adapter: BreakdownAdapter = {
"orderly-network": {
[CHAIN.NEAR]: {
start: 1669977923,
fetch: async(ts)=>{
const data = await httpGet(apiNear)
const cleanTimestamp = getUniqStartOfTodayTimestamp(new Date(ts * 1000))
return {
timestamp: cleanTimestamp,
dailyVolume: data.find((t:any)=>dateToTs(t.date) === cleanTimestamp)?.volume
fetch: async(__t: number, _: any, { startOfDay }: FetchOptions) => {
try {
const data = await httpGet(apiNear) // error
const cleanTimestamp = getUniqStartOfTodayTimestamp(new Date(startOfDay * 1000))
return {
timestamp: cleanTimestamp,
dailyVolume: data.find((t:any)=>dateToTs(t.date) === cleanTimestamp)?.volume
}
} catch (e) {
console.error(e);
return {
timestamp: startOfDay,
dailyVolume: 0
}
}
}
},
},
"orderly-network-derivatives": {
[CHAIN.ARBITRUM]: {
start: 1698278400,
fetch: async (timestamp: number) =>{
fetch: async (__t: number, _: any, { startOfDay }: FetchOptions) =>{
const data = await httpGet(apiEVM)
const cleanTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000))
const cleanTimestamp = getUniqStartOfTodayTimestamp(new Date(startOfDay * 1000))
return {
timestamp: cleanTimestamp,
dailyVolume: data.find((t:any)=>dateToTs(t.date) === cleanTimestamp)?.volume
Expand Down

0 comments on commit a3593af

Please sign in to comment.