Factory
Description
This contract acts as a high-level orchestrator for deploying and configuring complete instances of the voting escrow, gauge, bribe, and incentive management system. It utilizes various underlying "base" factory contracts (for gauges, bribes, vote escrow, etc.) to deploy the necessary functional contracts (GaugeFactory
, BribeFactory
, VoteEscrow
, Voter
, IncentivesManager
, VoteEscrowDistribution
). After deployment, it wires these contracts together by setting the required references (e.g., setting the Voter on the VoteEscrow, setting the Incentives Manager as the depositor on the VoteEscrowDistribution).
Constructor
Description:
Initializes the main Factory
contract upon deployment. It sets the deployer (msg.sender
) as the owner
and stores the addresses of all required underlying base factory contracts and external registry contracts. These addresses are used later during the deployment and configuration phases.
Input Parameters:
_baseGaugeFactory
address
Address of the contract that deploys GaugeFactory
instances.
_baseBribeFactory
address
Address of the contract that deploys BribeFactory
instances.
_voteEscrowFactory
address
Address of the contract that deploys VoteEscrow
instances.
_voteEscrowDistributionFactory
address
Address of the contract that deploys VoteEscrowDistribution
instances.
_incentivesManagerFactory
address
Address of the contract that deploys IncentivesManager
instances.
_voterFactory
address
Address of the contract that deploys Voter
instances.
_dappRegistry
address
Address of the IDappRegistry
contract.
_projectRegistry
address
Address of the IProjectRegistry
contract.
deployContracts
Description:
Deploys a complete set of core contracts required for one instance of the voting escrow system. It uses the pre-configured base factory addresses to deploy a GaugeFactory
, BribeFactory
, VoteEscrow
, VoteEscrowDistribution
, Voter
, and IncentivesManager
. It stores the addresses of these newly deployed contracts associated with an incrementing deploymentCounter
. It then wires the contracts together by calling setter functions (e.g., setting the IncentivesManager
on the Voter
, setting the Voter
on the VoteEscrow
, setting the IncentivesManager
as the depositor for VoteEscrowDistribution
). The caller (msg.sender
) is recorded as the owner of this specific deployment instance.
Input Parameters:
rewardToken
address
The address of the ERC20 token used for base rewards (distributed by the Voter).
voteEscrowToken
address
The address of the ERC20 token locked in the VoteEscrow
contract.
incentivesDistributorAddr
address
The address authorized to distribute incentives via the IncentivesManager
.
Events Emitted:
DeploymentComplete(...)
with details of the deployed contract addresses and configuration.
configureProjectsFromRegistry
Description:
Configures specific projects (represented by Dapp tokens) for a previously deployed system instance (deploymentIndex
). Requires the caller (msg.sender
) to be the owner of that specific deployment. It iterates through the provided dappIndices
, retrieves Dapp information (token address, protocol admin) from the dappRegistry
, creates a gauge for each Dapp's token via the deployment's Voter
contract (using voterFactory._createGauge
), mints a small initial amount of the Dapp's token (assuming it's IMintableERC20
), approves the gauge, and deposits the minted tokens into the gauge on behalf of the protocolAdmin
. It tracks which Dapps have been registered for the deployment and finally registers the entire deployment configuration in the external projectRegistry
.
Input Parameters:
deploymentIndex
uint256
The index of the deployment instance (created via deployContracts
) to configure.
dappIndices
uint256[] calldata
An array of indices corresponding to Dapps listed in the dappRegistry
.
Events Emitted:
ProjectConfigured(...)
for each Dapp successfully configured.
getDeploymentRegisteredDapps
Description:
A view function to retrieve the list of Dapps that have been configured for a specific deployment instance using configureProjectsFromRegistry
. Returns an array of DappInfo
structs, each containing the tokenAddress
and protocolAdmin
for a configured Dapp.
Input Parameters:
deploymentId
uint256
The index ID of the deployment to query for.
Return Value:
dapps
DappInfo[] memory
An array containing information about the Dapps registered for the deployment.
Last updated