Skip to content

Commit 39fcc87

Browse files
authored
track rocket perp oi (#6285)
1 parent 234fa5b commit 39fcc87

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

open-interest/rocket-oi.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { FetchOptions, SimpleAdapter } from "../adapters/types";
2+
import fetchURL from "../utils/fetchURL";
3+
import { CHAIN } from "../helpers/chains";
4+
5+
const ROCKET_API_URL = 'https://beta.rocket-cluster-1.com';
6+
7+
async function fetch(_options: FetchOptions) {
8+
9+
const instrumentsData = await fetchURL(`${ROCKET_API_URL}/instruments`);
10+
11+
let openInterestAtEnd = 0;
12+
const instrumentStats: Record<string, any> = instrumentsData.instrumentStats;
13+
for (const instrument of Object.entries(instrumentStats)) {
14+
const [id, data] = instrument;
15+
const oi = data.openInterest;
16+
const price = instrumentsData.instruments[id].lastMatchPrice;
17+
openInterestAtEnd += oi * price;
18+
}
19+
20+
return {
21+
openInterestAtEnd,
22+
};
23+
24+
}
25+
26+
const adapter: SimpleAdapter = {
27+
version: 2,
28+
runAtCurrTime: true,
29+
fetch,
30+
chains: [CHAIN.OFF_CHAIN],
31+
}
32+
33+
export default adapter;

0 commit comments

Comments
 (0)