DeFi Investing Algebra

Easing the process of talking DeFi

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.


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


  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

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 work 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 state, gaming, and other industries for years.

For more information, visit or follow the company on Medium and

DeFi Investing Algebra
Matias Morant
Article checked for relevance
We respect your privacy
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Talk to Our Experts to Find Out

  • The Rather Labs Way for developing impactful applications, fast
  • How can we get started on your project right now
  • How we helped founders and startups to design, develop and launch their projects globally
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Schedule a Meeting

linkedin logogithub logo