File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments