5/5
## Flash Loan Amount In this lesson, we'll derive a simple equation for determining the maximum borrow amount when creating a leveraged position via flash loans. First, let’s define our variables: - B = total borrowed USD - C = total collateral USD - C₀ = initial amount of collateral in USD deposited by user - L = loan to value ratio (LTV) So, the total borrowed divided by the total collateral must be less than or equal to the loan to value ratio. ```solidity B/C ≤ L ``` Now, let's denote F as the flash loan USD amount. Then: ```solidity B = F ``` Next, we will state that Cs is the USD amount of collateral swapped from a flash loan. ```solidity Cs = F ``` This assumes zero slippage on the swap and zero swap fees. Now, we'll rewrite Cs as a multiple of C₀ for some number k: ```solidity Cs = k * C₀ ``` From this point we can rewrite C as: ```solidity C = C₀ + Cs ``` or ```solidity C = C₀ + k*C₀ = (1 + k) * C₀ ``` Now, we can combine all our expressions to solve for F, starting with: ```solidity B/C ≤ L ``` Since B = F, we can rewrite the expression as: ```solidity F/C ≤ L ``` Next, we'll replace the C: ```solidity F/((1 + k) * C₀) ≤ L ``` Then we'll replace F: ```solidity Cs/((1 + k) * C₀) ≤ L ``` Since Cs = k \* C₀, then: ```solidity (k * C₀)/((1 + k) * C₀) ≤ L ``` The C₀ on the top and the bottom cancel out to give us: ```solidity k/(1 + k) ≤ L ``` From there, we can solve for k: ```solidity k ≤ L / (1 - L) ``` Finally, we can express F in terms of k: ```solidity F = Cs ≤ k * C₀ ``` or ```solidity F ≤ (L / (1 - L)) * C₀ ``` This expression gives us the maximum flash loan amount in terms of LTV and the initial collateral amount.
In this lesson, we'll derive a simple equation for determining the maximum borrow amount when creating a leveraged position via flash loans.
First, let’s define our variables:
B = total borrowed USD
C = total collateral USD
C₀ = initial amount of collateral in USD deposited by user
L = loan to value ratio (LTV)
So, the total borrowed divided by the total collateral must be less than or equal to the loan to value ratio.
Now, let's denote F as the flash loan USD amount. Then:
Next, we will state that Cs is the USD amount of collateral swapped from a flash loan.
This assumes zero slippage on the swap and zero swap fees.
Now, we'll rewrite Cs as a multiple of C₀ for some number k:
From this point we can rewrite C as:
or
Now, we can combine all our expressions to solve for F, starting with:
Since B = F, we can rewrite the expression as:
Next, we'll replace the C:
Then we'll replace F:
Since Cs = k * C₀, then:
The C₀ on the top and the bottom cancel out to give us:
From there, we can solve for k:
Finally, we can express F in terms of k:
or
This expression gives us the maximum flash loan amount in terms of LTV and the initial collateral amount.
A beginner's guide to understanding flash loan amounts. The lesson covers how flash loans can be used to leverage a position and derive the maximum amount you can flash loan based on initial collateral and LTV.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Stay in the loop with the latest Rocket Pool updates and connect with over 5,000 developers in the community.
Course Overview
About the course
Rocket Pool rETH staking, yield mechanisms, trading options, and contract architecture
How to distribute rewards and calculate rETH/ETH exchange rate
How to acquire and redeem rETH
Integrating rETH into DeFi protocols like AAVE V3
How to how to create leveraged ETH positions using rETH
How to provide rETH as liquidity to Balancer and Aura
Getting the USD price of rETH using Rocket Pool NAV oracle
Re-staking with EigenLayer
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on July 8, 2025
Duration: 4min
Duration: 48min
Duration: 57min
Duration: 30min
Duration: 7min
Duration: 23min
Duration: 6min
Course Overview
About the course
Rocket Pool rETH staking, yield mechanisms, trading options, and contract architecture
How to distribute rewards and calculate rETH/ETH exchange rate
How to acquire and redeem rETH
Integrating rETH into DeFi protocols like AAVE V3
How to how to create leveraged ETH positions using rETH
How to provide rETH as liquidity to Balancer and Aura
Getting the USD price of rETH using Rocket Pool NAV oracle
Re-staking with EigenLayer
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on July 8, 2025