diff --git a/src/dlc-core/DLCManager.sol b/src/dlc-core/DLCManager.sol index c61d3b8..63d5477 100644 --- a/src/dlc-core/DLCManager.sol +++ b/src/dlc-core/DLCManager.sol @@ -124,7 +124,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, _; } - modifier onlyVaultCreator(bytes32 _uuid) { + modifier onlyVaultCreator( + bytes32 _uuid + ) { if (dlcs[dlcIDsByUUID[_uuid]].creator != msg.sender) revert NotOwner(); _; } @@ -267,7 +269,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, * @param proposedTotalValueMinted proposed total minted value in all vaults on this chain. * @return bool whether the proposed total value minted is within bounds. */ - function _checkPoR(uint256 proposedTotalValueMinted) internal view returns (bool) { + function _checkPoR( + uint256 proposedTotalValueMinted + ) internal view returns (bool) { if (!porEnabled) { return true; } @@ -442,14 +446,18 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, // VIEW FUNCTIONS // //////////////////////////////////////////////////////////////// - function getDLC(bytes32 uuid) public view returns (DLCLink.DLC memory) { + function getDLC( + bytes32 uuid + ) public view returns (DLCLink.DLC memory) { DLCLink.DLC memory _dlc = dlcs[dlcIDsByUUID[uuid]]; if (_dlc.uuid == bytes32(0)) revert DLCNotFound(); if (_dlc.uuid != uuid) revert DLCNotFound(); return _dlc; } - function getDLCByIndex(uint256 index) external view returns (DLCLink.DLC memory) { + function getDLCByIndex( + uint256 index + ) external view returns (DLCLink.DLC memory) { return dlcs[index]; } @@ -472,15 +480,21 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, return dlcSubset; } - function getVault(bytes32 uuid) public view returns (DLCLink.DLC memory) { + function getVault( + bytes32 uuid + ) public view returns (DLCLink.DLC memory) { return getDLC(uuid); } - function getAllVaultUUIDsForAddress(address owner) public view returns (bytes32[] memory) { + function getAllVaultUUIDsForAddress( + address owner + ) public view returns (bytes32[] memory) { return userVaults[owner]; } - function getAllVaultsForAddress(address owner) public view returns (DLCLink.DLC[] memory) { + function getAllVaultsForAddress( + address owner + ) public view returns (DLCLink.DLC[] memory) { bytes32[] memory uuids = getAllVaultUUIDsForAddress(owner); DLCLink.DLC[] memory vaults = new DLCLink.DLC[](uuids.length); for (uint256 i = 0; i < uuids.length; i++) { @@ -489,7 +503,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, return vaults; } - function isWhitelisted(address account) external view returns (bool) { + function isWhitelisted( + address account + ) external view returns (bool) { return _whitelistedAddresses[account]; } @@ -509,7 +525,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, // ADMIN FUNCTIONS // //////////////////////////////////////////////////////////////// - function _hasAnyRole(address account) internal view returns (bool) { + function _hasAnyRole( + address account + ) internal view returns (bool) { return hasRole(DLC_ADMIN_ROLE, account) || hasRole(WHITELISTED_CONTRACT, account) || hasRole(APPROVED_SIGNER, account); } @@ -548,7 +566,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, _unpause(); } - function setThreshold(uint16 newThreshold) external onlyAdmin { + function setThreshold( + uint16 newThreshold + ) external onlyAdmin { if (newThreshold < _minimumThreshold) { revert ThresholdTooLow(_minimumThreshold); } @@ -556,35 +576,49 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, emit SetThreshold(newThreshold); } - function setTSSCommitment(bytes32 commitment) external onlyAdmin { + function setTSSCommitment( + bytes32 commitment + ) external onlyAdmin { tssCommitment = commitment; } - function setAttestorGroupPubKey(string calldata pubKey) external onlyAdmin { + function setAttestorGroupPubKey( + string calldata pubKey + ) external onlyAdmin { attestorGroupPubKey = pubKey; } - function whitelistAddress(address addressToWhitelist) external onlyAdmin { + function whitelistAddress( + address addressToWhitelist + ) external onlyAdmin { _whitelistedAddresses[addressToWhitelist] = true; emit WhitelistAddress(addressToWhitelist); } - function unwhitelistAddress(address addressToUnWhitelist) external onlyAdmin { + function unwhitelistAddress( + address addressToUnWhitelist + ) external onlyAdmin { _whitelistedAddresses[addressToUnWhitelist] = false; emit UnwhitelistAddress(addressToUnWhitelist); } - function setMinimumDeposit(uint256 newMinimumDeposit) external onlyAdmin { + function setMinimumDeposit( + uint256 newMinimumDeposit + ) external onlyAdmin { minimumDeposit = newMinimumDeposit; emit SetMinimumDeposit(newMinimumDeposit); } - function setMaximumDeposit(uint256 newMaximumDeposit) external onlyAdmin { + function setMaximumDeposit( + uint256 newMaximumDeposit + ) external onlyAdmin { maximumDeposit = newMaximumDeposit; emit SetMaximumDeposit(newMaximumDeposit); } - function setBtcMintFeeRate(uint256 newBtcMintFeeRate) external onlyAdmin { + function setBtcMintFeeRate( + uint256 newBtcMintFeeRate + ) external onlyAdmin { if (newBtcMintFeeRate > 10_000) { revert FeeRateOutOfBounds(newBtcMintFeeRate); } @@ -592,12 +626,16 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, emit SetBtcMintFeeRate(newBtcMintFeeRate); } - function setBtcRedeemFeeRate(uint256 newBtcRedeemFeeRate) external onlyAdmin { + function setBtcRedeemFeeRate( + uint256 newBtcRedeemFeeRate + ) external onlyAdmin { btcRedeemFeeRate = newBtcRedeemFeeRate; emit SetBtcRedeemFeeRate(newBtcRedeemFeeRate); } - function setBtcFeeRecipient(string calldata btcFeeRecipientToSet) external onlyAdmin { + function setBtcFeeRecipient( + string calldata btcFeeRecipientToSet + ) external onlyAdmin { btcFeeRecipient = btcFeeRecipientToSet; emit SetBtcFeeRecipient(btcFeeRecipient); } @@ -607,30 +645,42 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, dlc.btcFeeRecipient = btcFeeRecipientToSet; } - function setWhitelistingEnabled(bool isWhitelistingEnabled) external onlyAdmin { + function setWhitelistingEnabled( + bool isWhitelistingEnabled + ) external onlyAdmin { whitelistingEnabled = isWhitelistingEnabled; emit SetWhitelistingEnabled(isWhitelistingEnabled); } - function transferTokenContractOwnership(address newOwner) external onlyAdmin { + function transferTokenContractOwnership( + address newOwner + ) external onlyAdmin { dlcBTC.transferOwnership(newOwner); emit TransferTokenContractOwnership(newOwner); } - function setMinterOnTokenContract(address minter) external onlyAdmin { + function setMinterOnTokenContract( + address minter + ) external onlyAdmin { dlcBTC.setMinter(minter); } - function setBurnerOnTokenContract(address burner) external onlyAdmin { + function setBurnerOnTokenContract( + address burner + ) external onlyAdmin { dlcBTC.setBurner(burner); } - function setPorEnabled(bool enabled) external onlyAdmin { + function setPorEnabled( + bool enabled + ) external onlyAdmin { porEnabled = enabled; emit SetPorEnabled(enabled); } - function setDlcBTCPoRFeed(AggregatorV3Interface feed) external onlyAdmin { + function setDlcBTCPoRFeed( + AggregatorV3Interface feed + ) external onlyAdmin { dlcBTCPoRFeed = feed; emit SetDlcBTCPoRFeed(feed); } diff --git a/src/dlc-core/IBTC.sol b/src/dlc-core/IBTC.sol index 9871c5c..5066d6e 100644 --- a/src/dlc-core/IBTC.sol +++ b/src/dlc-core/IBTC.sol @@ -85,16 +85,22 @@ contract IBTC is Initializable, ERC20Upgradeable, ERC20PermitUpgradeable, Ownabl _burn(from, amount); } - function burn(uint256 amount) external onlyCCIPBurner { + function burn( + uint256 amount + ) external onlyCCIPBurner { _burn(msg.sender, amount); } - function setMinter(address minter) external onlyOwner { + function setMinter( + address minter + ) external onlyOwner { _minter = minter; emit MinterSet(minter); } - function setBurner(address burner) external onlyOwner { + function setBurner( + address burner + ) external onlyOwner { _burner = burner; emit BurnerSet(burner); } diff --git a/src/iBTC_Burner.sol b/src/iBTC_Burner.sol index 84d2c87..9107675 100644 --- a/src/iBTC_Burner.sol +++ b/src/iBTC_Burner.sol @@ -30,7 +30,9 @@ contract iBTC_Burner is UintRequests, IiBTC_Burner, IERC721Receiver { * This function triggers a withdrawal by creating one or more withdrawal requests. * It splits the total collateral balance into multiple requests based on the maximum withdrawal limit. */ - function triggerWithdrawal(uint256 maxRequests) external returns (uint256 firstRequestId, uint256 lastRequestId) { + function triggerWithdrawal( + uint256 maxRequests + ) external returns (uint256 firstRequestId, uint256 lastRequestId) { // Get the current balance of the COLLATERAL token held by this contract uint256 amount = IERC20(Collateral).balanceOf(address(this)); diff --git a/src/iBTC_NetworkMiddleware.sol b/src/iBTC_NetworkMiddleware.sol index 6826462..71c48d2 100644 --- a/src/iBTC_NetworkMiddleware.sol +++ b/src/iBTC_NetworkMiddleware.sol @@ -66,7 +66,9 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { EnumerableMap.AddressToUintMap private operators; EnumerableMap.AddressToUintMap private vaults; - modifier updateStakeCache(uint48 epoch) { + modifier updateStakeCache( + uint48 epoch + ) { if (!totalStakeCached[epoch]) { calcAndCacheStakes(epoch); } @@ -96,11 +98,15 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { SLASHING_WINDOW = _slashingWindow; } - function getEpochStartTs(uint48 epoch) public view returns (uint48 timestamp) { + function getEpochStartTs( + uint48 epoch + ) public view returns (uint48 timestamp) { return START_TIME + epoch * EPOCH_DURATION; } - function getEpochAtTs(uint48 timestamp) public view returns (uint48 epoch) { + function getEpochAtTs( + uint48 timestamp + ) public view returns (uint48 epoch) { return (timestamp - START_TIME) / EPOCH_DURATION; } @@ -135,15 +141,21 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { updateKey(operator, key); } - function pauseOperator(address operator) external onlyOwner { + function pauseOperator( + address operator + ) external onlyOwner { operators.disable(operator); } - function unpauseOperator(address operator) external onlyOwner { + function unpauseOperator( + address operator + ) external onlyOwner { operators.enable(operator); } - function unregisterOperator(address operator) external onlyOwner { + function unregisterOperator( + address operator + ) external onlyOwner { (, uint48 disabledTime) = operators.getTimes(operator); if (disabledTime == 0 || disabledTime + SLASHING_WINDOW > Time.timestamp()) { @@ -153,7 +165,9 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { operators.remove(operator); } - function registerVault(address vault) external onlyOwner { + function registerVault( + address vault + ) external onlyOwner { if (vaults.contains(vault)) { revert VaultAlreadyRegistred(); } @@ -177,15 +191,21 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { vaults.enable(vault); } - function pauseVault(address vault) external onlyOwner { + function pauseVault( + address vault + ) external onlyOwner { vaults.disable(vault); } - function unpauseVault(address vault) external onlyOwner { + function unpauseVault( + address vault + ) external onlyOwner { vaults.enable(vault); } - function unregisterVault(address vault) external onlyOwner { + function unregisterVault( + address vault + ) external onlyOwner { (, uint48 disabledTime) = vaults.getTimes(vault); if (disabledTime == 0 || disabledTime + SLASHING_WINDOW > Time.timestamp()) { @@ -217,14 +237,18 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { return stake; } - function getTotalStake(uint48 epoch) public view returns (uint256) { + function getTotalStake( + uint48 epoch + ) public view returns (uint256) { if (totalStakeCached[epoch]) { return totalStakeCache[epoch]; } return _calcTotalStake(epoch); } - function getValidatorSet(uint48 epoch) public view returns (ValidatorData[] memory validatorsData) { + function getValidatorSet( + uint48 epoch + ) public view returns (ValidatorData[] memory validatorsData) { uint48 epochStartTs = getEpochStartTs(epoch); validatorsData = new ValidatorData[](operators.length()); @@ -291,7 +315,9 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { } } - function calcAndCacheStakes(uint48 epoch) public returns (uint256 totalStake) { + function calcAndCacheStakes( + uint48 epoch + ) public returns (uint256 totalStake) { uint48 epochStartTs = getEpochStartTs(epoch); // for epoch older than SLASHING_WINDOW total stake can be invalidated (use cache) @@ -321,7 +347,9 @@ contract NetworkMiddleware is SimpleKeyRegistry32, Ownable { totalStakeCache[epoch] = totalStake; } - function _calcTotalStake(uint48 epoch) private view returns (uint256 totalStake) { + function _calcTotalStake( + uint48 epoch + ) private view returns (uint256 totalStake) { uint48 epochStartTs = getEpochStartTs(epoch); // for epoch older than SLASHING_WINDOW total stake can be invalidated (use cache) diff --git a/src/iBTC_Treasury.sol b/src/iBTC_Treasury.sol index c3a2184..9b782c2 100644 --- a/src/iBTC_Treasury.sol +++ b/src/iBTC_Treasury.sol @@ -62,7 +62,9 @@ contract iBTC_Treasury is ERC721, Ownable { * @dev Allows users to create a withdrawal request. * Transfers collateral from the caller to the treasury and mints an ERC721 token. */ - function createWithdrawRequest(uint256 amount) external { + function createWithdrawRequest( + uint256 amount + ) external { require(amount >= minWithdrawAmount, "Amount below minimum limit"); require(amount <= maxWithdrawAmount, "Amount exceeds maximum limit"); @@ -86,7 +88,9 @@ contract iBTC_Treasury is ERC721, Ownable { * @dev Finalizes a withdrawal request and burns the corresponding token. * Transfers the collateral back to the token owner. */ - function finalizeWithdrawal(uint256 requestId) external onlyOwner { + function finalizeWithdrawal( + uint256 requestId + ) external onlyOwner { require(!finalizedWithdrawals[requestId], "Already finalized"); address requester = ownerOf(requestId); @@ -109,7 +113,9 @@ contract iBTC_Treasury is ERC721, Ownable { * @dev Batch process withdrawals up to a specified token ID. * Only callable by the contract owner. */ - function processWithdrawals(uint256 _lastrequestIdToProcess) external onlyOwner { + function processWithdrawals( + uint256 _lastrequestIdToProcess + ) external onlyOwner { for (uint256 requestId = 1; requestId <= _lastrequestIdToProcess; requestId++) { if (_exits(requestId) && !finalizedWithdrawals[requestId]) { address requester = ownerOf(requestId); @@ -133,7 +139,9 @@ contract iBTC_Treasury is ERC721, Ownable { return minWithdrawAmount; } - function _exits(uint256 requestId) internal view returns (bool) { + function _exits( + uint256 requestId + ) internal view returns (bool) { return ownerOf(requestId) != address(0); } } diff --git a/src/iBTC_Vault.sol b/src/iBTC_Vault.sol index 19e7f6e..5d58e47 100644 --- a/src/iBTC_Vault.sol +++ b/src/iBTC_Vault.sol @@ -62,7 +62,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, /** * @inheritdoc IVault */ - function activeBalanceOf(address account) public view returns (uint256) { + function activeBalanceOf( + address account + ) public view returns (uint256) { return ERC4626Math.previewRedeem(activeSharesOf(account), activeStake(), activeShares()); } @@ -77,7 +79,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, /** * @inheritdoc IVault */ - function slashableBalanceOf(address account) external view returns (uint256) { + function slashableBalanceOf( + address account + ) external view returns (uint256) { uint256 epoch = currentEpoch(); return activeBalanceOf(account) + withdrawalsOf(epoch, account) + withdrawalsOf(epoch + 1, account); } @@ -262,7 +266,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, /** * @inheritdoc IVault */ - function setDepositWhitelist(bool status) external nonReentrant onlyRole(DEPOSIT_WHITELIST_SET_ROLE) { + function setDepositWhitelist( + bool status + ) external nonReentrant onlyRole(DEPOSIT_WHITELIST_SET_ROLE) { if (depositWhitelist == status) { revert AlreadySet(); } @@ -295,7 +301,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, /** * @inheritdoc IVault */ - function setIsDepositLimit(bool status) external nonReentrant onlyRole(IS_DEPOSIT_LIMIT_SET_ROLE) { + function setIsDepositLimit( + bool status + ) external nonReentrant onlyRole(IS_DEPOSIT_LIMIT_SET_ROLE) { if (isDepositLimit == status) { revert AlreadySet(); } @@ -308,7 +316,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, /** * @inheritdoc IVault */ - function setDepositLimit(uint256 limit) external nonReentrant onlyRole(DEPOSIT_LIMIT_SET_ROLE) { + function setDepositLimit( + uint256 limit + ) external nonReentrant onlyRole(DEPOSIT_LIMIT_SET_ROLE) { if (depositLimit == limit) { revert AlreadySet(); } @@ -318,7 +328,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, emit SetDepositLimit(limit); } - function setDelegator(address delegator_) external nonReentrant { + function setDelegator( + address delegator_ + ) external nonReentrant { if (isDelegatorInitialized) { revert DelegatorAlreadyInitialized(); } @@ -338,7 +350,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, emit SetDelegator(delegator_); } - function setSlasher(address slasher_) external nonReentrant { + function setSlasher( + address slasher_ + ) external nonReentrant { if (isSlasherInitialized) { revert SlasherAlreadyInitialized(); } @@ -382,7 +396,9 @@ contract iBTC_Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, emit Withdraw(msg.sender, claimer, withdrawnAssets, burnedShares, mintedShares); } - function _claim(uint256 epoch) internal returns (uint256 amount) { + function _claim( + uint256 epoch + ) internal returns (uint256 amount) { if (epoch >= currentEpoch()) { revert InvalidEpoch(); } diff --git a/src/iBTC_VaultConfigurator.sol b/src/iBTC_VaultConfigurator.sol index b87025e..9cd380e 100644 --- a/src/iBTC_VaultConfigurator.sol +++ b/src/iBTC_VaultConfigurator.sol @@ -34,7 +34,9 @@ contract VaultConfigurator is IVaultConfigurator { /** * @inheritdoc IVaultConfigurator */ - function create(InitParams memory params) public returns (address vault, address delegator, address slasher) { + function create( + InitParams memory params + ) public returns (address vault, address delegator, address slasher) { vault = VaultFactory(VAULT_FACTORY).create(params.version, params.owner, params.vaultParams); delegator = diff --git a/src/interfaces/IiBTC_Burner.sol b/src/interfaces/IiBTC_Burner.sol index b024191..30f930e 100644 --- a/src/interfaces/IiBTC_Burner.sol +++ b/src/interfaces/IiBTC_Burner.sol @@ -30,5 +30,7 @@ interface IiBTC_Burner is IUintRequests { * @return firstRequestId first request ID that was created * @return lastRequestId last request ID that was created */ - function triggerWithdrawal(uint256 maxRequests) external returns (uint256 firstRequestId, uint256 lastRequestId); + function triggerWithdrawal( + uint256 maxRequests + ) external returns (uint256 firstRequestId, uint256 lastRequestId); } diff --git a/src/interfaces/IiBTC_Treasury.sol b/src/interfaces/IiBTC_Treasury.sol index 06a8146..b17740e 100644 --- a/src/interfaces/IiBTC_Treasury.sol +++ b/src/interfaces/IiBTC_Treasury.sol @@ -8,9 +8,15 @@ interface IiBTC_Treasury { function withdrawRequestMinimum() external view returns (uint256); - function processWithdrawals(uint256 _lastTokenIdToProcess) external; + function processWithdrawals( + uint256 _lastTokenIdToProcess + ) external; - function createWithdrawRequest(uint256 amount) external; + function createWithdrawRequest( + uint256 amount + ) external; - function finalizeWithdrawal(uint256 tokenId) external; + function finalizeWithdrawal( + uint256 tokenId + ) external; } diff --git a/src/libraries/AggregatorV3Interface.sol b/src/libraries/AggregatorV3Interface.sol index 81b2aff..2062677 100644 --- a/src/libraries/AggregatorV3Interface.sol +++ b/src/libraries/AggregatorV3Interface.sol @@ -9,7 +9,9 @@ interface AggregatorV3Interface { function version() external view returns (uint256); - function getRoundData(uint80 _roundId) + function getRoundData( + uint80 _roundId + ) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); diff --git a/src/libraries/Counter.sol b/src/libraries/Counter.sol index ece483e..3631f01 100644 --- a/src/libraries/Counter.sol +++ b/src/libraries/Counter.sol @@ -6,17 +6,23 @@ library Counters { uint256 _value; // Default: 0 } - function current(Counter storage counter) internal view returns (uint256) { + function current( + Counter storage counter + ) internal view returns (uint256) { return counter._value; } - function increment(Counter storage counter) internal { + function increment( + Counter storage counter + ) internal { unchecked { counter._value += 1; } } - function decrement(Counter storage counter) internal { + function decrement( + Counter storage counter + ) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { @@ -24,7 +30,9 @@ library Counters { } } - function reset(Counter storage counter) internal { + function reset( + Counter storage counter + ) internal { counter._value = 0; } } diff --git a/src/libraries/SimpleKeyRegistry32.sol b/src/libraries/SimpleKeyRegistry32.sol index 90f5de6..5255d8f 100644 --- a/src/libraries/SimpleKeyRegistry32.sol +++ b/src/libraries/SimpleKeyRegistry32.sol @@ -18,11 +18,15 @@ abstract contract SimpleKeyRegistry32 { uint208 internal constant EMPTY_KEY_IDX = 0; - function getOperatorByKey(bytes32 key) public view returns (address) { + function getOperatorByKey( + bytes32 key + ) public view returns (address) { return keyToOperator[key]; } - function getCurrentOperatorKey(address operator) public view returns (bytes32) { + function getCurrentOperatorKey( + address operator + ) public view returns (bytes32) { uint208 keyIdx = operatorToIdx[operator].latest(); if (keyIdx == EMPTY_KEY_IDX) { diff --git a/test/iBTC_Vault.t.sol b/test/iBTC_Vault.t.sol index 7087210..54454a8 100644 --- a/test/iBTC_Vault.t.sol +++ b/test/iBTC_Vault.t.sol @@ -334,7 +334,9 @@ contract VaultTest is Test { ); } - function test_CreateRevertInvalidCollateral(uint48 epochDuration) public { + function test_CreateRevertInvalidCollateral( + uint48 epochDuration + ) public { epochDuration = uint48(bound(epochDuration, 1, 50 weeks)); address[] memory networkLimitSetRoleHolders = new address[](1); @@ -381,7 +383,9 @@ contract VaultTest is Test { ); } - function test_CreateRevertMissingRoles1(uint48 epochDuration) public { + function test_CreateRevertMissingRoles1( + uint48 epochDuration + ) public { epochDuration = uint48(bound(epochDuration, 1, 50 weeks)); uint64 lastVersion = vaultFactory.lastVersion(); @@ -410,7 +414,9 @@ contract VaultTest is Test { ); } - function test_CreateRevertMissingRoles2(uint48 epochDuration) public { + function test_CreateRevertMissingRoles2( + uint48 epochDuration + ) public { epochDuration = uint48(bound(epochDuration, 1, 50 weeks)); uint64 lastVersion = vaultFactory.lastVersion(); @@ -439,7 +445,9 @@ contract VaultTest is Test { ); } - function test_CreateRevertMissingRoles3(uint48 epochDuration) public { + function test_CreateRevertMissingRoles3( + uint48 epochDuration + ) public { epochDuration = uint48(bound(epochDuration, 1, 50 weeks)); uint64 lastVersion = vaultFactory.lastVersion(); @@ -468,7 +476,9 @@ contract VaultTest is Test { ); } - function test_CreateRevertMissingRoles4(uint48 epochDuration) public { + function test_CreateRevertMissingRoles4( + uint48 epochDuration + ) public { epochDuration = uint48(bound(epochDuration, 1, 50 weeks)); uint64 lastVersion = vaultFactory.lastVersion(); @@ -497,7 +507,9 @@ contract VaultTest is Test { ); } - function test_CreateRevertMissingRoles5(uint48 epochDuration) public { + function test_CreateRevertMissingRoles5( + uint48 epochDuration + ) public { epochDuration = uint48(bound(epochDuration, 1, 50 weeks)); uint64 lastVersion = vaultFactory.lastVersion(); @@ -1380,7 +1392,9 @@ contract VaultTest is Test { assertEq(iBTCVault.slashableBalanceOf(bob), amount2); } - function test_DepositRevertInvalidOnBehalfOf(uint256 amount1) public { + function test_DepositRevertInvalidOnBehalfOf( + uint256 amount1 + ) public { amount1 = bound(amount1, 1, 100 * 10 ** 18); uint48 epochDuration = 1; @@ -1501,7 +1515,9 @@ contract VaultTest is Test { assertEq(iBTCVault.totalStake(), amount1 - amount2 - amount3); } - function test_WithdrawRevertInvalidClaimer(uint256 amount1) public { + function test_WithdrawRevertInvalidClaimer( + uint256 amount1 + ) public { amount1 = bound(amount1, 1, 100 * 10 ** 18); uint48 epochDuration = 1; @@ -1515,7 +1531,9 @@ contract VaultTest is Test { vm.stopPrank(); } - function test_WithdrawRevertInsufficientWithdrawal(uint256 amount1) public { + function test_WithdrawRevertInsufficientWithdrawal( + uint256 amount1 + ) public { amount1 = bound(amount1, 1, 100 * 10 ** 18); uint48 epochDuration = 1; @@ -1527,7 +1545,9 @@ contract VaultTest is Test { _withdraw(alice, 0); } - function test_WithdrawRevertTooMuchWithdraw(uint256 amount1) public { + function test_WithdrawRevertTooMuchWithdraw( + uint256 amount1 + ) public { amount1 = bound(amount1, 1, 100 * 10 ** 18); uint48 epochDuration = 1; @@ -1641,7 +1661,9 @@ contract VaultTest is Test { assertEq(iBTCVault.totalStake(), amount1 - withdrawnAssets2 - withdrawnAssets3); } - function test_RedeemRevertInvalidClaimer(uint256 amount1) public { + function test_RedeemRevertInvalidClaimer( + uint256 amount1 + ) public { amount1 = bound(amount1, 1, 100 * 10 ** 18); uint48 epochDuration = 1; @@ -1655,7 +1677,9 @@ contract VaultTest is Test { vm.stopPrank(); } - function test_RedeemRevertInsufficientRedeemption(uint256 amount1) public { + function test_RedeemRevertInsufficientRedeemption( + uint256 amount1 + ) public { amount1 = bound(amount1, 1, 100 * 10 ** 18); uint48 epochDuration = 1; @@ -1667,7 +1691,9 @@ contract VaultTest is Test { _redeem(alice, 0); } - function test_RedeemRevertTooMuchRedeem(uint256 amount1) public { + function test_RedeemRevertTooMuchRedeem( + uint256 amount1 + ) public { amount1 = bound(amount1, 1, 100 * 10 ** 18); uint48 epochDuration = 1; @@ -2181,7 +2207,9 @@ contract VaultTest is Test { _deposit(alice, depositAmount); } - function test_SetDepositLimitToNull(uint256 limit1) public { + function test_SetDepositLimitToNull( + uint256 limit1 + ) public { uint48 epochDuration = 1; iBTCVault = _getVault(epochDuration); @@ -2222,7 +2250,9 @@ contract VaultTest is Test { vm.stopPrank(); } - function test_SetDepositLimitRevertAlreadySet(uint256 limit) public { + function test_SetDepositLimitRevertAlreadySet( + uint256 limit + ) public { uint48 epochDuration = 1; iBTCVault = _getVault(epochDuration); @@ -2654,7 +2684,9 @@ contract VaultTest is Test { // assertLt(gasStruct.gasSpent1 - gasStruct.gasSpent2, 10_000); // } - function _getVault(uint48 epochDuration) internal returns (iBTC_Vault) { + function _getVault( + uint48 epochDuration + ) internal returns (iBTC_Vault) { address[] memory networkLimitSetRoleHolders = new address[](1); networkLimitSetRoleHolders[0] = alice; address[] memory operatorNetworkSharesSetRoleHolders = new address[](1); @@ -2699,10 +2731,9 @@ contract VaultTest is Test { return iBTC_Vault(vault_); } - function _getVaultAndDelegatorAndSlasher(uint48 epochDuration) - internal - returns (iBTC_Vault, FullRestakeDelegator, Slasher) - { + function _getVaultAndDelegatorAndSlasher( + uint48 epochDuration + ) internal returns (iBTC_Vault, FullRestakeDelegator, Slasher) { address[] memory networkLimitSetRoleHolders = new address[](1); networkLimitSetRoleHolders[0] = alice; address[] memory operatorNetworkLimitSetRoleHolders = new address[](1); @@ -2747,7 +2778,9 @@ contract VaultTest is Test { return (iBTC_Vault(vault_), FullRestakeDelegator(delegator_), Slasher(slasher_)); } - function _registerOperator(address user) internal { + function _registerOperator( + address user + ) internal { vm.startPrank(user); operatorRegistry.registerOperator(); vm.stopPrank(); @@ -2816,13 +2849,17 @@ contract VaultTest is Test { vm.stopPrank(); } - function _optInOperatorVault(address user) internal { + function _optInOperatorVault( + address user + ) internal { vm.startPrank(user); operatorVaultOptInService.optIn(address(iBTCVault)); vm.stopPrank(); } - function _optOutOperatorVault(address user) internal { + function _optOutOperatorVault( + address user + ) internal { vm.startPrank(user); operatorVaultOptInService.optOut(address(iBTCVault)); vm.stopPrank(); diff --git a/test/mocks/MapWithTimeDataContract.sol b/test/mocks/MapWithTimeDataContract.sol index a53d8bf..615d5ba 100644 --- a/test/mocks/MapWithTimeDataContract.sol +++ b/test/mocks/MapWithTimeDataContract.sol @@ -11,23 +11,33 @@ contract MapWithTimeDataContract { EnumerableMap.AddressToUintMap internal elements; - function add(address addr) public { + function add( + address addr + ) public { elements.add(addr); } - function disable(address addr) public { + function disable( + address addr + ) public { elements.disable(addr); } - function enable(address addr) public { + function enable( + address addr + ) public { elements.enable(addr); } - function atWithTimes(uint256 idx) public view returns (address key, uint48 enabledTime, uint48 disabledTime) { + function atWithTimes( + uint256 idx + ) public view returns (address key, uint48 enabledTime, uint48 disabledTime) { return elements.atWithTimes(idx); } - function getTimes(address addr) public view returns (uint48 enabledTime, uint48 disabledTime) { + function getTimes( + address addr + ) public view returns (uint48 enabledTime, uint48 disabledTime) { return elements.getTimes(addr); }