diff --git a/components/bags/bag-card.tsx b/components/bags/bag-card.tsx index 4713711..52fdc65 100644 --- a/components/bags/bag-card.tsx +++ b/components/bags/bag-card.tsx @@ -4,11 +4,34 @@ import { useState } from 'react'; import { DepositModal } from './deposit-modal'; import { ArrowRight, RotateCw } from 'lucide-react'; import { allocationLabel, type SmartBagTemplate } from '@/lib/smart-bags/session-engine'; +import { useWalletBalances } from '@/hooks/use-wallet-balances'; +import { useWallet } from '@solana/wallet-adapter-react'; export function BagCard(bag: SmartBagTemplate) { const [isDepositOpen, setIsDepositOpen] = useState(false); + const { connected } = useWallet(); + const { balances } = useWalletBalances(); const { title, description, metricLabel, metricValue, risk, assets, strategy, maxSlippageBps } = bag; + // Compute user position for this bag's target mints + const position = connected && balances.length > 0 ? (() => { + const held = assets + .map((asset) => { + const match = balances.find((b) => b.mint === asset.mint); + return { + symbol: asset.symbol, + targetBps: asset.allocationBps, + valueUsd: match?.valueUsd ?? 0, + }; + }) + .filter((item) => item.valueUsd > 0); + + const totalValue = held.reduce((sum, h) => sum + h.valueUsd, 0); + if (totalValue < 0.01) return null; + + return { held, totalValue }; + })() : null; + return ( <>
No assets to display
+| Asset | -Balance | -
-
- Value (USD)
-
- |
- Network | -||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
-
-
-
- {asset.symbol[0]}
-
-
-
- {asset.symbol}
- {asset.name}
- |
- - {asset.balance} - | -- ${asset.valueUSD.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} - | -
-
-
- {asset.chain}
+
+ {isLoading && balances.length === 0 ? (
+
+
+ ) : balances.length === 0 ? (
+
+ No holdings found for this wallet.
+
+ ) : (
+
+
+
+
+ {balances.map((asset) => (
+
+ |
+
+
+
+ {asset.icon}
+
+
+
+ {asset.symbol}
+ {asset.name}
+
+ {asset.balanceUi.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 6 })}
+ |
+
+ ${asset.valueUsd.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
+ |
+
+ |
+
+
+ Solana
+
+ |
Total Net Worth
- +${dayChange.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} today + {/* Day change requires historical snapshots — available after SOL6 */} +
+ Daily change available after history tracking is enabled