Skip to content

Commit

Permalink
fix TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Feb 28, 2024
1 parent 3ea1727 commit 46166fb
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions adapters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type FetchOptions = {
chain: string,
api: ChainApi,
fromApi: ChainApi,
toApi: ChainApi,
startTimestamp: number,
endTimestamp: number,
getStartBlock: () => Promise<number>,
Expand Down
2 changes: 2 additions & 0 deletions adapters/utils/runAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default async function runAdapter(volumeAdapter: BaseAdapter, cleanCurren
const endTimestamp = toTimestamp
const getStartBlock = getFromBlock
const getEndBlock = getToBlock
const toApi = api

return {
createBalances,
Expand All @@ -102,6 +103,7 @@ export default async function runAdapter(volumeAdapter: BaseAdapter, cleanCurren
getLogs,
chain,
fromApi,
toApi,
api,
startOfDay,
startTimestamp,
Expand Down
4 changes: 2 additions & 2 deletions fees/apeswap.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { CHAIN } from "../helpers/chains";
import volumeAdapter from "../dexs/apeswap";
import { BaseAdapter, Adapter, ChainBlocks, FetchOptions } from "../adapters/types";
import { BaseAdapter, Adapter, ChainBlocks, FetchOptions, Fetch } from "../adapters/types";
import BigNumber from "bignumber.js";


const adapterObj = volumeAdapter.adapter;

const fetch = (chain: string, totalFees: number, revenueFee: number) => {
return async (timestamp: number, chainBlocks: ChainBlocks, options: FetchOptions) => {
const fetchedResult = await adapterObj[chain].fetch(timestamp, chainBlocks, options);
const fetchedResult = await (adapterObj[chain].fetch as Fetch)(timestamp, chainBlocks, options);
const chainDailyVolume = fetchedResult.dailyVolume as number || '0';
const chainTotalVolume = fetchedResult.totalVolume as number || '0';
const ssrFee = totalFees - revenueFee
Expand Down
4 changes: 2 additions & 2 deletions fees/verse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CHAIN } from "../helpers/chains";
import { BaseAdapter, Adapter, ChainBlocks, FetchOptions } from "../adapters/types";
import { BaseAdapter, Adapter, ChainBlocks, FetchOptions, Fetch } from "../adapters/types";
import volumeAdapter from "../dexs/verse";
import BigNumber from "bignumber.js";

Expand All @@ -8,7 +8,7 @@ const adapterObj = volumeAdapter.adapter;

const fetch = (chain: string, totalFees: number, revenueFee: number, ssrFee: number) => {
return async (timestamp: number, chainBlocks: ChainBlocks, options: FetchOptions) => {
const fetchedResult = await adapterObj[chain].fetch(timestamp, chainBlocks, options);
const fetchedResult = await (adapterObj[chain].fetch as Fetch)(timestamp, chainBlocks, options);
const chainDailyVolume = fetchedResult.dailyVolume as any;
const chainTotalVolume = fetchedResult.totalVolume as any;

Expand Down
6 changes: 3 additions & 3 deletions fees/zkswap-finance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CHAIN } from "../helpers/chains";
import volumeAdapter from "../dexs/zkSwap_Finance";
import { BaseAdapter, Adapter, ChainBlocks, FetchOptions } from "../adapters/types";
import { BaseAdapter, Adapter, ChainBlocks, FetchOptions, Fetch } from "../adapters/types";
import BigNumber from "bignumber.js";
import { Balances } from "@defillama/sdk";

Expand All @@ -11,8 +11,8 @@ const fetch = (chain: string, totalFees: number, revenueFee: number) => {
return async (timestamp: number, chainBlocks: ChainBlocks, options: FetchOptions) => {
const FEE_COLLECTED_START_TIME = 1696118400

const fetchedResult = await adapterObj[chain].fetch(timestamp, chainBlocks, options);
const fetchedResultStartTime = await adapterObj[chain].fetch(FEE_COLLECTED_START_TIME, chainBlocks, options);
const fetchedResult = await (adapterObj[chain].fetch as Fetch)(timestamp, chainBlocks, options);
const fetchedResultStartTime = await (adapterObj[chain].fetch as Fetch)(FEE_COLLECTED_START_TIME, chainBlocks, options);

const chainDailyVolume = (await (fetchedResult.dailyVolume as Balances).getUSDValue()).toString();
const chainTotalVolumeFromFeeCollectedDate = (Number(fetchedResult.totalVolume) - Number(fetchedResultStartTime.totalVolume))
Expand Down
6 changes: 3 additions & 3 deletions helpers/getUniSubgraphFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
DEFAULT_DAILY_VOLUME_FACTORY,
DEFAULT_DAILY_VOLUME_FIELD,
} from "../helpers/getUniSubgraphVolume";
import type { ChainEndpoints, FetchOptions } from "../adapters/types";
import type { ChainEndpoints, Fetch, FetchOptions } from "../adapters/types";

// To get ID for daily data https://docs.uniswap.org/protocol/V2/reference/API/entities
const getUniswapDateId = (date?: Date) => getUniqStartOfTodayTimestamp(date) / 86400;
Expand Down Expand Up @@ -98,7 +98,7 @@ const getDexChainBreakdownFees = ({ volumeAdapter, totalFees = 0, protocolFees =

const baseAdapters = Object.keys(volAdapter).map(chain => {
const fetchFees = async (timestamp: number, chainBlocks: ChainBlocks, options: FetchOptions) => {
const fetchedResult: FetchResultVolume = await volAdapter[chain].fetch(timestamp, chainBlocks, options)
const fetchedResult: FetchResultVolume = await (volAdapter[chain].fetch as Fetch)(timestamp, chainBlocks, options)
const chainDailyVolume = fetchedResult.dailyVolume ? fetchedResult.dailyVolume as number : "0";
const chainTotalVolume = fetchedResult.totalVolume ? fetchedResult.totalVolume as number : "0";

Expand Down Expand Up @@ -139,7 +139,7 @@ const getDexChainFees = ({ volumeAdapter, totalFees = 0, protocolFees = 0, ...pa

Object.keys(adapterObj).map(chain => {
const fetchFees = async (timestamp: number, chainBlocks: ChainBlocks, options: FetchOptions) => {
const fetchedResult: FetchResultVolume = await adapterObj[chain].fetch(timestamp, chainBlocks, options)
const fetchedResult: FetchResultVolume = await (adapterObj[chain].fetch as Fetch)(timestamp, chainBlocks, options)
const chainDailyVolume = fetchedResult.dailyVolume as number;
const chainTotalVolume = fetchedResult.totalVolume as number;
const response: FetchResultGeneric = { timestamp }
Expand Down

0 comments on commit 46166fb

Please sign in to comment.