<?php
require_once __DIR__."/../portal/config.php";

$uuid   = trim($_POST['trade_uuid'] ?? '');
$status = strtoupper(trim($_POST['status'] ?? ''));

if($uuid==='' || $status===''){
    echo "BAD_PARAMS";
    exit;
}

if(!in_array($status,["EXECUTED","FAILED"])){
    echo "BAD_STATUS";
    exit;
}

$stmt=$conn->prepare("
    UPDATE fxh_trade_queue
    SET status = ?
    WHERE trade_uuid = ?
    LIMIT 1
");

$stmt->bind_param("ss",$status,$uuid);
$stmt->execute();

echo "OK";
exit;
