Develop a Cairo function that integrates with the Ekubo protocol to perform token swaps inside the SwapX contract. The function should:
- Be named
swap_token_to_stable(token_in, token_out, amount_in)
- Use the Ekubo Router interface to perform the actual swap (see: [Ekubo Integration Guide](https://docs.ekubo.org/integration-guides/swapping))
- Assume that
token_in has already been deposited by the user into the SwapX contract
- Update internal user balances to reflect the change in tokens (decrease
token_in, increase token_out)
- Emit a
TokenSwapped(user, token_in, token_out, amount_in, amount_out) event to signal the result of the swap
This feature enables conversion to stablecoins, which is essential for off-ramping.
Develop a Cairo function that integrates with the Ekubo protocol to perform token swaps inside the SwapX contract. The function should:
swap_token_to_stable(token_in, token_out, amount_in)token_inhas already been deposited by the user into the SwapX contracttoken_in, increasetoken_out)TokenSwapped(user, token_in, token_out, amount_in, amount_out)event to signal the result of the swapThis feature enables conversion to stablecoins, which is essential for off-ramping.