adding redeem only function for killed pools)

This commit is contained in:
2025-11-19 15:43:10 -04:00
parent 66d854fb75
commit 107d2ae5c0
2 changed files with 62 additions and 23 deletions

View File

@@ -379,6 +379,7 @@ export interface PoolDetails {
tokens: readonly `0x${string}`[];
price?: string; // Formatted price string
tvl?: string; // Formatted TVL string (e.g., "$1.2M")
isKilled: boolean; // Whether the pool has been killed
}
export function useGetAllPools(offset: number = 0, limit: number = 100) {
@@ -457,10 +458,12 @@ export function useGetAllPools(offset: number = 0, limit: number = 100) {
}).catch(() => false),
]);
// Only add pool if it's working
// Fetch pool price and TVL (only for working pools)
let priceStr: string | undefined;
let tvlStr: string | undefined;
if (isWorking) {
// Fetch pool price (use first token as quote, index 0)
let priceStr: string | undefined;
try {
const priceRaw = await publicClient.readContract({
address: partyInfoAddress as `0x${string}`,
@@ -489,7 +492,6 @@ export function useGetAllPools(offset: number = 0, limit: number = 100) {
}
// Calculate TVL (approximate by getting first token balance and doubling it)
let tvlStr: string | undefined;
try {
if (tokens && tokens.length > 0) {
const firstTokenAddress = tokens[0];
@@ -519,16 +521,18 @@ export function useGetAllPools(offset: number = 0, limit: number = 100) {
console.error(`Error fetching TVL for ${poolAddress}:`, err);
tvlStr = undefined;
}
details.push({
address: poolAddress,
name: name as string,
symbol: symbol as string,
tokens: tokens as readonly `0x${string}`[],
price: priceStr,
tvl: tvlStr,
});
}
// Add all pools (both working and killed)
details.push({
address: poolAddress,
name: name as string,
symbol: symbol as string,
tokens: tokens as readonly `0x${string}`[],
price: priceStr,
tvl: tvlStr,
isKilled: !isWorking,
});
} catch (err) {
console.error('Error fetching pool details for', poolAddress, err);
// Skip pools that fail to load