From 1c79178aac5a106619e17db64a7911d92975fe0b Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Wed, 19 Nov 2025 18:25:54 +0100 Subject: [PATCH] fix: TypeScript errors in withdrawal system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed LAST_WITHDRAWAL_TIME type (null | string) - Removed parseFloat on health.freeCollateral (already number) - Fixed getDriftClient() → getClient() method name - Build now compiles successfully Deployed: Withdrawal system now live on dashboard --- app/api/withdrawals/settings/route.ts | 2 +- app/api/withdrawals/stats/route.ts | 2 +- lib/drift/withdraw.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/withdrawals/settings/route.ts b/app/api/withdrawals/settings/route.ts index c9d69e4..93c2df2 100644 --- a/app/api/withdrawals/settings/route.ts +++ b/app/api/withdrawals/settings/route.ts @@ -19,7 +19,7 @@ const DEFAULT_SETTINGS = { MIN_WITHDRAWAL_AMOUNT: 50, // Minimum $50 MIN_ACCOUNT_BALANCE: 500, // Never drop below $500 WITHDRAWAL_DESTINATION: process.env.WALLET_PUBLIC_KEY || '', - LAST_WITHDRAWAL_TIME: null, + LAST_WITHDRAWAL_TIME: null as string | null, TOTAL_WITHDRAWN: 0, } diff --git a/app/api/withdrawals/stats/route.ts b/app/api/withdrawals/stats/route.ts index 285a185..cfd1eca 100644 --- a/app/api/withdrawals/stats/route.ts +++ b/app/api/withdrawals/stats/route.ts @@ -18,7 +18,7 @@ export async function GET() { // Get current Drift balance const driftService = await initializeDriftService() const health = await driftService.getAccountHealth() - const currentBalance = parseFloat(health.freeCollateral) + const currentBalance = health.freeCollateral // Already a number // Calculate total P&L from database const trades = await prisma.trade.findMany({ diff --git a/lib/drift/withdraw.ts b/lib/drift/withdraw.ts index 6604c65..a59c47b 100644 --- a/lib/drift/withdraw.ts +++ b/lib/drift/withdraw.ts @@ -45,7 +45,7 @@ export async function withdrawFromDrift( // Execute withdrawal via Drift SDK // withdraw(amount, marketIndex, associatedTokenAddress, reduceOnly, subAccountId, txParams, updateFuel) - const signature = await driftService.getDriftClient().withdraw( + const signature = await driftService.getClient().withdraw( tokenAmount, usdcMarketIndex, destination, @@ -93,7 +93,7 @@ export async function calculateWithdrawalAmount(): Promise<{ try { const driftService = await initializeDriftService() const health = await driftService.getAccountHealth() - const currentBalance = parseFloat(health.freeCollateral) + const currentBalance = health.freeCollateral // Already a number // Configuration const totalInvested = 546 // From roadmap