test: add end-to-end trading integration script#4
Merged
Conversation
Bash script that exercises a full trading workflow: - Deposit USDC from Base → Hyperliquid - Quote and buy SILVER perp, monitor price for up to 10 min - Sell SILVER perp when price rises above entry (or on timeout) - Withdraw USDC back to Base - Buy ETH spot on Hyperliquid, withdraw to Ethereum mainnet - Buy TSLA on Coinbase Requires funded wallet with >= $10 USDC on Base and Coinbase keys. Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add informative before/after messages for each step showing key JSON response data — prices, funding rates, position sizes, PnL estimates, bridge TX hashes, and color-coded price monitoring output. Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace run_fintool() || true pattern that silently swallowed all errors. New approach captures stdout/stderr/exit-code separately via temp files. check_fail() helper prints the full error output (colored red) and calls fail() whenever a command returns non-zero. Each step now: - Gates on prior step success (e.g., skip sell if buy failed) - Prints fintool's stderr progress messages in gray on success, red on failure - Shows the exact error text from fintool on failure - Tracks pass/fail counts accurately in the summary Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deposit is a prerequisite for all subsequent trading steps. Stop immediately instead of continuing with steps that are guaranteed to fail. Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Before executing the USDC bridge, check ETH balances on both the source chain and Arbitrum. If Arbitrum has insufficient ETH for the final HL Bridge2 deposit tx, automatically bridge 0.001 ETH from the source chain via Across Protocol. Bail early with a clear error if the source chain lacks enough ETH to cover gas + the ETH bridge amount. 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> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use 0x0 as outputToken in the Across API to receive native ETH on Arbitrum instead of WETH. This avoids the chicken-and-egg problem where unwrapping WETH requires native ETH for gas but there is none. Flow: wrap ETH→WETH on Base → Across bridge → native ETH on Arbitrum. Also removes the WETH balance check and unwrap logic that is no longer needed. Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…P-3 dex names - Remove "Unit" from exchange list (it's a bridge, not trading exchange) - Split Balance/Positions in capability matrix (Positions doesn't support Coinbase) - Fix perp quote: Hyperliquid only, not Binance (--exchange flag not wired through) - Replace nonexistent "abcd" dex with actual dexes (km, flx) - Remove EWY from cash dex auto-resolved assets (requires cash: prefix) - Fix withdraw.sh: skip ETH withdrawal when amount is 0, default ETH to 0 Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…st scripts - Fix HIP-3 order signing: use SDK-compatible float_to_string_for_hashing (8 decimal places, strip trailing zeros) for correct msgpack/EIP-712 digest - Fix price_to_wire: round to 5 sig figs (tick size) before formatting - Fix size_to_wire: truncate to szDecimals before formatting - Add get_dex_collateral_token() for dynamic collateral lookup per HIP-3 dex (cash dex uses USDT0, not USDC) - Fix sendAsset destination and set_abstraction to use wallet-derived address - Add get_wallet_address() helper, update fintool address command - Add perp leverage command (Hyperliquid + HIP-3 + Binance) - Add perp set-mode command (unified/standard/disabled account abstraction) - Add transfer command (perp/spot/HIP-3 dex transfers) - Add 50% gas price buffer for Arbitrum withdrawal transactions - Replace blind sleep with polling loop for Arbitrum USDC arrival - Add Coinbase support for balance, orders, cancel commands - Add Binance support for balance, positions, orders, cancel, leverage - Add test scripts: helpers, deposit, buy/sell eth/hype/silver/tsla, show_status, e2e_trading (rewritten as clean fintool command list) 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> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix formatting issues in hyperliquid.md
Added command examples for checking Hyperliquid status.
…tions - Remove Options workflow (not supported yet) - Add Step 6 to perp workflow: close position with --close (reduce-only) - Remove options references from description, capability table, setup check - Renumber workflows 4-6 → 3-5 Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add step-by-step workflow guides for: - Deposit funds (Base → Hyperliquid via Across bridge) - Withdraw funds (Hyperliquid → Base/Ethereum/Arbitrum) - Price quotes, news, and SEC filings - Spot buy and sell (with exchange routing) - Open and close perp positions (with --close) - Commodity perp on HIP-3 (USDT0 conversion workflow) Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/e2e_trading.sh— a bash script that exercises a full real-money trading workflow across Hyperliquid and CoinbaseTest flow
Prerequisites
~/.fintool/config.tomlwith Hyperliquid wallet (>= $10 USDC on Base) and Coinbase API keysjqinstalledTest plan
bash -n tests/e2e_trading.sh— syntax check passes🤖 Generated with Claude Code