Mdex liquidity pools and price divergence in LP value
last updated
Mdex liquidity pools change an LP position's token mix as trades respond to price differences and alter paired reserves. When the assets diverge, arbitrage removes some of the outperforming asset from the pool and adds more of the underperforming one, so the position can trail simply holding the same starting amounts.
Price divergence changes an LP's reserve mix, so value must be compared with holding the same starting assets.
Establish the position and its comparison baseline
A meaningful LP comparison starts with the exact pair, the contributed amounts, and a valuation time. Without that baseline, a changing wallet value cannot be separated into market movement, pool rebalancing, fees, rewards, or network costs.
First verify that the selected network is active. Mdex's November 20, 2024 announcement said HECO would go offline on January 15, 2025. Then identify both assets by contract address on that network. Symbols can be copied, while contract addresses define the assets held by the pair. The pair contract, current reserves, LP token supply, and the account's LP balance together establish the account's proportional claim.
An addition to an existing pool follows its current reserve ratio. The routing contract calculates the matching amount of the second asset and does not treat any unused desired amount as liquidity. A newly created pair differs because its first provider sets the initial ratio, which can attract arbitrage if it departs from the wider market.
- Record the pair contract and selected network.
- Record both token contracts and contributed quantities.
- Use consistent external prices at the deposit and comparison times.
- Keep the LP token balance and total supply needed to derive the share.
- Separate network costs, pool fees, and any incentive rewards.
Token approvals and liquidity provision can be separate transactions, each with its own network cost. A successful addition mints LP tokens to the specified recipient. If those tokens are later deposited into an incentive contract, the wallet balance alone no longer shows where the claim is held.
Completion is visible in a successful transaction receipt, the pair's reserve update, and the credited LP tokens. Saving the contributed quantities and their value at that point creates the comparison baseline. A later valuation can then use the same unit of account instead of treating a rising dollar balance as proof that liquidity provision outperformed holding.
Reserve changes rewrite the token mix
Every swap shifts the two reserves, and an LP owns the same fraction of that changing inventory until the share changes. Buying one asset from the pool reduces its reserve and adds more of the other asset. Arbitrage trades tend to move the reserve ratio toward external prices, subject to fees and execution costs.
Mdex's automated market maker keeps each pair on a constant-product curve, expressed as x multiplied by y equals k when fees are set aside. The invariant does not preserve the quantity of either asset. It constrains their product, so a lower reserve of one asset corresponds to a higher reserve of the other.
The position amounts can be estimated by multiplying each pool reserve by the LP's share of total LP supply. That calculation explains why an unchanged LP token count can represent different asset quantities. When other providers add or remove liquidity, total reserves and LP supply change together, while swaps change the reserve composition available to every share.
Why can an LP position trail simple holding?
The shortfall appears when the relative price changes because the pool continuously exchanges part of the stronger asset for the weaker one. A holder keeps the original quantities. An LP instead ends with the pool's rebalanced quantities, plus the position's share of accrued fees and any separately earned rewards.
For a constant-product pair with equal starting values and no fees, the LP-to-hold value ratio is
2 x sqrt(r) / (1 + r), where
r
is the ending relative price divided by the starting relative price. The ratio is below one whenever
r
differs from one. Reciprocal moves, represented by
r
and
1/r, produce the same percentage shortfall.
“Impermanent” does not mean that the shortfall is trivial or certain to reverse. In the simplified model, the divergence component narrows if the relative price returns toward its starting ratio before withdrawal. Fees may offset some or all of it, but a withdrawal fixes the asset quantities received for the portion removed.
A hypothetical divergence calculation and reversible exit
Every amount, price, fee, reward, and network cost in this example is hypothetical. Model a position that represents 513 units of asset A and 513 units of asset B, each priced at one accounting unit. The starting value is 1,026 units, and the product of those position amounts is 263,169.
Suppose asset A rises to 2.56 accounting units while asset B remains at one. Ignoring fees and rewards, arbitrage changes the position's represented amounts to 320.625 units of A and 820.8 units of B. The LP position is then worth 1,641.6 units. Holding the original quantities would be worth 1,826.28 units, leaving the LP value 184.68 units, or about 10.11%, lower.
The calculation changes when any input changes. A smaller relative price move narrows the gap, while a larger move widens it. Accrued pool fees increase the LP side, incentive rewards add a separate component, and network costs reduce the final account result. None of those inputs supports a promised fixed return.
To keep the decision reversible, inspect the estimated amounts of both assets before signing. If the reserve ratio changes enough to make that estimate unacceptable, stop and obtain a fresh estimate rather than expanding the allowed range blindly. Once the removal is confirmed, the successful receipt and the two resulting wallet balance changes show what the withdrawal delivered.
Fees and incentives belong in separate columns
Fee income can close the gap with holding, but its size depends on trading activity, the position's pool share, and the applicable pair configuration. Read the relevant fee input from the live factory configuration for that pair; a historical headline percentage is not a safe substitute. Incentive rewards require an eligible program and, where applicable, a separate LP-token deposit. Value each component at the same comparison time and subtract every transaction cost used to enter, manage, or exit the position.
Withdrawal converts the share into current reserves
The exit amount depends on the LP share and the reserves available when the removal executes, not the two quantities originally deposited. Minimum-amount fields set the least acceptable output for each asset. A transaction reverts rather than completing below those limits, although the failed call can still consume network gas.
Removing liquidity burns the submitted LP tokens and returns the corresponding amounts of both reserve assets, subject to the transaction's minimum-amount conditions. If the LP token sits in a separate staking contract, it must first return to the account that can authorize removal. Pending rewards and pool reserves are different balances, so they should not be merged before each has actually reached the wallet.
After confirmation, reconcile four records: the burned LP amount, both token transfers, the receipt's gas cost, and any reward withdrawal made separately. A token with unusual transfer behavior can make wallet-level changes differ from a simple reserve-share estimate. The final comparison therefore uses received balances, not only the interface preview.
Separate holding offers the cleaner exposure
Holding the two assets separately preserves their original quantities and avoids automatic selling of the relative winner, but it earns no pool fee share. Liquidity provision accepts changing quantities in exchange for fee exposure and possible eligible incentives. The relevant choice is whether those variable earnings justify rebalancing risk, contract exposure, transaction costs, and the operational work of tracking the LP claim.
Questions and answers about Mdex liquidity pools
Does adding more liquidity erase an existing divergence shortfall?
No. A new contribution enters at the pool's current reserve ratio and does not restore the earlier token mix. It creates additional LP exposure from a new baseline. For accurate accounting, track each contribution separately or use a weighted cost basis that preserves the amounts, prices, fees, and transaction costs attached to every addition.
Is divergence loss zero if both assets fall by the same percentage?
The simplified divergence component is driven by the change in the assets' relative price, not their shared direction against a currency. If both fall equally and their ratio stays unchanged, that component is zero. The position can still lose substantial value because both reserve assets are worth less.
Can an LP position be valued while its tokens are staked?
Yes. Divide the LP amount attributed to the account by the pair's total LP supply, then apply that share to each reserve. Pending rewards remain a separate value component. The wallet may show no LP-token balance while the staking contract holds those tokens on the account's behalf.
Does widening withdrawal tolerance reduce divergence loss?
No. The minimum-amount settings define how much reserve movement the withdrawal may accept before reverting; they do not reverse past pool rebalancing. A wider range can permit execution after a larger change in expected amounts, so it changes the execution boundary rather than the divergence calculation.
Can transfer-tax or rebasing tokens break the simple divergence calculation?
Yes. The standard calculation assumes ordinary transfers and reserve accounting, so token-level deductions or supply changes can alter received balances and pool behavior. Contract compatibility and actual wallet transfers matter more than a symbolic formula in those cases. A reserve-share estimate should be reconciled with the confirmed transaction and final balances.