Skip to main content
TL;DR: Removed all heavy Solana DeFi SDKs (Drift, Solend, MarginFi, Meteora, Raydium) and replaced them with raw batched RPC calls, drastically reducing RPC costs. Added Kamino lending and Drift perpetuals support.

SDK Removal & RPC Optimization

The Wallet DeFi Positions endpoint (/api/2/wallet/defi-positions) has been completely refactored to eliminate heavy SDK dependencies:

Removed SDKs

SDKBeforeAfter
@drift-labs/sdkHeavy bundle, many RPC callsRaw RPC with batched account reads
@solendprotocol/solend-sdkSequential RPC callsBatched getMultipleAccounts
@marginfi/marginfi-client-v2Complex initializationDirect account deserialization
@meteora-ag/dlmmMultiple RPC roundtripsSingle batched request
@raydium-io/raydium-sdk-v2Heavy dependenciesPure CLMM math implementation

Performance Benefits

  • ~70% reduction in RPC calls per wallet query
  • Faster response times due to batched account fetching
  • Lower memory footprint without heavy SDK bundles
  • No SDK initialization overhead per request

New Protocol Support

Kamino Lending

The endpoint now supports Kamino lending positions:
{
  "protocol": {
    "id": "kamino",
    "name": "Kamino",
    "category": "lending"
  },
  "positions": [
    {
      "type": "deposit",
      "name": "USDC Supply",
      "valueUSD": 5000.00,
      "tokens": [...],
      "metadata": {
        "apy": "8.5",
        "collateralEnabled": true
      }
    }
  ]
}

Drift Perpetuals

Full support for Drift perpetual positions is now available:
{
  "protocol": {
    "id": "drift",
    "name": "Drift",
    "category": "perps"
  },
  "positions": [
    {
      "id": "drift-perp-0-subaccount-0",
      "type": "leverage",
      "name": "drift-sol-usd LONG",
      "valueUSD": 1250.50,
      "metadata": {
        "marketId": "drift-sol-usd",
        "exchange": "drift",
        "side": "BUY",
        "entryPriceQuote": 180.5,
        "currentPriceQuote": 185.2,
        "currentLeverage": 5.2,
        "liquidationPriceQuote": 145.8,
        "amountUSD": 6500.0,
        "unrealizedPnlUSD": 250.50,
        "unrealizedPnlPercent": 20.04
      }
    }
  ]
}

Updated Supported Protocols

Solana

CategoryProtocols
LendingKamino (new), MarginFi, Solend
DEX (LP)Orca, Raydium, Meteora
Liquid StakingJito, Marinade, BlazeStake, Sanctum
PerpsDrift (new)

Perps Metadata Fields

New metadata fields for perpetual positions:
FieldTypeDescription
marketIdstringMarket identifier (e.g., “drift-sol-usd”)
exchangestringExchange: drift, gains, hyperliquid, gte, lighter
sidestringBUY (Long) or SELL (Short)
entryPriceQuotenumberEntry price
currentPriceQuotenumberCurrent mark/oracle price
currentLeveragenumberCurrent effective leverage
liquidationPriceQuotenumberEstimated liquidation price
unrealizedPnlUSDnumberUnrealized P&L in USD
unrealizedPnlPercentnumberUnrealized P&L as percentage
collateralAssetstringCollateral token address

Affected Endpoints

All existing integrations remain backwards compatible. The response format is unchanged - only the underlying implementation was optimized.

🦀 Shipped by Krabs