Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
SigismundSchlomo committed Oct 7, 2024
1 parent 46aa1aa commit 1e691d7
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 18 deletions.
13 changes: 7 additions & 6 deletions contracts/staking/token/LimitedTokenPoolsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import "./LimitedTokenPool.sol";
import "../../funds/RewardsBank.sol";
import "../../LockKeeper.sol";

contract LimitedTokenPoolsManager is Ownable {
contract LimitedTokenPoolsManager is AccessControl {
LockKeeper lockKeeper;
RewardsBank public bank;
UpgradeableBeacon public limitedTokenPoolBeacon;

address[] public pools;

constructor(RewardsBank bank_, LockKeeper lockKeeper_, UpgradeableBeacon doubleSideBeacon_) Ownable() {
constructor(RewardsBank bank_, LockKeeper lockKeeper_, UpgradeableBeacon doubleSideBeacon_) {
lockKeeper = lockKeeper_;
bank = bank_;
limitedTokenPoolBeacon = doubleSideBeacon_;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

event LimitedPoolCreated(address pool);
Expand All @@ -27,7 +28,7 @@ contract LimitedTokenPoolsManager is Ownable {
event LimitedPoolActivated(address pool);

// LIMITED POOL METHODS
function createPool(LimitedTokenPool.MainConfig calldata params) public onlyOwner returns (address) {
function createPool(LimitedTokenPool.MainConfig calldata params) public onlyRole(DEFAULT_ADMIN_ROLE) returns (address) {
bytes memory data = abi.encodeWithSignature(
"initialize(address,address,(string,address,address,address))",
bank, lockKeeper, params);
Expand All @@ -38,21 +39,21 @@ contract LimitedTokenPoolsManager is Ownable {
return pool;
}

function configurePool(address _pool, LimitedTokenPool.LimitsConfig calldata params) public onlyOwner {
function configurePool(address _pool, LimitedTokenPool.LimitsConfig calldata params) public onlyRole(DEFAULT_ADMIN_ROLE) {
require(_isPool(_pool),"Pool does not exist");
LimitedTokenPool pool = LimitedTokenPool(_pool);
pool.setLimitsConfig(params);
emit LimitedPoolConfigured(_pool, params);
}

function deactivatePool(address _pool) public onlyOwner {
function deactivatePool(address _pool) public onlyRole(DEFAULT_ADMIN_ROLE) {
require(_isPool(_pool),"Pool does not exist");
LimitedTokenPool pool = LimitedTokenPool(_pool);
pool.deactivate();
emit LimitedPoolDeactivated(_pool);
}

function activatePool(address _pool) public onlyOwner {
function activatePool(address _pool) public onlyRole(DEFAULT_ADMIN_ROLE) {
require(_isPool(_pool),"Pool does not exist");
LimitedTokenPool pool = LimitedTokenPool(_pool);
pool.activate();
Expand Down
2 changes: 1 addition & 1 deletion contracts/staking/token/TokenPoolsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "./TokenPool.sol";
import "../../funds/RewardsBank.sol";
import "../../LockKeeper.sol";

contract TokenPoolsManager is AccessControl{
contract TokenPoolsManager is AccessControl {
LockKeeper lockKeeper;
RewardsBank public bank;
UpgradeableBeacon public beacon;
Expand Down
81 changes: 81 additions & 0 deletions scripts/ecosystem/token_staking/deploy_limited_manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { ethers, upgrades } from "hardhat";
import { deploy } from "@airdao/deployments/deploying";

import { ContractNames } from "../../../src";

import {
LimitedTokenPoolsManager__factory,
RewardsBank__factory,
LockKeeper__factory
} from "../../../typechain-types";

import { wrapProviderToError } from "../../../src/utils/AmbErrorProvider";
import { deployMultisig } from "../../utils/deployMultisig";

export async function main() {
const { chainId } = await ethers.provider.getNetwork();

const [deployer] = await ethers.getSigners();
wrapProviderToError(deployer.provider!);

const multisig = await deployMultisig(ContractNames.Ecosystem_LimitedTokenPoolsManager, deployer);

const rewardsBank = await deploy<RewardsBank__factory>({
contractName: ContractNames.Ecosystem_LimitedTokenPoolsManagerRewardsBank,
artifactName: "RewardsBank",
deployArgs: [],
signer: deployer,
loadIfAlreadyDeployed: true,
});

const lockKeeper = await deploy<LockKeeper__factory>({
contractName: ContractNames.LockKeeper,
artifactName: "LockKeeper",
deployArgs: [],
signer: deployer,
loadIfAlreadyDeployed: true,
isUpgradeableProxy: true,
});

console.log("deploying LimitedTokenPool Beacon");
const limitedTokenPoolFactory = await ethers.getContractFactory("LimitedTokenPool");
const limitedTokenPoolBeacon = await upgrades.deployBeacon(limitedTokenPoolFactory);
await limitedTokenPoolBeacon.deployed();
console.log("LimitedTokenPool Beacon deployed to:", limitedTokenPoolBeacon.address);

console.log("deploying TokenPoolsManager");
const poolsManager = await deploy<LimitedTokenPoolsManager__factory>({
contractName: ContractNames.Ecosystem_TokenPoolsManager,
artifactName: "TokenPoolsManager",
deployArgs: [rewardsBank.address, lockKeeper.address, limitedTokenPoolBeacon.address],
signer: deployer,
loadIfAlreadyDeployed: true,
});

console.log("Grant poolsManager rewardsBank admin roles");
await (await rewardsBank.grantRole(await rewardsBank.DEFAULT_ADMIN_ROLE(), poolsManager.address)).wait();

console.log("Grant multisig rewardsBank admin role");
await (await rewardsBank.grantRole(await rewardsBank.DEFAULT_ADMIN_ROLE(), multisig.address)).wait();

console.log("Grant multisig poolsManager admin role");
await (await poolsManager.grantRole(await poolsManager.DEFAULT_ADMIN_ROLE(), multisig.address)).wait();

if (chainId != 16718) return; // continue only on prod

console.log("Revoking roles from deployer");

console.log("Revoke rewardsBank admin role from deployer");
await (await rewardsBank.revokeRole(await rewardsBank.DEFAULT_ADMIN_ROLE(), deployer.address)).wait();

console.log("Revoke poolsManager admin role from deployer");
await (await poolsManager.revokeRole(await poolsManager.DEFAULT_ADMIN_ROLE(), deployer.address)).wait();

}

if (require.main === module) {
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,11 @@ export async function main() {
await tokenPoolBeacon.deployed();
console.log("TokenPool Beacon deployed to:", tokenPoolBeacon.address);

console.log("deploying LimitedTokenPool Beacon");
const limitedTokenPoolFactory = await ethers.getContractFactory("LimitedTokenPool");
const limitedTokenPoolBeacon = await upgrades.deployBeacon(limitedTokenPoolFactory);
await limitedTokenPoolBeacon.deployed();
console.log("LimitedTokenPool Beacon deployed to:", limitedTokenPoolBeacon.address);

console.log("deploying TokenPoolsManager");
const poolsManager = await deploy<TokenPoolsManager__factory>({
contractName: ContractNames.Ecosystem_TokenPoolsManager,
artifactName: "TokenPoolsManager",
deployArgs: [rewardsBank.address, lockKeeper.address, tokenPoolBeacon.address, limitedTokenPoolBeacon.address],
deployArgs: [rewardsBank.address, lockKeeper.address, tokenPoolBeacon.address],
signer: deployer,
loadIfAlreadyDeployed: true,
});
Expand Down
8 changes: 4 additions & 4 deletions src/contracts/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ export enum ContractNames {

Ecosystem_GovernmentMultisig = "Ecosystem_Government_Multisig",

Ecosystem_SingleSidePool = "Ecosystem_SingleSidePool",
Ecosystem_SingleSidePoolBeacon = "Ecosystem_SingleSidePool_Beacon",
Ecosystem_DoubleSidePool = "Ecosystem_DoubleSidePool",
Ecosystem_DoubleSidePoolBeacon = "Ecosystem_DoubleSidePool_Beacon",
Ecosystem_TokenPoolsManager = "Ecosystem_TokenPoolsManager",
Ecosystem_TokenPoolsManagerMultisig = "Ecosystem_TokenPoolsManager_Multisig",
Ecosystem_TokenPoolsManagerRewardsBank = "Ecosystem_TokenPoolsManager_RewardsBank",
Ecosystem_LimitedTokenPoolsManager = "Ecosystem_LimitedTokenPoolsManager",
Ecosystem_LimitedTokenPoolsManagerMultisig = "Ecosystem_LimitedTokenPoolsManager_Multisig",
Ecosystem_LimitedTokenPoolsManagerRewardsBank = "Ecosystem_LimitedTokenPoolsManager_RewardsBank",
Ecosystem_HBRToken = "Ecosystem_HBRToken",
}

Expand Down Expand Up @@ -130,6 +129,7 @@ export const MULTISIGS_ECOSYSTEM = {
[ContractNames.Ecosystem_LiquidPoolStAMB]: ContractNames.Ecosystem_LiquidPoolMultisig,
[ContractNames.Ecosystem_LiquidPoolStakingTiers]: ContractNames.Ecosystem_LiquidPoolMultisig,
[ContractNames.Ecosystem_TokenPoolsManager]: ContractNames.Ecosystem_TokenPoolsManagerMultisig,
[ContractNames.Ecosystem_LimitedTokenPoolsManagerMultisig]: ContractNames.Ecosystem_LimitedTokenPoolsManagerMultisig,
};

export const MULTISIGS = {...MULTISIGS_COMMON, ...MULTISIGS_ECOSYSTEM};
Expand Down

0 comments on commit 1e691d7

Please sign in to comment.