diff --git a/dexs/core-markets/index.ts b/dexs/core-markets/index.ts index eb7141a799..9f6a9a1c7b 100644 --- a/dexs/core-markets/index.ts +++ b/dexs/core-markets/index.ts @@ -80,7 +80,7 @@ const fetchVolume = async (timestamp: number): Promise => { const adapter: SimpleAdapter = { adapter: { - [CHAIN.BASE]: { + [CHAIN.BLAST]: { fetch: fetchVolume, start: async () => 236678, }, diff --git a/dexs/intent-x/index.tsx b/dexs/intent-x/index.tsx index 5616ddb74b..d05e5dee31 100644 --- a/dexs/intent-x/index.tsx +++ b/dexs/intent-x/index.tsx @@ -96,10 +96,6 @@ const fetchVolume = async (timestamp: number): Promise => { from: String(timestamp - ONE_DAY_IN_SECONDS), to: String(timestamp), }); - const response_blast: IGraphResponse = await request(endpoint_blast, queryBlast, { - from: String(timestamp - ONE_DAY_IN_SECONDS), - to: String(timestamp), - }); let dailyVolume = new BigNumber(0); response_0_8_0.dailyHistories.forEach((data) => { @@ -108,10 +104,6 @@ const fetchVolume = async (timestamp: number): Promise => { response.dailyHistories.forEach((data) => { dailyVolume = dailyVolume.plus(new BigNumber(data.tradeVolume)); }); - response_blast.dailyHistories.forEach((data) => { - dailyVolume = dailyVolume.plus(new BigNumber(data.tradeVolume)); - }); - let totalVolume = new BigNumber(0); response_0_8_0.totalHistories.forEach((data) => { @@ -120,6 +112,33 @@ const fetchVolume = async (timestamp: number): Promise => { response.totalHistories.forEach((data) => { totalVolume = totalVolume.plus(new BigNumber(data.tradeVolume)); }); + + dailyVolume = dailyVolume.dividedBy(new BigNumber(1e18)); + totalVolume = totalVolume.dividedBy(new BigNumber(1e18)); + + const _dailyVolume = toString(dailyVolume); + const _totalVolume = toString(totalVolume); + + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + + return { + timestamp: dayTimestamp, + dailyVolume: _dailyVolume ?? "0", + totalVolume: _totalVolume ?? "0", + }; +}; + +const fetchVolumeBlast = async (timestamp: number): Promise => { + let dailyVolume = new BigNumber(0); + let totalVolume = new BigNumber(0); + + const response_blast: IGraphResponse = await request(endpoint_blast, queryBlast, { + from: String(timestamp - ONE_DAY_IN_SECONDS), + to: String(timestamp), + }); + response_blast.dailyHistories.forEach((data) => { + dailyVolume = dailyVolume.plus(new BigNumber(data.tradeVolume)); + }); response_blast.totalHistories.forEach((data) => { totalVolume = totalVolume.plus(new BigNumber(data.tradeVolume)); }); @@ -145,6 +164,10 @@ const adapter: SimpleAdapter = { fetch: fetchVolume, start: 1698796800, }, + [CHAIN.BLAST]: { + fetch: fetchVolumeBlast, + start: 1698796800, + }, }, }; diff --git a/fees/core-markets/index.ts b/fees/core-markets/index.ts index ebd5f738fc..5d6776a8d0 100644 --- a/fees/core-markets/index.ts +++ b/fees/core-markets/index.ts @@ -107,7 +107,7 @@ const fetchVolume = async (timestamp: number): Promise => { const adapter: SimpleAdapter = { adapter: { - [CHAIN.BASE]: { + [CHAIN.BLAST]: { fetch: fetchVolume, start: async () => 236678, }, diff --git a/fees/intent-x/index.tsx b/fees/intent-x/index.tsx index e1aaace540..817482e92f 100644 --- a/fees/intent-x/index.tsx +++ b/fees/intent-x/index.tsx @@ -96,10 +96,6 @@ const fetchVolume = async (timestamp: number): Promise => { from: String(timestamp - ONE_DAY_IN_SECONDS), to: String(timestamp), }); - const response_blast: IGraphResponse = await request(endpoint_blast, queryBlast, { - from: String(timestamp - ONE_DAY_IN_SECONDS), - to: String(timestamp), - }); // Merging both responses let dailyFees = new BigNumber(0); @@ -109,9 +105,6 @@ const fetchVolume = async (timestamp: number): Promise => { response.dailyHistories.forEach((data) => { dailyFees = dailyFees.plus(new BigNumber(data.platformFee)); }); - response_blast.dailyHistories.forEach((data) => { - dailyFees = dailyFees.plus(new BigNumber(data.platformFee)); - }); let totalFees = new BigNumber(0); response_0_8_0.totalHistories.forEach((data) => { @@ -120,13 +113,61 @@ const fetchVolume = async (timestamp: number): Promise => { response.totalHistories.forEach((data) => { totalFees = totalFees.plus(new BigNumber(data.platformFee)); }); + + dailyFees = dailyFees.dividedBy(new BigNumber(1e18)); + totalFees = totalFees.dividedBy(new BigNumber(1e18)); + + const _dailyFees = toString(dailyFees); + const _totalFees = toString(totalFees); + + const dailyUserFees = _dailyFees; + const dailyRevenue = _dailyFees; + const dailyProtocolRevenue = "0"; + const dailyHoldersRevenue = _dailyFees; + const dailySupplySideRevenue = "0"; + + const totalUserFees = _totalFees; + const totalRevenue = _totalFees; + const totalProtocolRevenue = "0"; + const totalSupplySideRevenue = "0"; + + const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)); + + return { + timestamp: dayTimestamp, + + dailyFees: _dailyFees ?? "0", + totalFees: _totalFees ?? "0", + + dailyUserFees: dailyUserFees ?? "0", + dailyRevenue: dailyRevenue ?? "0", + dailyProtocolRevenue: dailyProtocolRevenue ?? "0", + dailyHoldersRevenue: dailyHoldersRevenue ?? "0", + dailySupplySideRevenue: dailySupplySideRevenue ?? "0", + totalUserFees: totalUserFees ?? "0", + totalRevenue: totalRevenue ?? "0", + totalProtocolRevenue: totalProtocolRevenue ?? "0", + totalSupplySideRevenue: totalSupplySideRevenue ?? "0", + }; +}; + +const fetchVolumeBlast = async (timestamp: number): Promise => { + let dailyFees = new BigNumber(0); + let totalFees = new BigNumber(0); + + const response_blast: IGraphResponse = await request(endpoint_blast, queryBlast, { + from: String(timestamp - ONE_DAY_IN_SECONDS), + to: String(timestamp), + }); + response_blast.dailyHistories.forEach((data) => { + dailyFees = dailyFees.plus(new BigNumber(data.platformFee)); + }); response_blast.totalHistories.forEach((data) => { totalFees = totalFees.plus(new BigNumber(data.platformFee)); }); dailyFees = dailyFees.dividedBy(new BigNumber(1e18)); totalFees = totalFees.dividedBy(new BigNumber(1e18)); - const _dailyFees = toString(dailyFees); const _totalFees = toString(totalFees); @@ -167,6 +208,10 @@ const adapter: SimpleAdapter = { fetch: fetchVolume, start: 1698796800, }, + [CHAIN.BLAST]: { + fetch: fetchVolumeBlast, + start: 1698796800, + }, }, }; export default adapter;