SDK Reference
Installation
bash
npm install @varla/sdk viem Core Methods
| Method | Returns | Description |
|---|---|---|
readPoolSnapshot() | PoolSnapshot | Current utilization, borrow APY, supply APY, total assets |
readAccountSnapshot(address) | AccountSnapshot | Collateral, debt, health factor, borrowing capacity |
deposit(tokenId, amount) | TxHash | Deposit ERC-1155 positions as collateral |
borrow(amount) | TxHash | Borrow stablecoins against collateral |
repay(amount) | TxHash | Repay borrowed stablecoins |
withdraw(tokenId, amount) | TxHash | Withdraw collateral positions |
liquidate(borrower, tokenId, amount) | TxHash | Execute liquidation on unhealthy position |
supply(assets) | TxHash | Supply stablecoins to lending pool (lender) |
redeemShares(shares) | TxHash | Redeem vault shares for stablecoins (lender) |
Quick Example
Read pool state + deposit collateral ts
import { createVarlaClient } from '@varla/sdk';
import { createWalletClient, http } from 'viem';
import { polygon } from 'viem/chains';
const client = createVarlaClient({
chain: polygon,
transport: http(),
});
// Read current pool state
const pool = await client.readPoolSnapshot();
console.log('Supply APY:', pool.supplyAPY);
console.log('Borrow APY:', pool.borrowAPY);
console.log('Utilization:', pool.utilization);
// Deposit collateral (requires wallet)
const wallet = createWalletClient({ ... });
const varla = client.withWallet(wallet);
await varla.deposit(tokenId, amount);
await varla.borrow(parseUnits('1000', 6)); // Borrow 1000 USDC 💡 Full examples
See TypeScript SDK Getting Started for detailed integration walkthroughs with complete code samples.