In the following section, we will guide you step by step on how to swap tokens using Uniswap and supply tokens to the Aave protocol.
Step 1: Prepare Strategy Using Tokens
To earn interest by supplying to the Aave Protocol, users holding 1000 USDC need to exchange it for WBTC. This scenario involves two separate steps of logic:
Exchange USDC to WBTC by Uniswap V3
Supply WBTC to get aWBTC by Aave V3
Retrieve the necessary token information by utilizing the Request Tokens API.
This endpoint offers an estimation of the amount of funds to be spent (funds) and the number of balances to be obtained (balances) from the transaction. Additionally, it will identify any necessary approvals that the user must execute (approvals) before proceeding with the transaction and whether there is any Permit2 data that the user needs to sign (permitData) beforehand.
The transaction to Router is what needs needs to be sent next. If you are using the ethers package, you can refer to the code example provided below to send the transaction: