forked from DefiLlama/dimension-adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |