Skip to content

Commit 0f96af3

Browse files
authored
Merge pull request #2401 from moby-dev02/moby-bera
feat: add moby berachain integration
2 parents fb83d2d + 57ae4f8 commit 0f96af3

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

options/moby/index.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,30 @@ interface IMobyVolumeResponse {
1010
}
1111

1212
// endTime is in ms
13-
export const mobyVolumeEndpoint = (endTime: number) => {
13+
export const arb_mobyVolumeEndpoint = (endTime: number) => {
1414
return `https://lambda-api.moby.trade/getVolumeData?end_time=${endTime}`;
1515
}
1616

17+
export const bera_mobyVolumeEndpoint = (endTime: number) => {
18+
return `https://lambda-bera-api.moby.trade/getVolumeData?end_time=${endTime}`;
19+
}
20+
1721
export const moby_adapter: SimpleAdapter = {
1822
adapter: {
1923
[CHAIN.ARBITRUM]: {
20-
fetch: fetchMobyVolumeData,
24+
fetch: arb_fetchMobyVolumeData,
2125
start: '2024-04-03'
2226
},
27+
[CHAIN.BERACHAIN]: {
28+
fetch: bera_fetchMobyVolumeData,
29+
start: '2025-02-08'
30+
}
2331
},
2432
};
2533

26-
export async function fetchMobyVolumeData(
27-
/** Timestamp representing the end of the 24 hour period */
28-
timestamp: number
29-
) {
34+
const _fetchMobyVolumeData = async (timestamp, endPoint) => {
3035
let timestamp_in_ms = timestamp * 1000
31-
const mobyVolumeData = await getMobyVolumeData(mobyVolumeEndpoint(timestamp_in_ms));
36+
const mobyVolumeData = await getMobyVolumeData(endPoint(timestamp_in_ms));
3237

3338
const dailyNotionalVolume = Number(mobyVolumeData.daily_notional_volume).toFixed(2);
3439
const dailyPremiumVolume = Number(mobyVolumeData.daily_premium_volume).toFixed(2);
@@ -44,6 +49,20 @@ export async function fetchMobyVolumeData(
4449
};
4550
}
4651

52+
export async function arb_fetchMobyVolumeData(
53+
/** Timestamp representing the end of the 24 hour period */
54+
timestamp: number
55+
) {
56+
return await _fetchMobyVolumeData(timestamp, arb_mobyVolumeEndpoint);
57+
}
58+
59+
export async function bera_fetchMobyVolumeData(
60+
/** Timestamp representing the end of the 24 hour period */
61+
timestamp: number
62+
) {
63+
return await _fetchMobyVolumeData(timestamp, bera_mobyVolumeEndpoint);
64+
}
65+
4766
async function getMobyVolumeData(endpoint: string): Promise<IMobyVolumeResponse> {
4867
const results = await fetchURL(endpoint)
4968

0 commit comments

Comments
 (0)