Skip to main content

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 ID 421614), 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 a ConfigError naming it. Mainnet is not live.
  • StakedGovernance is not deployed on testnet yet. Until it is, client.governance calls throw the same ConfigError.

See How Testnet Works. :::

What's in the package​

ClientWhat it does
client.apiREST: status, positions, markets, market, marketState, accountSnapshot, balance, chat, contracts, health
client.vaultdeposit, requestWithdrawal, completeWithdrawal, cancelWithdrawal, getWithdrawalRequest, previewRedeem, getIdleLiquidity, currentNav, balance, sharePrice, totalAssets
client.stakingstake, unstake, exit, earned, claim, balance
client.governanceStakedGovernance: listPairs, proposeListing, proposeDelisting, vote, finalize, getProposal, votingPower
client.tokenbalance, approve
DelegationClient and related exportsERC-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 with STAKED_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, then completeWithdrawal() 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() calls getReward(). 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.
  • privateKey is only needed for transactions. Read calls and the REST API work without it.

Next​

  1. Getting Started
  2. Depositing USDC
  3. Withdrawing
  4. Checking Balances
  5. API Reference