Lido Impact Staking (LIS)
  • Introduction to LIS
  • 🪙Donating staking returns
    • How to impact stake?
    • How to withdraw staked ETH/stETH/wstETH?
  • 🏢Apply to receive staking returns
  • 💸How to get your impact report
  • 🔑Custody For Impact Stakers and Social Impact Organisations
  • 📔Contracts
    • NGOLis
    • NGOLisFactory
  • Social Impact Project and NGO FAQs
  • Reference Materials
Powered by GitBook
On this page
  • Contract Architecture
  • Sequential Diagram
  • Core Logic and Operations
  • Function Documentation
  • constructor
  • setImplementation
  • createNGO
  • withdrawFeeStEth
  • Events
  • Security Features
  • Integration Guidelines
  • Common Operations
  1. Contracts

NGOLisFactory

PreviousNGOLisNextSocial Impact Project and NGO FAQs

Last updated 5 months ago

The contract includes functionality for creating new NGO instances, associating them with owners, and emitting events to log these actions. Additionally, it provides a method for the contract owner to withdraw fees in the form of staked Ether (stETH), ensuring proper fund management and transparency. The contract leverages interfaces and events to interact with other smart contracts and to notify external systems of significant actions. It utilizes the ERC1967 proxy pattern to create upgradeable NGO instances, manages ownership associations, and handles platform fee collection.

Contract Architecture

Proxy Implementation

  • Uses OpenZeppelin's ERC1967Proxy for creating upgradeable NGO instances

  • Maintains a reference to the current NGOLis implementation contract

  • Allows implementation updates through owner-controlled function

  • Each deployed NGO is a separate proxy pointing to the same implementation

Core Components

  1. Implementation Management

    address private _ngoImplementation;    // Current NGO implementation
    • Stores the reference implementation for all NGO proxies

    • Can be updated by factory owner through setImplementation

  2. Protocol Addresses

    address _lidoSCAddress;        // Lido staking contract
    address _withdrawalSCAddress;  // Withdrawal queue contract
    address wstETHSC;             // Wrapped stETH contract
    • Core protocol contracts used by NGO instances

    • Set during factory construction

    • Immutable after deployment

  3. Ownership Tracking

    mapping(address => address) public ownerToNgo;
    • Maps NGO owners to their respective NGO contract addresses

    • One-to-one relationship between owners and NGO

Sequential Diagram

Core Logic and Operations

NGO Deployment Process

  1. Proxy Creation

    • Creates new ERC1967Proxy instance

    • Points to current implementation

    • Initializes with provided parameters

  2. Ownership Association

    • Records owner to NGO address mapping

    • Enables lookup of NGO contracts by owner

  3. Configuration

    • Sets initial rewards owner

    • Configures oracle permissions

    • Associates with Lido protocol contracts

Fee Management

  • Collects platform fees in wstETH

  • Owner can withdraw accumulated fees

  • Emits events for fee collection transparency

Function Documentation

Administrative Functions

constructor

constructor(
    address _lidoSC,
    address _withdrawalSC,
    address _ngoImplementationAddress,
    address _wstETHSC
) Ownable(msg.sender)

Initializes the factory with required protocol addresses.

  • Parameters

    • _lidoSC: Lido protocol contract address

    • _withdrawalSC: Withdrawal queue contract address

    • _ngoImplementationAddress: NGOLis implementation contract

    • _wstETHSC: Wrapped stETH contract address

  • Effects

    • Sets immutable protocol addresses

    • Establishes initial implementation reference

    • Sets contract owner

setImplementation

function setImplementation(address newImplementation) public onlyOwner

Updates the NGO implementation contract address.

  • Parameters

    • newImplementation: Address of new implementation contract

  • Access Control

    • Restricted to factory owner

  • Effects

    • Updates implementation reference for future deployments

    • Does not affect existing NGO proxies

Deployment Functions

createNGO

function createNGO(
    string memory _name,
    string memory _imageLink,
    string memory _description,
    string memory _link,
    string memory _location,
    address _rewardsOwner,
    address owner,
    address oracle
) public onlyOwner

Creates and initializes a new NGO contract instance.

  • Parameters

    • _name: NGO name identifier

    • _imageLink: URL to NGO image

    • _description: NGO description

    • _link: External NGO website/resource

    • _location: Physical/operational location

    • _rewardsOwner: Address to receive NGO rewards

    • owner: NGO contract administrator

    • oracle: Address with oracle privileges

  • Access Control

    • Restricted to factory owner

  • Effects

    • Deploys new proxy contract

    • Initializes NGO configuration

    • Records owner association

    • Emits NGOCreated event

Fee Management Functions

withdrawFeeStEth

function withdrawFeeStEth() public onlyOwner

Withdraws accumulated platform fees.

  • Access Control

    • Restricted to factory owner

  • Effects

    • Transfers all wstETH balance to owner

    • Emits LisFeeClaimed event

  • Requirements

    • Factory must have non-zero wstETH balance

Events

NGOCreated

event NGOCreated(
    string _name,
    string _imageLink,
    string _description,
    string _link,
    address _rewardsOwner,
    address _ngoAddress,
    string _location,
    address oracle
);

Emitted when new NGO is deployed.

  • Includes all NGO metadata

  • Records contract addresses

  • Enables frontend/indexer tracking

LisFeeClaimed

event LisFeeClaimed(uint256 _value);

Emitted when platform fees are withdrawn.

  • Records withdrawal amount

  • Provides transparency for fee collection

Security Features

  1. Access Control

    • Owner-only administrative functions

    • Protected implementation updates

    • Controlled NGO deployment

  2. Proxy Pattern

    • Upgradeable NGO instances

    • Consistent implementation reference

    • State isolation between NGOs

  3. Address Validation

    • Protocol contract verification

    • Owner-NGO relationship tracking

    • Unique NGO deployment per owner

Integration Guidelines

  1. Deployment Process

    // Example deployment sequence
    const factory = await NGOLisFactory.deploy(
      lidoAddress,
      withdrawalAddress,
      implementationAddress,
      wstETHAddress
    );
    
    // Create NGO instance
    await factory.createNGO(
      "NGO Name",
      "image.url",
      "Description",
      "website.url",
      "Location",
      rewardsOwner,
      ngoAdmin,
      oracleAddress
    );
  2. Fee Management

    // Withdraw platform fees
    await factory.withdrawFeeStEth();
  3. Implementation Updates

    // Update NGO implementation
    await factory.setImplementation(newImplementationAddress);

Common Operations

  1. Finding NGO Address

    address ngoAddress = factory.ownerToNgo(ownerAddress);
  2. Verifying Ownership

    bool hasNGO = factory.ownerToNgo(address) != address(0);
📔
Source code
Deployed contract