Skip to content

Commit

Permalink
Add deploy script and integration test setup (#49)
Browse files Browse the repository at this point in the history
* Add deploy script with some placeholder values

---------

Co-authored-by: Ben DiFrancesco <[email protected]>
  • Loading branch information
alexkeating and apbendi authored Feb 7, 2024
1 parent 6b2d20e commit 3ed27c3
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MAINNET_RPC_URL=
FOUNDRY_PROFILE=default
DEPLOYER_PRIVATE_KEY=
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

env:
FOUNDRY_PROFILE: ci
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# Speed up compilation and tests during development.
optimizer = false

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"

[fmt]
bracket_spacing = false
int_types = "long"
Expand Down
47 changes: 45 additions & 2 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,51 @@

pragma solidity 0.8.23;

import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {Script} from "forge-std/Script.sol";

contract Deploy is Script {
function run() public {}
import {DeployInput} from "script/DeployInput.sol";
import {UniStaker} from "src/UniStaker.sol";
import {V3FactoryOwner} from "src/V3FactoryOwner.sol";
import {IERC20Delegates} from "src/interfaces/IERC20Delegates.sol";
import {INotifiableRewardReceiver} from "src/interfaces/INotifiableRewardReceiver.sol";
import {IUniswapV3FactoryOwnerActions} from "src/interfaces/IUniswapV3FactoryOwnerActions.sol";

contract Deploy is Script, DeployInput {
uint256 deployerPrivateKey;

function setUp() public {
deployerPrivateKey = vm.envOr(
"DEPLOYER_PRIVATE_KEY",
uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80)
);
}

function run() public returns (V3FactoryOwner, UniStaker) {
vm.startBroadcast(deployerPrivateKey);
// Deploy the staking contract
UniStaker uniStaker = new UniStaker(
IERC20(PAYOUT_TOKEN_ADDRESS),
IERC20Delegates(STAKE_TOKEN_ADDRESS),
vm.addr(deployerPrivateKey)
);

// Deploy a new owner for the V3 factory owner actions contract.
V3FactoryOwner v3FactoryOwner = new V3FactoryOwner(
UNISWAP_GOVERNOR_TIMELOCK,
IUniswapV3FactoryOwnerActions(UNISWAP_V3_FACTORY_ADDRESS),
IERC20(PAYOUT_TOKEN_ADDRESS),
PAYOUT_AMOUNT,
INotifiableRewardReceiver(uniStaker)
);

// Enable the v3FactoryOwner as a UniStaker rewards notifier
uniStaker.setRewardsNotifier(address(v3FactoryOwner), true);

// Change UniStaker admin from `msg.sender` to the Governor timelock
uniStaker.setAdmin(UNISWAP_GOVERNOR_TIMELOCK);
vm.stopBroadcast();

return (v3FactoryOwner, uniStaker);
}
}
14 changes: 14 additions & 0 deletions script/DeployInput.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: AGPL-3.0-only
// slither-disable-start reentrancy-benign

pragma solidity 0.8.23;

contract DeployInput {
address constant UNISWAP_GOVERNOR_TIMELOCK = 0x1a9C8182C09F50C8318d769245beA52c32BE35BC;
address constant UNISWAP_V3_FACTORY_ADDRESS = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
// TODO not finalized: currently WETH
address constant PAYOUT_TOKEN_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address constant STAKE_TOKEN_ADDRESS = 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984;
// TODO not determined yet
uint256 constant PAYOUT_AMOUNT = 10e18;
}
32 changes: 32 additions & 0 deletions test/UniStaker.integration.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.23;

import {Vm, Test, console2} from "forge-std/Test.sol";
import {Deploy} from "script/Deploy.s.sol";
import {DeployInput} from "script/DeployInput.sol";

import {V3FactoryOwner} from "src/V3FactoryOwner.sol";
import {UniStaker} from "src/UniStaker.sol";

contract DeployScriptTest is Test, DeployInput {
function setUp() public {
vm.createSelectFork(vm.rpcUrl("mainnet"));
}

function testFork_DeployStakingContracts() public {
Deploy _deployScript = new Deploy();
_deployScript.setUp();
(V3FactoryOwner v3FactoryOwner, UniStaker uniStaker) = _deployScript.run();

assertEq(v3FactoryOwner.admin(), UNISWAP_GOVERNOR_TIMELOCK);
assertEq(address(v3FactoryOwner.FACTORY()), address(UNISWAP_V3_FACTORY_ADDRESS));
assertEq(address(v3FactoryOwner.PAYOUT_TOKEN()), PAYOUT_TOKEN_ADDRESS);
assertEq(v3FactoryOwner.PAYOUT_AMOUNT(), PAYOUT_AMOUNT);
assertEq(address(v3FactoryOwner.REWARD_RECEIVER()), address(uniStaker));

assertEq(address(uniStaker.REWARDS_TOKEN()), PAYOUT_TOKEN_ADDRESS);
assertEq(address(uniStaker.STAKE_TOKEN()), STAKE_TOKEN_ADDRESS);
assertEq(uniStaker.admin(), UNISWAP_GOVERNOR_TIMELOCK);
assertTrue(uniStaker.isRewardsNotifier(address(v3FactoryOwner)));
}
}

0 comments on commit 3ed27c3

Please sign in to comment.