Skip to content

Commit

Permalink
only one adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Feb 9, 2024
1 parent 1b6491c commit 75fbe86
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 47 deletions.
28 changes: 0 additions & 28 deletions dexs/orderly-network-derivatives/index.ts

This file was deleted.

50 changes: 31 additions & 19 deletions dexs/orderly-network/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import type { SimpleAdapter } from "../../adapters/types";
import type { BreakdownAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import { httpGet } from "../../utils/fetchURL";

const dateToTs = (date: string) => new Date(date).getTime() / 1000

const apiNear = "https://api.orderly.org/md/volume/daily_stats"
const apiEVM = "https://api-evm.orderly.org/md/volume/daily_stats"

const adapter: SimpleAdapter = {
adapter: {
"near":{
start: async()=>{
const data = await httpGet(apiNear)
return dateToTs(data[0].date)
const adapter: BreakdownAdapter = {
breakdown: {
"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(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
},
"orderly-network-derivatives": {
[CHAIN.ARBITRUM]: {
start: 1698278400,
fetch: async (timestamp: number) =>{
const data = await httpGet(apiEVM)
const cleanTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000))
return {
timestamp: timestamp,
dailyVolume: data.find((t:any)=>dateToTs(t.date) === cleanTimestamp)?.volume
}
}
}
},
},
};

export default adapter;
}
}
}
export default adapter;

0 comments on commit 75fbe86

Please sign in to comment.