-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1627 from JoscelynFarr/master
add fee in JOJO
- Loading branch information
Showing
1 changed file
with
31 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,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<FetchResultV2> => { | ||
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 |