Swap with DEX
The idea
So far, we've explained two different ways of executing swaps: flash swaps, and swaps for caller. In both cases, the caller needs to have or get the tokens needed by the hub, in order to exchange them for the reward tokens. But, what if the user doesn't have the required liquidity, or doesn't know how to get it?
That's why we've added to the Swapper a way for users to actually execute swaps without having to provide any liquidity. The idea is quite simple: we will execute a flash swap, use the reward to get the needed funds in a DEX, send the needed funds to the Hub and keep the fee to ourselves. In the end, we would have executed a swap and kept the fee, without using any of our funds.
How it looks like
We can divide this whole process into two:
Preparation: we understand how much is needed for the swap, and get a quote from our DEX
Execution: we send the DEX swap transaction data to the Swapper, who executes everything
One important detail is that DEXes need to be whitelisted on the Swapper. So please contact us if you find that your favourite DEX is not whitelisted yet.
The code
Last updated