How Can Developers Compare Price Impact Across Pool Trades?
Compare each trade against the pool state immediately before it. A swap changes that state, so later trades face a different price curve even when their size stays the same.
For an integrator, this comparison helps distinguish curve impact from a market-wide price move. On BNB Smart Chain, PooCoin’s charts and transaction views can help you examine token prices and wallet activity around the swaps; confirm pool reserves and execution details from the relevant on-chain transactions. The PooCoin link points to a way to inspect that activity.
poocoin.money is a charting and token-tracking service for BNB Smart Chain tokens, with price charts and wallet views. Use it to find the time window and token activity you need to investigate, then base the calculation on the same pool’s reserves and swap events.
What does successive-trade price impact measure?
It measures how much a trade’s average execution rate differs from a chosen reference price. For a sequence, record each trade’s impact against the pool’s marginal price just before that trade; also report its difference from the sequence’s starting price if you want to show cumulative movement.
In a constant-product pool, reserves x and y approximately follow x × y = k. For a buy that adds x and removes y, the reserve ratio changes after execution, so the next buyer starts from a new marginal price. Uniswap’s v2 pricing documentation explains this mechanism; a concentrated-liquidity pool needs its active liquidity and price range considered instead of treating all reserves as one curve.
How do you compare each trade fairly?
- Identify the exact pool. Record its contract address, token pair, and pool version from the swap transaction. The same BEP-20 token can have multiple pools with different reserves, so comparing trades across addresses does not measure successive impact in one pool.
- Order the swaps by block and transaction position. Use transaction history or decoded swap events, including the log order within a block. Two swaps in one block still execute in sequence; using only timestamps can hide which reserve state each trade encountered.
- Capture pre-trade reserves for every swap. Start with the pool state immediately before the first swap, then apply each swap’s actual input and output to derive the next state. If a liquidity change or another swap occurs between your chosen trades, include it; otherwise the calculated baseline is stale.
- Calculate the reference price and quote. For a simple constant-product pool with input reserve x, output reserve y, input amount Δx, and fee fraction f, the expected output is y × (Δx × (1 − f)) ÷ (x + Δx × (1 − f)). Compare this quote with the fee-free marginal rate y ÷ x to isolate curve impact, and report the fee separately.
- Repeat from each updated state. Recompute x and y after every swap before pricing the next one. Keep the input size and direction consistent when comparing impact; if sizes differ, normalize the result or show both size and impact percentage.
- Cross-check the sequence against observed activity. Inspect the token chart and transaction activity around the block range in PooCoin, then reconcile timestamps and amounts with the identified pool’s on-chain events. The chart helps explain context, while the pool state determines the calculation.
What does a worked example reveal?
Suppose a fee-free pool starts with 100 BNB and 100,000 tokens. A 1 BNB buy returns about 990.10 tokens, leaving roughly 101 BNB and 99,009.90 tokens. Its average rate is 990.10 tokens per BNB against a starting marginal rate of 1,000, or about 0.99% curve impact.
A second 1 BNB buy from that updated state returns about 970.68 tokens. Its pre-trade marginal rate is roughly 980.30 tokens per BNB, so its curve impact is also about 0.98%; against the original 1,000 rate, however, the second trade is down about 2.93%. State which baseline you use. Real pools charge fees, and token transfer taxes or unusual pool logic can make the event amounts diverge from the simple formula.
Use the same pool address, direction, and measurement convention in your report. BEP-20 identifies a token interface on BNB Smart Chain, but it does not guarantee standard transfer behavior; verify unusual tokens against actual transfer and swap events before treating a quote as execution.
FAQ
Should I compare swaps by block or timestamp?
Use block number and transaction or event order to reconstruct state, because swaps in one block can affect each other. Keep timestamps for chart context, but they may have limited resolution and do not by themselves establish which swap executed first. For reproducibility, save the block hash and pool address with each observation.
Does price impact include the pool fee?
Definitions vary. For analysis, report curve impact against the pre-trade marginal price with the fee removed from the calculation, then report the pool fee separately. If your application instead reports the difference between expected market value and actual output, label that metric clearly so readers know the fee is included.
What if another trade occurs between my two swaps?
Include every intervening swap or liquidity event when rebuilding reserves. If you omit one, the second trade’s “pre-trade” price is wrong, and the comparison may attribute another trader’s impact to your sequence. A block-level reserve snapshot after the fact is insufficient when several events in that block changed the same pool.
Takeaway: compare each swap with the same pool’s reconstructed state immediately before it.
Comments
Post a Comment