2️⃣Build Logics
Trading strategy
Before using the SDK, it's important to have a clear understanding of your trading strategy. This will help you make informed decisions when using the SDK to send transactions. Below, we provide an example scenario to help illustrate how to define a trading strategy. You can use this as a guide to customize your own strategy.
Example: Suppose a user has 1000 USDC in Ethereum and wants to swap it for WBTC to supply the WBTC pool on the Aave V3 lending platform and earn interest. The user's address is 0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa
.
Typically, the user needs to perform two actions:
Exchange 1000 USDC to WBTC by Uniswap V3
Supply WBTC to get aWBTC by Aave V3
Each of the actions mentioned above represents a Logic
in Protocolink.
Let's start building these logics. Here you can find example code.
Logic 1: Swap
The user can swap 1000 USDC for WBTC using the SwapTokenLogic of Uniswap V3.
Use
api.protocols.uniswapv3.getSwapTokenQuotation
to get a quotation. Additionally, slippage is optional. The type should be a number, and the value should be in Basis Points, where 1 Basis Point equals 0.01%.Use
api.protocols.uniswapv3.newSwapTokenLogic
to build the swap Logic data.
Below is the code snippet:
Logic 2: Supply
Then you can take the output of the previous swapQuotation
and use it as an input to get the supply quotation.
Use
api.protocols.aavev3.getSupplyQuotation
to get a quote for supplying WBTC, which will provide a 1:1 aEthWBTC token.Use
api.protocols.aavev3.newSupplyLogic
to build the supply Logic data.
Last updated