Integration examples
End-to-end code samples for the most common Chamber integrations
Read a vault's current composition
import { Dhedge, Network, ethers } from "@dhedge/v2-sdk";
const provider = new ethers.providers.JsonRpcProvider(RPC_URL);
const chamber = new Dhedge(new ethers.Wallet(PK, provider), Network.POLYGON);
const vault = await chamber.loadPool(VAULT_ADDRESS);
const composition = await vault.getComposition();
console.log(composition);Deposit into a vault
const vault = await chamber.loadPool(VAULT_ADDRESS);
// ERC20 approve → deposit
await vault.approveDeposit(USDC_ADDRESS, "1000000000"); // 1000 USDC (6 decimals)
const tx = await vault.deposit(USDC_ADDRESS, "1000000000");
await tx.wait();Withdraw
Create a vault
Execute a trade
Prepare calldata without sending
Check if a protocol is supported
Query the subgraph
Set a trader
See also
Last updated

