Skip to content

Repository files navigation

⏳ Fixed-Term ETH Deposit Simulator

A fixed-term deposit smart contract where users can lock ETH for a set duration and automatically earn simple fixed interest upon maturity.


🧩 Overview

This smart contract simulates a traditional fixed(TradFi) deposit account using Ethereum.

Users deposit ETH for a fixed period. After the term expires, Chainlink Automation detects maturity and automatically triggers a payout of the principal + interest.

This project focuses on time-based automation, state transitions, and decentralized payout scheduling — no randomness, multi-user pooling, or external oracles beyond time and automation.


🛠️ Features

  • Fixed-term locking – Users deposit ETH that remains locked for a predefined duration.
  • 💰 Earn fixed interest – Upon maturity, users receive their deposit plus a simple fixed interest (funded from contract preload for simplicity).
  • ⚙️ Chainlink Automation – Automatically calls the payout function when the term ends.
  • ⏲️ Time-based logic – Uses block.timestamp for duration tracking.
  • 🔒 State control – Transitions from OPEN → LOCKED → PAYING_OUT.
  • 🧪 Fully testable – Includes Foundry tests with time manipulation (vm.warp) and upkeep simulation.

📄 Contract Flow

  1. Deposit ETH

    • User calls depositEth() with the required minimum deposit.
    • Contract locks and starts the fixed-term timer.
  2. Wait for Term Completion

    • Contract tracks elapsed time using block.timestamp.
    • During this period, ETH remains locked and cannot be withdrawn.
  3. Chainlink Automation Check

    • Chainlink Automation regularly calls checkUpkeep() to see if the term has ended.
    • When maturity is reached, performUpkeep() automatically triggers.
  4. Payout Execution

    • Contract transitions to the PAYING_OUT state.
    • Payout function releases principal + fixed interest back to the depositor.
  5. Reset or End

    • Once payout completes, the contract resets and emits the completed fixed deposit.

🔧 Constructor Parameters

Parameter Type Description
minimumDeposit uint256 The minimum eth deposit needed to enter the contract.
termPeriod uint256 Duration (in seconds) of the fixed deposit term.

⚙️ Example Setup (Local / Anvil)

  • Contract is preloaded with 0.1 ETH to fund interest payments.
  • Chainlink AutomationRegistrar is mocked locally for testing.
  • Foundry test suite uses:
    • vm.warp() to simulate time passing
    • vm.deal() to assign ETH balances
    • vm.recordLogs() to assert Automation-triggered state changes

🧱 Project Goals

This project demonstrates:

  • Automated smart contract execution (via Chainlink Automation)
  • Deterministic time-based logic
  • Secure payout mechanisms
  • Strong test-driven smart contract development

🧪 Example Test Scenarios

  • ✅ User deposits ETH → contract locks funds
  • ⏳ Time passes beyond term → upkeep becomes true
  • ⚙️ Chainlink Automation triggers payout
  • 💸 Payout transfers principal + interest
  • 🔁 Contract resets to allow future deposits

About

A time-locked ETH deposit simulator that mimics a fixed-term savings account. Users can deposit ETH for a fixed duration and automatically receive principal + fixed interest at maturity. Payout automated with Chainlink's Upkeep.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages