Developer Docs
AppGitHub
  • Welcome!
  • Smart contracts
    • Core
      • Introduction
      • Deep Dive
      • Smart Contract Reference
        • PWN Hub
          • Tags
        • PWN Config
        • PWN Vault
        • Loan Types
          • Simple Loan
        • Proposals
          • Simple Loan Proposal
            • Simple Proposal
            • List Proposal
            • Elastic Proposal
            • Elastic Chainlink Proposal
            • Dutch Proposal
        • PWN Utilized Credit
        • PWN LOAN
        • PWN Revoked Nonce
        • Peripheral Contracts
          • Acceptor Controller
            • World ID
          • State Fingerprint Computer
            • UniV3
            • Chicken Bonds
          • Pool Adapter
            • Aave
            • Compound
            • ERC4626
        • Miscellaneous
          • PWN Fee Calculator
          • PWN Signature Checker
          • PWN Errors
          • PWN Periphery
          • Timelock
    • PWN DAO
      • Governance
        • Optimistic
        • Token
      • Tokens
        • PWN
        • stPWN
        • vePWN
          • Stake
          • Power
          • Metadata
      • Epoch Clock
      • Miscellaneous
        • Errors
        • EpochPowerLib
    • Tools
      • PWN Safe
        • Architecture
        • Security considerations
        • Smart Contract Reference
          • PWN Safe Factory
          • ATR Module
            • Tokenized Asset Manager
            • Recipient Permission Manager
          • Whitelist
          • ATR Guard
            • Operators context
      • Token Bundler
      • PWN Deployer
    • Libraries
      • MultiToken
    • Contract Addresses
  • More documentation
    • PWN Docs
    • FAQ
    • Audits
    • Using PWN without front-end
  • Deprecated
    • PWN Beta
      • Architecture
      • PWN
        • Off-chain signed offer
        • Offer types
      • PWN Vault
      • PWN LOAN
Powered by GitBook
On this page
  • 1. Summary
  • 2. Important links
  • 3. Contract details
  • Features
  • Inherited contracts, implemented Interfaces and ERCs
  • Functions
Edit on GitHub
  1. Smart contracts
  2. PWN DAO

Epoch Clock

PreviousMetadataNextMiscellaneous

Last updated 5 months ago

1. Summary

The PWN Epoch Clock provides the current epoch number in the PWN DAO context. One epoch is 4 weeks long and the epoch numbering starts with 1. INITIAL_EPOCH_TIMESTAMP is set at the deployment time and can be used to sync the clock between different chains.

2. Important links

3. Contract details

  • PWNEpochClock.sol is written in Solidity version 0.8.25

Features

  • Get current epoch

  • Set epoch start at deployment

Inherited contracts, implemented Interfaces and ERCs

Functions

currentEpoch

Overview

Function to get the current epoch number. If this function is called before the clock start, 0 is returned.

This function doesn't take any arguments.

Implementation

function currentEpoch() external view returns (uint16) {
    // timestamps prior to `INITIAL_EPOCH_TIMESTAMP` are considered to be in epoch 0
    if (block.timestamp < INITIAL_EPOCH_TIMESTAMP) {
        return 0;
    }
    // first epoch is 1
    uint256 epoch = (block.timestamp - INITIAL_EPOCH_TIMESTAMP) / SECONDS_IN_EPOCH + 1;
    return uint16(epoch); // safe cast for the next 5041 years after deployment
}

IPWNEpochClock
pwn_dao/src/PWNEpochClock.sol at main · PWNDAO/pwn_daoGitHub
44KB
PWNEpochClock.json
ABI
Logo