Search
K

OrgFundFactory

Inherits: EntityFactory
This contract is the factory for both the Org and Fund objects.

State Variables

ETH_PLACEHOLDER

Placeholder address used in swapping method to denote usage of ETH instead of a token.
address public constant ETH_PLACEHOLDER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

orgImplementation

The concrete Org used for minimal proxy deployment.
Org public immutable orgImplementation;

fundImplementation

The concrete Fund used for minimal proxy deployment.
Fund public immutable fundImplementation;

baseToken

Base Token address is the stable coin used throughout the system.
ERC20 public immutable baseToken;

Functions

constructor

constructor(Registry _registry) EntityFactory(_registry);
Parameters
Name
Type
Description
_registry
Registry
The Registry this factory will configure Entities to interact with. This factory must be approved on this Registry for it to work properly.

deployFund

Deploys a Fund.
function deployFund(address _manager, bytes32 _salt) public returns (Fund _fund);
Parameters
Name
Type
Description
_manager
address
The address of the Fund's manager.
_salt
bytes32
A 32-byte value used to create the contract at a deterministic address.
Returns
Name
Type
Description
_fund
Fund
The deployed Fund.

deployFundAndDonate

Deploys a Fund then pulls base token from the sender and donates to it.
function deployFundAndDonate(address _manager, bytes32 _salt, uint256 _amount) external returns (Fund _fund);
Parameters
Name
Type
Description
_manager
address
The address of the Fund's manager.
_salt
bytes32
A 32-byte value used to create the contract at a deterministic address.
_amount
uint256
The amount of base token to donate.
Returns
Name
Type
Description
_fund
Fund
The deployed Fund.

deployFundSwapAndDonate

Deploys a new Fund, then pulls a ETH or ERC20 tokens, swaps them to base tokens, and donates to the new Fund.
function deployFundSwapAndDonate(
address _manager,
bytes32 _salt,
ISwapWrapper _swapWrapper,
address _tokenIn,
uint256 _amountIn,
bytes calldata _data
) external payable returns (Fund _fund);
Parameters
Name
Type
Description
_manager
address
The address of the Fund's manager.
_salt
bytes32
A 32-byte value used to create the contract at a deterministic address.
_swapWrapper
ISwapWrapper
The swap wrapper to use for the donation. Must be whitelisted on the Registry.
_tokenIn
address
The address of the ERC20 token to swap and donate, or ETH_PLACEHOLDER if donating ETH.
_amountIn
uint256
The amount of tokens or ETH being swapped and donated.
_data
bytes
Additional call data required by the ISwapWrapper being used.
Returns
Name
Type
Description
_fund
Fund
The deployed Fund.

deployOrg

Deploys an Org.
function deployOrg(bytes32 _orgId) public returns (Org _org);
Parameters
Name
Type
Description
_orgId
bytes32
The Org's ID for tax purposes.
Returns
Name
Type
Description
_org
Org
The deployed Org.

deployOrgAndDonate

Deploys an Org then pulls base token from the sender and donates to it.
function deployOrgAndDonate(bytes32 _orgId, uint256 _amount) external returns (Org _org);
Parameters
Name
Type
Description
_orgId
bytes32
The Org's ID for tax purposes.
_amount
uint256
The amount of base token to donate.
Returns
Name
Type
Description
_org
Org
The deployed Org.

deployOrgSwapAndDonate

Deploys a new Org, then pulls a ETH or ERC20 tokens, swaps them to base tokens, and donates to the new Org.
function deployOrgSwapAndDonate(
bytes32 _orgId,
ISwapWrapper _swapWrapper,
address _tokenIn,
uint256 _amountIn,
bytes calldata _data
) external payable returns (Org _org);
Parameters
Name
Type
Description
_orgId
bytes32
The Org's ID for tax purposes.
_swapWrapper
ISwapWrapper
The swap wrapper to use for the donation. Must be whitelisted on the Registry.
_tokenIn
address
The address of the ERC20 token to swap and donate, or ETH_PLACEHOLDER if donating ETH.
_amountIn
uint256
The amount of tokens or ETH being swapped and donated.
_data
bytes
Additional call data required by the ISwapWrapper being used.
Returns
Name
Type
Description
_org
Org
The deployed Org.

computeOrgAddress

Calculates an Org contract's deployment address.
This function is used off-chain by the automated tests to verify proper contract address deployment.
function computeOrgAddress(bytes32 _orgId) external view returns (address);
Parameters
Name
Type
Description
_orgId
bytes32
Org's tax ID.
Returns
Name
Type
Description
<none>
address
The Org's deployment address.

computeFundAddress

Calculates a Fund contract's deployment address.
This function is used off-chain by the automated tests to verify proper contract address deployment.
function computeFundAddress(address _manager, bytes32 _salt) external view returns (address);
Parameters
Name
Type
Description
_manager
address
The manager of the fund.
_salt
bytes32
A 32-byte value used to create the contract at a deterministic address.
Returns
Name
Type
Description
<none>
address
The Fund's deployment address.

_donate

Pulls base tokens from sender and donates them to the entity.
function _donate(Entity _entity, uint256 _amount) private;

_swapAndDonate

Pulls ERC20 tokens, or receives ETH, and swaps and donates them to the entity.
function _swapAndDonate(
Entity _entity,
ISwapWrapper _swapWrapper,
address _tokenIn,
uint256 _amountIn,
bytes calldata _data
) private;
Last modified 2mo ago