Finishing a Split Swap After Partial Completion
After several split swaps, confirmed pieces remain complete, and you should resume only the amount still owed because each transaction succeeds or reverts independently. First resolve any piece that is still pending; until its outcome is known, another attempt could trade the same amount twice.
Record each piece’s status before calculating the remainder
Begin with the transaction hash for every piece and the intended total input. Look up each hash on the block explorer for the network where that piece was submitted. A hash is specific to its network, so the explorer must match the network selected for the trade. Matcha swap networks are part of the broader routing context; checking the right network matters because each submitted swap has its own record there.
Classify every piece by what happened to its transaction:
- Confirmed success: The transaction completed, so count its actual input and output toward the total.
- Reverted: The transaction failed. Its input tokens remain in your wallet, though the network still charged gas.
- Pending: The transaction has no final result yet. It may still complete or fail.
- Never submitted: No transaction hash exists for that piece, so it has not traded.
A Matcha swap can route a token trade, but that routing does not bind separately submitted transactions together. Each hash reports the outcome of one piece. A successful piece stays successful even if another piece reverts; the failed piece does not undo it.
Follow this order to resume the trade:
- Look up every hash. Record whether each piece succeeded, reverted, or remains pending, and note the input and output shown for confirmed transactions.
- Resolve pending pieces first. Wait for the transaction to finish, or use your wallet’s speed-up or cancellation option if available. A replacement transaction can change the fee or cancel the pending attempt, but do not submit that piece again until its final status is clear.
- Work out what remains. Use your starting and current input-token balances, accounting for unrelated transfers, and compare them with the intended total. Confirmed input has been spent; reverted input is still available. Use transaction details to separate swap spending from other wallet activity.
- Read the revert reason. The explorer or wallet may show why the piece failed. A price or slippage error points to market movement; an allowance, balance, or contract error calls for a different fix.
- Request a fresh quote for only the remainder. Set the amount from your balance calculation, then review the route, expected output, and slippage setting before submitting.
A reverted piece leaves its input available, but costs gas
When a swap reverts, the transaction’s state changes are rolled back: the input token transfer for that swap does not take effect. The gas fee is separate and is still paid for the failed attempt. This is why resubmitting the original split sizes can overshoot your intended total: successful pieces already consumed part of the input, while reverted pieces did not.
Later pieces may fail after an earlier piece changes the price. Each piece’s slippage bound limits how far the execution price can move from its quote; if the available trade can no longer meet that bound, the transaction reverts. A failure for this reason is consistent with earlier pieces standing, since their transactions were settled independently.
Also check the balance of the network’s gas token before retrying. Earlier successful and reverted transactions may both have consumed gas, so the wallet can have enough input tokens for the remainder but too little gas to submit it. If so, the amount to trade has not changed; the retry must wait until the wallet can pay the network fee.
Re-quote the measured remainder after checking the cause
Use the revert reason to decide what to change. If price movement pushed execution beyond the slippage bound, request a new quote for the remaining input. You might reduce the size of that remainder or choose a slippage setting that reflects the price movement you are willing to accept. A wider bound can permit a less favorable execution price, so review the quoted output before confirming.
If the reason points to insufficient allowance or input balance, address that issue before retrying. A new quote alone will not fix a missing approval or a balance shortfall. If the reason is unclear, compare the wallet’s transaction details with the explorer record rather than treating every revert as a price problem.
For example, suppose one piece you thought had reverted is actually still pending, then confirms while you are checking the balances. Its input is now part of the completed total, so subtract it before quoting again. The rule that confirmed pieces stand still holds; only the remainder calculation changes.
Finish when the balances and receipts account for the intended trade
After the last piece confirms, add up the input spent and output received across the successful transactions, and compare those figures with the intended total and your wallet balances. That reconciliation establishes whether the planned trade is complete and whether any input remains. Keep the hashes with the amounts so the final position is traceable if you review the trade later.
Comments
Post a Comment