@@ -9,7 +9,7 @@ Devnet SOL marketplace. Users buy devnet SOL with mainnet USDC or sell devnet SO
99- ** Solana** : @solana/kit , @solana-program/system , @solana-program/token , @solana-program/memo
1010- ** DB** : better-sqlite3 (file-based, single table ` transactions ` )
1111- ** Logging** : pino (structured JSON logging)
12- - ** Testing** : Vitest (16 test files, 112 tests)
12+ - ** Testing** : Vitest (17 test files, 120 tests)
1313- ** Package Manager** : pnpm
1414
1515## Commands
@@ -38,7 +38,7 @@ pnpm exec tsc --noEmit # type-check without emitting
3838
3939```
4040src/
41- index.ts # Entry — wires services, starts server + both deposit detectors + expiry cleanup
41+ index.ts # Entry — wires services, starts server + both deposit detectors + expiry/auto-refund cleanup
4242 logger.ts # Pino structured logger with createLogger() factory
4343 app.ts # Hono app, rate limiter, CORS, route mounting
4444 config.ts # All env vars with defaults
5555 treasury.ts # Devnet SOL transfers (sendSol, getBalance)
5656 payout.ts # Mainnet USDC payouts (sendUsdc, canAffordPayout) with retry
5757 pricing.ts # Rate-based quotes (buy=1.05, sell=0.95 USDC/SOL)
58- deposit.ts # Polls devnet for incoming SOL deposits (sell flow), matches by memo + verifies amount
58+ deposit.ts # Polls devnet for incoming SOL deposits (sell flow), matches by memo or wallet+amount, verifies amount
5959 buy-deposit.ts # Polls mainnet for incoming USDC deposits (buy flow), matches by memo + verifies amount
6060 db/
61- sqlite.ts # TransactionDB — CRUD, atomicComplete/Buy, findPendingSells/Buys, expireStale
61+ sqlite.ts # TransactionDB — CRUD, atomicComplete/Buy, findPendingSells/Buys, expireStale, findFailedSellsWithDeposit
6262scripts/
6363 buy-e2e.ts # Buy flow E2E test (mainnet USDC → devnet SOL)
6464 sell-e2e.ts # Sell flow E2E test (devnet SOL → mainnet USDC)
@@ -69,7 +69,7 @@ scripts/
6969
7070** Buy** : Client ` POST /buy ` → gets payout wallet address + memo + USDC cost → client sends mainnet USDC with memo → BuyDepositDetector matches deposit → Treasury sends devnet SOL → status ` completed ` . If SOL delivery fails, USDC is refunded.
7171
72- ** Sell** : Client ` POST /sell ` → gets treasury address + memo → client sends devnet SOL with memo → DepositDetector matches deposit → PayoutService sends mainnet USDC → status ` completed ` . If payout fails, devnet SOL is refunded.
72+ ** Sell** : Client ` POST /sell ` → gets treasury address + memo → client sends devnet SOL with memo → DepositDetector matches deposit (by memo, or wallet+amount for manual sends) → PayoutService sends mainnet USDC → status ` completed ` . If payout fails, devnet SOL is refunded. Duplicate pending sell orders (same wallet + amount) are rejected with 409 .
7373
7474## Key Details
7575
@@ -83,6 +83,8 @@ scripts/
8383- Both detectors require mainnet keypair (` DEVSOL_MAINNET_KEYPAIR ` ) to be configured
8484- Both detectors verify on-chain transfer amounts before processing (SOL: 0.1% tolerance, USDC: exact)
8585- Pending orders expire after 30 minutes — cleanup job runs every 60s
86+ - Failed sell orders with confirmed deposits are auto-refunded every 60s (devnet SOL sent back to user)
87+ - Detectors record deposit signature (devnet_tx/mainnet_tx) even on failure, enabling auto-refund
8688- Low balance alerts log errors when treasury SOL < 10 or payout USDC < 10
8789- Structured logging via pino (set ` LOG_LEVEL ` env var to control verbosity)
8890
0 commit comments