Enhance token data retrieval and improve bot list filtering

- Updated `getTokenDataFromTicker` to support both synthetic and non-synthetic tokens by attempting to fetch v2 tokens first, falling back to a version-less search if necessary.
- Added minimum and maximum balance filters to the bot list, allowing users to specify balance constraints for better bot management.
- Refactored sorting direction to use a dedicated `SortDirection` enum for improved type safety.
This commit is contained in:
2026-01-02 01:20:53 +07:00
parent 9b83527acc
commit 16421a1c9c
2 changed files with 56 additions and 8 deletions

View File

@@ -23,6 +23,7 @@ import {
BotSortableColumn,
BotStatus,
MoneyManagement,
SortDirection,
StartCopyTradingRequest,
TradingBotConfig,
TradingBotResponse
@@ -72,8 +73,10 @@ const BotList: React.FC<IBotList> = ({ list }) => {
const [pageSize, setPageSize] = useState(20)
const [statusFilter, setStatusFilter] = useState<BotStatus | undefined>(undefined)
const [agentFilter, setAgentFilter] = useState<string | undefined>(undefined)
const [minBalance, setMinBalance] = useState<number | undefined>(undefined)
const [maxBalance, setMaxBalance] = useState<number | undefined>(undefined)
const [sortBy, setSortBy] = useState<BotSortableColumn>(BotSortableColumn.Roi)
const [sortDirection, setSortDirection] = useState<'Asc' | 'Desc'>('Desc')
const [sortDirection, setSortDirection] = useState<SortDirection>(SortDirection.Desc)
// Use the user data for bot ownership checking
const checkIsBotOwner = (botAgentName: string) => {
@@ -82,8 +85,8 @@ const BotList: React.FC<IBotList> = ({ list }) => {
// Fetch paginated bot data
const { data: paginatedBots, isLoading } = useQuery({
queryFn: () => client.bot_GetBotsPaginated(pageNumber, pageSize, statusFilter, undefined, undefined, agentFilter, sortBy, sortDirection),
queryKey: ['bots', pageNumber, pageSize, statusFilter, agentFilter, sortBy, sortDirection],
queryFn: () => client.bot_GetBotsPaginated(pageNumber, pageSize, statusFilter, undefined, undefined, agentFilter, minBalance ?? null, maxBalance ?? null, sortBy, sortDirection),
queryKey: ['bots', pageNumber, pageSize, statusFilter, agentFilter, minBalance, maxBalance, sortBy, sortDirection],
})
const [showMoneyManagementModal, setShowMoneyManagementModal] =
@@ -355,6 +358,11 @@ const BotList: React.FC<IBotList> = ({ list }) => {
accessor: 'profitAndLoss',
Cell: ({ value }: any) => value?.toFixed(2) || '0.00',
},
{
Header: 'Trading Balance $',
accessor: 'botTradingBalance',
Cell: ({ value }: any) => value?.toFixed(2) || '0.00',
},
{
Header: 'Actions',
accessor: 'actions',
@@ -410,6 +418,36 @@ const BotList: React.FC<IBotList> = ({ list }) => {
/>
</div>
<div className="form-control">
<label className="label">
<span className="label-text">Min Balance ($)</span>
</label>
<input
type="number"
placeholder="Min balance"
className="input input-bordered input-sm"
value={minBalance ?? ''}
onChange={(e) => setMinBalance(e.target.value ? Number(e.target.value) : undefined)}
min="0"
step="0.01"
/>
</div>
<div className="form-control">
<label className="label">
<span className="label-text">Max Balance ($)</span>
</label>
<input
type="number"
placeholder="Max balance"
className="input input-bordered input-sm"
value={maxBalance ?? ''}
onChange={(e) => setMaxBalance(e.target.value ? Number(e.target.value) : undefined)}
min="0"
step="0.01"
/>
</div>
<div className="form-control">
<label className="label">
<span className="label-text">Sort By</span>
@@ -422,6 +460,7 @@ const BotList: React.FC<IBotList> = ({ list }) => {
<option value={BotSortableColumn.Roi}>ROI</option>
<option value={BotSortableColumn.Pnl}>Profit & Loss</option>
<option value={BotSortableColumn.WinRate}>Win Rate</option>
<option value={BotSortableColumn.BotTradingBalance}>Trading Balance</option>
<option value={BotSortableColumn.Name}>Name</option>
<option value={BotSortableColumn.Status}>Status</option>
<option value={BotSortableColumn.CreateDate}>Created At</option>
@@ -435,10 +474,10 @@ const BotList: React.FC<IBotList> = ({ list }) => {
<select
className="select select-bordered select-sm"
value={sortDirection}
onChange={(e) => setSortDirection(e.target.value as 'Asc' | 'Desc')}
onChange={(e) => setSortDirection(e.target.value as SortDirection)}
>
<option value="Desc">Descending</option>
<option value="Asc">Ascending</option>
<option value={SortDirection.Desc}>Descending</option>
<option value={SortDirection.Asc}>Ascending</option>
</select>
</div>
</div>