TierraDAO
TierraDAO Explanation
Contract Overview
The TierraDAO
contract is designed to manage a fundraising campaign, distribute tokens, and set up liquidity and farming incentives on a Uniswap V3 DEX. It allows users to contribute BERA during a fundraising period, and if the fundraising goal is reached, it mints and distributes tokens, creates a Uniswap V3 pool, and sets up farming incentives.
The contract also includes whitelist functionality, allowing specific addresses to contribute during different tiers of the fundraising process. It integrates with external contracts such as Uniswap V3, a liquidity locker, and a staking contract.
Events
Contribution(address indexed contributor, uint256 amount)
Emitted when a user contributes Bera to the fundraising campaign.
contributor
: The address of the contributor.amount
: The amount of Bera contributed.
FundraisingFinalized(bool success)
Emitted when the fundraising campaign is finalized.
success
: Always true
Refund(address indexed contributor, uint256 amount)
Emitted when a contributor receives a refund.
contributor
: The address of the contributor.amount
: The amount of Bera refunded.
AddWhitelist(uint whitelist, address)
Emitted when an address is added to a whitelist tier.
whitelist
: The whitelist tier ID.address
: The address added to the whitelist.
RemoveWhitelist(uint whitelist, address)
Emitted when an address is removed from a whitelist tier.
whitelist
: The whitelist tier ID.address
: The address removed from the whitelist.
FarmCreated(address indexed token, address indexed pool, uint256 startTime, uint256 endTime, address refundee)
Emitted when a new farming incentive is created.
token
: The address of the reward token.pool
: The address of the Uniswap V3 pool.startTime
: The start time of the farming incentive.endTime
: The end time of the farming incentive.refundee
: The address that will receive any remaining rewards.
State Variables
UNI_V3_FEE:
uint24
The fee tier for the Uniswap V3 pool (10,000 = 1%).
FEE:
uint24
The fee percentage taken from the total raised funds (500 = 5%).
SUPPLY_TO_LP:
uint256
The amount of tokens allocated to the liquidity pool (100,000,000 tokens).
SUPPLY_TO_FARM:
uint256
The amount of tokens allocated to farming incentives (100,000,000 tokens).
UNISWAP_V3_FACTORY:
IUniswapV3Factory
The Uniswap V3 factory contract.
POSITION_MANAGER:
INonfungiblePositionManager
The Uniswap V3 Nonfungible Position Manager contract.
STAKER:
IUniV3Staker
The Uniswap V3 staking contract.
WETH:
address
The address of the WBera token.
liquidityLockerFactory:
ILockerFactory
The factory contract for deploying liquidity lockers.
liquidityLocker:
address
The address of the deployed liquidity locker.
totalRaised:
uint256
The total amount of Bera raised during the fundraising campaign.
fundraisingGoal:
uint256
The fundraising goal in Bera.
fundraisingFinalized:
bool
Indicates whether the fundraising campaign has been finalized.
goalReached:
bool
Indicates whether the fundraising goal has been reached.
fundraisingDeadline:
uint256
The deadline for the fundraising campaign.
fundExpiry:
uint256
The expiration time for the liquidity locker and farming incentives.
lpFeesCut:
uint8
The percentage of LP fees allocated to the protocol (60 = 60%).
protocolAdmin:
address
The address of the protocol admin.
name:
string
The name of the DAO.
symbol:
string
The symbol of the DAO token.
daoToken:
address
The address of the DAO token.
maxWhitelistAmount:
mapping(uint => uint256)
The maximum contribution amount allowed per whitelist tier.
contributions:
mapping(address => uint256)
The amount of Bera contributed by each address.
contributors:
address[]
An array of all contributors.
contributionsByTier:
mapping(uint => mapping(address => uint256))
The amount of Bera contributed by each address per whitelist tier.
whitelistEnabled:
mapping(uint256 => bool)
Indicates whether a whitelist tier is enabled.
whitelist:
mapping(uint => mapping(address => bool))
Indicates whether an address is whitelisted for a specific tier.
whitelistArray:
mapping(uint => address[])
An array of whitelisted addresses for each tier.
whitelistEndTime:
mapping(uint => uint)
The end time for a whitelist tier.
WHITELIST_TIER_AMOUNTS:
uint
The number of whitelist tiers.
signatureHashValid:
mapping(bytes32 => bool)
Indicates whether a signature hash is valid for EIP-1271 compliance.
Functions
Public Functions
contribute()
Allows users to contribute Bera to the fundraising campaign.
Reverts if the fundraising goal is already reached, the deadline has passed, or the contribution is not allowed based on whitelist tiers.
Emits a
Contribution
event.
refund()
Allows contributors to receive a refund if the fundraising goal is not reached and the deadline has passed.
Reverts if the goal was reached, the deadline has not passed, or the contributor has no contributions.
Emits a
Refund
event.
receive()
Fallback function that allows users to contribute Bera by simply sending it to the contract.
Calls the
contribute()
function if the fundraising campaign is active.
onERC721Received(address, address, uint256, bytes calldata)
ERC721 receiver function to handle NFT transfers.
Returns the ERC721 receiver selector.
Whitelist Management
addToWhitelist(uint whitelistId, address[] calldata addresses)
Adds addresses to a specific whitelist tier.
Reverts if the whitelist tier does not exist or the caller is not the owner or protocol admin.
Emits an
AddWhitelist
event.
removeFromWhitelist(uint whitelistId, address removedAddress)
Removes an address from a specific whitelist tier.
Reverts if the whitelist tier does not exist or the caller is not the owner or protocol admin.
Emits a
RemoveWhitelist
event.
getWhitelistLength(uint whitelistId)
Returns the number of addresses in a specific whitelist tier.
Reverts if the whitelist tier does not exist.
setMaxWhitelistAmount(uint whitelistId, uint256 _maxWhitelistAmount)
Sets the maximum contribution amount for a specific whitelist tier.
Reverts if the whitelist tier does not exist or the caller is not the owner or protocol admin.
setWhitelistTierAmounts(uint newAmounts)
Sets the number of whitelist tiers.
Reverts if the caller is not the owner or protocol admin.
setWhitelistsEnabled(uint256[] calldata whitelists, bool[] calldata enabled)
Enables or disables specific whitelist tiers.
Reverts if the caller is not the owner or protocol admin.
setWhitelistEndTimes(uint256[] calldata whitelists, uint256[] calldata endTimes)
Sets the end times for specific whitelist tiers.
Reverts if the caller is not the owner or protocol admin.
setMaxPublicContributionAmount(uint256 _maxPublicContributionAmount)
Sets the maximum contribution amount for the public round (whitelist tier 0).
Reverts if the caller is not the owner or protocol admin.
Fundraising Management
finalizeFundraising(int24 initialTick, int24 upperTick, bytes32 salt)
Finalizes the fundraising campaign, mints and distributes tokens, sets up a Uniswap V3 pool, and creates farming incentives.
Reverts if the fundraising goal is not reached, the campaign is already finalized, or the salt is invalid.
Emits a
FundraisingFinalized
event.
extendFundExpiry(uint256 newFundExpiry)
Extends the expiration time for the liquidity locker and farming incentives.
Reverts if the new expiration time is not later than the current one.
Can only be called by the owner.
extendFundraisingDeadline(uint256 newFundraisingDeadline)
Extends the fundraising deadline.
Reverts if the fundraising goal is already reached or the new deadline is not later than the current one.
Can only be called by the owner or protocol admin.
Admin Functions
execute(address[] calldata contracts, bytes[] calldata data, uint256[] calldata msgValues)
Allows the DAO manager to execute multiple calls to external contracts.
Reverts if the fundraising campaign is not finalized or the array lengths mismatch.
Can only be called by the owner.
emergencyEscape()
Allows the protocol admin to withdraw all Bera from the contract in case of an emergency.
Reverts if the fundraising campaign is already finalized.
Can only be called by the protocol admin.
Miscellaneous Functions
setSignatureValid(bytes32 sig, bool valid)
Sets the validity of a signature hash for EIP-1271 compliance.
Can only be called by the owner.
isValidSignature(bytes32 _hash, bytes calldata)
Validates a signature hash for EIP-1271 compliance.
Returns the EIP-1271 magic value if the signature is valid.
Last updated