!5385itz/migrate-refund-stuck-base-usdc → itz/bond-slash-refund-3.22.0b38e24863b

feat(thorchain): refund the stuck BASE.USDC outbound in Migrate20to21

AI-generatedEverything on this page was written by an AI agent from the diff: the summaries, the narration, the diagrams, the flags and the glossary. It can be wrong or incomplete, so check it against the code before you rely on it.

6commits
4files
736lines changed
323lines to read
1outbound refunded
≈69ktxout heights scanned

Where the diff is

Tests1 files · 395 lines

x/thorchain/migration_20to21_base_usdc_refund_test.go+395 −0
1refund + cancel2disabled3settled: no refund4idempotent5missing: soft-skip6amount mismatch: skip7settled + live duplicate

2-minute explainer

What changed

The stuck outbound

BASE.USDC outbound addressed to the token contract; never deliverable.

ETH.USDC inswapBASE.USDC out→ token contract ✗

Reverse-swap refund

Slasher recovery swap, recipient = original sender.

BASE.USDCrecovery swapETH.USDC→ 0x6e00…82a0

Cancel parked copy

OutHash = BlankTxID, not SetDone; one cache context.

  • refund queued first
  • then live copies blanked
  • commit only if both succeed

Finding the item

Scan parked height ± 2×TxOutDelayMax, classify each copy.

liveempty OutHashblankskipsettledno refund

Soft-skip guards

Toggle, settled, missing, amount, I/O error: never fails upgrade.

State + upgrade

Migration

v20→v21

Adds refundStuckBaseUsdc322 to migrate20to21Mainnet (mainnet build only): one reverse-swap refund plus cancel of the parked txout copy.

Toggles

  • newbaseUsdcRefundEnabled322true

Line by line · every changed logic line, narrated

5:54runtime
10code chapters
100%logic lines narrated (250/250)
6flagged spots
speed

Chapters

What to check

Ask an AI about this change

Chat assistantClaude, ChatGPT, … (reads a link)

Coding agentClaude Code, Cursor, … (reads the repo)

The context file is context.md. Use Copy with context for an AI that can't open links; it pastes the whole file in.

Glossary

CacheContext
A branched store; writes (and in SDK ≥0.50, events) reach the parent only on commit. Cosmos SDK ↗
Migrate20to21
The 3.22.0 store migration this step is appended to. migration_20to21_gaia.go ↗
OutHash / BlankTxID
OutHash records the paying tx; BlankTxID marks an item cancelled without payment.
queueRecoverySwap
Slasher helper that queues a protocol swap of a failed outbound's coin to a target asset and address. manager_slasher_current.go ↗
TxOutDelayMax
Max blocks an outbound can be delayed (default 17280); here it sizes the scan margin. constants_v1.go ↗
TxOutItem
A scheduled outbound stored per block height; signers pick it up until OutHash is set. type_tx_out.go ↗