The deposit function in the contract follows the above flow to make a Leveraged position on morpho v1. In the above flow diagram, we are assuming that the vault's current leverage is 3x. But Vault can work on other leverages like 1x, 2x, 3x.

Step 1: User deposits x ETH in the Sharpe Magnum (magETH) vault

  • In this step, a user initiates a deposit of a certain amount of Ether (ETH) into the Sharpe Magnum vault contract. This amount is denoted as "x."

Step 2: Wrap x ETH

  • After the user deposits ETH into the vault, the ETH is wrapped into a tokenized version called Wrapped ETH (WETH). WETH is more easily managed within smart contracts.

Step 3: Flashloan 2x WETH on Aave

  • A flashloan is a type of loan that is instantly borrowed and repaid within a single transaction. In this step, the user borrows 2 times the deposited amount of Wrapped ETH (2x WETH) from the Aave lending protocol using a flashloan. Flashloans allow for temporarily borrowing assets without collateral, with the condition that they are returned within the same transaction.

Step 4: Swap 3x WETH to stETH via 1inch

  • The user takes the borrowed 3x WETH and swaps it for staked Ether (stETH) tokens. This involves exchanging the borrowed WETH tokens for stETH tokens.

Step 5: Supply all the swapped stETH on morpho V1

  • The vault supplies all the stETH tokens acquired in the previous step to the Morpho V1 protocol. This step involves adding the stETH tokens to the liquidity pool on Morpho V1.

Step 6: Borrow 2x WETH from Morpho V1

  • With the stETH tokens supplied to Morpho V1 as collateral, the user can borrow 2 times the amount of WETH from the Morpho V1 protocol. This allows the user to leverage their stETH holdings to access additional WETH.

Step 7: Payback the flashloan of 2x WETH to Aave

  • In the final step, the user repays the flashloan taken from Aave by returning the 2x borrowed WETH tokens. This ensures that the flashloan is settled and the borrowed assets are returned as per the terms of the flashloan.

The user gets the equivalent amount of magETH shares as per the vault's share price.

Last updated