Swap & Supply (Example)
Step 1: Prepare Strategy Using Tokens
const client = axios.create({ baseURL: 'https://api.protocolink.com' });
const getSwapTokens = async () => {
const result = await client.get('/v1/protocols/1/uniswap-v3/swap-token/tokens');
return result.data;
}Step 2: Build the Logic
const getSwapQuote = async (inputToken, inputAmount, tokenOut) => {
const result = await client.post('/v1/protocols/1/uniswap-v3/swap-token/quote', {
input: {
token: inputToken,
amount: inputAmount
},
tokenOut: tokenOut,
});
return result.data;
}
const inputToken = USDC;
const inputAmount = '1000';
const tokenOut = WBTC;
const swapQuote = await getSwapQuote(inputToken, inputAmount, tokenOut);
const swapLogic = {
rid: 'uniswap-v3:swap-token',
fields: swapQuote,
}Step 3: Estimate Router Data
Step 4: Build Router Transaction
Step 5: Sending the Transaction
Last updated