Published in


Yield Aware AMMs #102

Let’s start with a basic example;

You have BAT, you have the following options;

  1. Supply BAT to Compound, earn interest + COMP

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;

  1. The pool (and not the LP) earns incentivized tokens. COMP, BAL, etc.

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.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store