7N7D SDK
@7n7d/sdk (v0.2.0) is a TypeScript client for the 7N7D REST API and contracts. It is built on ethers v6, and the delegation module uses viem.
:::info Networks
network: 'testnet'(the default) is Arbitrum Sepolia (chain ID421614), the network the 7N7D app runs on. The SDK reads and writes the same vault, staking and governance contracts as the app.network: 'mainnet'(Arbitrum One,42161) has no deployment yet. Every contract address is empty, and a call that needs one throws aConfigErrornaming it. Mainnet is not live.- StakedGovernance is not deployed on testnet yet. Until it is,
client.governancecalls throw the sameConfigError.
See How Testnet Works. :::
What's in the package
| Client | What it does |
|---|---|
client.api | REST: status, positions, markets, market, marketState, accountSnapshot, balance, chat, contracts, health |
client.vault | deposit, requestWithdrawal, completeWithdrawal, cancelWithdrawal, getWithdrawalRequest, previewRedeem, getIdleLiquidity, currentNav, balance, sharePrice, totalAssets |
client.staking | stake, unstake, exit, earned, claim, balance |
client.governance | StakedGovernance: listPairs, proposeListing, proposeDelisting, vote, finalize, getProposal, votingPower |
client.token | balance, approve |
DelegationClient and related exports | ERC-7710 delegations on Arbitrum Sepolia. See Delegation |
What the SDK does not have:
- APY, earnings or performance-history helpers.
- Strategy and treasury proposals (
proposeStrategy,proposeTreasury). Call StakedGovernance directly withSTAKED_GOVERNANCE_ABI. - Cross-chain deposits, React hooks, and a browser bundle.
Quick example
import { SevenNSevenD } from '@7n7d/sdk';
const client = new SevenNSevenD({
apiKey: process.env.SEVEN_N_SEVEN_D_API_KEY!,
network: 'testnet', // default: Arbitrum Sepolia
privateKey: process.env.PRIVATE_KEY, // only for transactions
});
// REST
const status = await client.api.status();
const positions = await client.api.positions({ assetClass: 'CRYPTO' });
// On-chain
const price = await client.vault.sharePrice(); // USDC per share
const tx = await client.vault.requestWithdrawal('100'); // locks 100 SHARES for 7 days
Vault semantics the SDK inherits
- Withdrawals take two steps.
requestWithdrawal(shares)locks the shares for 7 days, thencompleteWithdrawal()pays USDC. Completing needs enough idle USDC in the vault (getIdleLiquidity()). See Withdrawing. vault.sharePrice()reflects the NAV the agent last wrote, which is at most hourly and capped per update. See Share Price.staking.claim()callsgetReward(). Staking distribution is currently off. See Staking.
Security
- Never put private keys in client-side code. Load them from environment variables or a signer service.
privateKeyis only needed for transactions. Read calls and the REST API work without it.