Custom Lending Protocol on Compound Fork: Expert Development

How to build a custom lending protocol on a Compound fork? We develop custom lending protocols on a Compound fork. Our experience: 5+ years in DeFi and 20+ deployments. At first glance, "making a fork" sounds simple: copy the repository, change parameters, deploy. In practice, it's the source of

Blockchain Development Services

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1450
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1308
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    1003
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1269
  • image_logo-advance_0.webp
    B2B Advance company logo design
    717
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    1008

How to build a custom lending protocol on a Compound fork?

We develop custom lending protocols on a Compound fork. Our experience: 5+ years in DeFi and 20+ deployments. At first glance, "making a fork" sounds simple: copy the repository, change parameters, deploy. In practice, it's the source of most hacks in the lending category: incorrect exchange rate calculation, broken liquidation incentive logic, a single oracle price source. We break down what you actually need to do to make a Compound fork work correctly.

What usually breaks when forking Compound

Exchange rate and accumulated interest

Compound uses the cToken concept: a user deposits DAI, receives cDAI. Over time, the exchange rate increases due to accrued interest from borrowers. The rate calculation goes through accrueInterest(), which must be called before any balance operation.

A common mistake in forks: accrueInterest() is not called everywhere needed—for example, it's omitted in a custom liquidation function. Result: exchange rate becomes stale, users see incorrect balances, or the liquidator receives less collateral than they should. In one known fork, this led to bad debt accumulation unnoticed for weeks.

Check: in tests, explicitly call vm.roll(block + N) and verify that exchangeRateCurrent() correctly increases proportionally to borrowRate and time.

Collateral factor vs liquidation threshold

In Compound V2, collateralFactor serves two roles: it determines how much can be borrowed and sets the liquidation threshold. This means a position goes into liquidation almost immediately upon crossing the borrow limit—there is no buffer between max borrow and liquidation. Aave V3 addressed this by separating LTV (loan-to-value, how much can be borrowed) and liquidationThreshold (when to liquidate). A buffer of 10-15% gives the borrower time to add collateral.

If you're building a fork for production with real users—we recommend adding this separation. It doesn't change the core math of Compound, but it significantly improves UX and reduces unnecessary liquidations during short-term volatility.

Oracle: a single Chainlink feed is insufficient

Compound V2 uses Chainlink as the sole price source. If the Chainlink feed hangs for some reason (and it happens—feeds for less liquid assets may not update for hours), the protocol operates with stale prices. In high volatility, this creates either arbitrage opportunities or bad debt risk.

Minimum protection: check the updatedAt timestamp from Chainlink and block operations if data is older than N seconds. Extended protection: a secondary oracle (e.g., Uniswap V3 TWAP as fallback) with a circuit breaker—if the two oracle prices diverge by more than X%, operations are paused.

What we customize in the fork

Typical customizations for a specific project:

  • List of supported assets. Compound supports major assets—ETH, WBTC, USDC, DAI. If you need lending for niche tokens (LST, LP tokens, RWA), we add new markets with individual risk parameters. LP tokens as collateral require separate valuation logic via underlying assets.

  • Interest rate model. Compound uses JumpRateModel: low rate at low utilization, steep increase after the kink-point (usually 80%). For stablecoin pools, kink can be higher (90%); for volatile assets, lower (60%). We set parameters (baseRate, multiplier, jumpMultiplier, kink) to fit the specific tokenomics.

  • Governance and admin functions. Compound V2 has a single admin address with broad rights. For a production protocol, minimum: Gnosis Safe multisig for admin, timelock on critical changes (risk parameters, oracle, pause guardian). Decentralized governance via Governor Bravo can be added later.

  • Isolation mode. Compound V2 does not isolate risk between assets—a problem with one token can affect the entire protocol. Compound V3 (Comet) addressed this radically by introducing single-collateral markets. For a fork, we recommend at least basic isolation: separate pools for high-risk assets.

Why forking Compound isn't just a copy?

A fork without customization is a copy with someone else's bugs. Compound V2 lags behind Aave V3 in UX due to the lack of a liquidation buffer, but our customization bridges that gap. We add isolated pools, fallback oracle, and flexible risk parameters to make the protocol more secure and user-friendly.

Stack and process

Base: the compound-protocol repository or compound-v2-subgraph for The Graph indexing. Development in Foundry: unit tests for each market, integration tests with mainnet fork to verify oracle integration.

Auditing is mandatory. Forking Compound does not mean "automatically safe"—customizations create new vectors. We recommend Code4rena or Sherlock contest for broad auditor coverage at a fixed budget.

What's included in the work

  • Requirements analysis and architecture design
  • Smart contract development and customization
  • Unit and integration tests (coverage >90%)
  • Internal audit with Slither, Echidna, manual review
  • Testnet and mainnet deployment
  • Integration with Gnosis Safe, timelock, subgraph
  • Technical documentation and client team training

Estimated timelines

Stage Duration Content
Design 1-2 weeks Risk parameters, asset list, governance model
Development 4-8 weeks Contracts, customizations, tests
Internal audit 1-2 weeks Slither, Echidna, manual review
External audit 2-4 weeks Mandatory before mainnet
Deployment & monitoring 1 week Gnosis Safe, subgraph, dashboard

Basic fork with minimal parameter changes: 4-6 weeks development. Fork with significant customizations (new interest rate model, isolation pools, custom oracle): 8-12 weeks. Audit runs parallel to the last weeks of development, but the final code must be frozen two weeks before audit starts.

Comparison: Compound V2 vs custom fork

Feature Compound V2 Our custom fork
Liquidation buffer No 10-15% (LTV vs liquidationThreshold)
Oracle Chainlink solo Chainlink + Uniswap V3 TWAP fallback
Governance Single admin Multisig + timelock (until full DAO)
Risk isolation No Basic isolation pools

Ready to discuss your project? Contact us for a consultation. Order turnkey development and get a reliable lending protocol with quality assurance.