Skip to content

Feat: integrated Ekubo Swapping#9

Draft
emarc99 wants to merge 2 commits into
TevaLabs:mainfrom
emarc99:feat-ekubo-swap
Draft

Feat: integrated Ekubo Swapping#9
emarc99 wants to merge 2 commits into
TevaLabs:mainfrom
emarc99:feat-ekubo-swap

Conversation

@emarc99

@emarc99 emarc99 commented Jul 6, 2025

Copy link
Copy Markdown
Contributor

@emarc99 emarc99 marked this pull request as draft July 6, 2025 12:55
@Dprof-in-tech Dprof-in-tech requested a review from Copilot July 23, 2025 08:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Comment thread src/swapx.cairo
let pool_key = PoolKey {
token0: token0,
token1: token1,
fee: 100663296, // 0.3% fee (0.3 / 100 * 2^128)

Copilot AI Jul 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fee value 100663296 is a magic number. Consider defining it as a named constant to improve readability and maintainability.

Suggested change
fee: 100663296, // 0.3% fee (0.3 / 100 * 2^128)
fee: FEE_0_3_PERCENT, // 0.3% fee (0.3 / 100 * 2^128)

Copilot uses AI. Check for mistakes.
Comment thread src/swapx.cairo
token0: token0,
token1: token1,
fee: 100663296, // 0.3% fee (0.3 / 100 * 2^128)
tick_spacing: 1000, // 0.1% tick spacing

Copilot AI Jul 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tick_spacing value 1000 is a magic number. Consider defining it as a named constant to improve readability and maintainability.

Suggested change
tick_spacing: 1000, // 0.1% tick spacing
tick_spacing: TICK_SPACING, // 0.1% tick spacing

Copilot uses AI. Check for mistakes.
Comment thread src/swapx.cairo
mag: amount_in.try_into().unwrap(), sign: false,
}, // Positive for exact-input
is_token1: is_token1,
sqrt_ratio_limit: 18446748437148339061, // min sqrt ratio limit

Copilot AI Jul 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
sqrt_ratio_limit: 18446748437148339061, // min sqrt ratio limit
sqrt_ratio_limit: MIN_SQRT_RATIO_LIMIT, // min sqrt ratio limit

Copilot uses AI. Check for mistakes.
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);

Copilot AI Jul 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// fn deposit(ref self: TContractState, token_address: ContractAddress, amount: u256);
// TODO: Implement the `deposit` function to handle token deposits.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate Ekubo Swapping

2 participants