Docs

userAbstraction - HyperCore Info Endpoint

Get account abstraction mode for a user on Hyperliquid. Check whether an account uses unified, portfolio margin, or other abstraction modes.

Get the account abstraction mode for a user on Hyperliquid, indicating whether the account operates in unified, portfolio margin, or another mode.

Authenticate by including your Dwellir API key in the URL path: https://api-hyperliquid-mainnet-info.n.dwellir.com/YOUR_API_KEY/info.

When to Use This Endpoint

The userAbstraction endpoint is essential for:

  • Account Mode Detection — Determine how a user's account is configured
  • Margin Logic — Adapt margin calculations based on unified vs portfolio margin mode
  • UI Customization — Display the correct interface based on account abstraction type
  • Trading Logic — Adjust order placement and risk management based on account mode

Common Use Cases

1. Check Account Mode

Determine the account abstraction mode before executing trades:

JavaScript
async function checkAccountMode(userAddress) {
  const mode = await getUserAbstraction(userAddress);

  console.log('=== Account Mode ===\n');
  console.log(`Mode: ${mode}`);

  return mode;
}

// Usage
const mode = await checkAccountMode('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');

2. Adapt Trading Logic

Adjust trading behavior based on account mode:

JavaScript
async function getTradeConfig(userAddress) {
  const mode = await getUserAbstraction(userAddress);

  const configs = {
    unifiedAccount: {
      marginShared: true,
      spotAndPerpsLinked: true,
      description: 'Perps and spot share a single margin pool'
    },
    portfolioMargin: {
      marginShared: true,
      spotAndPerpsLinked: true,
      description: 'Margin calculated across the full portfolio'
    },
    disabled: {
      marginShared: false,
      spotAndPerpsLinked: false,
      description: 'Standard isolated margin mode'
    },
    default: {
      marginShared: false,
      spotAndPerpsLinked: false,
      description: 'Default account configuration'
    }
  };

  return configs[mode] || configs['default'];
}

// Usage
const config = await getTradeConfig('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
console.log(`Mode: ${config.description}`);
console.log(`Margin shared: ${config.marginShared}`);

3. Display Account Mode Badge

Show account mode in a dashboard:

JavaScript
async function getAccountModeBadge(userAddress) {
  const mode = await getUserAbstraction(userAddress);

  const badges = {
    unifiedAccount: { label: 'Unified Account', color: 'green' },
    portfolioMargin: { label: 'Portfolio Margin', color: 'blue' },
    disabled: { label: 'Standard', color: 'gray' },
    default: { label: 'Default', color: 'gray' }
  };

  return badges[mode] || { label: mode, color: 'gray' };
}

// Usage
const badge = await getAccountModeBadge('0x63E8c7C149556D5f34F833419A287bb9Ef81487f');
console.log(`Display badge: ${badge.label} (${badge.color})`);

Best Practices

  1. Cache mode data — Account mode changes infrequently, cache for 5-10 minutes
  2. Validate addresses — Ensure user addresses are valid Ethereum addresses
  3. Handle unknown modes — Have fallback logic for unrecognized mode values
  4. Check before trading — Query account mode before placing orders that depend on margin type
  5. Update on mode change — Invalidate cached data when users switch account modes

Check account abstraction modes with Dwellir's HyperCore Info Endpoint. Get your API key →