SDK Integration

Integrating the Kasu TypeScript SDK: installation, the chains it supports, the strategies, deposits and portfolio facades, KYC signatures and configuration.

The Kasu TypeScript SDK (@kasufinance/kasu-sdk) provides a high-level API for external applications and wallets to integrate with Kasu lending pools. It handles contract interactions, subgraph queries, epoch management, and KYC flows.

Installation#

npm install @kasufinance/kasu-sdk

Quick Start#

import { Kasu } from '@kasufinance/kasu-sdk';

// Initialize with a live chain (base, xdc, xdc-usdc)
const kasu = Kasu.create({ chain: 'base', signerOrProvider: provider });

// Browse strategies (lending pools)
const strategies = await kasu.strategies.getAll();

// Deposit into a pool
const tx = await kasu.deposits.deposit({
  poolId: '0x...',
  trancheId: '0x...',
  amount: parseUnits('1000', 6), // 1,000 USDC
  kycSignature: { blockExpiration, signature },
});

// Fetch user positions
const positions = await kasu.portfolio.getPositions('0xUser...');

Supported Chains#

The SDK includes built-in configurations for all Kasu-supported networks:

Chainchain keyChain IDUnderlying AssetDeployment ModeKSU TokenStatus
Basebase8453USDCFullYesLive
XDC (AUDD)xdc50AUDDLiteNoLive
XDC (USDC)xdc-usdc50USDCLiteNoLive
Plumeplume98866pUSDLiteNoRetired

plume is kept in CHAIN_CONFIGS for its frozen history only — the deployment was drained and wound down. It carries retired: true and no default RPC, so Kasu.create({ chain: 'plume' }) throws unless you pass your own signerOrProvider. Its subgraph is on a legacy Goldsky project, not the one the live chains use.

Custom chain configurations can be passed directly:

const kasu = Kasu.create({
  chain: { chainId: 123, name: 'MyChain', isLiteDeployment: true, ... },
  signerOrProvider: provider,
});

Facades#

The SDK exposes three domain facades on the Kasu instance:

kasu.strategies — Browse Lending Pools#

MethodDescription
getAll(poolIds?)Fetch all active lending strategies (pools). Returns APY, TVL, capacity, tranches, fixed-term options
getById(poolId)Fetch a single strategy by pool address
getPlatformStats()Aggregate platform statistics (total TVL, loans, yield, loss rate)
calculateDepositLimits(tranche)Min/max deposit and available capacity for a tranche

Each Strategy includes:

interface Strategy {
  id: string;               // Pool address
  name: string;             // Pool name
  apy: number;              // Weighted-average APY (decimal, 0.08 = 8%)
  tvl: { total, offchain }; // Total value locked
  availableCapacity: string; // Remaining capacity (USDC)
  tranches: StrategyTranche[];
  assetClass: string;       // e.g. "Tax Receivables"
  apyStructure: 'Variable' | 'Fixed';
}

Each StrategyTranche includes:

interface StrategyTranche {
  id: string;               // Tranche address
  name: string;             // e.g. "Senior"
  apy: number;              // Current base APY
  minimumDeposit: string;   // Min USDC deposit
  maximumDeposit: string;   // Max USDC deposit
  availableCapacity: string;
  fixedTermOptions: FixedTermOption[];
}

kasu.deposits — Deposit & Withdraw#

MethodDescription
deposit(params)Submit a deposit request (requires KYC signature)
withdraw(params)Submit a withdrawal request for a specific USDC amount
withdrawMax(poolId, trancheId, userAddress)Withdraw entire balance from a tranche
buildKycParams(userAddress)Build parameters for the KYC signature flow
isClearingPending(poolId)Check if the pool is in a clearing period
getCurrentEpoch()Get current epoch number

Deposit Parameters#

interface DepositParams {
  poolId: string;
  trancheId: string;
  amount: BigNumberish;        // USDC in base units (6 decimals)
  kycSignature: {
    blockExpiration: BigNumberish;
    signature: BytesLike;
  };
  fixedTermConfigId?: BigNumberish; // Pass 0 for variable deposits
  swapData?: BytesLike;            // Pass '0x' for direct USDC deposits
  depositData?: BytesLike;         // Pass '0x' when not needed
}

kasu.portfolio — User Positions#

MethodDescription
getPositions(userAddress, provider?)Fetch per-pool positions and aggregate summary
getTransactionHistory(userAddress)Fetch full deposit/withdrawal/cancellation history

Returns:

interface UserPositions {
  pools: PortfolioLendingPool[];  // Per-pool breakdown
  summary: PortfolioSummary;      // Aggregate: invested, yields, APY
}

KYC Integration Flow#

Deposits require a KYC signature, minted by Kasu's own KYC signer service — identity verification itself is Didit. The integrator's flow:

  1. Call kasu.deposits.buildKycParams(userAddress) to get the signature request parameters
  2. Send these parameters to your backend, which requests the signature from the Kasu KYC signer service with the credentials Kasu issued you
  3. If the wallet's recorded KYC status is verified, the service returns a signature and a block expiration
  4. Pass the signature to kasu.deposits.deposit() in the kycSignature field
  5. The on-chain KasuAllowList contract verifies the signature during the transaction

The SDK will never mint the signature for you: it is the deposit gate, and the credentials for it do not belong in a public package. Contact Kasu to be issued them.

The signature covers the wallet, the chain and the allow list's per-user nonce — not the deposit. It expires at the returned block, so obtain it at submission time rather than caching it.

Until 2026-08 this was Compilot's customer-tx-auth-signature endpoint. buildKycParams is unchanged; only who signs is. Note that the SDK's own JSDoc still says "Nexera" in places.

Advanced: Low-Level Services#

For power users who need direct contract access, the underlying KasuSdk services are available via kasu.services:

// Direct service access
const locks = await kasu.services.Locking.getUserLocks(address);
const poolData = await kasu.services.DataService.getPoolOverview(epochId);

Available services:

ServiceDescription
LockingKSU lock/unlock, fee claims, lock periods
UserLendingDirect contract calls for deposits, withdrawals, epoch queries
DataServicePool overviews, subgraph queries, Directus CMS data
PortfolioUser portfolio and position calculations
SwapperToken swap utilities

Configuration#

The Kasu.create() method accepts optional overrides:

const kasu = Kasu.create({
  chain: 'base',
  signerOrProvider: signer,
  configOverrides: {
    subgraphUrl: 'https://custom-subgraph-url.com',
    directusUrl: 'https://custom-cms-url.com',
    contracts: { ... },       // Override contract addresses
    isLiteDeployment: false,
    UNUSED_LENDING_POOL_IDS: ['0x...'],
    poolMetadataMapping: {},  // Map pool addresses to metadata sources
  },
});

Data Sources#

The SDK combines data from three sources:

SourceData
On-chain contractsBalances, interest rates, epoch state, clearing status
Goldsky subgraphUser requests, transaction history, pool events
Directus CMSPool names, descriptions, images, asset class labels

If the Directus URL is omitted, the SDK returns on-chain and subgraph data only (pool descriptions and images will be empty).