Skip to content

Commit

Permalink
Deploy with constructor arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasdenH committed May 4, 2022
1 parent 562fe74 commit 34a0a75
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ganache-cli --fork https://mainnet.infura.io/v3/6f4f43507fa24302a651b52073c98d8a
# --private-key: Private key belongs to mnemonic
# --gas-price: Needs to be high enough. Unfortunately Ganache can't yet suggest a gas price.
# --json: Export in JSON to extract contract info later
forge create contracts/YieldLever.sol:YieldLever --rpc-url "http://127.0.0.1:8545" --private-key 0xde7e35b0dd8b3bebebd1f793daf12659f9cf3cb7d52a3d3921fcff63808e7d05 --legacy --gas-price 182929878490 --json > ./frontend/src/generated/deployment.json
forge create contracts/YieldLever.sol:YieldLever --rpc-url "http://127.0.0.1:8545" --private-key 0xde7e35b0dd8b3bebebd1f793daf12659f9cf3cb7d52a3d3921fcff63808e7d05 --legacy --gas-price 182929878490 --json > ./frontend/src/generated/deployment.json --constructor-args 0x303900000000 0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE 0x32E4c68B3A4a813b710595AebA7f6B7604Ab9c15 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 0x0d9A1A773be5a83eEbda23bf98efB8585C3ae4f4 0x6cB18fF2A33e981D1e38A663Ca056c0a5265066A 0x403ae7384E89b086Ea2935d5fAFed07465242B38 0xc88191F8cb8e6D4a668B047c1C8503432c3Ca867

# Copy YieldLever ABI to the source folder and generate typings
cp ".\out\YieldLever.sol\YieldLever.json" ".\frontend\src\generated\abi/"
Expand Down
37 changes: 27 additions & 10 deletions contracts/YieldLever.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,36 @@ interface Cauldron {
}

contract YieldLever {
yVault constant yvUSDC = yVault(0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE);
bytes6 constant ilkId = bytes6(0x303900000000); // for yvUSDC
IToken constant iUSDC = IToken(0x32E4c68B3A4a813b710595AebA7f6B7604Ab9c15);
IERC20 constant usdc = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
address constant usdcJoin = address(0x0d9A1A773be5a83eEbda23bf98efB8585C3ae4f4);
YieldLadle constant ladle = YieldLadle(0x6cB18fF2A33e981D1e38A663Ca056c0a5265066A);
address constant yvUSDCJoin = address(0x403ae7384E89b086Ea2935d5fAFed07465242B38);
Cauldron constant cauldron = Cauldron(0xc88191F8cb8e6D4a668B047c1C8503432c3Ca867);
bytes6 ilkId; // for yvUSDC
yVault yvUSDC;
IToken iUSDC;
IERC20 usdc;
address usdcJoin;
YieldLadle ladle;
address yvUSDCJoin;
Cauldron cauldron;

bytes6 constant usdcId = bytes6(bytes32("02"));

/// @dev YieldLever is not expected to hold any USDC
constructor() {
/// @dev YieldLever is not expected to hold any USDC, so approve transfers for any amount.
constructor(
bytes6 ilkId_,
yVault yvUSDC_,
IToken iUSDC_,
IERC20 usdc_,
address usdcJoin_,
YieldLadle ladle_,
address yvUSDCJoin_,
Cauldron cauldron_
) {
ilkId = ilkId_;
yvUSDC = yvUSDC_;
iUSDC = iUSDC_;
usdc = usdc_;
usdcJoin = usdcJoin_;
ladle = ladle_;
yvUSDCJoin = yvUSDCJoin_;
cauldron = cauldron_;
usdc.approve(address(yvUSDC), type(uint256).max);
}

Expand Down
11 changes: 10 additions & 1 deletion test/YieldLever.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@ contract YieldLeverTest is Test {
}

function setUp() public {
yieldLever = new YieldLever();
yieldLever = new YieldLever(
0x303900000000,
yVault(0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE),
IToken(0x32E4c68B3A4a813b710595AebA7f6B7604Ab9c15),
IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48),
address(0x0d9A1A773be5a83eEbda23bf98efB8585C3ae4f4),
YieldLadle(0x6cB18fF2A33e981D1e38A663Ca056c0a5265066A),
address(0x403ae7384E89b086Ea2935d5fAFed07465242B38),
Cauldron(0xc88191F8cb8e6D4a668B047c1C8503432c3Ca867)
);
helperContract = new HelperContract();
helperContract.grantYieldLeverAccess(address(yieldLever));
}
Expand Down

0 comments on commit 34a0a75

Please sign in to comment.