fix: Implement Associated Token Account for USDC withdrawals

- Fixed PublicKey undefined error (derive from DRIFT_WALLET_PRIVATE_KEY)
- Implemented ATA resolution using @solana/spl-token
- Added comprehensive debug logging for withdrawal flow
- Fixed AccountOwnedByWrongProgram error (need ATA not wallet address)
- Successfully tested .58 withdrawal with on-chain confirmation
- Updated .env with TOTAL_WITHDRAWN and LAST_WITHDRAWAL_TIME tracking

Key changes:
- lib/drift/withdraw.ts: Added getAssociatedTokenAddress() for USDC ATA
- tsconfig.json: Excluded archive folders from compilation
- package.json: Added bn.js as direct dependency

Transaction: 4drNfMR1xBosGCQtfJ2a4r6oEawUByrT6L7Thyqu6QQWz555hX3QshFuJqiLZreL7KrheSgTdCEqMcXP26fi54JF
Wallet: 3dG7wayp7b9NBMo92D2qL2sy1curSC4TTmskFpaGDrtA
USDC ATA: 8ZEMwErnwxPNNNHJigUcMfrkBG14LCREDdKbqKm49YY7
This commit is contained in:
mindesbunister
2025-11-19 20:35:32 +01:00
parent 8d53c4bbad
commit c37a9a37d3
5 changed files with 60 additions and 9 deletions

1
package-lock.json generated
View File

@@ -14,6 +14,7 @@
"@pythnetwork/price-service-client": "^1.3.0",
"@solana/web3.js": "^1.91.1",
"autoprefixer": "^10.4.21",
"bn.js": "^5.2.2",
"bs58": "^5.0.0",
"next": "^15.0.0",
"postcss": "^8.5.6",