Skip to content
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
[submodule "lib/gas-killer-solidity-sdk"]
path = lib/gas-killer-solidity-sdk
url = https://github.com/BreadchainCoop/gas-killer-solidity-sdk
26 changes: 26 additions & 0 deletions foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"lib/bread-token-v2": {
"rev": "77710c4f9809d0e5cda0c76764a8fd9f1fe65354"
},
"lib/forge-std": {
"rev": "1714bee72e286e73f76e320d110e0eaf5c4e649d"
},
"lib/gas-killer-solidity-sdk": {
"rev": "729ab010967afa8835b31704142e823e13680338"
},
"lib/openzeppelin-contracts": {
"tag": {
"name": "v5.5.0",
"rev": "fcbae5394ae8ad52d8e580a3477db99814b9d565"
}
},
"lib/openzeppelin-contracts-upgradeable": {
"tag": {
"name": "v5.5.0",
"rev": "aa677e9d28ed78fc427ec47ba2baef2030c58e7c"
}
},
"lib/openzeppelin-foundry-upgrades": {
"rev": "4cd15fc50b141c77d8cc9ff8efb44d00e841a299"
}
}
4 changes: 3 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ src = "src"
out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read-write", path = "./" }]
solc_version = "0.8.25"
solc_version = "0.8.27"
build_info = true
ffi = true
ast = true
extra_output = ["storageLayout"]
evm_version = "cancun" # Compile Curve LP interface
optimizer = true
optimizer_runs = 10000

[rpc_endpoints]
sepolia = "QUICKNODE_ENDPOINT_URL"
Expand Down
1 change: 1 addition & 0 deletions lib/gas-killer-solidity-sdk
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts-upgradeable
3 changes: 1 addition & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ bread-token/=lib/bread-token-v2/
forge-std/=lib/forge-std/src/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
openzeppelin-contracts/=lib/openzeppelin-contracts/
openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/
gas-killer/=lib/gas-killer-solidity-sdk/
16 changes: 16 additions & 0 deletions script/deploy/DeployYieldDistributorImpl.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "forge-std/console.sol";

import {YieldDistributor} from "../../src/YieldDistributor.sol";

contract DeployYieldDistributorImpl is Script {
function run() external {
vm.startBroadcast();
YieldDistributor yieldDistributor = new YieldDistributor();
console2.log("Deployed YieldDistributor at address: {}", address(yieldDistributor));
vm.stopBroadcast();
}
}
2 changes: 1 addition & 1 deletion script/upgrades/ValidateUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract DeployYieldDistributor is Script {
function run() external {
vm.startBroadcast();
Options memory opts;
opts.referenceContract = "v1.0.4/YieldDistributor.sol:YieldDistributor";
opts.referenceContract = "v1.0.5/YieldDistributor.sol:YieldDistributor";
Upgrades.validateUpgrade("YieldDistributor.sol:YieldDistributor", opts);
vm.stopBroadcast();
}
Expand Down
13 changes: 6 additions & 7 deletions src/ButteredBread.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.25;
pragma solidity ^0.8.25;

import {ERC20VotesUpgradeable} from
"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";
import {
ERC20VotesUpgradeable
} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";
import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuardUpgradeable} from
"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import {IButteredBread} from "src/interfaces/IButteredBread.sol";
import {IERC20Votes} from "src/interfaces/IERC20Votes.sol";
Expand All @@ -20,7 +20,7 @@ import {IERC20Votes} from "src/interfaces/IERC20Votes.sol";
* @custom:coauthor @daopunk
* @custom:coauthor @bagelface
*/
contract ButteredBread is IButteredBread, ERC20VotesUpgradeable, Ownable2StepUpgradeable, ReentrancyGuardUpgradeable {
contract ButteredBread is IButteredBread, ERC20VotesUpgradeable, Ownable2StepUpgradeable, ReentrancyGuard {
/// @notice Value used for calculating the precision of scaling factors
uint256 public constant FIXED_POINT_PERCENT = 100;
/// @notice `IERC20Votes` contract used for powering `ButteredBread` voting
Expand Down Expand Up @@ -52,7 +52,6 @@ contract ButteredBread is IButteredBread, ERC20VotesUpgradeable, Ownable2StepUpg
__EIP712_init(_initData.name, "1");
__ERC20Votes_init();
__Ownable_init(msg.sender);
__ReentrancyGuard_init();

for (uint256 i; i < _initData.liquidityPools.length; ++i) {
scalingFactors[_initData.liquidityPools[i]] = _initData.scalingFactors[i];
Expand Down
26 changes: 17 additions & 9 deletions src/VotingMultipliers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.22;

import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

import {IVotingMultipliers, IMultiplier} from "src/interfaces/IVotingMultipliers.sol";
import {MultiplierConstants} from "src/libraries/MultiplierConstants.sol";

Expand All @@ -16,17 +17,13 @@ contract VotingMultipliers is Ownable2StepUpgradeable, IVotingMultipliers {
}

// keccak256(abi.encode(uint256(keccak256("breadchain.VotingMultipliers.storage")) - 1)) & ~bytes32(uint256(0xff));
bytes32 private constant VOTING_MULTIPLIERS_STORAGE_LOCATION = 0xf8ea84bd4d45550952f40e913fd59ad03bae30b4f3dc5a09695fefe1d0465d00;
bytes32 private constant VOTING_MULTIPLIERS_STORAGE_LOCATION =
0xf8ea84bd4d45550952f40e913fd59ad03bae30b4f3dc5a09695fefe1d0465d00;

/// @notice Initializes the contract
function initialize() public initializer {
__Ownable_init(msg.sender);
}

function _getVotingMultipliersStorage() private pure returns (VotingMultipliersStorage storage $) {
assembly {
$.slot := VOTING_MULTIPLIERS_STORAGE_LOCATION
}
/// @param _initialOwner The address of the initial owner
function __VotingMultipliers_init(address _initialOwner) internal onlyInitializing {
__Ownable_init(_initialOwner);
}

/// @notice Returns the multiplier at the given index
Expand Down Expand Up @@ -155,4 +152,15 @@ contract VotingMultipliers is Ownable2StepUpgradeable, IVotingMultipliers {
}
return Math.max(_totalMultiplier, MultiplierConstants.BASE_MULTIPLIER);
}

/**
* @notice Returns a storage pointer to the VotingMultipliers storage struct
* @dev Internal/private pure helper to retrieve the VotingMultipliersStorage storage location
* @return $ VotingMultipliersStorage storage pointer
*/
function _getVotingMultipliersStorage() private pure returns (VotingMultipliersStorage storage $) {
assembly {
$.slot := VOTING_MULTIPLIERS_STORAGE_LOCATION
}
}
}
Loading