lthn.io/app/Mod/Trade/Controllers/TradeApiController.php

74 lines
1.9 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace Mod\Trade\Controllers;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Mod\Chain\Services\DaemonRpc;
/**
* DEX trade API compatible with the upstream zano_trade_backend.
*
* GET /v1/trade/pairs available trading pairs
* GET /v1/trade/pair/{id} single pair details
* POST /v1/trade/order create order
* GET /v1/trade/orders list orders
* GET /v1/trade/config exchange configuration
*/
class TradeApiController extends Controller
{
public function __construct(
private readonly DaemonRpc $rpc,
) {}
public function config(): JsonResponse
{
$info = $this->rpc->getInfo();
return response()->json([
'success' => true,
'data' => [
'currencies' => [
[
'name' => 'LTHN',
'code' => 'lethean',
'type' => 'crypto',
'asset_id' => 'd6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a',
'asset_info' => ['decimal_point' => 12],
],
],
'network' => config('chain.network'),
'height' => $info['height'] ?? 0,
],
]);
}
public function pairs(): JsonResponse
{
// Pairs are configured, not discovered — for now return LTHN native
return response()->json([
'success' => true,
'data' => [],
]);
}
public function pair(int $id): JsonResponse
{
return response()->json([
'success' => false,
'error' => 'Pair not found',
], 404);
}
public function orders(): JsonResponse
{
return response()->json([
'success' => true,
'data' => [],
]);
}
}