diff --git a/fees/jojo/index.ts b/fees/jojo/index.ts new file mode 100644 index 0000000000..6f1d1d7cdf --- /dev/null +++ b/fees/jojo/index.ts @@ -0,0 +1,31 @@ +import { FetchOptions, SimpleAdapter, FetchV2, FetchResultV2 } from '../../adapters/types' +import { httpGet } from '../../utils/fetchURL' + +interface IFees { + day: string + fee: string +} + +const getFetch: FetchV2 = async (options: FetchOptions): Promise => { + const url = 'https://api.base-mainnet.jojo.exchange/v1/private/tradingFee?limit=365' + const dateStr = new Date((options.startOfDay - 86400) * 1000).toISOString().split('T')[0] + const res = await httpGet(url) + delete res['latestTen'] + const item: IFees[] = Object.values(res) + const dailyFees = item.flat().find((i) => i.day.split('T')[0] === dateStr)?.fee + return { + dailyFees: dailyFees ? dailyFees : undefined, + } +} + +const adapter: SimpleAdapter = { + version: 2, + adapter: { + "jojo": { + fetch: getFetch, + start: 1712678400, + } + } +} + +export default adapter