|
| 1 | +import { Adapter, FetchOptions } from "../../adapters/types"; |
| 2 | +import { CHAIN } from "../../helpers/chains"; |
| 3 | +import fetchURL from "../../utils/fetchURL"; |
| 4 | + |
| 5 | +interface VirtueFeeResponse { |
| 6 | + data: { |
| 7 | + collateralFee: number; |
| 8 | + liquidationFee: number; |
| 9 | + totalFee: number; |
| 10 | + periodDays: number; |
| 11 | + }; |
| 12 | +} |
| 13 | + |
| 14 | +const virtueApiURL = "https://info.virtue.money/api"; |
| 15 | + |
| 16 | +const fetch = async (_a: any, _b: any, options: FetchOptions) => { |
| 17 | + const dailyFees = options.createBalances() |
| 18 | + |
| 19 | + const url = `${virtueApiURL}/v1/fees`; |
| 20 | + const res: VirtueFeeResponse = await fetchURL(url); |
| 21 | + |
| 22 | + dailyFees.addUSDValue(res.data.collateralFee, 'Collateral Fees') |
| 23 | + dailyFees.addUSDValue(res.data.liquidationFee, 'Liquidation Fees') |
| 24 | + |
| 25 | + return { |
| 26 | + dailyFees, |
| 27 | + dailyUserFees: dailyFees, |
| 28 | + dailyRevenue: dailyFees, |
| 29 | + dailyProtocolRevenue: dailyFees, |
| 30 | + }; |
| 31 | +}; |
| 32 | + |
| 33 | +const adapter: Adapter = { |
| 34 | + version: 1, |
| 35 | + fetch, |
| 36 | + chains: [CHAIN.IOTA], |
| 37 | + runAtCurrTime: true, |
| 38 | + methodology: { |
| 39 | + Fees: "All the services fees paid by users, including liquidation and collateral fees", |
| 40 | + UserFees: "All the services fees paid by users, including liquidation and collateral fees", |
| 41 | + Revenue: "All the services fees paid by users, including liquidation and collateral fees earned by Virtue", |
| 42 | + ProtocolRevenue: "All revenue are earned by Virtue", |
| 43 | + }, |
| 44 | + breakdownMethodology: { |
| 45 | + Fees: { |
| 46 | + 'Collateral Fees': 'Collateral fees paid by users.', |
| 47 | + 'Liquidation Fees': 'Liquidation fees paid by users.', |
| 48 | + }, |
| 49 | + Revenue: { |
| 50 | + 'Collateral Fees': 'Protocol earns all collateral fees paid by users.', |
| 51 | + 'Liquidation Fees': 'Protocol earns all liquidation fees paid by users.', |
| 52 | + }, |
| 53 | + } |
| 54 | +}; |
| 55 | + |
| 56 | +export default adapter; |
0 commit comments