Table Of Contents
CrossLink is a project built on and Uniswap v4, designed to enhance the functionality and flexibility of decentralized exchanges (DEXs) by introducing custom hooks that can be integrated into the trading process. Two key components of CrossLink are the Nezlobin Dynamic Fee Hook and the Limit Order Book Hook.
• Nezlobin Dynamic Fee Hook: This hook adjusts transaction fees in real-time based on market conditions, using dynamic fee structures to protect liquidity providers from impermanent loss. By increasing fees during volatile periods and reducing them during stable times, this hook ensures a more balanced and fair trading environment.
• Limit Order Book Hook: This hook brings the functionality of a traditional order book to Uniswap v4, allowing users to set precise buy and sell orders that execute only when specific price conditions are met. This feature provides traders with greater control over their transactions, similar to the experience on centralized exchanges.
With CrossLink, developers can leverage these advanced hooks to implement dynamic fee adjustments, custom trading strategies, and optimized liquidity management, all while maintaining compatibility with existing DEX infrastructures. This project empowers users and developers to create more efficient, responsive, and tailored trading environments within the DeFi ecosystem.
In our platform, we have a section where you can create your own tokens or mint existing tokens. This feature is designed to facilitate more robust and realistic testing within the testnet environment. When you mint your first token, you will need to approve it for the hook liquidity router and the swap router, which are integral to the swap hook functionality. This approval is specifically required for the Limit Order Hook, and you’ll see this process in action as you interact with the platform.
On our platform, we offer three modes, with the first being the Uniswap v4 mode. This mode allows you to use the standard features of Uniswap v4. The way these modes work is straightforward: when you are in the Nezlobin mode, for example, only the pools attached to the Nezlobin hook will appear in the Explore, Add Liquidity, and Swap sections. The process of linking pools to specific hooks is managed through the Create Pool section. Each mode tailors the experience to the selected hook, ensuring that the interactions you have on the platform are consistent with the specific functionalities of that mode.
If you navigate to the “My Positions” section and then to the “Create Pool” tab, you can create a pool tailored to your preferences. In this section, you can select the tokens you want to pair, set the initial price ratio (which determines the starting price of the tokens in the pool), and choose other parameters like fee and tick spacing.
If the site were in Nezlobin mode, the dynamic fee field would automatically populate with a value. This value indicates that the pool carries the dynamic fee flag, which is essential for pools utilizing the Nezlobin hook. You can also customize the price ratios to set the initial trading conditions for your pool. Additionally, you have full control over selecting the tokens you want to use in the pool. This flexibility allows you to create pools that align with your trading or liquidity provision strategies, whether in standard Uniswap v4 mode or while using specialized hooks like Nezlobin or Limit Order.
To add liquidity, first, navigate to the “Explorer” section, where pools will be displayed based on the active mode. By clicking on the pool you are interested in, you can view its details and proceed to add liquidity. In the liquidity form, you can set your desired price range, which can be specified either as ticks or as a price, depending on your preference. Additionally, you can adjust the amount of each token you want to contribute to the pool. This setup allows for flexible and precise liquidity provision, tailored to your strategy.
In the approval process, if you’ve just minted a new token, you’ll need to approve it for the first time when performing actions like adding liquidity, swapping, or placing an order (specifically with the Limit Order Hook). This approval is a one-time action for that token, meaning you won’t need to re-approve the same token when interacting with the same pool or when creating new pools with the same tokens. The approval is typically set to a maximum limit to cover all future transactions involving that token.
When testing the Nezlobin hook, the process involves several steps. First, switch to the Nezlobin mode and create a pool by selecting the Nezlobin hook during the pool creation. For this test, we set the tick spacing to 100 (though you can choose a different value, this setup is calculated for a more accurate test). Once the pool is created, navigate to the Explorer, click on the pool, and add liquidity. If the tokens are newly minted, you may need to approve them first.
Next, set the parameters for liquidity provision: 5000, 5000, -887200, and 887200 (these are tick values, with the last two representing the minimum and maximum tick values for 100-tick spacing).
Then, go to the Swap section and perform a swap by selling 590 tokens in the direction of the pool’s pair (e.g., if the pool is USDC/WEDU, sell in this direction). Perform the swap twice, then use the direction toggle button to view the current swap fee. You should see a low fee, around 769, indicating the lower cost of the swap.
Next, reverse the direction (e.g., WEDU/USDC) and swap the same amount (590 tokens). After the swap, toggle the direction button again, and you’ll observe a higher swap fee, around 5006. This increase is due to the significant price impact in the buying direction. Additionally, if an approval prompt appears, ensure that the previous transaction has fully processed before initiating the swap, the same caution applies when adding liquidity.
In the Limit Order test, you will follow a similar process to the Nezlobin test but with some key differences:
Create a Pool: First, create a pool by selecting the Limit Order hook. Set the dynamic fee to 3000 and tick spacing to 100. In the price ratio section, choose a 1:1 ratio.
Add Liquidity: After creating the pool, add liquidity with the same parameters used in the Nezlobin test: 5000, 5000, -887200, and 887200.
Place an Order: Next, go to the “My Orders” section while in Limit Order mode. Place an order with the following instructions: “Sell 20 tokens when the tick reaches 100.” After placing the order, you’ll see it listed in the orders section. Notice that the “Redeem” button is disabled since the order hasn’t been executed yet, but you can cancel the order at this point.
Trigger the Order: Now, act as another user and perform a swap in the opposite direction of the pool pair (e.g., if the pool is USDC/WEDU, swap in the WEDU/USDC direction). Execute a swap of 200 tokens, which should push the tick to 100, triggering the order you placed.
Redeem: After the swap, return to the “My Orders” section. You will now see that the “Redeem” button has turned green, indicating that your order has been executed. At this point, you can redeem the order, while the “Cancel Order” option will no longer be available. The Limit Order hook has matched your order by executing a corresponding swap when the tick reached 100.
<aside> 💡
When you click “Approve” for a token, please ensure that you wait for the transaction to be fully processed before proceeding with any additional actions, such as adding liquidity. After clicking “Approve,” you may see a prompt for the next step, but do not proceed until the “Pending” transaction has completed. If you ignore this and try to proceed, the operation may fail. Always wait until the current transaction is fully confirmed to ensure everything works smoothly.
</aside>