forked from DefiLlama/dimension-adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathderive-options.ts
More file actions
28 lines (23 loc) · 925 Bytes
/
derive-options.ts
File metadata and controls
28 lines (23 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { CHAIN } from "../helpers/chains";
import fetchURL from "../utils/fetchURL";
async function fetch() {
let openInterestAtEnd = 0;
const [statsData, currencyData] = await Promise.all(
[
fetchURL("https://api.lyra.finance/public/all_statistics"),
fetchURL("https://api.lyra.finance/public/get_all_currencies")
]
);
const statsList = statsData.result.filter((statsEntry: any) => statsEntry.instrument_type === 'option');
const currencyList = currencyData.result;
statsList.forEach((statsEntry: any) => {
const currentPrice = currencyList.filter((currencyEntry: any) => statsEntry.currency === currencyEntry.currency).at(0)?.spot_price ?? 0;
openInterestAtEnd += (statsEntry.open_interest * currentPrice * 2);
});
return { openInterestAtEnd }
}
export default {
chains: [CHAIN.LYRA],
fetch,
runAtCurrTime: true,
}