Leviathan accounts are stored at program-derived addresses (PDAs). The SDK provides helpers to derive these deterministically:
import { findLoanPda, findPolicyPda, loanIdBuffer } from "@leviathan/sdk/svm/pda";import { findPoolPda } from "@leviathan/sdk/svm/pda";// Derive a loan PDA from the borrower's public keyconst borrower = new PublicKey("...");const [loanPda, loanBump] = findLoanPda(borrower, loanIdBuffer(0));// Derive the associated policy PDAconst [policyPda, policyBump] = findPolicyPda(loanPda);// Derive a pool PDAconst admin = new PublicKey("...");const [poolPda, poolBump] = findPoolPda(admin);
PDA helpers accept optional programId overrides for testing against custom deployments.
import { Connection, PublicKey } from "@solana/web3.js";import { buildDepositTx } from "@leviathan/sdk/svm/transactions";const connection = new Connection("https://api.mainnet-beta.solana.com");const depositor = new PublicKey("...");const poolPda = new PublicKey("...");// Build a deposit transactionconst depositAmount = 1_000_000; // in smallest units (e.g., lamports or token base units)const tx = await buildDepositTx(connection, depositor, poolPda, depositAmount);// Sign and send (using your wallet adapter or keypair)// tx is a ready-to-sign Transaction object