Open By Debt
Last updated
Last updated
Continuing from .
Open By Debt enables users to achieve the desired debt exposure in a single step by using a flash loan.
Zap token: the user-provided token to be swapped to the collateral token.
Collateral token: the collateral token to be leveraged.
Debt token: the debt token to be leveraged against.
By specifying the zap token, the zap token amount, the collateral token, the debt token, and the debt token amount, the function will return the deposited collateral token amount, the updated user portfolio, and the logics to be executed.
The logics should include:
Swap the zap token for the collateral token
Borrow a flash loan of the debt token
Swap the debt token for the collateral token
Deposit the collateral token and get the protocol token (aToken)
Return the protocol token (aToken) to the user
Borrow the debt token
Repay the flash loan with the debt token
To perform the logics, certain approvals need to be processed. You may refer to Estimate Router Data and Send Router Transaction for more details.