Open
Conversation
…rate_reset_unactive_sn
shamil-gadelshin
previously approved these changes
Jan 30, 2026
Collaborator
shamil-gadelshin
left a comment
There was a problem hiding this comment.
Looks good! Are we sure that the next PR will restore user liquidity? We left a lot of code comments that make the code harder to read.
Collaborator
|
Hey @gztensor, we are already preparing changes for But, also, we would like to clarify whether it is possible to implement two additional related functionalities for clients within current PR:
If you have any questions, please feel free to let us know and we will be happy to discuss them at the meeting. |
…r_alpha and sim_swap_alpha_for_tao
sam0x17
previously approved these changes
Feb 4, 2026
sam0x17
previously approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implement PalSwap (similar to balancer swap) to replace Uniswap V3.
Unlike uniswap v2 or v3, it allows adding liquidity unproportionally to price. This is achieved by introducing the weights w1 and w2 so that w1 + w2 = 1. In these formulas x means base currency (alpha) and y means quote currency (tao). The w1 weight in the code is referred as weight_base, and w2 as weight_quote. Because of the w1 + w2 = 1 constraint, only weight_quote is stored, and weight_base is always calculated.
The formulas used for pool operation are following:
Price
p = (w1 * y) / (w2 * x)
Reserve deltas
(or -1 * payouts) in swaps are computed by
if ∆x is given (sell): ∆y = y * ((x / (x+∆x))^(w1/w2) - 1)
if ∆y is given (buy): ∆x = x * ((y / (y+∆y))^(w2/w1) - 1)
Limit orders
When swaps are executing the orders with slippage control, we need to know what amount we can swap before the price reaches the limit value of p':
If p' < p (sell): ∆x = x * ((p / p')^w2 - 1)
If p' < p (buy): ∆y = y * ((p' / p)^w1 - 1)
Swap initialization
In order to initialize weights with existing reserve values and price (for existing subnets):
w1 = px / (px + y)
w2 = y / (px + y)
Injection
Weights are adjusted when some amounts are added to the reserves. This prevents price from changing.
new_w1 = p * (x + ∆x) / (p * (x + ∆x) + y + ∆y)
new_w2 = (y + ∆y) / (p * (x + ∆x) + y + ∆y)
User Liquidity
The user liquidity stays disabled for now. The last commit # where all comments about user liquidity and tests (commented out) are present: fb0017f , diff it with 4e21da2 to see the user liquidity code.
Type of Change
Breaking Change
This PR changes the following externally accessible entities:
add_liqudiityextrinsic: Remove tick_low and tick_high parameters.Positionsmap is replaced withPositionsV2mapChecklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctly