Skip to content

Commit

Permalink
Change CredbullVaultFactory to take an array of allowedCustodians at …
Browse files Browse the repository at this point in the history
…construct time
  • Loading branch information
lucasia committed Jun 17, 2024
1 parent 57c5eac commit fe0425e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/contracts/script/DeployVaultFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ contract DeployVaultFactory is Script {

address owner = config.factoryParams.owner;
address operator = config.factoryParams.operator;
address[] memory custodians = new address[](1);
custodians[0] = config.factoryParams.custodian;

DeployedContracts deployChecker = new DeployedContracts();

vm.startBroadcast();

if (isTestMode || deployChecker.isDeployRequired("CredbullFixedYieldVaultFactory")) {
factory = new CredbullFixedYieldVaultFactory(owner, operator);
factory = new CredbullFixedYieldVaultFactory(owner, operator, custodians);
console2.log("!!!!! Deploying CredbullFixedYieldVaultFactory !!!!!");
}

if (isTestMode || deployChecker.isDeployRequired("CredbullUpsideVaultFactory")) {
upsideFactory = new CredbullUpsideVaultFactory(owner, operator);
upsideFactory = new CredbullUpsideVaultFactory(owner, operator, custodians);
console2.log("!!!!! Deploying CredbullVaultWithUpsideFactory !!!!!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ contract CredbullFixedYieldVaultFactory is CredbullVaultFactory {
/**
* @param owner - The owner of the factory contract
* @param operator - The operator of the factory contract
* @param custodians - The custodians allowable for the vaults
*/
constructor(address owner, address operator) CredbullVaultFactory(owner, operator) { }
constructor(address owner, address operator, address[] memory custodians)
CredbullVaultFactory(owner, operator, custodians)
{ }

/**
* @notice - Function to create a new vault. Should be called only by the owner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import { CredbullVaultFactory } from "./CredbullVaultFactory.sol";

contract CredbullUpsideVaultFactory is CredbullVaultFactory {
/**
* @param owner - The owner of the Factory contract
* @param operator - The operator of the Factory contract
* @param owner - The owner of the factory contract
* @param operator - The operator of the factory contract
* @param custodians - The custodians allowable for the vaults
*/
constructor(address owner, address operator) CredbullVaultFactory(owner, operator) { }
constructor(address owner, address operator, address[] memory custodians)
CredbullVaultFactory(owner, operator, custodians)
{ }

/**
* @notice - Function to create a new upside vault. Should be called only by the owner
Expand Down
10 changes: 8 additions & 2 deletions packages/contracts/src/factories/CredbullVaultFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ abstract contract CredbullVaultFactory is AccessControl {
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

/**
*
* @param owner - Owner of the factory contract
* @param operator - Operator of the factory contract
* @param custodians - Initial set of custodians allowable for the vaults
*/
constructor(address owner, address operator) {
constructor(address owner, address operator, address[] memory custodians) {
_grantRole(DEFAULT_ADMIN_ROLE, owner);
_grantRole(OPERATOR_ROLE, operator);

// set the allowed custodians directly in the constructor, without access restriction
bool[] memory result = new bool[](custodians.length);
for (uint256 i = 0; i < custodians.length; i++) {
result[i] = allowedCustodians.add(custodians[i]);
}
}

/**
Expand Down

0 comments on commit fe0425e

Please sign in to comment.