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:
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:
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:
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
- Cache mode data — Account mode changes infrequently, cache for 5-10 minutes
- Validate addresses — Ensure user addresses are valid Ethereum addresses
- Handle unknown modes — Have fallback logic for unrecognized mode values
- Check before trading — Query account mode before placing orders that depend on margin type
- Update on mode change — Invalidate cached data when users switch account modes
Related Endpoints
- clearinghouseState — Get perpetual account state
- spotClearinghouseState — Get spot account balances
- userRole — Get user role information
- subAccounts — Get sub-account details
Check account abstraction modes with Dwellir's HyperCore Info Endpoint. Get your API key →