Skip to content

Commit

Permalink
testnet deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Aug 1, 2024
1 parent 533be18 commit 4925683
Show file tree
Hide file tree
Showing 9 changed files with 1,245 additions and 151 deletions.
306 changes: 306 additions & 0 deletions broadcast/DeployTestnet.s.sol/11155111/run-1722523794.json

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions broadcast/DeployTestnet.s.sol/11155111/run-1722523827.json

Large diffs are not rendered by default.

173 changes: 173 additions & 0 deletions broadcast/DeployTestnet.s.sol/11155111/run-1722525266.json

Large diffs are not rendered by default.

307 changes: 307 additions & 0 deletions broadcast/DeployTestnet.s.sol/11155111/run-1722526027.json

Large diffs are not rendered by default.

261 changes: 131 additions & 130 deletions broadcast/DeployTestnet.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[profile.default]
evm_version = "paris"
optimizer = true
optimizer_runs = 20
optimizer_runs = 100
via_ir = true
solc_version = "0.8.26"
verbosity = 3
Expand All @@ -20,3 +20,7 @@
mainnet = "${MAINNET_RPC_URL}"
testnet = "${TESTNET_RPC_URL}"

[etherscan]
mainnet = { key = "${ETHERSCAN_MAINNET_KEY}" }
testnet = { key = "${ETHERSCAN_MAINNET_KEY}", chain = "11155111" }

5 changes: 5 additions & 0 deletions script/testnet/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ address constant CONTRACT_OWNER = 0xcAd73213b07F35265fa46298a7Cc3405C3c53645;
uint256 constant MIN_STAKE = 50_000e18;
uint256 constant REWARD_RATE = 0.1333333333e18;
uint256 constant LOCK_PERIOD = 182 days;

address constant STAKING_CONTRACT_IMPL = 0x966aea71f391D044017143ab1D7e5DEd9a950e7e;
address constant STAKING_CONTRACT_PROXY = 0xe53a0850fDd90af0be3d4fDE02bD36C5EdFfc437;
address constant MOCKED_SHU = 0xF2215e7eDfc4782D85BAfA06114f22A0654cA8aC;
address constant REWARDS_DISTRIBUTOR = 0x8aA01CcdEec887f0a6AF127b094702F283d244DE;
2 changes: 1 addition & 1 deletion script/testnet/DeployTestnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Staking} from "src/Staking.sol";
import {MockGovToken} from "test/mocks/MockGovToken.sol";
import "./Constants.sol";

// forge script script/testnet/DeployTestnet.s.sol --rpc-url testnet -vvvvv --slow --always-use-create-2-factory --account test
// forge script script/testnet/DeployTestnet.s.sol --rpc-url testnet -vvvvv --slow --always-use-create-2-factory --account test --etherscan-api-key testnet --verify --chain 11155111
contract DeployTestnet is Script {
function run()
public
Expand Down
30 changes: 11 additions & 19 deletions src/BaseStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import {SafeTransferLib} from "./libraries/SafeTransferLib.sol";
import {FixedPointMathLib} from "./libraries/FixedPointMathLib.sol";
import {IRewardsDistributor} from "./interfaces/IRewardsDistributor.sol";

interface IStaking {
function keypers(address user) external returns (bool);
}

abstract contract BaseStaking is OwnableUpgradeable, ERC20VotesUpgradeable {
/*//////////////////////////////////////////////////////////////
LIBRARIES
Expand Down Expand Up @@ -61,9 +57,6 @@ abstract contract BaseStaking is OwnableUpgradeable, ERC20VotesUpgradeable {
/// @notice Emitted when a keyper claims rewards
event RewardsClaimed(address indexed user, uint256 rewards);

/// @notice Emitted when the rewards distributor is changed
event NewRewardsDistributor(address indexed rewardsDistributor);

/// @notice Emitted when the lock period is changed
event NewLockPeriod(uint256 indexed lockPeriod);

Expand Down Expand Up @@ -129,7 +122,7 @@ abstract contract BaseStaking is OwnableUpgradeable, ERC20VotesUpgradeable {
require(rewards > 0, NoRewardsToClaim());

// Calculates the amount of shares to burn
uint256 shares = previewWithdraw(rewards);
uint256 shares = _previewWithdraw(rewards);

_burn(user, shares);

Expand All @@ -149,8 +142,7 @@ abstract contract BaseStaking is OwnableUpgradeable, ERC20VotesUpgradeable {
) external onlyOwner {
require(_rewardsDistributor != address(0), AddressZero());
rewardsDistributor = IRewardsDistributor(_rewardsDistributor);

emit NewRewardsDistributor(_rewardsDistributor);
// no events for this function due to 24kb contract size limit
}

/// @notice Set the lock period
Expand Down Expand Up @@ -183,13 +175,6 @@ abstract contract BaseStaking is OwnableUpgradeable, ERC20VotesUpgradeable {
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/

function previewWithdraw(
uint256 assets
) public view virtual returns (uint256) {
// sum + 1 on both sides to prevent donation attack
return assets.mulDivUp(totalSupply() + 1, _totalAssets() + 1);
}

/// @notice Get the total amount of shares the assets are worth
/// @param assets The amount of assets
function convertToShares(
Expand Down Expand Up @@ -247,7 +232,7 @@ abstract contract BaseStaking is OwnableUpgradeable, ERC20VotesUpgradeable {
address user,
uint256 amount
) internal returns (uint256 shares) {
shares = previewWithdraw(amount);
shares = _previewWithdraw(amount);

// Decrease the amount from the total locked
totalLocked[user] -= amount;
Expand All @@ -260,10 +245,17 @@ abstract contract BaseStaking is OwnableUpgradeable, ERC20VotesUpgradeable {
}

/// @notice Get the amount of SHU staked for all keypers
function _totalAssets() internal view virtual returns (uint256) {
function _totalAssets() internal view returns (uint256) {
return stakingToken.balanceOf(address(this));
}

/// @notice Get the amount of shares that will be burned
/// @param assets The amount of assets
function _previewWithdraw(uint256 assets) internal view returns (uint256) {
// sum + 1 on both sides to prevent donation attack
return assets.mulDivUp(totalSupply() + 1, _totalAssets() + 1);
}

/// @notice Calculates the amount to withdraw
/// @param _amount The amount to withdraw
/// @param maxWithdrawAmount The maximum amount that can be withdrawn
Expand Down

0 comments on commit 4925683

Please sign in to comment.