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 instancesMaintains 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
Implementation Management
Stores the reference implementation for all NGO proxies
Can be updated by factory owner through
setImplementation
Protocol Addresses
Core protocol contracts used by NGO instances
Set during factory construction
Immutable after deployment
Ownership Tracking
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
Proxy Creation
Creates new
ERC1967Proxy
instancePoints to current implementation
Initializes with provided parameters
Ownership Association
Records owner to NGO address mapping
Enables lookup of NGO contracts by owner
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
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
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
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 rewardsowner
: NGO contract administratororacle
: 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
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
NGOCreated
Emitted when new NGO is deployed.
Includes all NGO metadata
Records contract addresses
Enables frontend/indexer tracking
LisFeeClaimed
LisFeeClaimed
Emitted when platform fees are withdrawn.
Records withdrawal amount
Provides transparency for fee collection
Security Features
Access Control
Owner-only administrative functions
Protected implementation updates
Controlled NGO deployment
Proxy Pattern
Upgradeable NGO instances
Consistent implementation reference
State isolation between NGOs
Address Validation
Protocol contract verification
Owner-NGO relationship tracking
Unique NGO deployment per owner
Integration Guidelines
Deployment Process
Fee Management
Implementation Updates
Common Operations
Finding NGO Address
Verifying Ownership
Last updated