A Go-based Binance BFUSD/USDT arbitrage bot with a BoltDB-backed persistent state machine, post-only maker orders, basis-point entry signals, BFUSD redemption-quota tracking, Telegram controls, and Docker deployment.
Warning
This software can place real orders and is intended for educational and research use. Review the strategy, API permissions, and risk controls before trading with real funds.
The bot monitors the Binance Spot BFUSD/USDT market for deviations from the 1.0000 reference price. The documented entry signal is:
bp = round((1.0 - price) * 10,000)
Orders are allowed when bp > 0, which means BFUSD is trading below 1.0000.
Examples:
- Price
0.9999→bp = 1 - Price
0.9998→bp = 2 - Price
1.0002→bp = -2and no entry
The bot tracks filled notional by round. When a round reaches its target, it notifies the configured Telegram chat and enters WAIT_REDEEM. After BFUSD has been redeemed, use /redeemed to continue to the next round.
- Monitors the Binance Spot
BFUSD/USDTmarket at a configurable interval - Calculates entry signals in basis points
- Supports post-only maker orders and optional taker execution
- Persists the trading state and round progress in BoltDB
- Restores state after a process or container restart
- Tracks the daily BFUSD fast-redemption quota
- Selects or previews
FASTversusSTANDARDredemption - Exposes operational controls through Telegram
- Supports dry-run mode
- Includes Docker and Docker Compose deployment
The current state is stored in BoltDB and uses the following modes:
IDLE: monitoring and trading are disabledARMED: the strategy is activeWAIT_REDEEM: the current target has been reached and redemption confirmation is requiredDONE: all configured rounds have completed
State includes the current round, accumulated notional, last observed price, last basis-point value, and update time.
The quota manager tracks the daily free fast-redemption allowance and estimates the remaining quota from Binance redemption history.
/quotadisplays the current quota status/preview <amount>previews whether an amount should useFASTorSTANDARDredemption- Fast-redemption usage is recorded against the configured daily allowance
- The quota window resets at the configured daily reset boundary
Quota information is an operational aid. Always verify current Binance product terms, limits, fees, and API behavior before relying on it.
git clone <your-repository-url> bn-bfusd-arb
cd bn-bfusd-arb
cp .env.example .envEdit .env and add your credentials:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
CHAT_ID=your_telegram_chat_id
BINANCE_API_KEY=your_binance_api_key
BINANCE_API_SECRET=your_binance_api_secretYou can obtain a Telegram bot token from @BotFather and determine your chat ID with a Telegram user-information bot.
./deploy.shThe deployment script validates the environment, builds the Docker image, starts the container, and displays its status.
In the configured Telegram chat:
- Send
/startto display the command summary. - Send
/statusto inspect the current state. - Send
/armto enable monitoring and trading.
- Go 1.22 or newer
- A Telegram bot token and chat ID
- A Binance API key with Spot trading access
go mod download
go build -o bfusd-arb
./bfusd-arbThe application loads .env automatically when the file is present. Environment variables provided by the runtime can also be used.
Copy .env.example to .env and adjust the following values:
# Required Telegram settings
TELEGRAM_BOT_TOKEN=
CHAT_ID=
# Required Binance settings
BINANCE_API_KEY=
BINANCE_API_SECRET=
# Market and round settings
PAIR=BFUSDUSDT
TARGET_NOTIONAL_USDT=1250
MAX_ROUNDS=4
POLL_INTERVAL_MS=800
# Strategy settings
MODE=SPEED
ALLOW_TAKER=true
MAKER_POST_ONLY=true
# Risk controls
ORDER_SIZE_USDT=50
MAX_OPEN_ORDERS=4
SLIPPAGE_BPS_FOR_TAKER=0
CANCEL_RESTING_ON_HIT=true
# Runtime settings
DRY_RUN=false
LOG_LEVEL=info
DB_PATH=./bot.db| Variable | Description | Default |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Telegram bot token | Required |
CHAT_ID |
Telegram chat that controls the bot | Required |
BINANCE_API_KEY |
Binance API key | Required |
BINANCE_API_SECRET |
Binance API secret | Required |
PAIR |
Binance Spot symbol | BFUSDUSDT |
TARGET_NOTIONAL_USDT |
Filled notional required per round | 1250 |
MAX_ROUNDS |
Total number of rounds | 4 |
POLL_INTERVAL_MS |
Market polling interval in milliseconds | 800 |
MODE |
Execution preference: SPEED or PRICE |
SPEED |
ALLOW_TAKER |
Enables taker execution when strategy conditions permit | true |
MAKER_POST_ONLY |
Uses post-only maker orders | true |
ORDER_SIZE_USDT |
Requested order notional | 50 |
MAX_OPEN_ORDERS |
Maximum number of resting orders | 4 |
SLIPPAGE_BPS_FOR_TAKER |
Minimum basis-point advantage for taker execution | 0 |
CANCEL_RESTING_ON_HIT |
Cancels resting orders after the round target is reached | true |
DRY_RUN |
Simulates order actions without submitting live orders | false |
LOG_LEVEL |
Application log level | info |
DB_PATH |
BoltDB state-file path | ./bot.db |
/start— Show the welcome message and command summary/status— Show the current state and strategy status/arm— Enable monitoring and trading/disarm— Stop trading and return toIDLE
/redeemed— Confirm redemption and advance to the next round/reset confirm— Reset all persisted progress
/quota— Display the current BFUSD redemption quota/preview <amount>— Preview the redemption method for an amount
/settarget 1250— Change the per-round target/rounds 4— Change the total number of rounds/dry— Toggle dry-run mode
- In
ARMED, poll the market everyPOLL_INTERVAL_MS. - Calculate
bp = round((1 - price) * 10,000). - Evaluate the configured entry and risk conditions.
- Submit a post-only maker order, or an optional taker order when enabled and allowed by the slippage threshold.
- Update accumulated notional from execution reports.
- When
TARGET_NOTIONAL_USDTis reached, notify Telegram and enterWAIT_REDEEM. - After redemption, send
/redeemedto start the next round. - Enter
DONEafterMAX_ROUNDSrounds.
# Show container status
docker compose ps
# Follow logs
docker compose logs -f bfusd-arb
# Restart the service
docker compose restart
# Stop the service
docker compose down
# Rebuild and restart
docker compose up --build -dThe Compose configuration stores BoltDB data in a named volume so state survives container replacement.
Start in dry-run mode:
DRY_RUN=trueThen deploy normally:
./deploy.shFor an initial live test, use small values:
TARGET_NOTIONAL_USDT=10
ORDER_SIZE_USDT=5Confirm observed orders, fills, quota calculations, state transitions, and Telegram notifications before increasing exposure.
- Language: Go 1.22+
- Persistence: BoltDB through
bbolt - Exchange integration: Binance REST API
- Control and notifications: Telegram Bot API
- Deployment: Docker and Docker Compose
View recent logs:
docker compose logs --tail=100 bfusd-arbCommon checks:
- If the bot does not respond, verify
TELEGRAM_BOT_TOKENandCHAT_ID. - If order submission fails, verify Binance API permissions, balances, symbol filters, and account restrictions.
- If prices do not update, check network connectivity and Binance API rate limits.
- If state cannot be opened, verify that
DB_PATHis writable and that only one process is using the BoltDB file.
- Store credentials only in
.envor the deployment platform's secret manager. - Never commit
.env, API keys, private keys, or production credentials. - Grant the Binance API key only the permissions required for Spot trading.
- Do not enable withdrawals for this bot.
- Restrict access to the host, Telegram chat, logs, and state database.
- Rotate credentials immediately if they are exposed.
- BFUSD may trade above or below its reference value.
- Redemption availability, timing, quotas, and fees can change.
- Post-only orders may remain unfilled or be rejected when they would cross the book.
- Taker orders can incur fees and slippage.
- API latency, rate limits, partial fills, and exchange outages can affect execution.
- Dry-run behavior cannot reproduce every live-market condition.
- You are responsible for all trading and operational risk.
MIT License.