📄AaveImpactFactory
The AaveImpactFactory is the administrative smart contract that acts as the central hub for creating and managing all Social Impact Organisations (SIOs) on the platform. Think of it as the main office that launches and oversees every new charitable project. Its primary role is to deploy a new, unique AaveImpact smart contract for each SIO that is onboarded.
How It Works
The factory is designed to be secure, transparent, and upgradeable.
Upgradeable Projects: The factory uses a "proxy" pattern, which is a secure method for launching SIO contracts. This means that if the core logic needs to be improved or fixed, the factory can be updated to use a new "master blueprint" for all future SIOs, ensuring the platform can evolve without disrupting existing projects. If new tokens are added to the factory, all NGOs (current and new) will have new available token to be deposited
The Master Blueprint: The factory holds the official, audited code for the
AaveImpactcontract. When a new SIO is created, the factory uses this blueprint to build and deploy a fresh, independent contract for that SIO.Connecting to Aave: The factory permanently stores the official Aave Protocol address. It passes this address to every new SIO contract it creates, ensuring each project is correctly connected to the Aave platform to generate yield on deposits.
Approved Stablecoins: The factory maintains a whitelist of stablecoins that are approved for donations across the platform (e.g., USDT, USDC, DAI). Each SIO contract created by the factory will only accept deposits from this approved list, ensuring security and consistency.
A Closer Look at The Factory's Functions
Here’s a simple breakdown of what each key function does. These actions are performed by the platform owner.
constructor
This is a special, one-time function that runs when the factory contract is first deployed to the blockchain. It sets up the essential, unchangeable addresses needed for the factory to operate, such as the Aave Pool address and the first version of the SIO "master blueprint." It also designates the official owner of the factory.
constructor(address _aaveSC, address _ngoImplementationAddress, address _owner) Ownable(_owner) {
if (_owner == address(0)) revert NullAddress();
if (_aaveSC == address(0)) revert NullAddress();
if (_ngoImplementationAddress == address(0)) revert NullAddress();
_aavePoolAddress = _aaveSC;
_ngoImplementation = _ngoImplementationAddress;
}
createNGO
This function is called by the platform owner to create a new, unique smart contract for an SIO. It configures the new contract with the SIO's name, description, and wallet addresses.
Upgrade the Blueprint (setImplementation)
This allows the platform owner to point the factory to a new version of the AaveImpact contract code. This ensures that any new SIOs created will use the latest, most secure, and feature-rich version. This does not affect SIOs that have already been created.
Add/Remove Approved Stablecoins
These two functions allow the owner to manage the platform-wide list of stablecoins that donors can use to make contributions.
addValidDepositToken: Adds a new stablecoin and its corresponding Aave yield-bearing token to the approved list.
removeValidDepositToken: Removes a stablecoin from the approved list.
Collect Platform Fees (withdrawFee)
This function allows the platform owner to withdraw the operational fees that have accumulated in the factory contract from the yield generated across all SIOs.
Public Notifications (Events)
The factory contract makes public announcements on the blockchain, known as "events," whenever an important action occurs. This ensures full transparency for all users.
NGOCreated: This is announced whenever a new SIO is added to the platform. It includes all the SIO's details, including its new smart contract address.
ImplementationChanged: This is announced when the "master blueprint" for SIO contracts has been updated.
SfiFeeClaimed: This provides a public record of when platform fees are withdrawn, showing the amount and which token was withdrawn.
Keeping the Platform Secure
Security and trust are paramount. The factory is built with several layers of protection.
Owner-Only Controls: All administrative actions—such as creating SIOs, upgrading the blueprint, and withdrawing fees—can only be performed by the designated owner of the factory contract.
Separate and Secure Projects: Each SIO contract deployed by the factory operates in isolation. Think of it like every project having its own secure vault. The funds and operations of one SIO are completely separate and independent from all others.
Safe Upgrades: The method used for upgrading the SIO blueprint is based on a thoroughly tested and audited industry standard (OpenZeppelin's
ERC1967Proxy), ensuring that upgrades are handled securely.Built-in Safeguards: The contract includes checks to prevent common errors, such as attempting to configure it with an invalid or empty address, which adds to its overall robustness.
Last updated
