-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dappos-intentEx volumes and fees
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { SimpleAdapter } from "../../adapters/types"; | ||
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; | ||
import { httpGet } from "../../utils/fetchURL"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const URL = "https://trade-info.dappos.com/market/archive?timestamp="; | ||
|
||
interface Response { | ||
daily_trade_volume: string; | ||
} | ||
|
||
const fetch = async (timestamp: number) => { | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); | ||
const url = `${URL}${dayTimestamp}` | ||
const respose: Response[] = await httpGet(url); | ||
const dailyVolume = respose.reduce((acc, item) => { | ||
return acc + Number(item.daily_trade_volume); | ||
}, 0); | ||
|
||
return { | ||
dailyVolume: dailyVolume?.toString(), | ||
timestamp: dayTimestamp, | ||
}; | ||
}; | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.OP_BNB]: { | ||
fetch, | ||
start: '2025-01-01', | ||
}, | ||
} | ||
}; | ||
|
||
export default adapter; |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { CHAIN } from "../helpers/chains" | ||
import { Adapter, FetchOptions, } from '../adapters/types'; | ||
import { httpGet } from "../utils/fetchURL"; | ||
import { getUniqStartOfTodayTimestamp } from "../helpers/getUniSubgraphVolume"; | ||
|
||
const URL = "https://trade-info.dappos.com/market/archive?timestamp="; | ||
|
||
interface Response { | ||
daily_trade_fee: string; | ||
total_trade_fee: string; | ||
} | ||
|
||
const fetchFees = async (options: FetchOptions) => { | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(options.endTimestamp * 1000)); | ||
const url = `${URL}${dayTimestamp}` | ||
const respose: Response[] = await httpGet(url); | ||
const dailyFees = respose.reduce((acc, item) => { | ||
return acc + Number(item.daily_trade_fee); | ||
}, 0); | ||
const totalFees = respose.reduce((acc, item) => { | ||
return acc + Number(item.total_trade_fee); | ||
}, 0); | ||
|
||
return { | ||
dailyFees, | ||
dailyRevenue: dailyFees, | ||
totalFees, | ||
totalRevenue: totalFees, | ||
} | ||
} | ||
|
||
const adapter: Adapter = { | ||
version: 2, | ||
adapter: { | ||
[CHAIN.OP_BNB]: { | ||
fetch: fetchFees, | ||
start: '2025-01-01', | ||
}, | ||
}, | ||
} | ||
export default adapter |