OptyFi: From Yield Farming to Yield Optimization

Open DeFi’s First Incubated Project


  • Determining the optimal strategy is not easy.
  • The optimal strategy changes frequently over time.
  • Optimization can provide a 50% greater APY.
  • It is almost impossible to achieve the optimal strategy manually.

First There Was an Opportunity

You learn that Aave recently launched its liquidity mining program (AIP-16), which incentivizes users by rewarding them with AAVE tokens for depositing and borrowing on the platform. You understand that this program would effectively increase your yield as a depositor and reduce your borrowing cost as a borrower. And if the reward earned from borrowing exceeds the borrowing interest rate, Aave could even be “paying you” to borrow from the platform.

Excited, you visit Aave.com. Being the “calculated risk taking type” you decide to keep your assets in the three major stable coins: DAI, USDC and USDT. The rates for these stable coins are as follows:

It doesn’t take you long to figure out that, with a given amount of capital, you can repeatedly deposit and borrow in order to increase the amount of rewards earned. You jump in with 100 DAI and undertake the following sequence of transactions.

Deposit 100 DAI → Borrow 75 DAI → Deposit 75 DAI → Borrow 56.25 DAI → Deposit 56.5 DAI

After the above cycles, your initial 100 DAI has turned into:

  • Deposits: 231.50 DAI
  • Borrows: 131.50 DAI

As you sit there proudly earning rewards on 231.50 DAI deposits and 131.50 DAI borrowings, you start realizing the situation is not as simple as it appeared at first glance.

Then There Was an Optimization Problem

  • Interest Rate Risk: Even though you are not exposed to exchange rate fluctuations, changes in interest rates could cause your borrowed amount to grow relative to your deposited amount, eating into your profit margin and possibly resulting in liquidation.
  • Liquidation Risk: If you were dealing with non-stable coins, exchange rate fluctuations could cause your debt to exceed your borrowing limit, exposing you to liquidation loss. With stable-coins, changes in interest rates could have the same potential effect.
  • Strategy Sequences: You realize that because you can deposit and borrow any of the three currencies (DAI, USDC, USDT), there are hundreds of possible sequences of deposits and borrows you can perform and it is not clear which one(s) are optimal. You also realize that the deposit, borrow and reward rates are constantly changing so “guessing” the optimal strategy would be exceedingly difficult.
  • Costs and Constraints: To further complicate matters, gas cost, swapping costs and your deposit amount would also need to be accounted for in determining an optimal strategy as well as relebancing frequency.

All of a sudden, your small contained experiment in a single protocol involving 3 liquidity pools starts to become nerve-wrecking. But….

Do we really need to Optimize?

To keep things simple, you assume:

  1. No gas cost
  2. No swap cost
  3. Limit of 5 steps
  4. Depositing USDT can only be a final step, as USDT deposits cannot be borrowed against

You realize the first two assumptions are not realistic, but rather than get bogged down at this stage, you decide to revisit these later.

A quick cartesian product (pruned for assumption 4 above) gives the number of possible unique strategies.

You pull in the DAI, USDC and USDT deposit rates, borrow rates and reward rates at Block 12358916 and calculate the APY for each strategy.

The top three strategies for DAI:

The top three strategies for USDC:

Digging in further you note that strategy APYs (almost) follow a log-normal distribution with some attractive returns in the right tail. On the other hand, at this particular block there appears to be no unprofitable strategy. (You pat yourself on the back again for having discovered DeFi).

So now you are convinced that returns can vary quite a bit, and optimization could make the difference between a DeFi-boring 10% APY and a brilliant 35% APY you can tweet about.

But you are left wondering, how frequently does the optimal strategy change?

A Tale of Three Simulations

You build three simualtions based on the above 4 assumptions (i.e. no gas cost, no swap cost, maximum 5 steps, USDT deposit can only be a final step).

Ranking Strategies Each Hour

The results show that this strategy, which was a 9th decile strategy (in fact, the best strategy) at the beginning frequently jumps to being a very poor strategy and then becomes a top strategy again.

Similar analysis of other strategies show that a top performing strategy changes frequently even within a span of a 7 day period.

And the Winner Is…..

Then, doing what a responsible data scientist would do, you extrapolate results to an annualized basis.

You arrive at the following conclusions:

  • Even with only one protocol (Aave) and three assets (DAI, USDC, USDT), there are a remarkable number of possible strategies.
  • Determining the optimal strategy is not easy.
  • The optimal strategy changes frequently over time.
  • Optimization can provide significantly superior returns. In the above case, with optimization, yield could be increased by almost 50%.
  • There is no way you can possibly achieve the optimal strategy manually.

Now if only there was a way you could easily optimize your yield farming without doing all the analysis, and then spending all day, day after day, rebalancing your portfolio in real time…..

OptyFi Protocol

OptyFi smart contracts are able to execute arbitrarily complex yield strategies with a simple yet powerful command interface. OptyFi’s optimization engine identifies optimal strategies in real time, enabling OptyFi vaults to capitalize on opportunities to earn outsized returns. The protocol’s open architecture allows new protocols and liquidity pools to be added rapidly, resulting in an exponentially growing universe of executable strategies.

OptyFi is the first incubated project of Open Defi. OptyFi vaults shall be operating Open Defi’s yield strategies.

We shall be releasing more information in the coming weeks. Please visit opty.fi and sign up for our email list and communication channels so we can update you on new developments.

A Postscript on Assumptions:

  1. Gas costs do not increase with the investment amount. If user assets are collected into vaults and then deployed collectively into optimized strategies, users would benefit from lower gas cost per unit of investment. When a vault reaches a certain size, gas costs start to become negligible. Also, we note that gas costs on many chains remain negligible even for small transaction amounts, and hold hope the scaling solutions will soon make this true for Ethereum as well.
  2. Swap costs could range from 0.1% to 0.3% per swap depending on swapped amount. In our example, we assume the investor has access to liquidity in DAI, USDC and USDT without accessing DEX liquidity for example. If this were not the case, a complex strategy model could run multiple strategies simultaneously, cross-swapping between strategies, and only accessing external liquidity as needed (on a net basis). Finally, in the worst case, we could restrict ourselves to strategies with no swapping. This would reduce the total strategies for DAI and USDC to 12 each, still leaving us with a substantial optimization problem to deal with.

A community driven DAO creating the next era of multi-chain DeFi.