Skip to main content
CONFIDENTIAL & PROPRIETARY © 2026 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:
The SDK requires @solana/web3.js as a peer dependency:

Core Client

The EmbeddedLendingClient is your primary integration surface:
The 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:
Eligibility is determined by the user’s on-chain credit score from 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:
The agreement links the legal terms (hashed) with the on-chain credit line parameters. Both parties can verify that the on-chain state matches the signed document.

Originate a Loan

When a user draws on their credit line:
Once originated, capital is deployed into a policy-gated environment scoped to your protocol’s approved function set.

Validate Capital Usage

Before executing an action with borrowed capital, validate that it conforms to the protocol’s function gate:
This client-side check mirrors the on-chain enforcement — use it to prevent users from submitting transactions that would be rejected, improving UX.

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:
Your protocol frontend is responsible for:
  • 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
Leviathan’s on-chain programs handle:
  • 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.js support
  • RPC access — reliable Solana RPC endpoint for transaction submission and account queries

Error Handling

The SDK provides typed errors for common failure modes: Handle these in your UI to provide clear feedback to users.

Next Steps

Protocol Onboarding

Complete the onboarding process to start integrating

Architecture

Understand the on-chain modules powering Embedded