Leverage By Debt
Last updated
Last updated
Continuing from .
Leverage By Debt enables users to achieve the desired debt exposure in a single step by using a flash loan.
Source token: the debt token to be leveraged.
Destination token: the collateral token to be leveraged against.
Specify the source token, source token amount, and the destination token that the user wants to leverage. The function will return the deposited destination token amount, the updated user portfolio, and the logics to be executed.
The logics should include:
Borrow a flash loan of the source token
Swap source token for destination token
Deposit the destination token and get the protocol destination token (aToken)
Return the protocol destination token (aToken) to the user
Borrow the source token
Repay the flash loan with the source 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.