#!/bin/bash # Test script to execute a tiny trade and verify exit orders are placed on-chain echo "๐Ÿงช Testing exit order placement with tiny position..." echo "๐Ÿ“Š Current settings:" echo " Position: \$10 (base)" echo " Leverage: 5x" echo " Notional: \$50" echo "" # API endpoint and credentials API_URL="http://localhost:3001/api/trading/execute" API_KEY="2a344f0149442c857fb56c038c0c7d1b113883b830bec792c76f1e0efa15d6bb" # Trade request payload PAYLOAD='{ "symbol": "SOLUSDT", "direction": "long", "timeframe": "5", "signalStrength": "strong" }' echo "๐Ÿš€ Sending trade execution request..." echo "" # Execute the request RESPONSE=$(curl -s -X POST "$API_URL" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_KEY" \ -d "$PAYLOAD") echo "๐Ÿ“จ Response:" echo "$RESPONSE" | jq '.' 2>/dev/null || echo "$RESPONSE" echo "" # Check if successful if echo "$RESPONSE" | jq -e '.success' > /dev/null 2>&1; then echo "โœ… Trade executed successfully!" # Extract signatures POSITION_ID=$(echo "$RESPONSE" | jq -r '.positionId') EXIT_SIGS=$(echo "$RESPONSE" | jq -r '.exitOrderSignatures[]?' 2>/dev/null) echo "" echo "๐Ÿ“ Transaction details:" echo " Entry TX: $POSITION_ID" if [ -n "$EXIT_SIGS" ]; then echo " Exit orders placed:" echo "$EXIT_SIGS" | while read -r sig; do echo " - $sig" done echo "" echo "๐Ÿ” Verify on Drift:" echo " https://app.drift.trade/" echo "" echo "๐Ÿ” Verify on Solscan:" echo "$EXIT_SIGS" | while read -r sig; do echo " https://solscan.io/tx/$sig" done else echo " โš ๏ธ No exit order signatures in response" fi else echo "โŒ Trade execution failed!" ERROR=$(echo "$RESPONSE" | jq -r '.error // .message') echo " Error: $ERROR" fi echo "" echo "๐Ÿ“Š Check container logs for details:" echo " docker logs trading-bot-v4 --tail 100"