Skip to content

v0.23.0 — exit swaps that timed out no longer book as total losses

Choose a tag to compare

@CryptoGnome CryptoGnome released this 24 Aug 23:36
· 60 commits to main since this release
8ecf5a4
  • A close whose Jupiter swap timed out was booking the whole token side as a loss. On a below-range exit the swap is the exit value — the remove-liquidity tx returns little more than rent. When the confirm timed out, the slippage ladder correctly detected the swap had landed, logged landed after all (wallet now 0) — and then returned null, the caller's "no swap happened" value, so the signature never reached the close's wealth delta.
  • What it cost: Railway pos#104 PUMP booked −0.719 SOL / −88.8% on a position that came back roughly flat (0.070 SOL from the remove + 0.695 SOL from a swap 44 seconds later, against a 0.750 deposit). The phantom loss tripped the daily circuit breaker one second later and the bot stopped entering.
  • Fix: swapToSol attaches the signature to the confirm error instead of losing it with the throw, and the ladder hands it back whenever the wallet proves the tier landed — between tiers and after the last tier, which had no re-read and lost the same money on the final rung. It never invents one: no signature recovered still returns null, and now says so in the log.
  • New: npm run repair-close -- <id…> [--apply] (dry-run by default) for rows the bug already wrote. Reads the chain, not the ledger: a transaction counts only if the wallet sold that position's token for SOL near the close and the close did not already book it. Credits recovered_sol, leaving close_return_sol as the honest record of what the close could measure. Records a per-signature receipt, so re-running is a no-op.
  • New: REPAIR_CLOSES env var — Railway has no shell; set it to a comma-separated list of ids and redeploy to repair before the bot opens the DB. Safe to leave set, and it never blocks startup.
  • Seven rows were affected (Railway pos#104/#122/#123/#124, server pos#186/#187/#188), all inside a window of RPC 429s that made confirms expire. Nothing would have restated them — stranded_sol and the residual sweep only recover tokens left in the wallet, and these were sold. Server rows already repaired: +0.0539 SOL restored, all three flipping from negative to positive.