Leveraged Yielding Positions
One of the features of using Kashi as our lending engine is that it allows users to leverage their interest-bearing tokens positions. Here at Abracadabra, we have developed a one-click UI that allows you to do so automatically. Let's dive into this!

How the process works:

To open a leveraged position, users need to deposit the interest-bearing token they want to leverage. Kashi allows withdrawing more MIMs than it should be possible, as long as the collateral required is supplied to the position eventually, within the same transaction. To better explain this, let's use the example of a user that wants to leverage his yvUSDT position:
    Step 1 and 2 - The user selects the desired leverage, obtains the yvUSDT, and deposits them as collateral.
    Step 3 - Given the selected leverage, the protocol borrows the respective amount of MIMs.
    Step 4 - These MIMs are swapped into USDT (current price peg and slippage play an important role here).
    Step 5 - These USDT are deposited into a Yearn Vault to receive yvUSDT.
    Step 6 - These yvUSDT tokens are deposited back into the Abracadababra to collateralize the user's position.
This process can be visualized using the following infographic:
Notice that all of these steps happen in one single transaction, and therefore only one gas fee will be required. If one of these steps fails, the whole transaction fails. Note that if the token is not an Interest Bearing Token, STEP 4 and STEP 5 are substituted by a simple market buy of the token the user is leveraging.

Leveraging a Position on Abracadabra

First head to the BORROW page, then click on the collateral you want to use to leverage.
Toggle the โ€œCHANGE LEVERAGEโ€ checkbox.
Here users will be able to select the number of loops desired (up to 10x), as well as the swap tolerance for the whole transaction. Remember that a 10x selected on the scale above means 10 loops from your initial capital given the selected swap tolerance and LTV. Make sure to check the amount of MIM borrowed in the box underneath, as well as your actual leverage!
To be clear, 10x does NOT mean that you are increasing your initial capital by 10 times. Rather, the user interface calculates how much total you would borrow in MIM if you were to borrow MIM 10x at your selected LTV, creating new collateral each time. It then borrows that amount of MIM via a flashloan and makes collateral in one transaction.
For example, if you choose a LTV of 90% and select 10x loops, you will actually be borrowing 6.7x your initial collateral value. Note that a 0.05% Fee will be charged on the leveraged MIM amount that the user is borrowing.
Swap Tolerance is the amount of change in value a user is comfortable with. Factors that affect the change in value when MIM are swapped for other tokens are, the initial price peg difference at the market, and the slippage of trade from price changes during execution.
If the swap tolerance is not high enough, the transaction will fail and an error will pop up.
Below this, users will see the following dynamic data:
    Expected MIM amount: This number will tell the wizard approximately how many MIM will be borrowed and used to create leveraged components.
    Expected APY: This number estimates the ROI on their initial collateral.
    Expected Leverage: The actual leverage you have on your investment given LTV and Number of Loops.
    Expected Liquidation price: Price of collateral at which you can expect this leveraged position to be liquidated. This will depend on what percentage of collaterals the user selects as well as the leverage chosen.
Please note that every position you open on Abracadabra using the same collateral will be combined into a single position, no matter if it is leveraged or not. Therefore be sure to check your combined liquidation parameters after each adjustment using the data in the My Open Positions box, as they are likely to be different from the ones above.
After all the parameters are set, click on ADD COLLATERAL AND BORROW and open your leverage position!
Note: The user will not end up with any MIM in their wallet from this transaction, and will be farming yield at the leverage they have selected.
โš This is extremely importantโš 
Different from what happens in unleveraged positions, if the leveraged position gets liquidated, users will not have any assets in their possession.

Transactions

It should be noted that 1st-time users will be met with several transactions in the following order.
    1.
    Users will have to approve the spending of their collateral token to Bentobox.
    2.
    Then, users will need to approve the spending of their collateral token to the contract specific to the position they are entering.
    3.
    Next, they will have to approve the spending of the MIM they are borrowing to the contract specific to the position they are entering.
    4.
    Finally, they will need to send the entire transaction to open up the position.
This is important to note, as each transaction will come with an individual gas cost.

Deleverage Positions

Please note that as Abracadabra cannot distinguish between leveraged and not leveraged positions this function can be used to repay any kind of debt, but it will cost more with gas than a usual repay transaction. Use this function accordingly.
Bear in mind that leveraged positions can be closed by simply repaying the amount of MIM owed to the protocol, it is not compulsory to use this function. This function allows users to close their position even if they do not have the required MIMs in their wallets.

How the process works:

Kashi allows withdrawing collaterals even without repaying MIMs, as long as the MIMs required are supplied to the position eventually, within the same transaction. The process works the exact opposite as the "Leverage Yielding Transaction".
To better explain this, let's use the example of a user that wants to close his yvUSDT leveraged position. This user does not have enough MIMs in his wallet to repay his debt, therefore he needs to use the "Deleverage" function.
    Step 1 - The user selects the desired amount of collaterals he wants to withdraw and the amount of MIMs he wants to repay.
    Step 2 - The protocol releases the user's collateral, in this case, yvUSDT.
    Step 3 - These yvUSDT tokens are then unstaked from the yearn vault and turn into USDT.
    Step 4 - These USDT are swapped for MIMs. (current price peg and slippage play an important role here).
    Step 5 - These MIMs tokens are deposited back into the Abracadababra to repay for the user's released collaterals.
    Step 6 - The user receives whatever collaterals are left after these transactions, in this case, the value will be equal to the profit that the leveraged position has produced.
This process can be visualized using the following infographic:
Notice that all of these steps happen in one single transaction, and therefore only one gas fee will be required. If one of these steps fails, the whole transaction fails.

Deleveraging Positions on Abracadabra.

First, click on the REPAY button. Secondly, toggle the "Deleverage" tickbox at the bottom of the screen. A warning pop-up will open. Once closed users will be able to see the following page.
Here users will be able to select the number of MIM they want to repay as well as the amount of collaterals they want to remove. Please note that the amount of collaterals a user wants to remove changes dynamically with Swap tolerance and the amount of MIMs the user wants to repay, and will be reset every time one of these two parameters changes. Users will also be able to select the Swap Tolerance they are willing to accept. If the swap tolerance is not high enough, the transaction will fail and an error will pop up.
After all the parameters are set to the user's desire, they can click on REPAY and start the transaction. Please note that gas fees are usually higher than the usual repay action, therefore we recommend using this function only if the user's willing to accept the cost. Attention! Note that, as of right now, after the full unwind process, some dust (in both MIM and/or Collateral) still remains in the position. This small issue will soon be addressed! In the meantime, if you wish to clear the remaining dust, process an additional, normal transaction. Stay tuned!
Last modified 13d ago