一键导入
gdex-portfolio
Cross-chain portfolio overview, chain-specific token balances, and paginated trade history
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Cross-chain portfolio overview, chain-specific token balances, and paginated trade history
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
HyperLiquid perpetual futures — open/close positions, set leverage, place market and limit orders with TP/SL, and manage open orders
CSS theming system for GDEX trading UIs — dark/light modes, trading colors, responsive breakpoints, and Tailwind CSS configuration
Troubleshoot GDEX SDK errors — error codes, encryption debugging, chain-specific quirks, HL gotchas, and copy trade pitfalls
Start here — GDEX overview, architecture, supported chains, available skills, and quickstart for cross-chain DeFi trading via managed-custody wallets
HyperLiquid HIP-3 outcome / event markets — list markets, place outcome orders, and manage outcome positions
Deposit and withdraw USDC to/from HyperLiquid for perpetual futures trading — constraints, amounts, and managed-custody flow
| name | gdex-portfolio |
| description | Cross-chain portfolio overview, chain-specific token balances, and paginated trade history |
Query cross-chain portfolio summaries, chain-specific balances, and trade history.
@gdexsdk/gdex-skill installedloginWithApiKey() — see gdex-authenticationWARNING (Live-Tested): The high-level
getPortfolio()andgetBalances()methods sendwalletAddress+chainto the backend, but the backend expectsuserId+chainId+data(encrypted session key). These methods return empty or incorrect results. Use the raw client workaround below.
import { GdexSkill, GDEX_API_KEY_PRIMARY, buildGdexUserSessionData } from '@gdexsdk/gdex-skill';
const skill = new GdexSkill();
skill.loginWithApiKey(GDEX_API_KEY_PRIMARY);
// Build encrypted session data
const data = buildGdexUserSessionData(sessionKey, GDEX_API_KEY_PRIMARY);
// Portfolio — use raw client with correct params
const portfolio = await skill.client.get('/v1/portfolio', {
params: {
userId: controlAddress, // control wallet, NOT managed
chainId: 622112261, // numeric Solana chain ID
data, // encrypted session key
}
});
// ❌ These send wrong params to backend — DO NOT USE for managed custody
const portfolio = await skill.getPortfolio({ walletAddress: '0x...', chain: 'solana' });
const balances = await skill.getBalances({ walletAddress: '0x...', chain: 8453 });
interface Portfolio {
totalValueUsd: number;
balances: Balance[];
perpPositions?: PerpPosition[];
realizedPnl?: number;
unrealizedPnl?: number;
totalPnl?: number;
}
interface Balance {
tokenAddress: string;
symbol: string;
name: string;
decimals: number;
rawBalance: string;
balance: string; // human-readable
usdValue: number;
priceUsd: number;
change24h?: number;
chain: string | number;
}
WARNING (Live-Tested): Same issue as portfolio — use raw client. On backend v1.1.0 balances are embedded in the portfolio response under
portfolio.balances[](there is no separate/v1/balancesendpoint).
const portfolio = await skill.client.get('/v1/portfolio', {
params: {
userId: controlAddress,
chainId: 622112261, // numeric chain ID
data, // encrypted session key
}
});
const balances = portfolio.balances ?? [];
| Parameter | Type | Required | Description |
|---|---|---|---|
walletAddress | string | Yes | Wallet address to query |
chain | string | ChainId | Yes | Chain to query balances on |
tokenAddress | string | No | Filter to a specific token |
WARNING (Live-Tested): The backend expects param
user(NOTuserId), and managed Solana chainId for trade history is900(NOT622112261). Use the raw client:
const history = await skill.client.get('/v1/user_history', {
params: {
user: controlAddress, // NOTE: "user", not "userId"
chainId: 900, // NOTE: 900 for Solana trade history, not 622112261
data, // encrypted session key
page: 1,
limit: 20,
}
});
The high-level
getTradeHistory()sends wrong param names. Use raw client above.
interface TradeRecord {
id: string;
type: string; // 'buy' | 'sell'
inputToken: string;
outputToken: string;
amountIn: string;
amountOut: string;
usdValue?: number;
chain: string | number;
dex?: string;
txHash: string;
timestamp: number;
status: string;
}
import { GdexSkill, GDEX_API_KEY_PRIMARY, buildGdexUserSessionData } from '@gdexsdk/gdex-skill';
const skill = new GdexSkill();
skill.loginWithApiKey(GDEX_API_KEY_PRIMARY);
// Build encrypted session data (required for all portfolio/balance/history queries)
const data = buildGdexUserSessionData(sessionKey, GDEX_API_KEY_PRIMARY);
const userId = controlAddress; // control wallet, NOT managed
// 1. Get portfolio (raw client — high-level method has wrong params)
const portfolio = await skill.client.get('/v1/portfolio', {
params: { userId, chainId: 622112261, data }
});
// 2. Get balances (embedded in portfolio.balances[] on backend v1.1.0)
const balances = portfolio.balances ?? [];
// 3. Get trade history (use "user" param, chainId 900 for Solana)
const history = await skill.client.get('/v1/user_history', {
params: { user: userId, chainId: 900, data, page: 1, limit: 20 }
});
622112261 for Solana, standard EVM chain IDs for others.900 for Solana (not 622112261). This is a backend quirk.user (not userId) — backend expects different param name for this endpoint.buildGdexUserSessionData().