// All runtime config comes from env (Coolify sets these in phase 2). Read once. // 5xYourTeam "The Draft" (Marty approved 2026-11-14): a $10 one-time position = 5 picks right away + a draft spot every week. Each // Monday the coaches draft people waiting in the network holding tank, in rounds; draft order is EARNED by how many of last week's // picks switched on payouts or bought. A pick is an ADOPTION under the tank rules (tankpool.js). Paid in POL through DraftPosition // (../contracts): sponsor 25%, levels 2-5 5% each (pass-up), 10% weekly Best Coach prize pot, 45% company. // Purchases are inert until CONTRACT_ADDRESS / CHAIN_RPC / KEEPER_KEY are set. const path = require('path'); let cfg = null; function get() { if (cfg) return cfg; const e = process.env; const num = (v, d, min, max) => { const n = Number(v); return Number.isFinite(n) && v !== '' && v != null ? Math.min(max, Math.max(min, Math.round(n))) : d; }; const addr = v => /^0x[0-9a-fA-F]{40}$/.test(String(v || '').trim()) ? require('ethers').getAddress(String(v).trim().toLowerCase()) : ''; cfg = { port: Number(e.PORT || 3000), isProd: e.NODE_ENV === 'production', site: e.SITE_HOST || '5xyourteam.com', siteName: '5xYourTeam', siteId: 'fivex', // hub site id, network sign-in audience, netsites id dataDir: e.DATA_DIR || path.join(__dirname, 'data'), chainId: Number(e.CHAIN_ID || 137), chainName: e.CHAIN_NAME || 'Polygon', publicRpc: e.PUBLIC_RPC || 'https://polygon-bor-rpc.publicnode.com', walletConnectProjectId: (e.WALLETCONNECT_PROJECT_ID || '').trim(), // ---- the position (Marty 2026-11-14: "$10 on 5x your team makes sense"). One-time, never a subscription. The contract's // priceCents holds the real price; this is display copy and must match it (smoke + chain tests check). position: { usd: Number(e.POSITION_USD || 10), maxQty: 10, picksOnBuy: num(e.PICKS_ON_BUY, 5, 1, 20) }, // DraftPosition constants (display copy): option C split: { sponsorPct: 25, levelPct: 5, levels: 5, potPct: 10, companyPct: 45, maxDepth: 20 }, // ---- the weekly draft (US Central). Every number here is an open question for Marty; these are the build's defaults. draft: { dow: num(e.DRAFT_DOW, 1, 0, 6), // 1 = Monday hour: num(e.DRAFT_HOUR_CT, 19, 0, 23), // 7 PM Central rounds: num(e.DRAFT_ROUNDS, 5, 1, 20), // "draft 5 people from that week's pool" pickSeconds: num(e.DRAFT_PICK_SECONDS, 90, 5, 3600), // the clock for a coach who is in the draft room presenceSeconds: num(e.DRAFT_PRESENCE_SECONDS, 120, 10, 3600), // "in the room" = the board page pinged within this long tickMs: num(e.DRAFT_TICK_MS, 5000, 100, 600000), lateHours: num(e.DRAFT_LATE_HOURS, 6, 0, 72) // a draft missed by more than this (app down) is skipped }, picks: { returnDays: num(e.PICK_RETURN_DAYS, 3, 1, 30), // an unconverted pick goes back to the pool after this holdHours: num(e.PICK_HOLD_HOURS, 48, 0, 720), // a coach cannot release a pick sooner (the IAP churn rule) maxOpen: num(e.PICK_MAX_OPEN, 10, 1, 100), // open picks per coach (Marty 11-13: "10 at a time") maxAdoptions: 2, // per person, lifetime, across the network (tank rule) graceHours: num(e.PICK_GRACE_HOURS, 24, 0, 168) // a new sign-up is not draftable for this long (IAP GRACE_MS) }, pot: { split: String(e.POT_SPLIT || '50,30,20').split(',').map(Number).filter(n => n > 0) }, // Best Coach places, % of the week's pot explorer: String(e.EXPLORER || (Number(e.CHAIN_ID || 137) === 137 ? 'https://polygonscan.com' : '')).replace(/\/+$/, ''), // DraftPosition (../contracts). KEEPER_KEY is read by shop.js only, never kept here. contractAddress: addr(e.CONTRACT_ADDRESS), companyWallet: addr(e.COMPANY_WALLET) || '0x7627Fc78876948AC9d95C1C9eB061E7D6d647b70', // Tangem (immutable in the contract) prizeWallet: addr(e.PRIZE_WALLET), // the Best Coach pot (immutable in the contract; decided at deploy) chainRpc: String(e.CHAIN_RPC || '').trim(), shopStartBlock: num(e.SHOP_START_BLOCK, 0, 0, 1e12), shopConfirmations: num(e.SHOP_CONFIRMATIONS, 10, 0, 1000), shopPollMs: num(e.SHOP_POLL_MS, 30000, 200, 3600000), voucherSeconds: num(e.VOUCHER_SECONDS, 1800, 60, 86400), iapBase: String(e.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, ''), lsBase: String(e.LS_URL || 'https://linkspin.app').replace(/\/+$/, ''), joinUrl: String(e.JOIN_URL || 'https://instantadpay.com/join/{ref}'), // the holding tank behind the draft: 'stub' (phase 1, local fixture, adopts nobody for real) | 'iap' (the real network tank on // InstantAdPay through its signed partner routes, DRAFT_PARTNER_SECRET + IAP_URL; TANK_MODE=hub means the same) tankMode: /^(iap|hub)$/i.test(String(e.TANK_MODE || '').trim()) ? 'iap' : 'stub', stubPool: String(e.STUB_POOL_FILE || '').trim(), owner: String(e.OWNER_USERNAME || 'martbost'), // builder fallback links (the DownlineHydra rule) testClock: e.ALLOW_TEST_CLOCK === '1' && e.NODE_ENV !== 'production' }; return cfg; } module.exports = { get, reset: () => { cfg = null; } };