Integrate USDRIF Vault on Rootstock
The Vaults SDK is a TypeScript client for the USDRIF yield vault on Rootstock. You can deposit USDRIF, hold shares, and redeem or withdraw back to USDRIF using the Vault SDK. Refer to the repository README as the source of truth for installation steps, and contract addresses.
About the SDK
You connect a viem WalletClient and optional PublicClient to the SDK. Read calls go through sdk.vault (vault metrics, strategies, user position, previews, allowance). Write calls go through sdk.write (approve USDRIF, deposit, withdraw, redeem, including slippage-protected variants).
You still pay transaction fees in rBTC. Deposits and withdrawals use USDRIF (and the protocol may surface USDT0 balances where relevant). Do not assume estimated APY or strategy names are guarantees. They are on-chain views that can change with market conditions and allocator updates.
Prerequisites
- Node.js and a package manager compatible with the README install path.
- A wallet funded with rBTC on Rootstock Testnet (chain ID
31) for gas. Mainnet (chain ID30) support in the SDK is coming soon per the README. - USDRIF in that wallet for testnet.
- An RPC URL you are allowed to use in production (the README examples use Rootstock RPC with an API key).
Initialize the SDK
Pass chain ID 31 for testnet or 30 for mainnet when it is available. Optional overrides include rpcUrl, vaultAddress, usdrifAddress, and usdt0Address if you run against custom deployments.
import { VaultsSDK } from "@rsksmart/vaults-sdk"
// 31 = Rootstock Testnet, 30 = Mainnet (when supported)
const sdk = new VaultsSDK({ chainId: 31 })
Testnet contract addresses and the latest options are listed in the Vaults SDK README.
Read vault state
Call getVaultInfo() for aggregate metrics: total assets, total shares, estimated APY, price per share, buffer ratio, and buffer balance. Call getStrategies() for per-strategy allocation and APY. Use getUserBalance(address) for shares, USDRIF equivalent, wallet balances, and max withdraw or redeem amounts.
const vaultInfo = await sdk.vault.getVaultInfo()
console.log("Total assets:", vaultInfo.totalAssets.formatted, "USDRIF")
console.log("Estimated APY:", vaultInfo.estimatedApy.toFixed(2), "%")
const { strategies } = await sdk.vault.getStrategies()