feat: Helius primary + Alchemy fallback for trade execution

- Helius HTTPS: Primary RPC for Drift SDK initialization and subscriptions
- Alchemy HTTPS (10K CU/s): Fallback RPC for transaction confirmations
- Added getFallbackConnection() method to DriftService
- openPosition() and closePosition() now use Alchemy for tx confirmations
- accountSubscribe errors are non-fatal warnings (SDK falls back gracefully)
- System fully operational: Drift initialized, Position Manager ready
- Trade execution will use high-throughput Alchemy for confirmations
This commit is contained in:
mindesbunister
2025-11-14 16:51:14 +01:00
parent 1cf5c9aba1
commit 6445a135a8
3 changed files with 35 additions and 23 deletions

View File

@@ -146,8 +146,16 @@ export async function openPosition(
console.log(`📝 Transaction submitted: ${txSig}`)
// CRITICAL: Confirm transaction actually executed on-chain
console.log('⏳ Confirming transaction on-chain...')
const connection = driftService.getConnection()
// Use Alchemy (fallback RPC) for confirmation - higher throughput
console.log('⏳ Confirming transaction on-chain (using Alchemy for high throughput)...')
const alchemyConnection = driftService.getFallbackConnection()
const connection = alchemyConnection || driftService.getConnection()
if (alchemyConnection) {
console.log('✅ Using Alchemy RPC for transaction confirmation')
} else {
console.log('⚠️ No fallback RPC available, using primary RPC')
}
try {
const confirmation = await connection.confirmTransaction(txSig, 'confirmed')
@@ -557,9 +565,16 @@ export async function closePosition(
console.log(`✅ Close order placed! Transaction: ${txSig}`)
// CRITICAL: Confirm transaction on-chain to prevent phantom closes
// BUT: Use timeout to prevent API hangs during network congestion
console.log('⏳ Confirming transaction on-chain (30s timeout)...')
const connection = driftService.getConnection()
// Use Alchemy (fallback RPC) for confirmation - higher throughput
console.log('⏳ Confirming transaction on-chain (using Alchemy, 30s timeout)...')
const alchemyConnection = driftService.getFallbackConnection()
const connection = alchemyConnection || driftService.getConnection()
if (alchemyConnection) {
console.log('✅ Using Alchemy RPC for transaction confirmation')
} else {
console.log('⚠️ No fallback RPC available, using primary RPC')
}
try {
const confirmationPromise = connection.confirmTransaction(txSig, 'confirmed')