14.05.2026 rip

This commit is contained in:
2026-05-14 21:23:27 +03:00
parent 1e5f792854
commit c2a1ca3ee5
4 changed files with 50 additions and 5 deletions

View File

@@ -41,6 +41,32 @@ export interface WalletAddress {
derivationPath: string
}
export interface PortfolioToken {
symbol: string
amountFormatted: string
usd: number
}
export interface PortfolioNative {
amount: string
amountFormatted: string
usd: number
}
export interface PortfolioChain {
address: string
stale: boolean
native: PortfolioNative
tokens: PortfolioToken[]
totalUsd: number
}
export interface PortfolioData {
totalUsd: number
asOfMs: number
chains: Record<Chain, PortfolioChain>
}
export const CHAINS: Chain[] = ['ETH', 'BSC', 'BTC', 'TRX', 'SOL']
async function walletGet<T>(path: string, allowRetry: boolean = true): Promise<T> {
@@ -120,3 +146,8 @@ export async function getPrices(symbols: string[]): Promise<Record<string, Price
export async function sendWallet(chain: Chain, payload: SendWalletPayload): Promise<SendWalletResponse> {
return walletPost<SendWalletResponse>(`/api/wallets/${chain}/send`, payload)
}
export async function getPortfolio(): Promise<PortfolioData> {
const res = await walletGet<{ success: boolean; data: PortfolioData }>('/api/wallets/portfolio')
return res.data
}

View File

@@ -1,3 +1,3 @@
export { useAllWalletBalances, usePrices, useSendWallet, useWalletAddresses, useWalletBalance } from './model/useWalletData'
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse, WalletAddress } from './api/walletApi'
export { useAllWalletBalances, usePrices, useSendWallet, useWalletAddresses, useWalletBalance, usePortfolio } from './model/useWalletData'
export type { Chain, FormattedAmount, WalletBalanceData, PriceEntry, SendWalletPayload, SendWalletResponse, WalletAddress, PortfolioData, PortfolioChain, PortfolioNative, PortfolioToken } from './api/walletApi'
export { CHAINS } from './api/walletApi'

View File

@@ -1,5 +1,5 @@
import { useQuery, useQueries, useMutation } from '@tanstack/react-query'
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, CHAINS, type Chain, type SendWalletPayload } from '../api/walletApi'
import { getWalletBalance, getPrices, sendWallet, getWalletAddresses, getPortfolio, CHAINS, type Chain, type SendWalletPayload } from '../api/walletApi'
export function useWalletBalance(chain: Chain) {
return useQuery({
@@ -41,3 +41,11 @@ export function useWalletAddresses() {
staleTime: 10 * 60 * 1000,
})
}
export function usePortfolio() {
return useQuery({
queryKey: ['wallet', 'portfolio'],
queryFn: getPortfolio,
staleTime: 30_000,
})
}