Skip to content

feat: Binance enhancements — configurable URL, quote, transfer, tests#10

Merged
juntao merged 2 commits intomainfrom
feat/binance-enhancements
Mar 10, 2026
Merged

feat: Binance enhancements — configurable URL, quote, transfer, tests#10
juntao merged 2 commits intomainfrom
feat/binance-enhancements

Conversation

@juntao
Copy link
Member

@juntao juntao commented Mar 10, 2026

Summary

  • Add optional binance_base_url config field for Binance US / custom endpoints
  • Refactor src/binance.rs to use config-based URLs instead of hardcoded constants
  • Add Binance as a quote data source (24hr ticker) alongside Hyperliquid, Yahoo Finance, CoinGecko
  • Add Binance transfer command for spot ↔ futures (universal transfer API)
  • Add quote and transfer CLI + JSON commands to the binance binary
  • Fix bootstrap.sh to install all 5 binaries (was only copying fintool)
  • Fix HL chained withdrawal: re-fetch Across quote after Bridge2, account for ~$1 fee
  • Add 9 integration test scripts in tests/binance/ matching hyperliquid patterns

New Binance API functions

  • get_ticker_price — spot 24hr ticker (no auth)
  • get_futures_ticker_price — futures 24hr ticker (no auth)
  • universal_transfer — spot ↔ futures wallet transfer
  • get_funding_rate — futures funding rate (no auth)

Test scripts

Script Purpose
show_status.sh Display balances, positions, orders
buy_eth.sh Buy ~$12 ETH USDS-M futures (2x leverage)
sell_eth.sh Close all ETH futures positions
buy_btc_spot.sh Buy ~$12 BTC spot
sell_btc_spot.sh Sell all BTC spot
deposit.sh Get deposit addresses (USDC/ETH on Base/Ethereum)
withdraw.sh Withdraw USDC to Base/Ethereum
transfer.sh Transfer USDT between spot ↔ futures
e2e_trading.sh Full 8-step E2E trading test

Test plan

  • cargo build --release passes
  • cargo clippy clean (no warnings)
  • cargo fmt applied
  • binance quote BTC returns Binance price data
  • binance --json '{"command":"quote","symbol":"ETH"}' returns JSON with Binance source
  • binance --help shows new quote and transfer commands
  • Run tests/binance/show_status.sh with live API keys
  • Run tests/binance/e2e_trading.sh with live API keys

🤖 Generated with Claude Code

juntao and others added 2 commits March 11, 2026 02:09
…test scripts

- Add optional `binance_base_url` config field (defaults to Binance Global,
  can be set to https://api.binance.us for Binance US spot-only)
- Refactor src/binance.rs to use config-based URLs instead of hardcoded
  constants; futures/options return errors when custom URL is set
- Add Binance as a quote data source (24hr ticker, no auth needed) alongside
  Hyperliquid, Yahoo Finance, and CoinGecko
- Add Binance spot↔futures universal transfer command (MAIN_UMFUTURE /
  UMFUTURE_MAIN)
- Add `quote` and `transfer` CLI commands + JSON variants to binance binary
- Add new API functions: get_ticker_price, get_futures_ticker_price,
  universal_transfer, get_funding_rate
- Fix bootstrap.sh to install all 5 binaries (was only installing fintool)
- Update install.md manual instructions for all binaries
- Fix HL chained withdrawal: re-fetch Across quote after Bridge2, account
  for ~$1 Bridge2 fee by tracking actual arrived balance
- Add integration test scripts in tests/binance/ matching hyperliquid patterns:
  show_status, buy/sell ETH futures, buy/sell BTC spot, deposit addresses,
  withdraw, transfer, and full e2e_trading

Signed-off-by: Michael Yuan <michael@secondstate.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Michael Yuan <michael@secondstate.io>
New `okx` binary supporting:
- Spot trading (buy/sell with cash mode, BTC-USDT instrument format)
- Perpetual futures (buy/sell with cross margin, BTC-USDT-SWAP format)
- Leverage control, funding rate queries
- Orderbook, quote (public, no auth needed)
- Balance (trading + funding accounts), positions, orders, cancel
- Deposit address lookup, withdrawal with auto fee detection
- Funding ↔ trading account transfers
- Full --json mode for programmatic use

HMAC-SHA256 + base64 authentication matching OKX API spec.
Configurable base URL (okx_base_url) for OKX US support.

Signed-off-by: Michael Yuan <michael@secondstate.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@juntao juntao merged commit 0c77aba into main Mar 10, 2026
2 checks passed
@juntao juntao deleted the feat/binance-enhancements branch March 10, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant