Sperax
  • USDs (Sperax USD)
    • Minting and Redeeming
    • Auto Yield
      • Smart Contracts can opt in for the rebase feature (Auto-yield).
    • Stability Mechanism
    • Key parameters and functions
    • Technical documents
      • Sequence diagrams
      • Smart contracts
        • Vault
        • USDs
        • CollateralManager
        • SPA Buyback
        • MasterPriceOracle
        • Yield Reserve
        • Fee Calculator
        • RebaseManager
        • Dripper
        • BaseStrategy
      • Deployed contracts
  • Buyback Contract
  • Staking Protocol
    • Locking SPA
    • Withdrawing SPA
    • Staking Rewards
  • Demeter Protocol
    • How does Demeter Work?
    • Technical documents
      • Smart contracts
        • E721 Farms
          • E721Farm
          • Camelot V3
            • CamelotV3FarmDeployer
            • CamelotV3Farm
        • Base contracts
          • Farm
          • FarmStorage
          • FarmRegistry
          • FarmDeployer
        • Features
          • ClaimableFee
          • ExpirableFarm
          • OperableDeposit
        • Rewarder
          • Rewarder
          • RewarderFactory
      • Deployed contracts
  • Getting Started on Our DApp
    • Minting & Redeeming USDs
    • Stake SPA
  • Governance
  • Bug Bounty Program
  • FAQ
    • SPA Tokenomics
    • xSPA token
    • Smart Contract Addresses
    • How to Transfer SPA from Ethereum to Arbitrum
  • Quick Links
    • Audit Reports
    • Sperax Dapp
    • Demeter Dapp
    • Discord
    • Forum
    • Snapshot
Powered by GitBook
On this page
  • State Variables
  • MIN_EXTENSION
  • MAX_EXTENSION
  • farmEndTime
  • farmRegistry
  • Functions
  • extendFarmDuration
  • updateFarmStartTime
  • isFarmOpen
  • _setupFarmExpiry
  • _collectExtensionFee
  • Events
  • FarmEndTimeUpdated
  • ExtensionFeeCollected
  • Errors
  • InvalidExtension
  • DurationExceeded
  • FarmNotYetStarted

Was this helpful?

Export as PDF
  1. Demeter Protocol
  2. Technical documents
  3. Smart contracts
  4. Features

ExpirableFarm

PreviousClaimableFeeNextOperableDeposit

Was this helpful?

Inherits: Farm

Author: Sperax Foundation.

This contract helps in creating farms with expiry feature.

State Variables

MIN_EXTENSION

uint256 public constant MIN_EXTENSION = 100;

MAX_EXTENSION

uint256 public constant MAX_EXTENSION = 300;

farmEndTime

uint256 public farmEndTime;

farmRegistry

address public farmRegistry;

Functions

extendFarmDuration

Update the farm end time.

Can be updated only before the farm expired or closed. Extension should be incremented in multiples of 1 USDs/day with minimum of 100 days at a time and a maximum of 300 days. Extension is possible only after farm started.

function extendFarmDuration(uint256 _extensionDays) external onlyOwner nonReentrant;

Parameters

Name
Type
Description

_extensionDays

uint256

The number of days to extend the farm. Example: 150 means 150 days.

updateFarmStartTime

Update the farm start time.

Can be updated only before the farm start. New start time should be in future. Adjusts the farm end time accordingly.

function updateFarmStartTime(uint256 _newStartTime) public virtual override;

Parameters

Name
Type
Description

_newStartTime

uint256

The new farm start time.

isFarmOpen

Returns bool status if farm is open. Farm is open if it is not closed and not expired.

function isFarmOpen() public view virtual override returns (bool);

Returns

Name
Type
Description

<none>

bool

bool True if farm is open.

_setupFarmExpiry

Setup the farm data for farm expiry.

function _setupFarmExpiry(uint256 _farmStartTime, address _farmRegistry) internal;

Parameters

Name
Type
Description

_farmStartTime

uint256

Start time of the farm.

_farmRegistry

address

Address of the farm registry.

_collectExtensionFee

Collects farm extension fee and transfers it to feeReceiver.

Function fetches all the fee params from farmRegistry.

function _collectExtensionFee(uint256 _extensionDays) private;

Parameters

Name
Type
Description

_extensionDays

uint256

The number of days to extend the farm. Example: 150 means 150 days.

Events

FarmEndTimeUpdated

event FarmEndTimeUpdated(uint256 newEndTime);

ExtensionFeeCollected

event ExtensionFeeCollected(address indexed token, uint256 extensionFee);

Errors

InvalidExtension

error InvalidExtension();

DurationExceeded

error DurationExceeded();

FarmNotYetStarted

error FarmNotYetStarted();
Git Source