Getting started
Quickstart
Install the SDK, point it at a vault, and read its state. Then deposit.
Install
npm install @recurvemoney/sdk viem
viem is a peer dependency. The SDK reuses the clients you already have rather than
opening its own transport. It ships as ESM only and needs Node 20 or newer.
Connect
viem 2.55 and newer ship Robinhood Chain, so import it. Pass the chain to both
clients: the SDK forwards walletClient.chain to every transaction as-is and never
checks that your clients and your addresses agree on a chain id, so the chain and the address
set always travel together.
import {createPublicClient, createWalletClient, http} from "viem";
import {robinhood} from "viem/chains"; // Robinhood Chain (chain id 4663)
import {privateKeyToAccount} from "viem/accounts";
import {Recurve, type RecurveAddresses} from "@recurvemoney/sdk";
const chain = robinhood;
const addresses: RecurveAddresses = {
vault: "0x...",
governor: "0x...",
registry: "0x...",
};
const publicClient = createPublicClient({chain, transport: http()});
const recurve = new Recurve({publicClient, addresses});
Every address is under Contracts. On viem older than 2.55,
build the chain with defineChain (id 4663, RPC
https://rpc.mainnet.chain.robinhood.com).
Leaving out walletClient gives you a read-only instance. Every write rejects
immediately with This call needs a walletClient; the SDK was built read-only.
instead of failing partway through, which is what you want in an indexer.
Read a vault
const snap = await recurve.vault.snapshot();
snap.totalAssets // everything the vault owes depositors: idle balance + deployedAssets
snap.float // the idle balance, what an exit can take right now
snap.deployedAssets // committed to a live strategy
snap.totalSupply // shares outstanding
snap.sharePrice // asset base units per 1e18 shares; exactly 1e18 while the vault is empty
snap.asset // the ERC-20 the fund is denominated in
Every number is a bigint in on-chain base units; the SDK never reads
decimals() or formats. float and deployedAssets sum to
totalAssets: a position mid-strategy still belongs to depositors, so it stays
counted.
Deposit
const walletClient = createWalletClient({
account: privateKeyToAccount(PRIVATE_KEY),
chain, // the same chain the addresses belong to
transport: http(),
});
const recurveWithWallet = new Recurve({publicClient, walletClient, addresses});
const hash = await recurveWithWallet.depositor.deposit(1_000_000n); // 1 USDG, which has 6 decimals
That is up to three transactions, each awaited to its receipt: an unlimited
approve of the asset to the vault if the allowance is short, the
deposit itself (the receiver is always the signer), and a
delegate to the signer. Only the deposit hash is returned.
ERC20Votes weight is zero until delegated. A depositor who skips that step holds shares
that cannot veto anything, and only finds out during a live proposal. The SDK delegates for
you on every deposit; pass {skipDelegate: true} if you delegate elsewhere.
Exit
const {instant, requestId} = await recurveWithWallet.depositor.redeem(500_000n); // 0.5 rvFUND
if (!instant && requestId !== undefined) {
// The float did not cover it. Claim once the vault's balance does.
await recurveWithWallet.depositor.claim(requestId);
}
Branch on instant rather than assuming, and check requestId
explicitly — its type is bigint | undefined, and TypeScript will not narrow it
from instant. claim reverts with RequestNotReady until
the vault's idle balance covers the request. The SDK has no read for a queued request; with the
full vault ABI, withdrawalQueue(requestId) returns its shares and
claimed flag, and it is claimable once previewRedeem(shares) <= float().
Next
The full method list is on the SDK reference. Proposing, executing and settling as an agent is on Running the agent; staking and verdicts on the watcher skill.