Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions fees/apex-omni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import { FetchOptions, FetchResultFees, SimpleAdapter } from "../adapters/types"
import { CHAIN } from "../helpers/chains";
import { httpGet } from "../utils/fetchURL"
import { METRIC } from "../helpers/metrics";
import ADDRESSES from '../helpers/coreAssets.json'
import { addTokensReceived } from "../helpers/token";

const BUYBACK_VAULT_ADDR = '0x18A45C46840CF830e43049C8fe205CA05B43527B';
const TOKEN_APEX = ADDRESSES.arbitrum.APEX;

interface IFees {
feeOfDate: string;
}

interface IRevenue {
revenueOfDate: string;
}

const fetch = async (_: any, _b: any, options: FetchOptions): Promise<FetchResultFees> => {
const url = `https://omni.apex.exchange/api/v3/data/fee-by-date?time=${options.startOfDay * 1000}`;
const feesData: IFees = (await httpGet(url)).data;
Expand All @@ -23,14 +22,17 @@ const fetch = async (_: any, _b: any, options: FetchOptions): Promise<FetchResul

// tracks APEX token buybacks
const fetchRevenue = async (_: any, _b: any, options: FetchOptions): Promise<FetchResultFees> => {
// Buybacks are not automated, so we have to track this address for any inflows
const dailyHoldersRevenue = await addTokensReceived({ options, token: TOKEN_APEX, target: BUYBACK_VAULT_ADDR})
const url = `https://omni.apex.exchange/api/v3/data/revenue?time=${options.startOfDay * 1000}`;
const revenueData: IRevenue = (await httpGet(url)).data;

return {
dailyRevenue: dailyHoldersRevenue,
dailyHoldersRevenue
if (typeof revenueData?.revenueOfDate !== "string") {
throw new Error("No revenue data");
}
}

return {
dailyRevenue: revenueData.revenueOfDate,
};
};

const info = {
methodology: {
Expand Down
Loading