NGOLisFactory

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

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

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

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

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

Emitted when new NGO is deployed.

  • Includes all NGO metadata

  • Records contract addresses

  • Enables frontend/indexer tracking

LisFeeClaimed

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

  2. Fee Management

  3. Implementation Updates

Common Operations

  1. Finding NGO Address

  2. Verifying Ownership

Last updated