Skip to content

Commit

Permalink
fix helix perp
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmkeng committed Feb 20, 2024
1 parent a613257 commit 230c5a1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 40 deletions.
33 changes: 0 additions & 33 deletions dexs/helix-perp/index.ts

This file was deleted.

34 changes: 27 additions & 7 deletions dexs/helix/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ChainBlocks, FetchOptions, FetchResultVolume, SimpleAdapter } from "../../adapters/types";
import { BreakdownAdapter, ChainBlocks, FetchOptions, FetchResultVolume, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import fetchURL from "../../utils/fetchURL"

const URL = "https://external.api.injective.network/api/aggregator/v1/spot/tickers";
interface IVolume {
target_volume: number;
open_interest: number;
}

const fetch = async (timestamp: number, _: ChainBlocks, { createBalances }: FetchOptions): Promise<FetchResultVolume> => {
Expand All @@ -18,14 +19,33 @@ const fetch = async (timestamp: number, _: ChainBlocks, { createBalances }: Fetc
}
}

const URL_Derivative = "https://external.api.injective.network/api/aggregator/v1/derivative/contracts";
const fetchDerivative = async (timestamp: number): Promise<FetchResultVolume> => {
const volume: IVolume[] = (await fetchURL(URL_Derivative));
const dailyVolume = volume.reduce((e: number, a: IVolume) => a.target_volume + e, 0);
const dailyOpenInterest = volume.reduce((e: number, a: IVolume) => a.open_interest + e, 0);

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.INJECTIVE]: {
fetch: fetch,
start: 1676505600,
}
return {
dailyVolume: dailyVolume.toString(),
dailyOpenInterest: dailyOpenInterest.toString(),
timestamp
}
}

const adapter: BreakdownAdapter = {
breakdown: {
"helix": {
[CHAIN.INJECTIVE]: {
fetch: fetch,
start: 1676505600,
}
},
"helix-perp": {
[CHAIN.INJECTIVE]: {
fetch: fetchDerivative,
start: 1706313600,
}
}
}
}
export default adapter;

0 comments on commit 230c5a1

Please sign in to comment.