Smart Contracts

CommunityPool.sol

Reference for every external function, event, and custom error on CommunityPool.sol. Source lives in src/CommunityPool.sol.

Constructor

constructor(
    string memory name_,
    string memory description_,
    uint256 minimumUsd_,
    address[] memory coOwners,
    uint64 expiresAt_,
    address ethUsdFeed,
    TokenConfig[] memory tokenConfigs
)

Deploys a pool. The caller becomes the immutable deployer and is automatically added to the owner set. minimumUsd_ is denominated in 18-decimal USD wei. TokenConfig is { address token; address usdFeed; uint8 decimals }.

Reverts: CommunityPool__ZeroAddress, CommunityPool__DuplicateOwner, CommunityPool__DuplicateToken.

Funding

fund() — payable

Contribute ETH. The contract converts msg.value to USD via the ETH/USD feed and reverts if below minimumUsd. Emits Funded. Also triggered by the receive() and fallback() handlers, so plain ETH transfers to the contract fund the pool.

Reverts: CommunityPool__PoolExpired, CommunityPool__BelowMinimumUsd.

fundERC20(IERC20 token, uint256 amount)

Contribute a whitelisted ERC-20. Requires prior approve(). Uses the token's configured decimals and USD feed to enforce the minimum. Emits FundedERC20.

Reverts: CommunityPool__PoolExpired, CommunityPool__TokenNotWhitelisted, CommunityPool__BelowMinimumUsd.

Owner withdraws (before expiry)

withdraw(uint256 amount)

Partial ETH withdraw. Reverts if amount == 0or if it exceeds the contract's ETH balance. Emits Withdrawn.

cheaperWithdraw()

Full ETH withdraw. Sweeps the contract's entire ETH balance tomsg.sender. Emits Withdrawn.

withdrawTokenAmount(IERC20 token, uint256 amount)

Partial ERC-20 withdraw of a whitelisted token. Reverts if amount == 0or exceeds the contract's balance of that token. Emits WithdrawnToken.

withdrawToken(IERC20 token)

Full ERC-20 withdraw. Sweeps the contract's entire balance of the given token. Emits WithdrawnToken when the balance is non-zero.

All four owner withdraws revert with CommunityPool__NotOwner for non-owners and CommunityPool__WithdrawDisabledAfterExpiry after the expiry timestamp.

Release (after expiry)

releaseExpiredFundsToDeployer()

Callable by anyone once block.timestamp > expiresAt. Sweeps all ETH and every whitelisted ERC-20 balance to the original deployer. Emits Withdrawn and WithdrawnToken for each asset with a non-zero balance.

Reverts: CommunityPool__NotYetExpiredForRelease.

View functions

Pool name, description, and per-funder accounting are not stored on-chain. Read them off-chain from the PoolCreated, Funded, and FundedERC20 event logs.

  • minimumUsd, expiresAt, deployer — public immutables.
  • isOwner(address)bool
  • getOwner()address — returns the deployer (kept for legacy UI callers).
  • getWhitelistedTokens()address[]
  • getVersion()uint256— returns the ETH/USD aggregator's version.

Events

event PoolCreated(
    address indexed deployer,
    string name,
    string description,
    uint256 minimumUsd,
    uint64 expiresAt,
    address[] coOwners,
    address[] whitelistedTokens
);

event Funded(address indexed funder, uint256 amount);
event FundedERC20(address indexed token, address indexed funder, uint256 amount);
event Withdrawn(address indexed owner, uint256 amount);
event WithdrawnToken(address indexed token, address indexed owner, uint256 amount);

Custom errors

  • CommunityPool__NotOwner
  • CommunityPool__PoolExpired
  • CommunityPool__TokenNotWhitelisted
  • CommunityPool__ZeroAddress
  • CommunityPool__BelowMinimumUsd
  • CommunityPool__DuplicateOwner
  • CommunityPool__DuplicateToken
  • CommunityPool__NotYetExpiredForRelease
  • CommunityPool__WithdrawDisabledAfterExpiry
  • CommunityPool__InvalidWithdrawAmount
  • CommunityPool__InsufficientBalance
  • CommunityPool__EthTransferFailed

Deployed addresses

Sepolia deployment artifacts live in communitypool/broadcast/. Mainnet addresses will be published here when we ship.