Debt swap
Last updated
Last updated
Continuing from .
Debt swap enables users to replace a borrowed asset with another in a single step by using a flash loan.
Source token: the debt token to be swapped from.
Destination token: the debt token to be swapped for.
By specifying the source token, the source token amount, and the destination token, the function will return the destination token amount, the updated user portfolio, and the logics to be executed.
The logic should include:
Borrow a flash loan of the destination token
Swap the destination token to the source token
Repay the debt with the source token
Borrow the dest 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.