> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inkwell.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Credit Scoring

> How Leviathan assesses borrower creditworthiness with on-chain scores, ML models, and oracle integration.

> **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

Leviathan's credit scoring system, managed by the `leviathan-score` Solana program, provides **on-chain credit assessments** for borrowers. Every borrower has a score between 0 and 1000 that determines their borrowing terms, limits, and eligibility across the protocol.

The system is designed around a key principle: **scores live on-chain for transparency and composability, while the raw data and models that produce them remain off-chain for privacy and flexibility.**

## How Scoring Works

```mermaid theme={null}
graph LR
    A[Borrower History] --> B[ML Scoring Pipeline]
    B --> C[Oracle Feed]
    C --> D[On-Chain Score Account]
    D --> E[Loan Terms & Eligibility]
```

### 1. Data Collection

The scoring pipeline analyzes a borrower's on-chain footprint:

* Trading history and portfolio composition
* Historical performance across markets and protocols
* Position sizing patterns and risk management behavior
* Repayment history on previous Leviathan loans

Data is collected from public on-chain sources. Borrowers are not required to submit documentation or undergo manual review — their on-chain track record speaks for itself.

### 2. ML Analysis

An **ensemble of machine learning models** evaluates the collected data:

* Multiple models analyze different aspects of borrower behavior
* Model outputs are combined to produce a robust, well-calibrated score
* The ensemble approach reduces the impact of any single model's weaknesses

The ML pipeline runs off-chain to maintain model privacy and computational flexibility. Specific model architectures and training data are not disclosed.

### 3. Score Publication

Computed scores are published on-chain through oracle integration:

* Scores are written to per-borrower **credit registry accounts** on Solana
* Each score update includes a timestamp for freshness tracking
* Historical score data is preserved, enabling trend analysis

### 4. Term Determination

On-chain scores directly affect borrowing parameters:

* Higher scores unlock better rates, higher limits, and longer terms
* Lower scores result in more conservative terms or ineligibility
* Score thresholds are enforced programmatically — there is no manual override

## Score Range and Tiers

Scores map to risk tiers that the protocol uses for term determination:

| Range    | Tier      | Implication                                    |
| -------- | --------- | ---------------------------------------------- |
| 800–1000 | Excellent | Best available terms, highest borrowing limits |
| 600–799  | Good      | Competitive terms with standard limits         |
| 400–599  | Fair      | Conservative terms, reduced limits             |
| 200–399  | Poor      | Limited eligibility, restrictive terms         |
| 0–199    | Very Poor | May not qualify for lending                    |

<Note>
  Tier boundaries and their associated terms are configurable per lending pool. Different pools may interpret the same score differently based on their risk appetite.
</Note>

## Privacy Model

The credit scoring system balances transparency with privacy:

**On-chain (public):**

* Credit score (0–1000)
* Risk tier classification
* Score timestamps and update history
* Loan performance history (repayments, defaults)

**Off-chain (private):**

* Raw trading data and transaction history
* ML model inputs and feature vectors
* Model architectures, weights, and training data
* Intermediate scoring calculations

This separation ensures that borrowers benefit from transparent, verifiable scores while their detailed financial behavior is not exposed on a public ledger.

## Oracle Integration

Scores are bridged from the off-chain ML pipeline to on-chain accounts through oracle feeds:

* Oracle operators submit score updates with cryptographic attestations
* The `leviathan-score` program validates attestations before accepting updates
* Stale scores (beyond a configurable age threshold) can be flagged or excluded from lending decisions

Oracle integration ensures that on-chain programs can trust the integrity of off-chain computations without needing to replicate the full scoring pipeline on-chain.

## Composability

Because credit scores live on-chain as standard Solana accounts, they are **composable**:

* Other programs can read a borrower's score to make their own lending or risk decisions
* Scores can be used as inputs to automated strategies or governance mechanisms
* Third-party protocols can integrate Leviathan credit data without permission

This creates a shared credit layer that benefits the broader ecosystem, not just Leviathan's own lending pools.
