Skip to content

K13.2: keep buys in flight when NEAR gives no clear result - #137

Merged
MFrancis-dev merged 1 commit into
mainfrom
fix/buy-unclear-outcome
Nov 8, 2026
Merged

MFrancis-dev merged 1 commit into
mainfrom
fix/buy-unclear-outcome

Conversation

@MFrancis-dev

Copy link
Copy Markdown
Owner

Second fix from the pre-launch review.

Problem: any error from execute_buy marked the buy failed, so History said "Nothing spent". If the RPC timed out after the transaction landed, the USDC had in fact left.

Fix:

  • isClearTxFailure() (lib/near/vault.ts): only a contract refusal, a failed action or a rejected transaction counts as a clear failure
  • The NEAR adapter raises BuyOutcomeUnknownError for everything else
  • scheduleBuys keeps that buy sent with a note and alerts; pollBuys settles it from 1Click's status, and K13.1's 30-minute expiry covers a deposit that never arrived

Tests: 3 new (scheduler keeps the row in flight and blocks a second buy; classifier for clear failures; classifier for timeouts/network). 137 total.

Docs: README status, ARCHITECTURE §4.4, ROADMAP.

Closes #128

A timeout after the transaction was sent marked the buy failed, and History
said nothing was spent while the USDC may already have left.

Closes #128
@MFrancis-dev
MFrancis-dev merged commit bd6a38a into main Nov 8, 2026
7 of 8 checks passed
@MFrancis-dev
MFrancis-dev deleted the fix/buy-unclear-outcome branch November 8, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

K13.2 Unclear execute_buy errors must not be recorded as failed

2 participants