API Reference
Complete reference for the @7n7d/sdk package (v0.2.0).
:::caution Published 0.2.0 still targets Arbitrum Sepolia
npm install @7n7d/sdk currently installs 0.2.0. Its testnet default is Arbitrum Sepolia, its staking and governance are the retired Arbitrum Sepolia contracts, and its vault calls target the retired V1 vault. Do not use 0.2.0's vault calls. The Ethereum Sepolia default, the v2 staking and governance contracts and the no-vault behaviour on these pages are in the repository source and ship in the next release (0.3.0).
:::
:::info Networks
network: 'testnet'(default) is Ethereum Sepolia (chain ID11155111), the testnet hub: the canonical 7N7D, staking (ProfitDistributor v2) and governance (StakedGovernance v2) live there.- No vault on testnet today. The V1
TradingVaultand MockUSDC on Arbitrum Sepolia were retired on 2026-11-25, and Vault V2 (HyperEvmTradingVault, HyperEVM testnet, chain ID998) is not deployed yet.NETWORKS.testnet.contracts.tradingVaultandusdcare empty, so everyclient.vaultmethod throwsConfigErrornamingtradingVault. See VaultClient and Vault V2 ABIs and constants. network: 'mainnet'(Arbitrum One,42161) has no deployment yet. Its addresses are empty, and a call that needs one throwsConfigError.
See How Testnet Works. :::
Installation
npm install @7n7d/sdk
SevenNSevenD (Main Client)
The main entry point. Creates API and on-chain sub-clients.
import { SevenNSevenD } from '@7n7d/sdk';
const client = new SevenNSevenD({
apiKey: 'your-api-key',
network: 'testnet', // 'testnet' (Ethereum Sepolia) | 'mainnet'
privateKey: '0x...', // Required for on-chain transactions
});
client.chainId; // 11155111
SevenNSevenDConfig
| Property | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | API key for the 7N7D REST API |
apiUrl | string | No | Override the default API URL |
rpcUrl | string | No | Override the RPC endpoint (wins over chain.rpcUrl) |
privateKey | string | No | Private key for signing on-chain transactions |
network | 'testnet' | 'mainnet' | No | Network selection (default: 'testnet') |
chain | ChainOverride | No | { id: number; name?: string; rpcUrl?: string; explorerUrl?: string }. Builds the provider for id instead of the network's chain (for example a local fork). rpcUrl and explorerUrl replace the network's when given |
contracts | Partial<ContractAddresses> | No | Override the network's default contract addresses (tradingVault, usdc, token, profitDistributor, stakedGovernance). Keys you omit keep the network default. Required in practice on mainnet, whose built-in addresses are empty until the deployment is published. |
A contract with no address is not an error until a method needs it; then the method throws ConfigError("<contract> is not deployed on <network> yet. ...").
Sub-Clients
| Property | Type | Description |
|---|---|---|
api | ApiClient | REST API client (status, positions, chat) |
vault | VaultClient | Trading vault on-chain operations |
staking | StakingClient | Token staking on-chain operations |
token | TokenClient | 7N7D token on-chain operations |
governance | GovernanceClient | StakedGovernance token-listing votes |
chainId | number | Chain ID the provider was built for |
ApiClient
REST API client for querying the 7N7D backend. Accessed via client.api.
Methods
api.status()
Get vault and agent status.
const { data } = await client.api.status();
// data: { vault: { status, network }, agent: { status, positions }, trading?: { venue, network, dexes }, timestamp }
Returns: Promise<ApiResponse<StatusData>>
api.positions(filter?)
List open trading positions. Each position carries additive market identity
(market_id, network, dex, asset_class, display_ticker). The optional
filter is applied client-side on that identity.
const { data } = await client.api.positions();
// data: { positions: Position[], timestamp }
const stocks = await client.api.positions({ assetClass: 'EQUITY' });
const tesla = await client.api.positions({ marketId: 'hl-testnet:xyz:TSLA' });
| Parameter | Type | Required | Description |
|---|---|---|---|
filter.assetClass | AssetClass | string | No | CRYPTO, EQUITY, COMMODITY, PREDICTION |
filter.marketId | string | No | Canonical id, e.g. hl-testnet:xyz:TSLA |
Returns: Promise<ApiResponse<PositionsData>>
api.markets(filter?)
Every market on the configured Hyperliquid network (native DEX plus enabled
HIP-3 builder DEXes) with its activation state. Display names are never
execution identifiers — use marketId / coin.
const catalog = await client.api.markets();
// { network: 'TESTNET', dexes: ['', 'xyz'], markets: Market[], count, timestamp }
const activeStocks = await client.api.markets({ assetClass: 'EQUITY', activeOnly: true });
Returns: Promise<MarketsData>
api.market(marketId)
One market by canonical id.
const tsla = await client.api.market('hl-testnet:xyz:TSLA');
// { marketId, network, venue, dex: 'xyz', coin: 'xyz:TSLA', displayTicker: 'TSLA', assetClass: 'EQUITY', activation, maxLeverage, reference, ... }
Returns: Promise<Market>
api.marketState(marketId)
Venue session, underlying session, entry status and data freshness for one market — the facts behind “entries paused” on the dashboard.
const state = await client.api.marketState('hl-testnet:xyz:TSLA');
// { marketId, asOf, venueSession, referenceSession, entry: { status, reason }, quote, freshness }
Returns: Promise<MarketState>
api.accountSnapshot()
Mode-aware account snapshot from the trading agent: account mode, per-DEX
state, capital reservations and pending transfers. null fields mean
unknown, never zero.
const { data } = await client.api.accountSnapshot();
Returns: Promise<ApiResponse<AccountSnapshotData>>
api.balance(address)
Get balance information for an address.
const { data } = await client.api.balance('0x...');
// data: { address, network, contracts: { tradingVault, token, usdc }, timestamp }
Returns: Promise<ApiResponse<BalanceData>>
api.chat(message, walletAddress?, conversationHistory?)
Send a message to the AI agent.
const { data } = await client.api.chat('What is the current TVL?');
// data: { response, intent, action, timestamp }
| Parameter | Type | Required | Description |
|---|---|---|---|
message | string | Yes | User message |
walletAddress | string | No | Wallet for context |
conversationHistory | Array<{ role: string; content: string }> | No | Previous messages |
Returns: Promise<ApiResponse<ChatData>>
api.contracts()
Get deployed contract addresses and network info.
const { data } = await client.api.contracts();
// data: { network, chainId, contracts: { tradingVault, token, usdc, profitDistributor, stakedGovernance }, rpcUrl, explorerUrl, timestamp }
Returns: Promise<ApiResponse<ContractsData>>
api.health()
Health check endpoint.
const health = await client.api.health();
// { ok: true, service: '7n7d-api', version: '...', timestamp: '...' }
Returns: Promise<HealthData>
VaultClient
On-chain trading vault operations. Accessed via client.vault.
Methods that write to the blockchain (deposit, requestWithdrawal, completeWithdrawal, cancelWithdrawal) require a privateKey in the client config. V1 vault shares have 6 decimals, the same as USDC (DECIMALS.SHARES). VaultClient speaks the V1 ABI; for Vault V2 see Vault V2 ABIs and constants.
:::warning No vault on testnet; the V1 vault is retired The testnet preset has no vault (V1 retired 2026-11-25, V2 not deployed yet), so every vault method throws before any transaction is built:
await client.vault.deposit('1000');
// ConfigError: tradingVault is not deployed on testnet yet. ...
Every write (deposit, requestWithdrawal, withdraw, completeWithdrawal, cancelWithdrawal) also refuses the retired V1 vault (0x225c91C3943028EbBa44e33202Ef914B845F0267) and MockUSDC (0x3a55B1E3B5Af2D90A3802b7359a6EC1fc0a435FD) with a ConfigError, even when you pass them through contracts. Reads still work for history; point the client at Arbitrum Sepolia:
const legacy = NETWORKS.testnet.legacy.arbitrumSepolia;
const history = new SevenNSevenD({
apiKey: 'your-api-key',
chain: { id: legacy.chainId, rpcUrl: legacy.rpcUrl, explorerUrl: legacy.explorerUrl },
contracts: { tradingVault: legacy.tradingVaultV1 },
});
await history.vault.totalAssets(); // read-only
:::
Methods
vault.deposit(amount)
Deposit USDC into the trading vault. Automatically approves USDC spending first.
const result = await client.vault.deposit('1000'); // 1000 USDC
// { txHash: '0x...', explorerLink: 'https://...' }
| Parameter | Type | Description |
|---|---|---|
amount | string | USDC amount in human-readable units |
Returns: Promise<{ txHash: string; explorerLink: string }>
vault.requestWithdrawal(shares)
Request a withdrawal of vault shares (not USDC). Calls requestWithdrawal(shares): the shares are locked in the vault for 7 days. One request per address at a time.
const result = await client.vault.requestWithdrawal('100'); // 100 shares
// { txHash: '0x...', explorerLink: 'https://sepolia.arbiscan.io/tx/0x...' }
| Parameter | Type | Description |
|---|---|---|
shares | string | Share amount in human-readable units |
Returns: Promise<TxResult> ({ txHash: string; explorerLink: string })
vault.completeWithdrawal()
Complete your withdrawal after the 7-day lock (processWithdrawal()): burns the locked shares and sends USDC at the current share price. Reverts (as ContractError) before the lock ends or while the vault holds less idle USDC than the payout.
await client.vault.completeWithdrawal();
Returns: Promise<TxResult>
vault.cancelWithdrawal()
Cancel your pending request (cancelWithdrawal()); the locked shares return to your wallet.
Returns: Promise<TxResult>
vault.withdraw(shares) (deprecated)
Alias of requestWithdrawal(shares), kept from 0.1. It only requests.
vault.getWithdrawalRequest(address)
Read an address's request from getWithdrawalRequest(user).
const req = await client.vault.getWithdrawalRequest('0x...');
// { shares: '100.0', requestTime: 1786340034, unlockTime: 1786944834,
// processed: false, pending: true, unlocked: true }
Returns: Promise<WithdrawalRequestInfo>
interface WithdrawalRequestInfo {
shares: string; // locked shares ('0.0' when there is no request)
requestTime: number; // unix seconds
unlockTime: number; // unix seconds; completeWithdrawal() works from here
processed: boolean;
pending: boolean; // a request exists and is not completed or cancelled
unlocked: boolean; // pending and the lock has elapsed
}
vault.previewRedeem(shares)
USDC that shares would pay out at the current NAV (previewRedeem).
const payout = await client.vault.previewRedeem('100'); // '73.5835'
Returns: Promise<string> — Human-readable USDC.
vault.getIdleLiquidity()
USDC held by the vault contract right now (USDC.balanceOf(vault)). Withdrawals are paid from this; the rest of the NAV is out trading.
Returns: Promise<string> — Human-readable USDC.
vault.currentNav()
The NAV the agent last wrote (currentNav()), in USDC. '0.0' before the first write.
Returns: Promise<string> — Human-readable USDC.
vault.balance(address)
Get vault share balance for an address.
const shares = await client.vault.balance('0x...');
// '1234.567890'
Returns: Promise<string> — Human-readable share balance.
vault.sharePrice()
Get current share price (USDC per 1 share).
const price = await client.vault.sharePrice();
// '1.023456'
Returns: Promise<string> — Human-readable USDC value per share (convertToAssets(1 share)). This reflects the NAV the agent last wrote. See Share Price.
vault.totalAssets()
Get the vault's totalAssets(): the agent-written NAV, in USDC.
const tvl = await client.vault.totalAssets();
// '50000.000000'
Returns: Promise<string> — Human-readable USDC total.
vault.withdrawalRequest(address) (deprecated)
The raw withdrawalRequests(address) struct: { shares: bigint; requestTime: bigint; processed: boolean }. Use getWithdrawalRequest, which adds the unlock time.
StakingClient
Token staking operations via the ProfitDistributor contract. Accessed via client.staking. On testnet this is ProfitDistributor v2 on Ethereum Sepolia (0xAbFdcB235b56dd32cc1172C64D0550f99423FEdA), which stakes the hub 7N7D and pays rewards in Circle USDC.
Methods that write to the blockchain (stake, unstake, exit, claim) require a privateKey in the client config.
:::tip Staked in ProfitDistributor v1?
v1 on Sepolia (NETWORKS.testnet.legacy.sepolia.profitDistributorV1, 0x3d2742c5C5EdF2Fcd3A27254e27620D6c1BDDCdD) still lets its stakers leave. Pass it as contracts.profitDistributor and call client.staking.exit(), then stake into v2.
:::
Methods
staking.stake(amount)
Stake 7N7D tokens. Automatically approves token spending first.
const result = await client.staking.stake('5000'); // 5000 7N7D
// { txHash: '0x...', explorerLink: 'https://...' }
Returns: Promise<{ txHash: string; explorerLink: string }>
staking.unstake(amount)
Unstake 7N7D tokens.
const result = await client.staking.unstake('5000');
// { txHash: '0x...', explorerLink: 'https://...' }
Returns: Promise<{ txHash: string; explorerLink: string }>
staking.exit()
Unstake your whole balance and claim pending USDC rewards in one transaction (exit()).
const result = await client.staking.exit();
Returns: Promise<TxResult>
staking.earned(address)
Get pending USDC rewards for an address.
const rewards = await client.staking.earned('0x...');
// '42.500000'
Returns: Promise<string> — Human-readable USDC rewards.
staking.claim()
Claim pending USDC staking rewards.
const result = await client.staking.claim();
// { txHash: '0x...', explorerLink: 'https://...' }
Returns: Promise<{ txHash: string; explorerLink: string }>
staking.balance(address)
Get staked 7N7D token balance for an address.
const staked = await client.staking.balance('0x...');
// '5000.000000000000000000'
Returns: Promise<string> — Human-readable staked token balance.
TokenClient
7N7D token operations. Accessed via client.token.
Methods
token.balance(address)
Get 7N7D token balance for an address.
const balance = await client.token.balance('0x...');
// '10000.000000000000000000'
Returns: Promise<string> — Human-readable token balance.
token.approve(spender, amount)
Approve a spender to use 7N7D tokens.
const result = await client.token.approve('0xSpender...', '5000');
// { txHash: '0x...', explorerLink: 'https://...' }
| Parameter | Type | Description |
|---|---|---|
spender | string | Address to approve |
amount | string | Token amount in human-readable units |
Returns: Promise<{ txHash: string; explorerLink: string }>
GovernanceClient
On-chain token-listing votes on StakedGovernance. Accessed via client.governance. Voting power is your staked 7N7D in the ProfitDistributor. Every method throws ConfigError until StakedGovernance is deployed on the selected network (pass contracts.stakedGovernance to point at a deployment yourself).
proposeListing, proposeDelisting, vote and finalize require a privateKey.
Methods
governance.listPairs()
The tokens the agent may trade.
const { long, short } = await client.governance.listPairs();
// { long: ['BTC', 'ETH'], short: ['SOL', 'HYPE', 'xyz:TSLA'] }
Returns: Promise<ListedPairs> ({ long: string[]; short: string[] })
governance.proposeListing(symbol, category)
Propose adding symbol (TICKER, or HIP-3 dex:TICKER) to the long-term or short-term list. Needs at least the contract's proposal threshold in staked 7N7D.
| Parameter | Type | Description |
|---|---|---|
symbol | string | e.g. 'SOL', 'xyz:TSLA' |
category | 'long' | 'short' | Which list |
const { proposalId, txHash } = await client.governance.proposeListing('SOL', 'short');
Returns: Promise<ProposalTxResult> — TxResult plus proposalId?: bigint, read from the ProposalCreated event.
governance.proposeDelisting(symbol)
Propose removing a listed symbol. Returns: Promise<ProposalTxResult>.
governance.vote(proposalId, support)
Vote with your stake at the proposal's snapshot (the second before the proposal was created). Voting again changes your side; the weight stays the snapshot stake. Staking after a proposal was created does not add weight to it.
| Parameter | Type | Description |
|---|---|---|
proposalId | bigint | number | string | Proposal id |
support | 'for' | 'against' | 'abstain' | Your vote |
Returns: Promise<TxResult>
governance.finalize(proposalId)
After voting ends, apply the result. The tallies are already final (snapshot weights do not change), so finalizing only compares them against quorum and records the outcome. Anyone can call it.
Returns: Promise<TxResult>
governance.getProposal(proposalId)
const p = await client.governance.getProposal(7);
// { id: 7n, kind: 'TOKEN_LISTING', symbol: 'SOL', category: 'short', state: 'Active',
// startTime, endTime, quorum, forVotes, againstVotes, abstainVotes, voterCount, passed, executed, ... }
Returns: Promise<GovernanceProposal>. kind is TOKEN_LISTING | TOKEN_DELISTING | STRATEGY | TREASURY; state is Active | Ended | Succeeded | Executed | Defeated; vote weights and quorum are human-readable 7N7D amounts.
governance.votingPower(address)
Current staked 7N7D of address. This is what it would vote with on a proposal created now. Returns: Promise<string>.
governance.proposalVotingPower(proposalId, address)
The weight address votes with on proposalId: its staked 7N7D at the proposal's snapshot (proposalVotingPower on StakedGovernance v2). Returns: Promise<string>.
DelegationClient
ERC-7710 delegation encoding, on-chain redemption, and status reads.
Imported directly from @7n7d/sdk and constructed with a
DelegationClientConfig.
Methods
delegationClient.redeemDelegation(delegation, execution, walletClient)
Redeem a signed delegation on-chain by sending
DelegationManager.redeemDelegations calldata from the agent's own wallet.
The delegator can be offline and never pays gas.
const txHash = await delegationClient.redeemDelegation(
delegation,
{ target: usdcAddress, callData: transferCalldata },
walletClient,
);
| Parameter | Type | Description |
|---|---|---|
delegation | Delegation | The signed delegation to redeem |
execution | RedeemExecution | The scoped action: { target, callData, value? } |
walletClient | RedemptionWalletClient | Any client with sendTransaction({ to, data }) |
Returns: Promise<Hex> — the redemption transaction hash.
delegationClient.encodeRedeemDelegation(delegation, execution)
Encode the redeemDelegations calldata without submitting it — for callers
that wrap the action in a UserOperation instead of a direct transaction.
Returns: { to: Address; data: Hex } — the DelegationManager call target and calldata.
delegationClient.getStatus(delegation, publicClient, options?)
Read the live on-chain status of a delegation. Checks the DelegationManager's
disabled map (revocation), the timestamp caveat's after/before window, and
the ERC20 transfer amount enforcer's spent map.
const status = await delegationClient.getStatus(delegation, publicClient);
// "active" | "not_yet_active" | "expired" | "revoked" | "redeemed"
| Parameter | Type | Description |
|---|---|---|
delegation | Delegation | The delegation to check |
publicClient | Client | viem public client for the delegation's chain |
options.now | bigint (optional) | Current time in unix seconds (defaults to clock) |
Returns: Promise<DelegationStatus>
delegationClient.getRemainingAllowance(delegation, publicClient)
Read the remaining USDC the delegation still allows: maxAmount from the ERC20
transfer amount caveat minus the amount already spent on-chain.
Returns: Promise<bigint> — remaining allowance in base units (0 once fully spent).
Exported Types
All types are importable from @7n7d/sdk:
import {
type SevenNSevenDConfig,
type ContractAddresses,
type ApiResponse,
type StatusData,
type TradingEnvironment,
type Position,
type PositionFilter,
type PositionsData,
type AssetClass,
type HlNetwork,
type MarketIdentity,
type MarketReference,
type MarketActivation,
type Market,
type MarketFilter,
type MarketsData,
type MarketQuote,
type MarketState,
type AccountSnapshotData,
type BalanceData,
type ChatData,
type ContractsData,
type HealthData,
type WithdrawalRequest,
type WithdrawalRequestInfo,
type ChainOverride,
type TxResult,
type ListingCategory,
type VoteSupport,
type ListedPairs,
type GovernanceProposal,
type ProposalTxResult,
type ProposalKindName,
type ProposalStateName,
GovernanceClient,
// Delegation (ERC-7710)
DelegationClient,
type DelegationClientConfig,
type Caveat,
type Delegation,
type DelegationResult,
type DelegationStatus,
type RedeemExecution,
type RedemptionWalletClient,
type VaultDepositDelegationConfig,
CAVEAT_ENFORCERS,
DELEGATION_EIP712_DOMAIN,
ROOT_AUTHORITY,
// Agent-to-agent delegation + handshake
AgentDelegationManager,
type AgentDelegationManagerConfig,
type AcceptDelegationResult,
type DelegationAcceptancePolicy,
type DelegationRecord,
DELEGATION_TYPED_DATA_TYPES,
delegationId,
AgentHandshake,
HANDSHAKE_PROTOCOL_VERSION,
serializeHandshakeMessage,
parseHandshakeMessage,
type AgentHandshakeConfig,
type HandshakeAck,
type HandshakeOffer,
type HandshakeOfferResult,
type HandshakeRequest,
type HandshakeSession,
type HandshakeSessionState,
// Errors
SdkError,
ApiError,
ContractError,
ConfigError,
} from '@7n7d/sdk';
ApiResponse<T>
interface ApiResponse<T = unknown> {
ok: boolean;
data: T;
}
Error Classes
All errors extend SdkError:
| Class | Code | Description |
|---|---|---|
SdkError | (varies) | Base error class |
ApiError | API_ERROR | REST API request failure (includes HTTP status) |
ContractError | CONTRACT_ERROR | On-chain transaction failure |
ConfigError | CONFIG_ERROR | Invalid client configuration, a contract not deployed on the network, or a write without privateKey |
try {
await client.vault.deposit('1000');
} catch (error) {
if (error instanceof ApiError) {
console.log(error.status); // HTTP status code
}
if (error instanceof SdkError) {
console.log(error.code); // Error code string
console.log(error.message); // Human-readable message
console.log(error.cause); // Underlying error (if any)
}
}
Exported Constants
import {
NETWORKS,
DECIMALS,
API_PATHS,
SEPOLIA_TOKEN, // hub Token7N7D on Ethereum Sepolia
SEPOLIA_USDC, // Circle USDC on Ethereum Sepolia (staking rewards)
SEPOLIA_DEPLOYED, // generated: profitDistributor, stakedGovernance (Sepolia)
LEGACY_ARBITRUM_SEPOLIA, // retired V1 vault, MockUSDC, old token/distributor/governance (read-only)
LEGACY_SEPOLIA, // ProfitDistributor v1 (exit only) and the interim distributor
RETIRED_VAULT_ADDRESSES, // vaults VaultClient never writes to (lowercase)
RETIRED_USDC_ADDRESSES, // deposit assets VaultClient never approves (lowercase)
HYPEREVM_TESTNET, // Vault V2: chain 998, Circle USDC, HyperCore deposit wallet
} from '@7n7d/sdk';
ARBITRUM_SEPOLIA_TOKEN, ARBITRUM_SEPOLIA_USDC and ARBITRUM_SEPOLIA_DEPLOYED still export the retired Arbitrum Sepolia addresses but are deprecated; nothing in the SDK uses them.
NETWORKS
Pre-configured network settings for testnet and mainnet.
const NETWORKS: {
testnet: NetworkConfig;
mainnet: NetworkConfig;
};
interface NetworkConfig {
chainId: number; // testnet: 11155111 (Ethereum Sepolia); mainnet: 42161 (Arbitrum One)
name: string; // e.g. "Ethereum Sepolia"
rpcUrl: string; // JSON-RPC endpoint
explorerUrl: string; // Block explorer base URL
apiUrl: string; // 7N7D API base URL
contracts: {
token: string; // Token7N7D (testnet: the hub token, fixed 1B supply)
usdc: string; // The vault's deposit asset; empty where there is no vault
profitDistributor: string; // Staking; USDC rewards from vault fees (testnet: v2)
tradingVault: string; // Vault; empty on testnet (V1 retired, V2 is on chain 998)
stakedGovernance: string; // StakedGovernance (testnet: v2, snapshot voting)
};
// testnet only: Vault V2 on HyperEVM testnet (chain 998); addresses empty until deployed
vaultV2?: { chainId: 998; vault: string; adapter: string };
// testnet only: retired contracts, read-only history
legacy?: {
arbitrumSepolia: { // chain 421614, retired 2026-11-25
chainId: 421614; rpcUrl: string; explorerUrl: string;
tradingVaultV1: string; mockUsdc: string; token: string;
profitDistributor: string; stakedGovernance: string;
};
sepolia: { chainId: 11155111; profitDistributorV1: string; interimProfitDistributor: string };
};
}
Testnet contract addresses (Ethereum Sepolia):
| Key | Address |
|---|---|
token | 0x535bd08033A06d3CbF2D4566BafB62445eed9702 |
usdc | empty (no vault on this chain) |
tradingVault | empty (V1 retired; V2 on HyperEVM 998, not deployed yet) |
profitDistributor | 0xAbFdcB235b56dd32cc1172C64D0550f99423FEdA (v2) |
stakedGovernance | 0x925585C2cAC054b1517bB0FA28B78d7Ae4f5aA0E (v2) |
Usage:
import { NETWORKS } from '@7n7d/sdk';
// Get the testnet staking contract
const distributor = NETWORKS.testnet.contracts.profitDistributor;
// Get RPC URL for direct provider setup
const rpcUrl = NETWORKS.testnet.rpcUrl;
You typically don't need to access NETWORKS directly — the SevenNSevenD client resolves network config automatically from the network option.
DECIMALS
Token decimal constants used for parsing and formatting on-chain values.
| Key | Value | Description |
|---|---|---|
USDC | 6 | USDC decimal places |
TOKEN | 18 | 7N7D token decimals |
SHARES | 6 | V1 TradingVault share decimals (same as USDC); the V1 vault was retired on 2026-11-25 |
V2_SHARES | 12 | HyperEvmTradingVault (V2) share decimals: USDC 6 + _decimalsOffset() 6 |
Usage:
import { DECIMALS } from '@7n7d/sdk';
import { parseUnits, formatUnits } from 'viem';
// Parse 1000 USDC to on-chain units
const amount = parseUnits('1000', DECIMALS.USDC); // 1000000000n
// Format V2 vault shares from on-chain units (12 decimals)
const shares = formatUnits(rawShares, DECIMALS.V2_SHARES);
API_PATHS
REST API endpoint paths used internally by ApiClient. Exported for custom integrations.
| Key | Path | Description |
|---|---|---|
status | /api/v1/agent/status | Vault and agent status |
positions | /api/v1/agent/positions | Open trading positions |
balance | /api/v1/agent/balance | Address balance information |
chat | /api/v1/agent/chat | AI agent chat endpoint |
contracts | /api/v1/agent/contracts | Deployed contract addresses |
health | /api/v1/agent/health | Health check |
accountSnapshot | /api/v1/agent/account/snapshot | Mode-aware account snapshot |
markets | /api/markets | Market catalog (append /:marketId, /:marketId/state) |
Usage:
import { API_PATHS, NETWORKS } from '@7n7d/sdk';
// Build a custom request URL
const url = `${NETWORKS.testnet.apiUrl}${API_PATHS.status}`;
const response = await fetch(url);
Exported ABIs
Contract ABIs for direct use with ethers.js, viem, or any EVM library. Use these when you need low-level contract access beyond what the SDK clients provide.
import {
TRADING_VAULT_ABI,
USDC_ABI,
TOKEN_ABI,
PROFIT_DISTRIBUTOR_ABI,
STAKED_GOVERNANCE_ABI,
HYPEREVM_TRADING_VAULT_ABI,
HYPEREVM_DEPOSIT_ADAPTER_ABI,
} from '@7n7d/sdk';
TRADING_VAULT_ABI, PROFIT_DISTRIBUTOR_ABI, STAKED_GOVERNANCE_ABI, HYPEREVM_TRADING_VAULT_ABI and HYPEREVM_DEPOSIT_ADAPTER_ABI are generated from the contracts' compiled artifacts, so they list every function, event and custom error.
| ABI | Contract | Description |
|---|---|---|
TRADING_VAULT_ABI | TradingVault (V1, retired 2026-11-25) | Arbitrum Sepolia vault, kept for historical reads |
USDC_ABI | USDC (ERC-20) | Standard ERC-20 for USDC approve/transfer operations |
TOKEN_ABI | 7N7D Token (ERC-20) | 7N7D token: transfer, approve, balance reads |
PROFIT_DISTRIBUTOR_ABI | ProfitDistributor v2 | Staking rewards — stake, unstake, claim USDC rewards; checkpointed stakes (balanceOfAt, totalSupplyAt) |
STAKED_GOVERNANCE_ABI | StakedGovernance v2 | On-chain token listing proposals, snapshot votes (proposalSnapshot, proposalVotingPower) and the registry. castVoteReplacing, getVoters and MAX_VOTERS are gone |
HYPEREVM_TRADING_VAULT_ABI | HyperEvmTradingVault (V2, HyperEVM 998) | ERC-4626 vault with 12-decimal shares, requestWithdrawal / processWithdrawal / cancelWithdrawal, navStatus |
HYPEREVM_DEPOSIT_ADAPTER_ABI | HyperEvmDepositAdapter (V2) | Cross-chain deposit completer: depositFor with a signed intent, DepositCompleted |
Usage with viem:
import { createPublicClient, http } from 'viem';
import { arbitrumSepolia } from 'viem/chains';
import { TRADING_VAULT_ABI, NETWORKS } from '@7n7d/sdk';
// Read-only history from the retired V1 vault on Arbitrum Sepolia
const client = createPublicClient({ chain: arbitrumSepolia, transport: http() });
const tvl = await client.readContract({
address: NETWORKS.testnet.legacy.arbitrumSepolia.tradingVaultV1 as `0x${string}`,
abi: TRADING_VAULT_ABI,
functionName: 'totalAssets',
});
Vault V2 ABIs and constants
The V2 vault, HyperEvmTradingVault, and its cross-chain deposit completer, HyperEvmDepositAdapter, run on HyperEVM testnet (chain ID 998). The SDK ships their ABIs and chain constants; there is no V2 client yet, so build the contracts yourself with ethers or viem.
import { ethers } from 'ethers';
import {
HYPEREVM_TRADING_VAULT_ABI,
HYPEREVM_DEPOSIT_ADAPTER_ABI,
HYPEREVM_TESTNET,
NETWORKS,
DECIMALS,
} from '@7n7d/sdk';
const provider = new ethers.JsonRpcProvider(rpcUrl, HYPEREVM_TESTNET.chainId); // 998
const vault = new ethers.Contract(vaultAddress, HYPEREVM_TRADING_VAULT_ABI, provider);
const shares = await vault.balanceOf(address);
ethers.formatUnits(shares, DECIMALS.V2_SHARES); // V2 shares have 12 decimals
const [locked, requestTime] = await vault.withdrawalRequests(address); // (shares, requestTime)
const [navOk, assets] = await vault.navStatus();
| Export | Value |
|---|---|
HYPEREVM_TRADING_VAULT_ABI | HyperEvmTradingVault ABI, generated from the Hardhat artifact |
HYPEREVM_DEPOSIT_ADAPTER_ABI | HyperEvmDepositAdapter ABI (depositFor, depositId, sourceMessageKey, COMPLETER_ROLE, completerAllowlistEnabled, event DepositCompleted) |
HYPEREVM_TESTNET | { chainId: 998, usdc, coreDepositWallet }: Circle native USDC and the HyperCore deposit wallet on HyperEVM testnet |
NETWORKS.testnet.vaultV2 | { chainId: 998, vault, adapter }; both addresses are empty until the V2 deployment is recorded |
DECIMALS.V2_SHARES | 12: USDC's 6 decimals plus the vault's _decimalsOffset() of 6. DECIMALS.SHARES (6) is the retired V1 vault |
:::warning 12-decimal shares
V2 share balances, withdrawalRequests(...).shares, previewDeposit and convertToShares results are in 12-decimal units. Format them with DECIMALS.V2_SHARES, not DECIMALS.SHARES or DECIMALS.USDC. Asset amounts (previewRedeem, totalAssets, requiredReserve, depositCap) stay 6-decimal USDC.
:::
What differs from V1:
withdrawalRequests(address)returns(shares, requestTime); V1 returned a thirdprocessedfield. The unlock time isrequestTime + WITHDRAWAL_LOCK().deposit(assets, receiver)anddeposit(assets, receiver, minShares)are both in the ABI, as aremint(shares, receiver)andmint(shares, receiver, maxAssets). With ethers, call an overload by signature, e.g.vault['deposit(uint256,address,uint256)'](assets, receiver, minShares).- The standard ERC-4626
withdrawandredeemrevert withUseRequestWithdrawal; userequestWithdrawal(shares), thenprocessWithdrawal()after the lock, orcancelWithdrawal(). currentNav,getWithdrawalRequest,updateNavandwithdrawFundsForTradingdo not exist on V2. ReadnavStatus()(ok,assets) instead ofcurrentNav.- Custom errors:
LiquidityPending(required, idle),NavUnavailable,SlippageExceeded,UseRequestWithdrawal. Events:WithdrawalRequested(user, shares, unlockTime),WithdrawalProcessed(user, shares, assets),WithdrawalCancelled(user, shares)and the ERC-4626Deposit(sender, owner, assets, shares).
Testnet only. The V2 contracts are not audited and the deployment addresses are not published through the SDK yet.
Need Help?
- Getting Started — Installation and setup
- Deposit Guide — Deposit examples
- Withdraw Guide — Withdrawal examples
- FAQ — Common questions