DeFi Investing Algebra

Easing the process of talking DeFi

Matias Morant
Rather Labs
3 min readMar 28, 2022

--

In Rather Labs, we design DeFi strategies to maximize yield. We used to have a hard time communicating new strategies. In our equations, it was confusing to keep track of APYs, what amounts of money ended invested where, and figure out the APY of the overall strategy.
So we came up with a handy algebraic structure to ease this task.

Definition

A@B represents an investment of "amount of money A at interest rate B"

If ...
A>0 and B>0 : an appreciating asset
A>0 and B<0 : a depreciating asset
A<0 and B>0 : an appreciating debt
A<0 and B<0 : a depreciating debt

These properties hold:

1- (a+b)@C = a@C + b@C
2- (a@B)@C = a@( B+C + B×C) ≈ a@(B+C)
3- (a@B)×k = (a×k)@B
4- a@A + b@B = (a+b)@( (a A + b B) / (a+b) )
5- a@A - b@B = a@A + (-b)@B

properties 3 and 4 are the fundamental definitions that make investments a vector space. Properties 1 and 5 follow from 3 and 4. Property 2 is an additional structure of this algebra.

Example strategy

We will leverage the difference in rates for borrowing UST in Edge Protocol and depositing UST in Anchor

Steps:

1- Start with 1 UST in your wallet. This is earning 0% rate: 1@0
2- Deposit all in Anchor at 19.6% rate (Anchor represents this deposit giving you aUST tokens): (1@0)@19.6 = 1@19.6
3- Deposit all aUST in Edge Protocol. Edge gives you 0.2% on your aUST: (1@19.6)@0.2 = 1@19.8
4- Borrow UST against aUST in Edge.
When you take a loan, this adds to your position an investment of the form a@0 - a@R, where a is the size of your loan and R is the borrow rate. The negative part represents your debt and the positive part represents the new idle assets in your wallet.
In Edge Protocol, max debt ratio is 90%, so we will borrow 0.9 UST. The borrow rate is 17.9%. So our loan will be: 0.9@0 - 0.9@17.9.
5- At this point, our final position is:
1@19.8 - 0.9@17.9 + 0.9@0 = 0.1@36.9 + 0.9@0

With this strategy, we achieved an investment APY of 36.9%. We end with 0.1 UST invested at this rate and 0.9 UST idle in our wallet.

You can inverst all your 1 UST capital at this 36.9 % rate (not limited to 0.1 UST), like this:

To invest all our capital of 1 UST we can iterate this process many times (investing 10% of our capital each time), or we can take a flashloan of 9 UST and invest the full 1 UST in a single iteration.

Complex, high-yield strategies like this can be tailored to you at Rather Labs

About Rather Labs

Rather Labs is a Blockchain Technical partner who provides the blockchain expertise along with the partner intensity founders need.
Rather Labs is committed to working alongside our clients as a technical partner, providing insights, technical design, engineering team management, recommendations, maintenance and technology projection.
The company is led by co-founders which have been involved in blockchain projects in finance, real estate, gaming, and other industries for years.
For more information, visit https://www.ratherlabs.com or follow the company on Medium https://medium.com/rather-labs and https://www.linkedin.com/company/ratherlabs

--

--