Skip to content

Commit bde0f3a

Browse files
authored
feat: tracking resolv fees and revenue (DefiLlama#3984)
1 parent c220c2d commit bde0f3a

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

fees/resolv/index.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
2+
import { CHAIN } from "../../helpers/chains";
3+
import { addTokensReceived } from "../../helpers/token";
4+
import ADDRESSES from '../../helpers/coreAssets.json';
5+
6+
const USR = '0x66a1e37c9b0eaddca17d3662d6c05f4decf3e110';
7+
const ST_USR = '0x6c8984bc7DBBeDAf4F6b2FD766f16eBB7d10AAb4';
8+
const WST_USR = '0x1202F5C7b4B9E47a1A484E8B270be34dbbC75055';
9+
const RLP = '0x4956b52aE2fF65D74CA2d61207523288e4528f96';
10+
const RLP_ORACLE = '0xaE2364579D6cB4Bbd6695846C1D595cA9AF3574d';
11+
const FEE_COLLECTOR = '0x6E02e225329E32c854178d7c865cF70fE1617f02';
12+
13+
const WST_USR_ABI = 'function convertToAssets(uint256 _wstUSRAmount) external view returns (uint256 usrAmount)';
14+
15+
const fetch = async (options: FetchOptions) => {
16+
17+
const totalSupply = await options.api.multiCall({
18+
abi: 'uint256:totalSupply',
19+
calls: [ST_USR, RLP],
20+
permitFailure: true
21+
});
22+
23+
const [stUsrSupply, rlpSupply] = totalSupply.map(v => v / 1e18);
24+
const rlpPriceYesterday = await options.fromApi.call({
25+
abi: 'uint256:lastPrice',
26+
target: RLP_ORACLE,
27+
}) / 1e18;
28+
29+
const rlpPriceToday = await options.toApi.call({
30+
abi: 'uint256:lastPrice',
31+
target: RLP_ORACLE,
32+
}) / 1e18;
33+
34+
const wstPriceYesterday = await options.fromApi.call({
35+
abi: WST_USR_ABI,
36+
target: WST_USR,
37+
params: ['1000000000000000000']
38+
}) / 1e18;
39+
40+
const wstPriceToday = await options.toApi.call({
41+
abi: WST_USR_ABI,
42+
target: WST_USR,
43+
params: ['1000000000000000000']
44+
}) / 1e18;
45+
46+
47+
const dailyYield = (((rlpPriceToday - rlpPriceYesterday) * rlpSupply) + ((wstPriceToday - wstPriceYesterday) * stUsrSupply));
48+
49+
const dailyRevenue = await addTokensReceived({
50+
options,
51+
fromAdddesses: [ADDRESSES.null],
52+
token: USR,
53+
target: FEE_COLLECTOR
54+
});
55+
56+
const dailyFees = options.createBalances();
57+
dailyFees.addUSDValue(dailyYield);
58+
dailyFees.add(dailyRevenue);
59+
60+
return {
61+
dailyFees,
62+
dailyRevenue,
63+
dailyProtocolRevenue: dailyRevenue,
64+
};
65+
};
66+
67+
const methodology = {
68+
Fees: 'Total yields from RLP and stUSR',
69+
Revenue: '10% of yields charged as protocol fee',
70+
ProtocolRevenue: 'All revenue goes to the protocol'
71+
};
72+
73+
const adapter: SimpleAdapter = {
74+
version: 2,
75+
methodology,
76+
fetch,
77+
chains: [CHAIN.ETHEREUM],
78+
start: '2024-09-02'
79+
};
80+
81+
export default adapter;

0 commit comments

Comments
 (0)