Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit missing events on important configuration changes #33

Merged
merged 4 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/zkbob/ZkBobPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ contract ZkBobPool is EIP1967Admin, Ownable, Parameters, ZkBobAccounting {

ITokenSeller public tokenSeller;

event UpdateTokenSeller(address seller);
event UpdateOperatorManager(address manager);
event WithdrawFee(address indexed operator, uint256 fee);

event Message(uint256 indexed index, bytes32 indexed hash, bytes message);

constructor(uint256 __pool_id, address _token, ITransferVerifier _transfer_verifier, ITreeVerifier _tree_verifier) {
Expand Down Expand Up @@ -102,6 +106,7 @@ contract ZkBobPool is EIP1967Admin, Ownable, Parameters, ZkBobAccounting {
*/
function setTokenSeller(address _seller) external onlyOwner {
tokenSeller = ITokenSeller(_seller);
emit UpdateTokenSeller(_seller);
}

/**
Expand All @@ -111,6 +116,7 @@ contract ZkBobPool is EIP1967Admin, Ownable, Parameters, ZkBobAccounting {
*/
function setOperatorManager(IOperatorManager _operatorManager) external onlyOwner {
operatorManager = _operatorManager;
emit UpdateOperatorManager(address(_operatorManager));
}

/**
Expand Down Expand Up @@ -240,10 +246,11 @@ contract ZkBobPool is EIP1967Admin, Ownable, Parameters, ZkBobAccounting {
_operator == msg.sender || operatorManager.isOperatorFeeReceiver(_operator, msg.sender),
"ZkBobPool: not authorized"
);
uint256 fee = accumulatedFee[_operator];
uint256 fee = accumulatedFee[_operator] * TOKEN_DENOMINATOR;
require(fee > 0, "ZkBobPool: no fee to withdraw");
IERC20(token).safeTransfer(_to, fee * TOKEN_DENOMINATOR);
IERC20(token).safeTransfer(_to, fee);
accumulatedFee[_operator] = 0;
emit WithdrawFee(_operator, fee);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/zkbob/manager/MutableOperatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ contract MutableOperatorManager is IOperatorManager, Ownable {
// current operator public API URL
string public operatorURI;

event UpdateOperator(address indexed operator, address feeReceiver, string operatorURI);

constructor(address _operator, address _feeReceiver, string memory _operatorURI) Ownable() {
_setOperator(_operator, _feeReceiver, _operatorURI);
}
Expand All @@ -36,6 +38,8 @@ contract MutableOperatorManager is IOperatorManager, Ownable {
}
operator = _operator;
operatorURI = _operatorURI;

emit UpdateOperator(_operator, _feeReceiver, _operatorURI);
}

function isOperator(address _addr) external view override returns (bool) {
Expand Down
5 changes: 4 additions & 1 deletion src/zkbob/utils/ZkBobAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ contract ZkBobAccounting {
mapping(uint256 => Snapshot) private snapshots; // single linked list of hourly snapshots
mapping(address => UserStats) private userStats;

event UpdateLimits(uint8 indexed tier, PoolLimits limits);
event UpdateTier(address user, uint8 tier);

/**
Expand Down Expand Up @@ -252,13 +253,15 @@ contract ZkBobAccounting {
require(_dailyDepositCap >= _dailyUserDepositCap, "ZkBobAccounting: daily deposit cap too low");
require(_tvlCap >= _dailyDepositCap, "ZkBobAccounting: tvl cap too low");
require(_dailyWithdrawalCap > 0, "ZkBobAccounting: zero daily withdrawal cap");
poolLimits[_tier] = PoolLimits({
PoolLimits memory pl = PoolLimits({
tvlCap: uint56(_tvlCap / PRECISION),
dailyDepositCap: uint32(_dailyDepositCap / PRECISION),
dailyWithdrawalCap: uint32(_dailyWithdrawalCap / PRECISION),
dailyUserDepositCap: uint32(_dailyUserDepositCap / PRECISION),
depositCap: uint32(_depositCap / PRECISION)
});
poolLimits[_tier] = pl;
emit UpdateLimits(_tier, pl);
}

function _setUsersTier(uint8 _tier, address[] memory _users) internal {
Expand Down