-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee016fd
commit e9be7c7
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { FetchOptions, SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
import fetchURL from "../../utils/fetchURL"; | ||
import { getTimestampAtStartOfDayUTC } from "../../utils/date"; | ||
|
||
const ZIVOE_API_URL = "https://analytics.zivoe.com/api/stats/feesAndRevenue"; | ||
|
||
type DailyAmount = { | ||
tokenAddress: string; | ||
value: string; | ||
}; | ||
|
||
type DailyFeesAndRevenue = { | ||
fees: Array<DailyAmount>; | ||
revenue: Array<DailyAmount>; | ||
}; | ||
|
||
const fetch = async (options: FetchOptions) => { | ||
const dailyFees = options.createBalances(); | ||
const dailyRevenue = options.createBalances(); | ||
|
||
const params = new URLSearchParams({ | ||
network: "MAINNET", | ||
periodStart: getTimestampAtStartOfDayUTC(options.toTimestamp).toString(), | ||
}); | ||
|
||
const { fees, revenue }: DailyFeesAndRevenue = await fetchURL(ZIVOE_API_URL + "?" + params.toString()); | ||
|
||
fees.forEach((record) => { | ||
dailyFees.add(record.tokenAddress, BigInt(record.value)); | ||
}); | ||
|
||
revenue.forEach((record) => { | ||
dailyRevenue.add(record.tokenAddress, BigInt(record.value)); | ||
}); | ||
|
||
return { dailyFees, dailyRevenue }; | ||
}; | ||
|
||
const adapter: SimpleAdapter = { | ||
version: 2, | ||
adapter: { | ||
[CHAIN.ETHEREUM]: { | ||
fetch, | ||
start: "2024-10-10", | ||
meta: { | ||
methodology: { | ||
Fees: `Interest earned from borrowers + fees generated by deploying idle capital into DeFi.`, | ||
Revenue: `Portion of fees retained by the protocol.`, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default adapter; |