Skip to content

Commit 8a21702

Browse files
KPHEMRAJnoateden
andauthored
fix: usual fee (#4338)
* fix: usual fee * fix typo --------- Co-authored-by: Eden <noat.eth@gmail.com>
1 parent 4535fbd commit 8a21702

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

fees/usual.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import ADDRESSES from '../helpers/coreAssets.json'
22
import { Adapter, FetchOptions, FetchResultV2 } from "../adapters/types";
33
import { CHAIN } from "../helpers/chains";
4+
import { getEulerVaultFee } from "../helpers/curators/index";
45

56
/**
67
*
78
* Usual takes RWA stablecoins from users and issue USD0 stablecoins
89
* Users can stake USD0, receive USD0++ and earn USUAL tokens
9-
* Users can stake USUAL, receive USUALx and earn USIAL tokens
10+
* Users can stake USUAL, receive USUALx and earn USUAL tokens
1011
*
11-
* There are fours places where Usual takes fees:
12+
* There are four places where Usual takes fees:
1213
* 1. Usual earns fees from locked RWA assets
1314
* 2. When users redeem USD0 stablecoins, Usual takes an amount of redemption fees in USD0 tokens
1415
* 3. When users early unstake USD0++ at floor price
1516
* 4. When users early unstake USD0++, users must commit an amount of USUAL tokens
1617
* these USUAL tokens then are burnt and distributed to USUALx stakers
18+
* 5. Usual deployed Euler vaults for borrowing and takes borrow interest
1719
*
1820
* So:
19-
* We count 1, 2, 3 as protocol revenue
21+
* We count 1, 2, 3, 5 as protocol revenue
2022
* We count 4 as holder revenue
2123
*
2224
* There is no source of revenue for supply side users - USD0 minters.
@@ -25,21 +27,24 @@ import { CHAIN } from "../helpers/chains";
2527
*/
2628

2729
const methodology = {
28-
Fees: 'Total USD0 redemption fees and USD0++ early unstake fees.',
30+
Fees: 'Yields from underlying assets,usual stability loan interests, total USD0 redemption fees and USD0++ early unstake fees.',
31+
Revenue: 'Total fees collected by protocol, distributed to USUAL token stakers, buyback and burn.',
2932
ProtocolRevenue: 'Total fees are distributed to protocol treasury.',
30-
HoldersRevenue: 'Total fees are distributed to token holders.',
33+
HoldersRevenue: 'Total fees are distributed to token holders, token burns',
3134
}
3235

3336
const DaoCollateral = '0xde6e1F680C4816446C8D515989E2358636A38b04'
3437
const Treasury = '0xdd82875f0840AAD58a455A70B88eEd9F59ceC7c7'
3538
const USD0 = ADDRESSES.ethereum.USD0
3639
const USUAL = '0xc4441c2be5d8fa8126822b9929ca0b81ea0de38e'
3740
const USD0PP = '0x35d8949372d46b7a3d5a56006ae77b215fc69bc0'
41+
const USUALX = '0x06B964d96f5dCF7Eae9d7C559B09EDCe244d4B8E'
3842

3943
const USYC = '0x136471a34f6ef19fe571effc1ca711fdb8e49f2b'
4044
const USYCOracle = '0x4c48bcb2160F8e0aDbf9D4F3B034f1e36d1f8b3e'
4145
const wM = '0x437cc33344a0B27A429f795ff6B469C72698B291'
4246
const USUAL_wM = '0x4Cbc25559DbBD1272EC5B64c7b5F48a2405e6470'
47+
const EULER_VAULTS = ['0xd001f0a15D272542687b2677BA627f48A4333b5d']
4348

4449
const ContractAbis = {
4550
// USYC
@@ -63,13 +68,14 @@ async function fetch(options: FetchOptions): Promise<FetchResultV2> {
6368
const dailyFees = options.createBalances()
6469
const dailyProtocolRevenue = options.createBalances()
6570
const dailyHoldersRevenue = options.createBalances()
71+
const dailyRevenue = options.createBalances()
6672

6773
const redeemEvents: Array<any> = await options.getLogs({
6874
target: DaoCollateral,
6975
eventAbi: ContractAbis.RedeemEvent,
7076
})
7177
const feeSweptEvents: Array<any> = await options.getLogs({
72-
target: USD0PP,
78+
targets: [USD0PP,USUALX],
7379
eventAbi: ContractAbis.FeeSweptEvent,
7480
})
7581
const usd0ppUnlockedFloorPriceEvents: Array<any> = await options.getLogs({
@@ -85,8 +91,9 @@ async function fetch(options: FetchOptions): Promise<FetchResultV2> {
8591
dailyFees.add(USUAL, Number(event.amount))
8692

8793
// https://docs.usual.money/usual-products/usd0-liquid-staking-token/usd0++-early-redemption-mechanism#how-does-it-work
88-
const forHolders = Number(event.amount) * 0.67
89-
dailyHoldersRevenue.add(USUAL, forHolders)
94+
//67% of the fees are distributed to USUALx,Usual* stakers
95+
//33% of the fees are burnt
96+
dailyHoldersRevenue.add(USUAL, Number(event.amount))
9097
}
9198
for (const event of usd0ppUnlockedFloorPriceEvents) {
9299
const feeAmount = Number(event.usd0ppAmount) - Number(event.usd0Amount)
@@ -133,9 +140,14 @@ async function fetch(options: FetchOptions): Promise<FetchResultV2> {
133140

134141
dailyFees.addUSDValue(totalRwaYield)
135142
dailyProtocolRevenue.addUSDValue(totalRwaYield)
143+
await getEulerVaultFee(options, { dailyFees, dailyRevenue }, EULER_VAULTS)
144+
145+
dailyRevenue.add(dailyProtocolRevenue)
146+
dailyRevenue.add(dailyHoldersRevenue)
136147

137148
return {
138149
dailyFees,
150+
dailyRevenue,
139151
dailyProtocolRevenue,
140152
dailyHoldersRevenue,
141153
}

helpers/curators/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async function getMorphoVaultFee(options: FetchOptions, balances: Balances, vaul
189189
}
190190
}
191191

192-
async function getEulerVaultFee(options: FetchOptions, balances: Balances, vaults: Array<string>) {
192+
export async function getEulerVaultFee(options: FetchOptions, balances: Balances, vaults: Array<string>) {
193193
const vaultInfo = await getVaultERC4626Info(options, vaults)
194194
const vaultFeeRates = await options.api.multiCall({
195195
abi: ABI.euler.interestFee,

0 commit comments

Comments
 (0)