Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
scolear committed Nov 19, 2024
1 parent 6606b8f commit d86342d
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 276 deletions.
9 changes: 9 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ ast = true
build_info = true
extra_output = ["storageLayout"]

[fmt]
bracket_spacing = false
int_types = "long"
line_length = 120
multiline_func_header = "params_first"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
2 changes: 1 addition & 1 deletion lib/core
Submodule core updated 260 files
2 changes: 1 addition & 1 deletion lib/forge-std
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts-upgradeable
2 changes: 1 addition & 1 deletion lib/rewards
Submodule rewards updated 30 files
+4 −1 .gitignore
+4 −0 README.md
+36 −0 cli/defaultOperatorRewards/data/distribution.json.example
+1 −0 cli/defaultOperatorRewards/data/trees.json.example
+45 −0 cli/defaultOperatorRewards/distributionToProofs.js
+31 −0 cli/defaultOperatorRewards/distributionToRoots.js
+37 −0 cli/defaultOperatorRewards/distributionToTrees.js
+42 −0 cli/defaultOperatorRewards/treesToDistribution.js
+44 −0 cli/defaultOperatorRewards/treesToProofs.js
+31 −0 cli/defaultOperatorRewards/treesToRoots.js
+0 −3 foundry.toml
+1 −1 lib/core
+5 −3 package.json
+21 −0 script/deploy/DefaultOperatorRewards.s.sol
+24 −0 script/deploy/DefaultOperatorRewardsFactory.s.sol
+31 −0 script/deploy/DefaultRewardsFactories.s.sol
+7 −6 script/deploy/DefaultStakerRewards.s.sol
+22 −0 script/deploy/DefaultStakerRewardsFactory.s.sol
+0 −19 script/deploy/defaultStakerRewards/DefaultStakerRewardsFactory.s.sol
+110 −0 specs/OperatorRewards.md
+4 −4 specs/StakerRewards.md
+1 −7 src/contracts/defaultStakerRewards/DefaultStakerRewards.sol
+1 −1 src/interfaces/defaultOperatorRewards/IDefaultOperatorRewards.sol
+1 −1 src/interfaces/defaultOperatorRewards/IDefaultOperatorRewardsFactory.sol
+1 −7 src/interfaces/defaultStakerRewards/IDefaultStakerRewards.sol
+1 −1 src/interfaces/defaultStakerRewards/IDefaultStakerRewardsFactory.sol
+1 −1 src/interfaces/stakerRewards/IStakerRewards.sol
+25 −0 test/defaultOperatorRewards/DefaultOperatorRewards.t.sol
+41 −28 test/defaultStakerRewards/DefaultStakerRewards.t.sol
+43 −32 test/defaultStakerRewards/DefaultStakerRewardsFactory.t.sol
105 changes: 76 additions & 29 deletions src/DLCManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable,
_;
}

modifier onlyVaultCreator(bytes32 _uuid) {
modifier onlyVaultCreator(
bytes32 _uuid
) {
if (dlcs[dlcIDsByUUID[_uuid]].creator != tx.origin) revert NotOwner();
_;
}
Expand Down Expand Up @@ -211,7 +213,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable,
* @param signatures Array of signatures.
* @return bool True if there are duplicates, false otherwise.
*/
function _hasDuplicates(bytes[] memory signatures) internal pure returns (bool) {
function _hasDuplicates(
bytes[] memory signatures
) internal pure returns (bool) {
for (uint256 i = 0; i < signatures.length - 1; i++) {
for (uint256 j = i + 1; j < signatures.length; j++) {
if (keccak256(signatures[i]) == keccak256(signatures[j])) {
Expand Down Expand Up @@ -277,11 +281,12 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable,
* @param signatures Signatures of the Attestors.
* @param newValueLocked New value locked in the DLC.
*/
function setStatusFunded(bytes32 uuid, string calldata btcTxId, bytes[] calldata signatures, uint256 newValueLocked)
external
whenNotPaused
onlyApprovedSigners
{
function setStatusFunded(
bytes32 uuid,
string calldata btcTxId,
bytes[] calldata signatures,
uint256 newValueLocked
) external whenNotPaused onlyApprovedSigners {
_attestorMultisigIsValid(abi.encode(uuid, btcTxId, "set-status-funded", newValueLocked), signatures);
DLCLink.DLC storage dlc = dlcs[dlcIDsByUUID[uuid]];

Expand Down Expand Up @@ -378,14 +383,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];
}

Expand All @@ -408,15 +417,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++) {
Expand All @@ -425,7 +440,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];
}

Expand All @@ -445,7 +462,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);
}
Expand Down Expand Up @@ -477,56 +496,76 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable,
_unpause();
}

function setThreshold(uint16 newThreshold) external onlyAdmin {
function setThreshold(
uint16 newThreshold
) external onlyAdmin {
if (newThreshold < _minimumThreshold) {
revert ThresholdTooLow(_minimumThreshold);
}
_threshold = newThreshold;
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 {
if (newBtcMintFeeRate > 10000) {
function setBtcMintFeeRate(
uint256 newBtcMintFeeRate
) external onlyAdmin {
if (newBtcMintFeeRate > 10_000) {
revert FeeRateOutOfBounds(newBtcMintFeeRate);
}
btcMintFeeRate = newBtcMintFeeRate;
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);
}
Expand All @@ -536,21 +575,29 @@ 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);
}
}
8 changes: 6 additions & 2 deletions src/SimpleKeyRegistry32.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit d86342d

Please sign in to comment.