Skip to content

BlockchainInes/nexus-lend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nexus Lend

A non-custodial collateralized lending protocol deployed on Ethereum Sepolia. Users deposit ETH as collateral to borrow ERC20 tokens, with on-chain liquidation logic and a React/TypeScript frontend.

The project demonstrates the core building blocks of decentralized lending, including collateral management, borrowing, repayment, interest accrual, and liquidation within a transparent on-chain protocol.

Nexus Lend Frontend

Test Suite — 6/6 passing, 256 fuzz runs

Motivation

Decentralized lending protocols enable users to access liquidity without relying on centralized financial institutions.

Nexus Lend demonstrates the core mechanics of collateralized on-chain lending, including collateral management, borrowing limits, interest accrual, repayment, and liquidation, while emphasizing secure smart contract design and transparent protocol logic.

Technical Architecture

The protocol is built around a single NexusLendingPool contract implementing a 150% collateralization ratio with automatic liquidation at 120%. Interest accrual is tracked per-position using block timestamps.

Smart Contract: Solidity 0.8.24 · Foundry · OpenZeppelin
Frontend: React · TypeScript · wagmi · viem · Vite
Network: Ethereum Sepolia Testnet

Protocol Flow

  1. User deposits ETH as collateral.
  2. The protocol records the collateral position.
  3. The user borrows ERC20 tokens within the allowed collateral ratio.
  4. Interest accrues over time.
  5. The borrower repays the loan and withdraws the collateral.
  6. Undercollateralized positions can be liquidated by third parties.

Core Mechanics

  • ETH collateral deposits with per-address position tracking
  • ERC20 borrowing with 150% collateralization
  • Automatic liquidation below 120% collateral ratio
  • SafeERC20 token transfers
  • ReentrancyGuard protection
  • Custom Solidity errors for gas-efficient execution

Deployment

Contract Network Address
NexusLendingPool Sepolia 0x1e96DE8C083FE1C74d2e50a50fB696941F5d9b20

Verified on Etherscan (Exact Match)

Test Suite

6 tests · 0 failures · includes fuzz testing with 256 runs per invariant

forge test -v
Test Type Status
test_DepositCollateral Unit PASS
test_Borrow Unit PASS
test_Repay Unit PASS
test_RevertWhen_BorrowExceedsLimit Unit PASS
testFuzz_DepositCollateral Fuzz (256 runs) PASS
testFuzz_BorrowNeverExceedsMax Fuzz (256 runs) PASS

Local Setup

git clone https://github.com/BlockchainInes/nexus-lend
cd nexus-lend
forge install
forge build
forge test

Deploy:

cp .env.example .env
# Add PRIVATE_KEY, SEPOLIA_RPC_URL, ETHERSCAN_API_KEY, BORROW_TOKEN
forge script script/Counter.s.sol:DeployNexusLendingPool \
  --rpc-url $SEPOLIA_RPC_URL \
  --broadcast \
  --verify

Frontend

Live demo: Coming soon: nexus-lend-ui.vercel.app

cd nexus-lend-ui
npm install
npm run dev

Security Considerations

  • Reentrancy protection on all external calls
  • Pull-over-push pattern for ETH transfers
  • Collateral locked until debt is fully repaid
  • Current version uses a simplified collateral model. A production deployment would integrate Chainlink Data Feeds for decentralized price discovery.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages