Skip to content

Commit 9e8ed1e

Browse files
noatedenCJMario89
andauthored
Virtue pr (#5676)
* Add Virtue adapter for fee and revenue tracking, including IOTA support * breakdown fees --------- Co-authored-by: cjmario89 <[email protected]>
1 parent fd63304 commit 9e8ed1e

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

fees/virtue/index.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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;

helpers/chains.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,5 @@ export enum CHAIN {
334334
STRATIS = "stratis",
335335
OMAX = "omax",
336336
Q_PROTOCOL = "q",
337+
IOTA = "iota",
337338
}

0 commit comments

Comments
 (0)