Update balance tracking
This commit is contained in:
@@ -4588,13 +4588,16 @@ export enum SortableFields {
|
||||
}
|
||||
|
||||
export interface AgentBalanceHistory {
|
||||
userId?: number;
|
||||
agentName?: string | null;
|
||||
agentBalances?: AgentBalance[] | null;
|
||||
}
|
||||
|
||||
export interface AgentBalance {
|
||||
agentName?: string | null;
|
||||
userId?: number;
|
||||
totalBalanceValue?: number;
|
||||
usdcWalletValue?: number;
|
||||
usdcInPositionsValue?: number;
|
||||
botsAllocationUsdValue?: number;
|
||||
pnL?: number;
|
||||
time?: Date;
|
||||
|
||||
@@ -1071,13 +1071,16 @@ export enum SortableFields {
|
||||
}
|
||||
|
||||
export interface AgentBalanceHistory {
|
||||
userId?: number;
|
||||
agentName?: string | null;
|
||||
agentBalances?: AgentBalance[] | null;
|
||||
}
|
||||
|
||||
export interface AgentBalance {
|
||||
agentName?: string | null;
|
||||
userId?: number;
|
||||
totalBalanceValue?: number;
|
||||
usdcWalletValue?: number;
|
||||
usdcInPositionsValue?: number;
|
||||
botsAllocationUsdValue?: number;
|
||||
pnL?: number;
|
||||
time?: Date;
|
||||
|
||||
@@ -80,6 +80,8 @@ function AgentSearch({ index }: { index: number }) {
|
||||
const latestBalance = balances[balances.length - 1]
|
||||
return {
|
||||
totalBalanceValue: latestBalance.totalBalanceValue || 0,
|
||||
usdcWalletValue: latestBalance.usdcWalletValue || 0,
|
||||
usdcInPositionsValue: latestBalance.usdcInPositionsValue || 0,
|
||||
botsAllocation: latestBalance.botsAllocationUsdValue || 0,
|
||||
}
|
||||
}
|
||||
@@ -139,12 +141,16 @@ function AgentSearch({ index }: { index: number }) {
|
||||
|
||||
const dates = sortedBalances.map(balance => new Date(balance.time || 0))
|
||||
const totalBalanceValues = sortedBalances.map(balance => balance.totalBalanceValue || 0)
|
||||
const usdcWalletValues = sortedBalances.map(balance => balance.usdcWalletValue || 0)
|
||||
const usdcInPositionsValues = sortedBalances.map(balance => balance.usdcInPositionsValue || 0)
|
||||
const botsAllocationValues = sortedBalances.map(balance => balance.botsAllocationUsdValue || 0)
|
||||
const pnlValues = sortedBalances.map(balance => balance.pnL || 0)
|
||||
|
||||
return {
|
||||
dates,
|
||||
totalBalanceValues,
|
||||
usdcWalletValues,
|
||||
usdcInPositionsValues,
|
||||
botsAllocationValues,
|
||||
pnlValues
|
||||
}
|
||||
@@ -247,11 +253,19 @@ function AgentSearch({ index }: { index: number }) {
|
||||
{currentBalance && (
|
||||
<div className="mb-6 p-4 bg-primary/10 rounded-lg border border-primary/20">
|
||||
<h3 className="text-lg font-semibold mb-2">Current Balance</h3>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div>
|
||||
<div className="text-sm opacity-70">Total Balance Value</div>
|
||||
<div className="text-2xl font-bold">${currentBalance.totalBalanceValue.toLocaleString(undefined, { maximumFractionDigits: 2 })}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm opacity-70">USDC in Wallet</div>
|
||||
<div className="text-xl font-semibold text-blue-500">${currentBalance.usdcWalletValue.toLocaleString(undefined, { maximumFractionDigits: 2 })}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm opacity-70">USDC in Positions</div>
|
||||
<div className="text-xl font-semibold text-green-500">${currentBalance.usdcInPositionsValue.toLocaleString(undefined, { maximumFractionDigits: 2 })}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm opacity-70">Bots Allocation</div>
|
||||
<div className="text-xl font-semibold">${currentBalance.botsAllocation.toLocaleString(undefined, { maximumFractionDigits: 2 })}</div>
|
||||
@@ -275,14 +289,32 @@ function AgentSearch({ index }: { index: number }) {
|
||||
line: { color: theme.primary, width: 3 },
|
||||
marker: { size: 6 }
|
||||
},
|
||||
{
|
||||
x: chartData.dates,
|
||||
y: chartData.usdcWalletValues,
|
||||
type: 'scatter' as const,
|
||||
mode: 'lines+markers' as const,
|
||||
name: 'USDC in Wallet',
|
||||
line: { color: '#3b82f6', width: 2 },
|
||||
marker: { size: 5 }
|
||||
},
|
||||
{
|
||||
x: chartData.dates,
|
||||
y: chartData.usdcInPositionsValues,
|
||||
type: 'scatter' as const,
|
||||
mode: 'lines+markers' as const,
|
||||
name: 'USDC in Positions',
|
||||
line: { color: '#10b981', width: 2 },
|
||||
marker: { size: 5 }
|
||||
},
|
||||
{
|
||||
x: chartData.dates,
|
||||
y: chartData.botsAllocationValues,
|
||||
type: 'scatter' as const,
|
||||
mode: 'lines+markers' as const,
|
||||
name: 'Bots Allocation',
|
||||
line: { color: theme.success, width: 3 },
|
||||
marker: { size: 6 }
|
||||
line: { color: theme.success, width: 2 },
|
||||
marker: { size: 5 }
|
||||
},
|
||||
{
|
||||
x: chartData.dates,
|
||||
@@ -290,8 +322,8 @@ function AgentSearch({ index }: { index: number }) {
|
||||
type: 'scatter' as const,
|
||||
mode: 'lines+markers' as const,
|
||||
name: 'PnL',
|
||||
line: { color: theme.warning, width: 3 },
|
||||
marker: { size: 6 }
|
||||
line: { color: theme.warning, width: 2 },
|
||||
marker: { size: 5 }
|
||||
}
|
||||
]}
|
||||
layout={{
|
||||
|
||||
Reference in New Issue
Block a user