CONFIDENTIAL & PROPRIETARY © 2025 Inkwell Finance, Inc. All Rights Reserved. This document is for informational purposes only and does not constitute legal, tax, or investment advice, nor an offer to sell or a solicitation to buy any security or other financial instrument. Any examples, structures, or flows described here are design intent only and may change.
Overview
This guide walks through the technical steps for integrating Leviathan Embedded Lending into your protocol. The integration is SDK-driven — your frontend calls the@leviathan/sdk/embedded package, which handles all communication with Leviathan’s on-chain programs.
PrerequisitesBefore starting integration, your protocol must complete the onboarding process. Onboarding establishes your protocol’s whitelist, approved functions, and revenue split configuration on-chain.
SDK Installation
Install the Leviathan SDK:@solana/web3.js as a peer dependency:
Core Client
TheEmbeddedLendingClient is your primary integration surface:
protocolId is the on-chain address of your protocol’s whitelist configuration, created during onboarding.
Key Operations
Check Credit Line Eligibility
Before offering lending features, check whether a user qualifies:leviathan-score. Users with insufficient history or low scores may not qualify.
Create Agreement
Before a user can borrow, they must accept the lending agreement:Originate a Loan
When a user draws on their credit line:Validate Capital Usage
Before executing an action with borrowed capital, validate that it conforms to the protocol’s function gate:Query Loan State
Monitor a user’s active loan:Manage Splitters
Query the revenue split configuration for a loan:Integration Pattern
The recommended integration pattern follows this flow:- Calling the SDK at the right points in your user flow
- Presenting lending options within your existing UI
- Handling wallet signing via your existing wallet adapter
- Displaying loan state and repayment progress
- Credit assessment and eligibility
- Policy enforcement and function gating
- Revenue split execution
- Loan lifecycle state transitions
Requirements
Protocol Requirements
- Whitelisted — your protocol must be registered through the onboarding process
- Verifiable revenue — user activity within your protocol must generate verifiable on-chain revenue
- Contract stability — your protocol’s contract addresses and function signatures should be stable (changes require whitelist updates)
Technical Requirements
- Solana wallet integration — your frontend must support Solana wallet signing
- SDK compatibility — TypeScript/JavaScript frontend with
@solana/web3.jssupport - RPC access — reliable Solana RPC endpoint for transaction submission and account queries
Error Handling
The SDK provides typed errors for common failure modes:| Error | Meaning |
|---|---|
NotEligible | User does not meet credit criteria |
CreditLineExhausted | User has reached their borrowing limit |
FunctionNotPermitted | Action targets a non-approved function |
LoanNotActive | Attempting to use capital from a non-active loan |
PolicyViolation | Transaction violates protocol policy constraints |