Documentation

How AlignBTC works

An AI-native credit-risk underwriter for Bitcoin DeFi. It scores a borrower's on-chain Stacks history to unlock capital-efficient, under-collateralised lending — built for the Stacks Endowment grant.

Overview

Stacks-based lending protocols today require heavy over-collateralisation because no on-chain credit profiling exists. AlignBTC closes that gap: a machine-learning model parses a wallet's historical behaviour — transaction frequency, Stacking participation, and stablecoin usage — to generate an autonomous trust score (0–100).

That score is surfaced here and connected to a Clarity escrow contract on testnet, demonstrating a credible path to under-collateralised micro-lending on Bitcoin and increasing capital efficiency across sBTC markets.

The Problem

Bitcoin DeFi on Stacks is structurally constrained by the absence of native credit infrastructure. Current protocols operate fully collateralised — borrowers must lock sBTC or STX worth more than the loan. This:

  • Excludes users with strong repayment histories but little collateral
  • Locks capital inefficiently, reducing the velocity of sBTC
  • Makes micro-lending economically unviable at current ratios

The data exists — every Stacks address has a public, auditable history — but no tooling aggregates and scores it in a lending-relevant format.

How It Works

Three independently testable layers turn wallet history into a loan offer:

1 · Data pipeline (Python)

Aggregates on-chain wallet metrics from the Stacks Extended API — full transaction history, Stacking participation, and USDCx stablecoin transfers — into a feature vector per address.

2 · ML scoring engine (scikit-learn)

A Random Forest classifier (max_depth 6, 100 estimators, 5-fold CV) trained on labelled wallet profiles outputs a probability normalised to a 0–100 trust score. Target AUC-ROC ≥ 0.72.

3 · Presentation (Next.js + Clarity)

A FastAPI service serves the score as JSON. This frontend renders the score, feature breakdown, and a simulated loan offer — priced by a Clarity escrow stub deployed on Stacks testnet.

Trust Score

The model encodes each wallet as a feature vector across seven dimensions. Each contributes a weighted share of the final score:

Wallet Age · 15%

Days since first on-chain activity

Activity (90d) · 20%

Transactions in the last 90 days

Avg Tx Value · 10%

Mean STX moved per transaction

Stacking Cycles · 20%

Completed Stacking cycles

Stacking Streak · 15%

Consecutive cycles without interruption

Stablecoin Usage · 10%

USDCx send/receive events

DeFi Footprint · 10%

Distinct DeFi contracts used

Collateral Tiers

The trust score maps to a required collateral ratio. A higher score unlocks a lower requirement — the core of the capital-efficiency thesis. These tiers are enforced on-chain.

Trust scoreCollateralTier
Below 40150%Subprime
40 – 70120%Standard
Above 70100%Prime

Smart Contract

A Clarity escrow stub is deployed on Stacks testnet. Its initiate-loan function accepts a trust score and enforces the tiered collateral above; quote-collateral prices a loan without writing state. No funds move — this is a read-only/parameter-reading MVP; full escrow logic is post-grant.

Deployed contract

ST24BDDZQHPNM6CMH2NVXSGZHD1M0S3ZE1NWFPDTV.credit-underwriter

View on explorer

Tech Stack

Data pipelinePython 3.11 · pandas · requests · scikit-learn
Model servingFastAPI — REST endpoint returning the trust score as JSON
Smart contractClarity · Clarinet CLI · Stacks testnet
FrontendNext.js · TypeScript · Tailwind CSS · Stacks.js
DeploymentVercel (web) · Railway/Render (API) · GitHub (MIT)

Roadmap

M1

Weeks 1–4

Data pipeline & dataset

Parsing scripts aggregating wallet metrics; an exported labelled dataset of ≥ 500 records.

M2

Weeks 5–8

Trained model & serving

Random Forest producing a 0–100 score with AUC-ROC ≥ 0.72; FastAPI scoring service. (50% tranche.)

M3

Weeks 9–12

Frontend, contract & demo

Leather wallet integration showing score + simulated loan offer; Clarity escrow stub on testnet; demo video. (Final tranche.)

FAQ

Is this live on mainnet with real funds?

No. This is a testnet proof-of-concept. No mainnet loan origination or capital deployment happens in the grant period — and no funds move in the contract stub.

Does AlignBTC use KYC or off-chain identity?

No. Scoring uses purely public, on-chain Stacks signals — there is no identity or KYC integration.

Which chains are supported?

Stacks only. Non-Stacks chains and sBTC bridge interactions are out of scope for this grant.

Is this a lending protocol?

No — it is a scoring primitive. The goal is infrastructure any Stacks lending protocol (e.g. Zest, Granite) could integrate to offer differentiated collateral requirements.