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