Skip to content

CreditScore.sol

UUPS-upgradeable on-chain credit scoring. Tracks farmer repayment history, delivery consistency, and cooperative standing. Portable, permanent, and public — any MFI can query it before approving a loan.

EventScore changeNotes
Account created+500Starting score for every farmer
On-time repayment (EXPORTED triggers auto-repay)+50Per loan cycle
On-time batch delivery+10Per delivery, even without a loan
Default (loan not repaid after forbearance)−100Farmer blocked from new loans
Cooperative penalty (late cooperative-level obligations)−25Applied to all farmers in that cooperative
Score floor0Cannot go below zero
Score ceiling850Maximum score

As credit score improves, farmers access higher LTV and larger loan ceilings:

Score rangeLTV tierMax loan (USDC)Notes
500–549Standard$200Starting tier
550–649Enhanced$500After 1–2 successful repayments
650–749Premium$1,500After 3–5 successful repayments
750–850Institutional$5,000Cooperative-level loans available
// Get current score (public — any MFI can call)
function getScore(string calldata farmerId) external view returns (uint256);
// Record successful repayment (VAULT_ROLE — called by LendingVault on SETTLED)
function recordRepayment(string calldata farmerId) external onlyRole(VAULT_ROLE);
// Record delivery (AGENT_ROLE — called by API on DELIVERED)
function recordDelivery(string calldata farmerId) external onlyRole(AGENT_ROLE);
// Record default (VAULT_ROLE — called by LendingVault after forbearance expires)
function recordDefault(string calldata farmerId) external onlyRole(VAULT_ROLE);
// Get loan tier for farmer (used by LendingVault.originate)
function getLoanTier(string calldata farmerId)
external view returns (uint256 maxLoanUsdc, uint256 ltvBps);

Keeping scores public has genuine privacy tradeoffs. The design rationale:

  • Scores are linked to MAAIF farmer IDs (government-issued) — not to phone numbers or names
  • A government ID being associated with creditworthiness is the same as a credit bureau report — standard in formal finance
  • The alternative (private scores) requires AsiliChain to act as a credit bureau with associated regulatory obligations
  • Public scores allow multiple MFIs to compete for the same farmer’s loan — which drives rates down, benefiting the farmer
  • Farmers can build score history and take it to any future lender — true financial inclusion

A farmer’s CreditScore follows their MAAIF farmer ID — not their current cooperative membership. If a farmer moves to a different cooperative, their score persists. This is the mechanism that makes formal credit history genuinely portable for the first time.

// Score is keyed by MAAIF farmer ID, not wallet address
// Farmers can switch cooperatives without losing credit history
mapping(string => uint256) public scores; // maaifId → score
mapping(string => uint256[]) public scoreHistory; // maaifId → [score snapshots]
mapping(string => uint256) public lastUpdated; // maaifId → timestamp