Why Sweeping Is Needed
Each customer gets a unique deposit address derived from your HD wallet. Funds land there, but you need them in a single master wallet for treasury management. Paychainly automates this with a three-step sweep pipeline.
Step 1 — BNB Gas Top-Up
USDT transfers require BNB for gas. The gas wallet sends a small amount of BNB (default 0.002 BNB ≈ $1) to the deposit address before sweeping. A per-address Redis lock prevents concurrent gas top-ups to the same address.
Step 2 — USDT Transfer
Once BNB arrives, the platform calls transfer(masterAddress, balance) on the USDT ERC-20 contract from the deposit address private key (derived from your MASTER_SEED mnemonic).
Step 3 — Fee Deduction
The platform fee is deducted before crediting you:
fee = Math.max(feeFlat, balance × feePercent / 100)
// default: max($0.60, 1% of payment)
netAmount = balance − fee − gasReimbursement
Gas reimbursement is the actual BNB cost converted to USDT via the PancakeSwap V2 price feed — you never pay more than the real gas cost.
Step 4 — Leftover BNB Returned
Any unused BNB in the deposit address is transferred back to the gas wallet, keeping it funded for future sweeps without manual top-ups.
Concurrency Control
- Per-address Redis lock prevents double-sweep of the same address.
- Gas wallet nonce collision is prevented by
GasWalletLockService. - Up to 5 addresses are swept in parallel (configurable via
SWEEP_CONCURRENCY).