SDK

TypeScript SDK for creating vaults, trading, and managing positions

The Chamber SDK is the TypeScript wrapper over the vault contracts. It covers vault creation, deposits, withdrawals, trading across supported protocols, and LP/lending/perp operations — all composed into guard-compliant transactions.

Package: @dhedge/v2-sdk (npm name is staying — code identifiers don't rebrand) Install: npm install @dhedge/v2-sdk Requires: ethers v5 with a signer connected to an RPC for a supported chain.

Supported chains

The SDK tracks contract deployments but typically trails by a release. If you need a chain, asset, or protocol that's live in the contracts but not in the installed SDK version, call the contracts directly. The deployment matrix, contract addresses, and Guard System pages are the authoritative sources for what Chamber supports — not the SDK.

The SDK's Network enum currently covers Polygon, Optimism, Arbitrum, Base, Ethereum, Plasma, and HyperEVM (exposed in code as Network.HYPERLIQUID). Pin a version and verify the enum on it before targeting newer chains.

Quick start

import { Dhedge, Dapp, Network, ethers } from "@dhedge/v2-sdk";

const provider = new ethers.providers.JsonRpcProvider(providerUrl);
const wallet = new ethers.Wallet(privateKey, provider);
const chamber = new Dhedge(wallet, Network.POLYGON);

The Dhedge client needs a wallet with a connected provider — a read-only provider is not enough for state-changing calls.

Creating a vault

const vault = await chamber.createPool(
  "Alice", // manager name (display)
  "My Vault", // vault name
  "MVLT", // token symbol
  [
    // enabled assets: [address, isDepositAsset]
    [usdcAddress, true],
    [wethAddress, false],
  ],
  10, // performance fee (percent, 0–50)
  2, // management fee (percent/yr, 0–3)
  0, // entry fee (percent, 0–2)
  0, // exit fee (percent, 0–2)
);

See create a vault for the manager-facing walkthrough of what these parameters mean. Fees are entered as percentages (e.g. 10 = 10%, matching the UI). Respect the fee caps.

Loading an existing vault

For non-Chamber contracts (other pools not created by the factory), pass a second argument: loadPool(address, false).

Core vault operations

Every method returns either a sent transaction or, when you pass sdkOptions, the prepared calldata so you can sign externally.

Composition and state

A few manager-side contract functions don't yet have SDK wrappers — notably setMaxSupplyCap (deposit limit) and setPoolLogic. Use the contracts directly for those; the Chamber apparrow-up-right UI also exposes them. See permissions & access and create a vault.

Deposits and withdrawals

deposit and withdraw wrap the vault's underlying deposit / withdraw calls. The SDK's withdraw returns a pro-rata slice of the vault's holdings. For withdrawals that involve complex assets (LPs, perps, lending positions), you currently need to call withdrawSafe on the contract directly with an encoded ComplexAsset[] argument — the SDK doesn't yet wrap this. See Lockup & withdrawals for the underlying semantics.

Trading

The Dapp enum covers the aggregators, DEXes, and protocols the SDK wraps — currently including Uniswap V3, 1inch, Odos, KyberSwap, CoW Swap, Pendle, Aave (V2 and V3), Compound V3, Fluid (via the Compound V3 surface), Velodrome (V2 and CL), Aerodrome (and CL), PancakeSwap CL, Toros, and Hyperliquid.

Flat Money has contract-level guards but isn't yet wrapped in the SDK — trades on it go through the contracts directly.

Each SDK route is composed into a guard-compliant call. Check Dapp in the installed version for the exact list, and the Guard System page for the full set of protocols Chamber allows at the contract level.

LP, lending, perps

  • addLiquidityUniswapV3 — concentrated liquidity mint (Uniswap V3, Velodrome CL, Aerodrome CL, Pancake CL)

  • addLiquidityV2 — Velodrome V2, Aerodrome

  • lend / withdrawDeposit / borrow / repay — Aave V2 / V3

  • lendCompoundV3 / withdrawCompoundV3 / harvestCompoundV3Rewards — Compound V3 and Fluid

  • depositHyperliquid / perpToSpotHyperliquid / spotToPerpHyperliquid / withdrawHyperliquid — Hyperliquid wallet/bridge ops

  • openMarketOrderHyperliquid / closePositionHyperliquid — Hyperliquid perps

  • approveTorosLimitOrder / createTorosLimitOrder / modifyTorosLimitOrder / deleteTorosLimitOrder — Toros stop-loss / take-profit

  • mintUnitViaFlatMoney / redeemUnitViaFlatMoney / cancelOrderViaFlatMoney — Flat Money

Method surface and supported protocols move with releases. Check the SDK's exported types on the installed version.

Getting calldata without sending

Most methods accept an sdkOptions argument for dry-runs:

Pass onlyGetTxData: true to return the encoded transaction rather than broadcasting it. This is how you'd integrate the SDK into a multisig flow, or hand the calldata to a user's wallet to sign.

Version pinning

  • The SDK tracks the contracts repo's version tags. Pin to a minor version in production and test across upgrades.

  • Breaking changes to method signatures are documented in the repo's CHANGELOG.md.

See also

Last updated