PollarPollarDemo

Products

AuthenticationWalletTransactions

Integrations

KYCSoonRampNewSwapNewEarnNew

Wallet Adapters

Stellar Wallets KitPrivyNew

Adapters

Trustless Work

Built with Pollar

LumenWipeNew
OverviewImplementation

Earn

Put idle balances to work: deposit into DeFindex vaults or Blend pools and earn on-chain yield. Pollar lists every enabled provider with its live APY and renders the whole deposit-and-withdraw flow inside a modal.

Providers are configured in your dashboard

The Earn modal only offers the providers you enable under Treasury → Earn in the Pollar dashboard, intersected with server capability — Blend needs a pool address, DeFindex needs an API key. The SDK reads that selection at runtime via getEarnProviders() (the SDK_EARN_PROVIDERS response). An empty list hides the Earn UI entirely.

GET /earn/providers →
{
  "content": { "providers": ["blend", "defindex"] },
  "code": "SDK_EARN_PROVIDERS",
  "success": true
}

Drop-in button that opens a prebuilt modal — the whole provider → opportunity → deposit / withdraw flow is rendered for you.

openEarnModal() takes no arguments — provider, opportunity and amount are picked inside the modal.

Hook & values used

All of these come from the usePollar() hook — the react layer built on top of getClient().

  • usePollar()hook

    params: No arguments. Call it at the top level of a component — it reads React context, so it must run during render.

    returns: PollarContextValue — the whole SDK surface: reactive state values, modal openers, and getClient() to drop down to core.

  • getEarnProviders()async

    params: No arguments — resolves the providers this app exposes, from your dashboard selection (Treasury → Earn).

    returns: Promise<EarnProviderId[]> — enabled providers; empty means Earn is disabled for this app, so hide the Earn UI.

  • openEarnModal()sync

    params: No arguments — provider, opportunity and amount are picked inside the modal.

    returns: void — opens the prebuilt modal; there is nothing to await.

@pollar/react— hooks & components
import { usePollar } from '@pollar/react';

export function EarnButton() {
  const { openEarnModal, isAuthenticated } = usePollar();

  // openEarnModal renders the whole provider → opportunity →
  // deposit / withdraw flow on top of client.earnDeposit /
  // earnWithdraw (build + sign + submit handled for you).
  return (
    <button
      onClick={openEarnModal}
      disabled={!isAuthenticated}
    >
      Earn yield
    </button>
  );
}