docs / sdk

SDK Reference

Notherc is built on @yo-protocol/react. All on-chain reads and writes go through the hooks below.

Required provider setup

<PrivyProvider appId={PRIVY_APP_ID} config={privyConfig}>
  <QueryClientProvider client={queryClient}>
    <WagmiProvider config={wagmiConfig}>  {/* @privy-io/wagmi */}
      <YieldProvider>
        <App />
      </YieldProvider>
    </WagmiProvider>
  </QueryClientProvider>
</PrivyProvider>

Privy's @privy-io/wagmi adapter exposes wallet addresses as standard useAccount() — no special handling needed for YO hooks.

Vault data

useVaults
useVaults() → { vaults: Vault[] }

Returns the full list of available vaults with live 7-day APY data. Re-fetches on a configurable interval.

const { vaults } = useVaults();
const bestApy = vaults?.reduce((acc, v) => {
  const apy = parseFloat(v.yield?.["7d"] ?? "0");
  return apy > acc.apy ? { apy, id: v.id } : acc;
}, { apy: 0, id: "" });
useVaultState
useVaultState(vaultId: string) → { tvl, exchangeRate }

Returns TVL and current share/asset exchange rate for a specific vault.

const { tvl, exchangeRate } = useVaultState("yoUSD");
useUserPosition
useUserPosition(vaultId: string) → { shares, assetValue }

Returns the connected wallet's share balance and current underlying asset value for a vault.

const { shares, assetValue } = useUserPosition("yoUSD");

Deposit

useTokenBalance
useTokenBalance(tokenAddress: Address) → { balance: bigint }

Returns live ERC-20 balance for the connected wallet. Used to populate the MAX button.

const { balance } = useTokenBalance("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");
usePreviewDeposit
usePreviewDeposit(vaultId, amount: bigint) → { shares: bigint }

Simulates the vault's previewDeposit — shows exactly how many shares the user would receive. Called on every keystroke for live preview.

const { shares } = usePreviewDeposit("yoUSD", parseUnits(inputValue, 6));
useDeposit
useDeposit(vaultId) → { deposit, status, error }

Executes an ERC-20 approval followed by an ERC-4626 deposit. Exposes step-level status for UX feedback.

const { deposit, status } = useDeposit("yoUSD");
// status: "idle" | "approving" | "depositing" | "waiting" | "success" | "error"
await deposit({ amount: parseUnits("100", 6) });

Withdraw

useShareBalance
useShareBalance(vaultId: string) → { balance: bigint }

Returns the user's current share token balance for a vault. Used for the MAX button on the withdraw sheet.

const { balance: shareBalance } = useShareBalance("yoUSD");
usePreviewRedeem
usePreviewRedeem(vaultId, shares: bigint) → { assets: bigint }

Simulates previewRedeem — shows the underlying asset amount the user would receive for a given share amount.

const { assets } = usePreviewRedeem("yoUSD", shareAmount);
useRedeem
useRedeem(vaultId) → { redeem, status, error }

Executes a vault redemption. The instant flag controls whether the withdrawal settles on-chain immediately or is queued.

const { redeem, status } = useRedeem("yoUSD");
await redeem({ shares: parseUnits("50", 6), instant: true });
// instant: false → queued withdrawal, shown as "Request #X · Available within 24h"