Skip to content

feat: add microloans stack type with MiniPay flows - #200

Draft
nomoregas wants to merge 1 commit into
BreadchainCoop:developmentfrom
nomoregas:feat/microloans
Draft

nomoregas wants to merge 1 commit into
BreadchainCoop:developmentfrom
nomoregas:feat/microloans

Conversation

@nomoregas

Copy link
Copy Markdown

Adds a Microloans stack type for the step-up microloans contract (BreadchainCoop/saving-circles#198): a lender offers a zero-interest loan to one borrower and escrows a grant that unlocks once the loan is repaid. Everything is behind the new microloans feature flag.

What's in it

  • /new/microloan: offer a loan (approve + create). Optional borrower address and a plain-language agreement whose hash becomes termsHash.
  • /microloans/[id]:
    • Borrower: accept (when there's an agreement, the pasted text must match before Accept enables) and repay any amount, with an "All" shortcut.
    • Anyone: release the grant once the loan is repaid.
    • Lender: set the borrower, cancel, extend the deadline, reclaim the grant when overdue, and collect repayments.
  • Microloans list on the account page.
  • Low-balance hint that links to MiniPay Add Cash.
  • waitForTxReceipt now returns the receipt, so create can read LoanCreated. Existing callers ignore the return value.

Chain state only for now: no Supabase metadata or invite links.

Testnet deployment

Microloans is deployed on Celo Sepolia at 0xbB1428678354c1694188066Bf5C04BcfaD5C9653, with test USDC (0x01C5C0122039549AD1493B8220cABEdD739BC44E) allowed.

To make the deploy preview usable (needs a maintainer)

Add these to the deploy-preview environment in Netlify. It must be a Celo Sepolia environment (NEXT_PUBLIC_CHAIN_ID=11142220, USDC deposit token with 6 decimals):

  • NEXT_PUBLIC_MICROLOANS_CONTRACT_ADDRESS=0xbB1428678354c1694188066Bf5C04BcfaD5C9653
  • "microloans":{"enabled":true} added to NEXT_PUBLIC_FEATURES

Testing

  • pnpm lint, tsc, and prettier --check . pass.
  • Ran the MiniPay provider stack against a local anvil chain with a window.ethereum.isMiniPay shim, at a 375px viewport. Exercised these flows and checked the on-chain results:
    • create (approve + create, redirect)
    • set borrower
    • accept (with mismatched and matching agreement text)
    • repay in full
    • release grant
    • collect
    • the account list
  • Not yet exercised: cancel, extend, and reclaim (they need an expired or overdue loan), plus a real MiniPay device.

Lender offers a zero-interest loan and escrows a grant that unlocks on
repayment (saving-circles Microloans contract). Behind the `microloans`
feature flag:

- /new/microloan: offer a loan (approve + create), optional borrower and
  plain-language agreement hashed into termsHash
- /microloans/[id]: borrower accepts (pasted agreement must match) and
  repays; anyone releases the grant once repaid; lender sets the borrower,
  cancels, extends the deadline, reclaims the grant when overdue, and
  collects repayments
- Microloans list on the account page
- Low-balance hint links to MiniPay Add Cash
- waitForTxReceipt now returns the receipt so create can read LoanCreated

Chain state only for now: no Supabase metadata or invite links.
@netlify

netlify Bot commented Oct 7, 2026

Copy link
Copy Markdown

👷 Deploy request for app-stacks pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit cac1555

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants