Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Lending Pool & Loans

Lending Pools

Who it's for: Capital providers — businesses, cooperatives, or investors — who want to earn interest by supplying cGHS to a pool that verified borrowers can draw from. Why it matters: Delegates set their own terms and bear first-loss risk, creating a market-driven lending layer where pool operators are accountable and borrowers get transparent pricing.

Pools are created by delegates — capital providers who supply first-loss liquidity and set terms. Borrowers draw from the pool.

POST /pool/create

Request
{
  "userAddressId": "wallet-uuid",
  "userAddress": "0xabc...",
  "stablecoin": "0x3126627A607E730E3eCF9BbfFD67fa18Deaab846",
  "interestRateBps": 1200,
  "maxLoanDurationSeconds": 2592000,
  "firstLossCapAmount": "500000000"
}
FieldConstraints
interestRateBps1–10000 (1bp = 0.01%)
maxLoanDurationSecondsMax loan term in seconds
firstLossCapAmountDelegate's first-loss deposit (base units)

Transaction batch: [approve(lendingDiamond, firstLossCapAmount), createPool(...)]

Response: { id, status: 'pending' }


POST /pool/:poolId/add-liquidity

{ "userAddressId": "...", "userAddress": "0x...", "stablecoin": "0x...", "amount": "100000000" }

POST /pool/:poolId/remove-liquidity

{ "userAddressId": "...", "userAddress": "0x...", "amount": "100000000" }

GET /pool/:poolId

{
  "stablecoin": "0x...",
  "delegate": "0x...",
  "totalLiquidity": "600000000",
  "totalBorrowed": "200000000",
  "firstLossCap": "500000000",
  "interestRateBps": 1200,
  "maxLoanDuration": 2592000,
  "active": true
}

Loans

Who it's for: Verified individuals and small business owners who need short-term working capital and have built enough on-chain credit history to qualify. Why it matters: Borrowers access funds without collateral as long as their credit tier allows it — the more consistently they repay, the more they can borrow and the lower their effective rate.

POST /loan/request

Borrow from a pool (requestLoan on-chain). Borrower must not be UNRATED (maxLtvBps > 0).

Request
{
  "userAddressId": "wallet-uuid",
  "userAddress": "0xabc...",
  "poolId": "1",
  "principal": "50000000"
}

No token approval needed — borrower receives tokens.

Response: { id, status: 'pending' }


POST /loan/:loanId/repay

Full repayment. Service reads outstandingDebt(loanId) first, then submits batch with approval.

{ "userAddressId": "...", "userAddress": "0x..." }

POST /loan/:loanId/repay-partial

{ "userAddressId": "...", "userAddress": "0x...", "amount": "25000000" }

POST /loan/:loanId/mark-default

Called by keeper or admin when dueDate has passed.

{ "callerAddressId": "...", "callerAddress": "0x..." }

Read Endpoints

GET /loan/:loanId                    — loan state + D1 tracking
GET /loan/:loanId/outstanding        — { principal, interest, totalDue }
GET /loan/borrower/:address          — all loans for an address