Two root causes fixed:
1. Missing ERC-1155 setApprovalForAll for copy-trade flow
- executeBuy: call ensureExchangeApproval() after a successful fill so
the CTF Exchange is authorised to move tokens before the next sell
- executeSell: call ensureExchangeApproval() before every sell attempt;
the function is idempotent (checks isApprovedForAll first, only sends
a Safe tx if approval is actually missing)
2. Stored shares can exceed real on-chain balance (fee deductions, float
drift across partial FAK fills)
- executeSell: query ctf.balanceOf(proxyWallet, tokenId) before selling
- If on-chain balance is 0 → position is already gone, remove it and skip
- If on-chain balance < stored shares → adjust down and log the delta
- Round sell amount to 4 decimal places to avoid sub-unit precision errors
Also add getOnChainTokenBalance() helper using a minimal CTF ABI slice.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename project to polymarket-terminal
- Add Market Maker bot (src/mm.js) with on-chain CTF split/merge/redeem via Gnosis Safe
- Add Orderbook Sniper bot (src/sniper.js) with multi-asset GTC low-price orders
- Add WebSocket watcher (src/services/wsWatcher.js) for real-time RTDS trade events
- Add terminal dashboard UI (src/ui/dashboard.js) using blessed
- Add CTF contract helpers (src/services/ctf.js) for splitPosition, mergePositions, redeemPositions
- Add mmDetector, mmExecutor, sniperDetector, sniperExecutor services
- Add simStats utility for dry-run P&L tracking
- Translate all Indonesian-language strings to professional English across all files
- Rewrite README.md in English with full setup guide, configuration reference, and architecture overview
- Rewrite AGENT.MD in English as comprehensive AI agent and developer reference
- Update package.json name, description, scripts, and keywords
Co-Authored-By: direkturcrypto <direkturcrypto.x@mail3.me>