fix: proxy uses undici ProxyAgent for fetch, schedule moved to .env, verbose redeem logging

- Fix proxy: native fetch needs undici ProxyAgent with dispatcher option
  (https-proxy-agent only works with axios, not Node's built-in fetch)
- Move schedule from hardcoded to .env: SNIPER_SCHEDULE_BTC=19:40-22:40,03:40-06:10
- Add verbose logging to redeemSniperPositions for debugging
- Config dynamically reads all SNIPER_SCHEDULE_* env vars
This commit is contained in:
direkturcrypto
2026-03-01 19:07:57 +07:00
parent f31f257da5
commit 0dc8024ceb
5 changed files with 114 additions and 103 deletions
+9 -3
View File
@@ -560,13 +560,19 @@ export async function redeemSniperPositions() {
let dataPositions = [];
try {
const resp = await proxyFetch(`${config.dataHost}/positions?user=${config.proxyWallet}`);
if (resp.ok) dataPositions = await resp.json();
if (!resp.ok) {
logger.warn(`SNIPER redeemer: Data API returned ${resp.status} — will retry`);
return;
}
dataPositions = await resp.json();
if (!Array.isArray(dataPositions)) dataPositions = [];
} catch {
return; // silent — will retry next interval
} catch (err) {
logger.warn(`SNIPER redeemer: Data API fetch failed — ${err.message}`);
return;
}
if (dataPositions.length === 0) return;
logger.info(`SNIPER redeemer: checking ${dataPositions.length} position(s)...`);
const provider = await getPolygonProvider();
const ctf = new ethers.Contract(CTF_ADDRESS, CTF_ABI, provider);