Skip to content

Commit 22efa45

Browse files
juntaoclaude
andcommitted
feat: Binance enhancements — configurable base URL, quote, transfer, 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>
1 parent b043bc2 commit 22efa45

20 files changed

Lines changed: 1279 additions & 35 deletions

config.toml.default

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ testnet = false
3232
# Sign up at https://www.binance.com/
3333
# binance_api_key = "..."
3434
# binance_api_secret = "..."
35+
# Custom base URL (default: https://api.binance.com)
36+
# For Binance US (spot only, no futures/options): https://api.binance.us
37+
# binance_base_url = "https://api.binance.com"
3538

3639
# Coinbase Advanced Trade API credentials — enables spot trading on Coinbase
3740
# Sign up at https://www.coinbase.com/

skills/bootstrap.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,25 @@ esac
4242
echo "Downloading ${ARTIFACT}..."
4343
curl -L -o /tmp/fintool.zip "${RELEASE_BASE}/${ARTIFACT}.zip"
4444
unzip -o /tmp/fintool.zip -d /tmp/fintool-extract
45-
cp "/tmp/fintool-extract/${ARTIFACT}/fintool" "$SKILL_DIR/scripts/fintool"
46-
chmod +x "$SKILL_DIR/scripts/fintool"
45+
BINARIES="fintool hyperliquid binance coinbase polymarket"
46+
for bin in $BINARIES; do
47+
src="/tmp/fintool-extract/${ARTIFACT}/${bin}"
48+
if [ -f "$src" ]; then
49+
cp "$src" "$SKILL_DIR/scripts/${bin}"
50+
chmod +x "$SKILL_DIR/scripts/${bin}"
51+
elif [ -f "${src}.exe" ]; then
52+
cp "${src}.exe" "$SKILL_DIR/scripts/${bin}.exe"
53+
else
54+
echo "⚠️ Binary not found in release: ${bin}"
55+
fi
56+
done
4757
rm -rf /tmp/fintool.zip /tmp/fintool-extract
4858

4959
# 4. Initialize config (never overwrites existing)
5060
"$SKILL_DIR/scripts/fintool" init
5161

5262
echo ""
53-
echo "✅ fintool installed to $SKILL_DIR/scripts/fintool"
63+
echo "✅ fintool binaries installed to $SKILL_DIR/scripts/"
5464
echo ""
5565

5666
# 5. Check config for required keys

skills/install.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ rm -rf /tmp/fintool-repo
2323
The bootstrap script will:
2424
1. Clone skill files to `~/.openclaw/skills/fintool/`
2525
2. Detect your platform (Linux x86_64/aarch64, macOS Apple Silicon)
26-
3. Download the correct binary from the latest GitHub release
26+
3. Download all binaries (fintool, hyperliquid, binance, coinbase, polymarket) from the latest GitHub release
2727
4. Run `fintool init` to create `~/.fintool/config.toml` (never overwrites existing)
2828
5. Check config for required keys and tell you what's missing
2929

@@ -57,8 +57,8 @@ If the bootstrap script fails:
5757
```bash
5858
mkdir -p ~/.openclaw/skills/fintool/scripts
5959
unzip fintool-<platform>.zip
60-
cp fintool-<platform>/fintool ~/.openclaw/skills/fintool/scripts/fintool
61-
chmod +x ~/.openclaw/skills/fintool/scripts/fintool
60+
cp fintool-<platform>/{fintool,hyperliquid,binance,coinbase,polymarket} ~/.openclaw/skills/fintool/scripts/
61+
chmod +x ~/.openclaw/skills/fintool/scripts/*
6262
```
6363
4. Copy the skill definition:
6464
```bash

src/bin/binance.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ enum Commands {
102102
#[arg(long)]
103103
dry_run: bool,
104104
},
105+
106+
/// Get a price quote for a symbol
107+
Quote { symbol: String },
108+
109+
/// Transfer assets between spot and futures wallets
110+
Transfer {
111+
/// Asset: USDT, USDC, BTC, ETH, etc.
112+
asset: String,
113+
/// Amount to transfer
114+
#[arg(long)]
115+
amount: String,
116+
/// Source wallet: spot or futures
117+
#[arg(long)]
118+
from: String,
119+
/// Destination wallet: spot or futures
120+
#[arg(long)]
121+
to: String,
122+
},
105123
}
106124

107125
#[derive(Subcommand)]
@@ -223,6 +241,15 @@ enum JsonCommand {
223241
#[serde(default)]
224242
dry_run: bool,
225243
},
244+
Quote {
245+
symbol: String,
246+
},
247+
Transfer {
248+
asset: String,
249+
amount: f64,
250+
from: String,
251+
to: String,
252+
},
226253
}
227254

228255
async fn run_json(json_str: &str) -> Result<()> {
@@ -329,6 +356,13 @@ async fn run_json(json_str: &str) -> Result<()> {
329356
)
330357
.await
331358
}
359+
JsonCommand::Quote { symbol } => commands::quote::run_spot(&symbol, true).await,
360+
JsonCommand::Transfer {
361+
asset,
362+
amount,
363+
from,
364+
to,
365+
} => commands::transfer::run(&asset, &fmt_num(amount), &from, &to, EXCHANGE, true).await,
332366
}
333367
}
334368

@@ -439,6 +473,13 @@ async fn main() -> Result<()> {
439473
)
440474
.await
441475
}
476+
Commands::Quote { symbol } => commands::quote::run_spot(&symbol, json_output).await,
477+
Commands::Transfer {
478+
asset,
479+
amount,
480+
from,
481+
to,
482+
} => commands::transfer::run(&asset, &amount, &from, &to, EXCHANGE, json_output).await,
442483
};
443484

444485
if let Err(e) = result {

src/bin/hyperliquid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ async fn run_json(json_str: &str) -> Result<()> {
465465
amount,
466466
from,
467467
to,
468-
} => commands::transfer::run(&asset, &fmt_num(amount), &from, &to, true).await,
468+
} => commands::transfer::run(&asset, &fmt_num(amount), &from, &to, EXCHANGE, true).await,
469469
JsonCommand::BridgeStatus => commands::bridge_status::run(true).await,
470470
}
471471
}
@@ -628,7 +628,7 @@ async fn main() -> Result<()> {
628628
amount,
629629
from,
630630
to,
631-
} => commands::transfer::run(&asset, &amount, &from, &to, json_output).await,
631+
} => commands::transfer::run(&asset, &amount, &from, &to, EXCHANGE, json_output).await,
632632
Commands::BridgeStatus => commands::bridge_status::run(json_output).await,
633633
};
634634

0 commit comments

Comments
 (0)