Knowing how AI quant trading BSC works is what separates a clean trade from a costly one. Every backtest fill is a claim about a state the chain has already left behind. When you call getAmountsOut through eth_call at a given block, the router reads the pair's reserves at that block and runs the constant-product formula against them. That answer is correct for that block and useless for the next one, because the pair only writes new reserves after a swap executes inside a block.
The pair itself has no memory of your intent. It reads its current reserves, computes the output, transfers tokens, and writes the new reserve values, in that order. Any swap ordered ahead of yours in the same block changes the reserves your trade is priced against. The realized price is whatever the pair computed at execution, not what your simulation saw.
Verification is a two-call comparison. Take the transaction hash of a fill you actually got, find its parent block, and call getAmountsOut with the same amountIn and path at that parent block. Then read the Swap event the pair emitted in the block your transaction landed in. The ratio of the two output amounts, expressed in basis points of notional, is the realized slippage for that trade. Both the pair address and the event are visible on BscScan under the pair contract's Logs tab.
Three leaks sit between the signal and the settled fill, and a single-hop backtest models none of them. Signal latency is the first. The block your bot reads is already final, so the opportunity it detects may be consumed before its transaction is included. Ordering inside the block is the second, and it is the one that scales with your size. Routing is the third, and it is the one that hides in plain sight.
Sum the input and output amounts across every Swap log in the transaction and compare that to the getAmountsOut result at the parent block. The difference in basis points is the aggregate leak for that trade. Run this on a losing fill and the leak usually concentrates in one hop rather than spreading evenly, which tells you whether the problem is your path selection or your timing.
Edge cases break the clean comparison. On a thin pair the parent-block quote and the executed fill can diverge far enough that the ratio stops being a slippage measurement and becomes a liquidity event. If eth_getTransactionReceipt returns null, the transaction is pending or dropped, and there is no fill to measure yet. When two RPC endpoints disagree on the parent block hash, stop and re-query: a fork or a lagging node will corrupt every quote built on it.
Decision rules you can apply today. If the parent-block hash differs between your two endpoints, then discard the sample rather than averaging it in. If the aggregate leak on a losing fill concentrates in one hop, then re-price that hop's path before you touch your timing logic. If the pair's reserves at the parent block fall below your notional times a fixed multiple, then skip the trade rather than sampling it.
Pool fees are baked into the constant-product formula, so most backtests include them by construction. A separate fee-taking hop is not in the formula, and that is where the model quietly overstates output on every trade. When a swap routes through the YESswap fee router at 0x0c9a2351e6e982b16559a68767003e7f4d02fb0d, the amount that reaches the pair is smaller than the amount the signer authorized.
The pool then prices the swap against that reduced input. Effective cost becomes pool fee plus router fee, compounded, and the compounding is what a flat percentage assumption misses. A model that assumes the full signed amount reaches the pool is not slightly optimistic. It is wrong by the router's take on every single fill.
Read the ERC-20 Transfer events for the input token in the transaction rather than trusting the transaction's value field. One leg runs from the signer to the router, another from the router to the pair. The pair's Swap event amountIn reflects only the second leg. Subtracting the pair's amountIn from the signer's debit gives the router's take directly, in token units, per transaction. Log those two numbers separately or the fee becomes invisible in your own dataset.
Confirm the router address before you attribute anything to it. Decode the log's address field and match it against 0x0c9a2351e6e982b16559a68767003e7f4d02fb0d exactly; a lookalike contract takes a fee too, and it is not the one your model should assume. If the emitting address differs, then treat the transaction as out of sample and exclude it.
Shadow mode means live blocks and minimal size, not a paper ledger. For each signal, compute the expected output with getAmountsOut at the parent block, submit a minimal transaction, and record the realized output from the Swap event. Every shadow trade yields a transaction hash, and the parent block number, the quote at that block, and the Swap amounts are all retrievable through eth_getTransactionReceipt and eth_call. The sample is auditable end to end.
The distribution matters, not the mean. Averaging slippage across a sample lets a strategy pass its own threshold on quiet blocks and fail on exactly the blocks where size matters. Set the rejection threshold at a tail percentile of the observed gap and enforce it in the signing path, before the transaction is built. A threshold you derived from your own fills is a different object from one you assumed.
Three failure modes account for most of the gap. Quoting against the latest block instead of the parent block of the transaction you intend to send makes every simulated fill look better than any fill you can actually get. Modelling pool fees but not the fee router hop overstates output on every trade. Averaging instead of using the tail percentile hides the loss until size arrives.
Cost and timing are bounded by gas, not by the measurement. Each shadow trade costs one transaction's gas plus whatever the router and pool take on the notional, so keep notional minimal and let the count carry the sample. The clock is block time on BSC: one observation per block, and the parent-block quote is available the moment the receipt resolves. Budget the sample in blocks, not in wall-clock hours, because a quiet stretch of blocks teaches you nothing about the tail.
A fill is reconstructable only if you persist enough to replay it. Capture the block number, the transaction hash, the pair address, and the Swap event's amount0In, amount1In, amount0Out, and amount1Out. Without the pair address you cannot tell which hop contributed the impact. Without the block number you cannot rebuild the parent-block quote.
The Swap event on a BSC pair carries exactly those four amount fields plus the sender, and the pair address is the emitting contract in the log's address field. Store the signed amountIn separately from the pair's amountIn so router fees stay visible in your own records. A bot holding these fields plus the parent-block getAmountsOut result has a complete, replayable record of every fill, checkable later on BscScan against the same transaction hash.
Before trusting any address, verify it on chain. The YES token on BNB Smart Chain is 0xc22955b28e092060bc5d1e1f3b9d4dcd81091111, and the only official domain is https://yesswap. Telegram and X are both @web3yesswap. Any other contract, handle, or domain is not official, and a strategy that routes through an unverified address has a slippage problem larger than the one this article measures.
Open YESswapThe backtest priced fills against a reserve snapshot that your transaction never traded against. Measure the gap per fill by comparing getAmountsOut at the parent block to the Swap event amounts, then set a rejection threshold at a tail percentile of that distribution.
The ratio of the two output amounts in basis points is your realized slippage.
Compare the signer's ERC-20 debit to the pair's Swap amountIn to see the router's take per transaction.
getAmountsOut is a read-only quote against reserves at one block. The difference is the gap you are trying to measure.
Enough that the tail percentile is stable when you resample the set. The count is less important than the method: use a tail percentile, not the mean, because the mean lets the strategy pass on quiet blocks and fail where size matters.
Every card below opens the live product with your own wallet — no signup, no custody.
Everything above is one page away: ai quant trading bsc.