Yield Aware AMMs #102
Let’s start with a basic example;
You have BAT, you have the following options;
- Supply BAT to Compound, earn interest + COMP
- Supply BAT to Aave, earn interest
- Sell 50% of your BAT for ETH, supply BAT+ETH to uniswap, earn fees ~ impermanent loss
- Sell 50% of your BAT for ETH, supply BAT+ETH to balancer, earn fees + BAL ~ impermanent loss
Adding one more layer of complexity;
Supply BAT to Compound, get cBAT, supply cBAT+ETH to balancer, earn fees + BAL ~ impermanent loss, and on the surface, you think you are earning COMP+cBAT interest.
The balancer pool is actually earning the COMP (you aren’t), and the balancer pool is earning the cBAT (which will be arbitraged away, so technically you are earning trading fees, but not cBAT interest. So even though the strategy seems smart, the net result is similar to BAT+ETH to balancer.
So we have identified the following problems;
- The pool (and not the LP) earns incentivized tokens. COMP, BAL, etc.
- The pool (and not the LP) earns interest on tokens.
- You had to sell 50% of your BAT exposure to fund a pool. (This one is critical to our solution, but will be discussed in a post on its own).
The above problem statement, makes it clear that current AMM (Automated Market Maker) pools can’t support our requirement, and we need a new yield aware AMM.
Supporting Aave tokens (aTokens) is easy enough, they support a function called redirectInterestStream, which allows you to configure an address to which the interest goes. This however does mean your interest is non compounding.
Compound tokens (cTokens) however grow in value based on their supply index, and such, are a bit more tricky to manage themselves. The AMM needs to be aware of the cTokens underlying value, instead of the cToken value, so all swaps, and quote checks need to measure the underlying, and not the raw token.
The cToken solution also works for the aToken solution and fixes the compounding issue.
So this change to the AMM allows it to trade BAT/ETH while actually holding cBAT or aBAT.
The solution for COMP is fairly straight forward, we measure COMP balance changes on every internal balance (cBAT) change and assign an index.
However, we want to support any token that might be added in the future, and also allow for distributions that don’t occur on balance changes. So we modify the above to be generic for any token requested, and we add an address lookup for core supported tokens.
The above is building block number 1, the yield aware AMM. It’s able to allow LP’s to earn interest from the highest yield paying lender, while earning incentivized tokens (such as COMP).
Next post will detail how we managed to get rid of selling 50% of your token, and how you can keep your exposure 100% in a single asset.