fix: TypeScript errors in withdrawal system

- 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
This commit is contained in:
mindesbunister
2025-11-19 18:25:54 +01:00
parent ca7b49f745
commit 1c79178aac
3 changed files with 4 additions and 4 deletions

View File

@@ -19,7 +19,7 @@ const DEFAULT_SETTINGS = {
MIN_WITHDRAWAL_AMOUNT: 50, // Minimum $50 MIN_WITHDRAWAL_AMOUNT: 50, // Minimum $50
MIN_ACCOUNT_BALANCE: 500, // Never drop below $500 MIN_ACCOUNT_BALANCE: 500, // Never drop below $500
WITHDRAWAL_DESTINATION: process.env.WALLET_PUBLIC_KEY || '', WITHDRAWAL_DESTINATION: process.env.WALLET_PUBLIC_KEY || '',
LAST_WITHDRAWAL_TIME: null, LAST_WITHDRAWAL_TIME: null as string | null,
TOTAL_WITHDRAWN: 0, TOTAL_WITHDRAWN: 0,
} }

View File

@@ -18,7 +18,7 @@ export async function GET() {
// Get current Drift balance // Get current Drift balance
const driftService = await initializeDriftService() const driftService = await initializeDriftService()
const health = await driftService.getAccountHealth() const health = await driftService.getAccountHealth()
const currentBalance = parseFloat(health.freeCollateral) const currentBalance = health.freeCollateral // Already a number
// Calculate total P&L from database // Calculate total P&L from database
const trades = await prisma.trade.findMany({ const trades = await prisma.trade.findMany({

View File

@@ -45,7 +45,7 @@ export async function withdrawFromDrift(
// Execute withdrawal via Drift SDK // Execute withdrawal via Drift SDK
// withdraw(amount, marketIndex, associatedTokenAddress, reduceOnly, subAccountId, txParams, updateFuel) // withdraw(amount, marketIndex, associatedTokenAddress, reduceOnly, subAccountId, txParams, updateFuel)
const signature = await driftService.getDriftClient().withdraw( const signature = await driftService.getClient().withdraw(
tokenAmount, tokenAmount,
usdcMarketIndex, usdcMarketIndex,
destination, destination,
@@ -93,7 +93,7 @@ export async function calculateWithdrawalAmount(): Promise<{
try { try {
const driftService = await initializeDriftService() const driftService = await initializeDriftService()
const health = await driftService.getAccountHealth() const health = await driftService.getAccountHealth()
const currentBalance = parseFloat(health.freeCollateral) const currentBalance = health.freeCollateral // Already a number
// Configuration // Configuration
const totalInvested = 546 // From roadmap const totalInvested = 546 // From roadmap