Examples
End-to-end walkthroughs for the most common protocol interactions.
Third-party documentation. This is independently authored analysis of the public Aurum Protocol codebase — not the official docs, and not reviewed or endorsed by the Aurum Protocol team.
End-to-End Examples
These walkthroughs show complete interaction sequences. All code uses ethers v6 and assumes a provider connected to an Aurum-enabled network.
Setup
Install dependencies and configure the SDK before running any example:
Examples
1. SDK Setup
import { AurumSDK } from "@aurum-protocol/sdk";import { JsonRpcProvider, Wallet } from "ethers";const provider = new JsonRpcProvider(process.env.RPC_URL);const signer = new Wallet(process.env.PRIVATE_KEY!, provider);const aurum = new AurumSDK({ signer, network: "mainnet" });
Initialise the SDK with a signer. The SDK auto-resolves contract addresses from the deployment registry.
2. Open a levered USDC position
// Step 1 — Open vaultconst vaultId = await aurum.vaults.open();// Step 2 — Deposit 10,000 USDC collateralawait aurum.vaults.deposit(vaultId, "USDC", "10000");// Step 3 — Borrow 6,000 USDC worth of ETH (60% LTV)const ethPrice = await aurum.oracle.getPrice("ETH");const ethAmount = (6000e18 / Number(ethPrice)).toFixed(6);await aurum.lending.borrow("ETH", ethAmount);console.log("Position open — health factor:", await aurum.core.healthFactor(signer.address));
The canonical leveraged-long ETH trade using USDC collateral.
3. Monitor and top-up before liquidation
const hf = await aurum.core.healthFactor(signer.address);console.log("Current HF:", ethers.formatEther(hf));if (hf < ethers.parseEther("1.15")) {// Deposit more collateral to stay safeawait aurum.vaults.deposit(vaultId, "USDC", "2000");console.log("Topped up — new HF:", ethers.formatEther(await aurum.core.healthFactor(signer.address)));}
A safety-check script to run periodically. Top-up when HF drops below 1.15.
4. Full repay and close
// Repay all ETH debtawait aurum.lending.repay("ETH", "max");// Withdraw all USDC collateralconst [, balances] = await aurum.vaults.getAssets(vaultId);await aurum.vaults.withdraw(vaultId, "USDC", balances[0]);// Close vault (gas refund)await aurum.vaults.close(vaultId);console.log("Position fully unwound");
Clean exit — repay debt, withdraw collateral, close vault for a gas refund.
