We all know it, theres this new hyped lending protocol which pays a higher APR for supplying an asset than it takes APR for lending the asset.
What do we do? We deposit the asset, borrow it, deposit the borrowed amount again, borrow it etc etc.
At the end of the day we have a pretty large capital efficiency and high APR.
--------------------------------------------------------
Let's take a hypothetical example:
- USDC deposit APR = 10%
- USDC borrow APR = 5%
- Allowed LTV = 80%
- Initial capital = 100k USDC
Loop 1:
Deposit 100,000 USDC
Borrow 80,000 USDC (80% LTV)
Total deposits: 100,000 USDC
Total borrows: 80,000 USDC
Loop 2:
Deposit 80,000 USDC
Borrow 64,000 USDC (80% LTV)
Total deposits: 180,000 USDC
Total borrows: 144,000 USDC
Loop 3:
Deposit 64,000 USDC
Borrow 51,200 USDC (80% LTV)
Total deposits: 244,000 USDC
Total borrows: 195,200 USDC
Loop 4:
Deposit 51,200 USDC
Borrow 40,960 USDC (80% LTV)
Total deposits: 295,200 USDC
Total borrows: 236,160 USDC
Loop 5:
Deposit 40,960 USDC
Borrow 32,768 USDC (80% LTV)
Total deposits: 336,160 USDC
Total borrows: 268,928 USDC
Now, let's calculate the effective APR:
Effective APR = (Deposit Interest - Borrow Interest) / Initial Capital * 100%
Deposit Interest = Total deposits * Deposit APR = 336,160 * 10% = 33,616 USDC
Borrow Interest = Total borrows * Borrow APR = 268,928 * 5% = 13,446.40 USDC
Effective APR = (33,616 - 13,446.40) / 100,000 * 100% = 20,169.60 / 100,000 * 100% = 20.17%
(This is done by GPT because i'm lazy - you get the idea)
----------------------------------------------------------
Now there's an easy way to avoid this gas-consuming loop and just flashloan the way up to your leverage:
a) Provide initial USDC capital
b) Flashloan USDC
c) Deposit the initial USDC capital and the flashloaned amount
d) Borrow the flashloaned amount
e) Pay back the flashloaned amount
Illustrated (GPT 4 WIN):
Step a) Provide initial USDC capital:
Initial capital = 100,000 USDC
Step b) Flashloan USDC:
Flashloan amount = Initial capital / (1 - LTV)
Flashloan amount = 100,000 / (1 - 0.8)
Flashloan amount = 100,000 / 0.2
Flashloan amount = 500,000 USDC
Step c) Deposit the initial USDC capital and the flashloaned amount:
Total deposit = Initial capital + Flashloan amount
Total deposit = 100,000 + 500,000
Total deposit = 600,000 USDC
Step d) Borrow the flashloaned amount:
Borrow amount = Flashloan amount
Borrow amount = 500,000 USDC
Step e) Pay back the flashloaned amount:
Repay the flashloan of 500,000 USDC
After executing these steps, the resulting position would be:
Total deposits: 600,000 USDC
Total borrows: 500,000 USDC
Now, let's calculate the effective APR:
Effective APR = (Deposit Interest - Borrow Interest) / Initial Capital * 100%
Deposit Interest = Total deposits * Deposit APR = 600,000 * 10% = 60,000 USDC
Borrow Interest = Total borrows * Borrow APR = 500,000 * 5% = 25,000 USDC
Effective APR = (60,000 - 25,000) / 100,000 * 100% = 35,000 / 100,000 * 100% = 35%
What do we do? We deposit the asset, borrow it, deposit the borrowed amount again, borrow it etc etc.
At the end of the day we have a pretty large capital efficiency and high APR.
--------------------------------------------------------
Let's take a hypothetical example:
- USDC deposit APR = 10%
- USDC borrow APR = 5%
- Allowed LTV = 80%
- Initial capital = 100k USDC
Loop 1:
Deposit 100,000 USDC
Borrow 80,000 USDC (80% LTV)
Total deposits: 100,000 USDC
Total borrows: 80,000 USDC
Loop 2:
Deposit 80,000 USDC
Borrow 64,000 USDC (80% LTV)
Total deposits: 180,000 USDC
Total borrows: 144,000 USDC
Loop 3:
Deposit 64,000 USDC
Borrow 51,200 USDC (80% LTV)
Total deposits: 244,000 USDC
Total borrows: 195,200 USDC
Loop 4:
Deposit 51,200 USDC
Borrow 40,960 USDC (80% LTV)
Total deposits: 295,200 USDC
Total borrows: 236,160 USDC
Loop 5:
Deposit 40,960 USDC
Borrow 32,768 USDC (80% LTV)
Total deposits: 336,160 USDC
Total borrows: 268,928 USDC
Now, let's calculate the effective APR:
Effective APR = (Deposit Interest - Borrow Interest) / Initial Capital * 100%
Deposit Interest = Total deposits * Deposit APR = 336,160 * 10% = 33,616 USDC
Borrow Interest = Total borrows * Borrow APR = 268,928 * 5% = 13,446.40 USDC
Effective APR = (33,616 - 13,446.40) / 100,000 * 100% = 20,169.60 / 100,000 * 100% = 20.17%
(This is done by GPT because i'm lazy - you get the idea)
----------------------------------------------------------
Now there's an easy way to avoid this gas-consuming loop and just flashloan the way up to your leverage:
a) Provide initial USDC capital
b) Flashloan USDC
c) Deposit the initial USDC capital and the flashloaned amount
d) Borrow the flashloaned amount
e) Pay back the flashloaned amount
Illustrated (GPT 4 WIN):
Step a) Provide initial USDC capital:
Initial capital = 100,000 USDC
Step b) Flashloan USDC:
Flashloan amount = Initial capital / (1 - LTV)
Flashloan amount = 100,000 / (1 - 0.8)
Flashloan amount = 100,000 / 0.2
Flashloan amount = 500,000 USDC
Step c) Deposit the initial USDC capital and the flashloaned amount:
Total deposit = Initial capital + Flashloan amount
Total deposit = 100,000 + 500,000
Total deposit = 600,000 USDC
Step d) Borrow the flashloaned amount:
Borrow amount = Flashloan amount
Borrow amount = 500,000 USDC
Step e) Pay back the flashloaned amount:
Repay the flashloan of 500,000 USDC
After executing these steps, the resulting position would be:
Total deposits: 600,000 USDC
Total borrows: 500,000 USDC
Now, let's calculate the effective APR:
Effective APR = (Deposit Interest - Borrow Interest) / Initial Capital * 100%
Deposit Interest = Total deposits * Deposit APR = 600,000 * 10% = 60,000 USDC
Borrow Interest = Total borrows * Borrow APR = 500,000 * 5% = 25,000 USDC
Effective APR = (60,000 - 25,000) / 100,000 * 100% = 35,000 / 100,000 * 100% = 35%