Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RWA Invoice Financing

AI-assessed, tranched on-chain invoice financing for Indonesian SMEs. Unpaid invoices are tokenized as NFTs; global liquidity providers fund them through a two-tranche vault where a junior first-loss layer protects senior capital. Funding, repayment, and default loss-absorption all happen visibly on-chain.

Hackathon demo. Regulation and real fiat rails are intentionally out of scope (mock IDRX stablecoin, no licensed off-ramp). The DeFi mechanics are the star.

Monorepo layout

blockchain/   Foundry smart contracts (the star) — InvoiceNFT, tranche vaults,
              FundingManager waterfall, MockIDRX. 8 tests passing.
AI/           Zero-dependency Node risk-assessment service. Reads an invoice and
              grades it. Gemini (vision) → Groq (text) → deterministic rules.
frontend/     Next.js + wagmi + RainbowKit. LP / SME / Admin dashboards.
docs/         SPEC.md — the full design.

The mechanism (why it's interesting)

Single-pool NAV model: the FundingManager custodies all mIDRX and tracks each tranche's net asset value. Loss seniority is enforced pool-wide (junior absorbs losses first across all loans), which is what makes "senior stays whole on a default" actually true.

  • Repayment: senior principal → senior capped coupon → junior takes the residual.
  • Default: junior NAV absorbs the loss first; senior is only touched once junior is fully wiped.
  • Invariant: seniorNAV + juniorNAV == idle balance + deployed.

Each invoice is an ERC-721 with fully on-chain metadata (a self-contained SVG card whose color tracks status), and its document pinned to IPFS via Pinata.

Quick start

# 1. Contracts
cd blockchain && forge test            # 8 passing
anvil                                  # (separate terminal) local chain
forge script script/Deploy.s.sol --rpc-url http://127.0.0.1:8545 \
  --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast

# 2. AI service
cd ../AI && npm test && npm start       # :8787

# 3. Frontend
cd ../frontend && npm run write-env && npm run dev   # :3000

Then open http://localhost:3000, connect MetaMask to Anvil (chainId 31337), and walk the flow: LP deposits → SME submits → Admin approves & funds → repay, then trigger a default and watch the junior tranche absorb it while senior stays whole.

See each folder's README for details, and docs/SPEC.md for the full design.

About

AI-assessed, tranched on-chain invoice financing for Indonesian SMEs — invoice NFTs funded by a junior/senior liquidity vault.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages