RevenueFacet

Contract in charge of checking if the charged fees and generated yield has reached one of the predetermined revenue tiers that would entail deviating a portion of the protocols' AUM to the owner of the Diamond as part of their only stream of revenue.

These are those revenue tiers:

  • If the protocols has 10M in AUM, the owner gets 2M.

  • If it's 50M --> 5M.

  • 100M --> 10M

  • 500M --> 50M

  • 1B --> 100M

  • 5B --> 500M

  • 10B --> 1B

Each tier is a one-time payment which would be removed once it's executed. It's worth noting that the implementation of this revenue distribution is a very naive one, only to show a basic mechanism of distribution which wouldn't work as intended in practice.

For example, the funds that the owner would get come from an Uniswap swap of the AUM, so it wouldn't be very logical to do a 10B swap on Uniswap and expect an amountOut of 1B with very little slippage (or at least not at the moment with the current levels of liquidity).

Github repo here.

Open methods

checkForRevenue

function checkForRevenue() external payable;

On each call to an implementation that's not part of the nonRevenueFacets group, this function checks if the charged fees and generated yield (aka the protocol's AUM) has reached a revenue tier.

If it has, it start computing and distributing the revenue to the owner.

System methods

_computeRevenue

function _computeRevenue(uint denominator_, uint balance_, uint price_) private;

Once a revenue tier has been reached, this function computes the revenue for the owner, which entails removing liquidity from Yearn's Curve Tricrypto vault, then Curve's Tricrypto pool, and calling _swapWETHForRevenue().

The computing might fail due to slippage when removing liquidity from Curve's Tricrypto pool, so the try/catch technique is implemented here, and in case of failure, it sends crv3crypto to the owner.

Parameters:

Name
Type
Description

denominator_

uint256

Share of the total AUM belonging to the owner

balance_

uint256

yv-Curve-Tricrypto balance

price_

uint256

Current ETH/USD price

_swapWETHForRevenue

function _swapWETHforRevenue(address owner_, uint balanceWETH_, uint price_) private;

Once funds have been pulled out from DeFi in _computeRevenue(), this function swaps them for the established revenue token, on Uniswap.

A try/catch technique is implemented, so if the swap fails, the slippage is amplified by two and the call is retried. If it fails again, WETH is sent instead to the owner as the revenue.

Parameters:

Name
Type
Description

owner_

address

Owner of the Diamond

balanceWETH_

uint256

WETH to swap (aka the owner's revenue)

price_

uint256

Current ETH/USD price

Last updated