Antler by Autoflux

Examples

End-to-end walkthroughs for the most common protocol interactions.

Path: examples

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

1. SDK Setup
typescript
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" });
STATUSexample

Initialise the SDK with a signer. The SDK auto-resolves contract addresses from the deployment registry.

2. Open a levered USDC position

2. Open a levered USDC position
typescript
// Step 1 — Open vault
const vaultId = await aurum.vaults.open();
 
// Step 2 — Deposit 10,000 USDC collateral
await 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));
STATUSexample

The canonical leveraged-long ETH trade using USDC collateral.

3. Monitor and top-up before liquidation

3. Monitor and top-up before liquidation
typescript
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 safe
await aurum.vaults.deposit(vaultId, "USDC", "2000");
console.log("Topped up — new HF:", ethers.formatEther(
await aurum.core.healthFactor(signer.address)
));
}
STATUSexample

A safety-check script to run periodically. Top-up when HF drops below 1.15.

4. Full repay and close

4. Full repay and close
typescript
// Repay all ETH debt
await aurum.lending.repay("ETH", "max");
 
// Withdraw all USDC collateral
const [, 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");
STATUSexample

Clean exit — repay debt, withdraw collateral, close vault for a gas refund.