import axios from "axios";
interface WalletData {
totalProfit: number;
winRate: number;
totalSolanaHoldings: number;
realizedProfit7Days: number;
}
interface Activity {
transactionHash: string;
type: string;
date: string;
}
export const fetchSolanaBalance = async (walletAddress: string): Promise<number> => {
const response = await axios.get(`https://api.mainnet-beta.solana.com`, {
params: {
method: "getBalance",
params: [walletAddress],
},
});
return response.data.result.value;
};
export const fetchRecentActivity = async (walletAddress: string): Promise<Activity[]> => {
const response = await axios.get(`https://api.mainnet-beta.solana.com`, {
params: {
method: "getConfirmedSignaturesForAddress2",
params: [walletAddress],
},
});
return response.data.result.map((activity: any) => ({
transactionHash: activity.signature,
type: activity.type,
date: new Date(activity.blockTime * 1000).toISOString(),
}));
};