linkedin logogithub logo
March 28, 2022

DeFi Investing Algebra

Key Points

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"

<pre><code>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</code></pre>

These properties hold:

<pre><code>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</code></pre>

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: <span class='code-small'>1@0</span>
  2. Deposit all in Anchor at 19.6% rate (Anchor represents this deposit giving you aUST tokens): <span class='code-small'>(1@0)@19.6 = 1@19.6</span>
  3. Deposit all aUST in Edge Protocol. Edge gives you 0.2% on your aUST: <span class='code-small'>(1@19.6)@0.2 = 1@19.8</span>
  4. Borrow UST against aUST in Edge.

When you take a loan, this adds to your position an investment of the form <span class='code-small'>a@0 - a@R</span>, 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: <span class='code-small'>0.9@0 - 0.9@17.9.</span>

At this point, our final position is:
<span class='code-small'>1@19.8 - 0.9@17.9 + 0.9@0 = 0.1@36.9 + 0.9@0</span>

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

Macarena López Morillo
Head of People
Get the Full Picture
For an in-depth understanding of this topic, don't miss out. Learn more here and elevate your knowledge.
right arrow

More articles

Web3 —
Blockchain Technical Partners

Uncover our Web3 creations and discover how we're redefining tomorrow.
Learn More