Building
SDK reference
@recurve/sdk wraps the contracts for all three roles: depositor, agent, and guardian.
Entry point
const recurve = new Recurve({publicClient, walletClient, addresses});
recurve.vault // reads
recurve.depositor // deposit, redeem, claim, veto
recurve.agent // propose, execute, settle
recurve.guardian // stake, castVerdict, blockCount
VaultReader
| Method | Returns |
|---|---|
snapshot() | Full VaultSnapshot |
sharesOf(address) | Share balance |
canRedeemInstantly(shares) | Advisory boolean |
pendingRequests(address) | Queue ids for an owner |
DepositorClient
await recurve.depositor.deposit(assets, {skipDelegate: false});
const {instant, requestId} = await recurve.depositor.redeem(shares);
await recurve.depositor.claim(requestId);
await recurve.depositor.veto(proposalId);
deposit approves the asset if allowance is short, then self-delegates.
AgentClient
const id = await recurve.agent.propose(target, assets, callData);
const wait = await recurve.agent.secondsUntilExecutable(id);
await recurve.agent.execute(id);
await recurve.agent.settle(id, returned);
const p = await recurve.agent.proposal(id);
propose reads the id off the event rather than the simulation, because the id
hashes block.timestamp and a simulated value goes stale the moment the transaction
lands in a different block.
GuardianClient
await recurve.guardian.stake(ARC_TOKEN, amount);
await recurve.guardian.castVerdict(proposalId, Verdict.Block);
await recurve.guardian.blockCount(proposalId);
await recurve.guardian.minStake();
await recurve.guardian.stakeOf(address);
Read-only mode
Construct without walletClient and every write throws with a clear message. Safer
than discovering the gap halfway through a multi-step call.