Conversation
emarc99
commented
Jul 6, 2025
- Closes: Integrate Ekubo Swapping #4
- Adding tests
There was a problem hiding this comment.
Pull Request Overview
This PR integrates Ekubo DEX swapping functionality into the SwapX contract. The implementation allows users to swap tokens through Ekubo's liquidity pools while maintaining internal balance tracking within the SwapX contract.
- Adds Ekubo DEX integration for token swapping functionality
- Implements the ILocker interface to handle swap callbacks
- Introduces a new TokenSwapped event and SwapData struct
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/swapx.cairo | Adds Ekubo imports, swap functionality, ILocker implementation, and internal balance management for swaps |
| src/interfaces/iswapx.cairo | Extends ISwapX trait with swap_token_to_stable method |
Comments suppressed due to low confidence (1)
src/swapx.cairo:178
- The variable names shadow the input parameters token_in, token_out, and amount_in. Consider using different names like actual_token_in, actual_token_out, actual_amount_in, actual_amount_out to avoid confusion.
let (token_in, token_out, amount_in, amount_out) = if delta.amount0.sign {
| let pool_key = PoolKey { | ||
| token0: token0, | ||
| token1: token1, | ||
| fee: 100663296, // 0.3% fee (0.3 / 100 * 2^128) |
There was a problem hiding this comment.
The fee value 100663296 is a magic number. Consider defining it as a named constant to improve readability and maintainability.
| fee: 100663296, // 0.3% fee (0.3 / 100 * 2^128) | |
| fee: FEE_0_3_PERCENT, // 0.3% fee (0.3 / 100 * 2^128) |
| token0: token0, | ||
| token1: token1, | ||
| fee: 100663296, // 0.3% fee (0.3 / 100 * 2^128) | ||
| tick_spacing: 1000, // 0.1% tick spacing |
There was a problem hiding this comment.
The tick_spacing value 1000 is a magic number. Consider defining it as a named constant to improve readability and maintainability.
| tick_spacing: 1000, // 0.1% tick spacing | |
| tick_spacing: TICK_SPACING, // 0.1% tick spacing |
| mag: amount_in.try_into().unwrap(), sign: false, | ||
| }, // Positive for exact-input | ||
| is_token1: is_token1, | ||
| sqrt_ratio_limit: 18446748437148339061, // min sqrt ratio limit |
There was a problem hiding this comment.
The sqrt_ratio_limit value 18446748437148339061 is a magic number. Consider defining it as a named constant with a descriptive name to improve readability and maintainability.
| sqrt_ratio_limit: 18446748437148339061, // min sqrt ratio limit | |
| sqrt_ratio_limit: MIN_SQRT_RATIO_LIMIT, // min sqrt ratio limit |
| pub trait ISwapX<TContractState> { | ||
| fn add_supported_token(ref self: TContractState, token_address: ContractAddress); | ||
| fn is_token_supported(self: @TContractState, token_address: ContractAddress) -> bool; | ||
| // fn deposit(ref self: TContractState, token_address: ContractAddress, amount: u256); |
There was a problem hiding this comment.
Commented out code should be removed. If this functionality is planned for future implementation, consider using a TODO comment or tracking it in an issue instead.
| // fn deposit(ref self: TContractState, token_address: ContractAddress, amount: u256); | |
| // TODO: Implement the `deposit` function to handle token deposits. |