julien/lovepublic Fork 0
92dc0c79aceff6c4cc680853544b8d15e08396f6
Commits
Clone
git clone https://git.rickub.com/julien/love.git
git clone ssh://git@rickub.com/julien/love.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Love.s.sol · 88 lines · 3.3 KBSolidity Blame HistoryRaw
add love contract 9bf25a7 julienbrg 11h ago1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.30;
3
4import {Love} from "../src/Love.sol";
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago5import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
add love contract 9bf25a7 julienbrg 11h ago6import {Script, console} from "forge-std/Script.sol";
7
Merge 1-add-main-logic into main dded29a rickub 10h ago8/// @notice Deploys `Love` with CREATE2 through the canonical deterministic
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago9/// deployer. The address depends on the salt and the creation code, and
10/// the creation code embeds the wETH address — so the token only gets
11/// the same address on chains where wETH sits at the same address. Keep
Merge 1-add-main-logic into main dded29a rickub 10h ago12/// `solc`, the optimizer settings and `bytecode_hash = "none"` as they
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago13/// are in `foundry.toml`, or the address changes too.
add love contract 9bf25a7 julienbrg 11h ago14contract LoveScript is Script {
Merge 1-add-main-logic into main dded29a rickub 10h ago15 bytes32 public constant DEFAULT_SALT = keccak256("LOVE");
16
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago17 /// @dev wETH on Base, Optimism and every other OP-Stack chain.
18 address public constant DEFAULT_WETH = 0x4200000000000000000000000000000000000006;
19
add love contract 9bf25a7 julienbrg 11h ago20 Love public love;
21
Merge 1-add-main-logic into main dded29a rickub 10h ago22 function run() public returns (Love) {
23 bytes32 s = salt();
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago24 address w = wethAddress();
25 address predicted = predict(s, w);
Merge 1-add-main-logic into main dded29a rickub 10h ago26
27 console.log("deployer ", CREATE2_FACTORY);
28 console.log("salt ", vm.toString(s));
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago29 console.log("weth ", w);
30 console.log("initCodeHash ", vm.toString(initCodeHash(w)));
Merge 1-add-main-logic into main dded29a rickub 10h ago31 console.log("predicted ", predicted);
32
33 if (predicted.code.length > 0) {
34 console.log("already deployed, nothing to do");
35 love = Love(predicted);
36 return love;
37 }
38
add love contract 9bf25a7 julienbrg 11h ago39 vm.startBroadcast();
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago40 love = new Love{salt: s}(IERC20(w));
Merge 1-add-main-logic into main dded29a rickub 10h ago41 vm.stopBroadcast();
42
43 require(address(love) == predicted, "LoveScript: address mismatch");
add love contract 9bf25a7 julienbrg 11h ago44
45 console.log("Love deployed at", address(love));
make love an erc20 with public mint 4c8048e julienbrg 11h ago46 console.log("name ", love.name());
47 console.log("symbol ", love.symbol());
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago48 console.log("weth ", address(love.weth()));
49 console.log("rate ", love.RATE());
make love an erc20 with public mint 4c8048e julienbrg 11h ago50 console.log("totalSupply ", love.totalSupply());
add love contract 9bf25a7 julienbrg 11h ago51
Merge 1-add-main-logic into main dded29a rickub 10h ago52 return love;
53 }
54
55 /// @notice Print the address `run()` would deploy to, without broadcasting.
56 function predict() public view returns (address predicted) {
57 bytes32 s = salt();
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago58 address w = wethAddress();
59 predicted = predict(s, w);
Merge 1-add-main-logic into main dded29a rickub 10h ago60
61 console.log("salt ", vm.toString(s));
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago62 console.log("weth ", w);
63 console.log("initCodeHash ", vm.toString(initCodeHash(w)));
Merge 1-add-main-logic into main dded29a rickub 10h ago64 console.log("predicted ", predicted);
65 }
66
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago67 function predict(bytes32 s, address w) public pure returns (address) {
68 return vm.computeCreate2Address(s, initCodeHash(w), CREATE2_FACTORY);
69 }
70
71 function initCode(address w) public pure returns (bytes memory) {
72 return abi.encodePacked(type(Love).creationCode, abi.encode(w));
Merge 1-add-main-logic into main dded29a rickub 10h ago73 }
74
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago75 function initCodeHash(address w) public pure returns (bytes32) {
76 return keccak256(initCode(w));
Merge 1-add-main-logic into main dded29a rickub 10h ago77 }
78
79 /// @dev `SALT` overrides the default, e.g. to mine a vanity address.
80 function salt() public view returns (bytes32) {
81 return vm.envOr("SALT", DEFAULT_SALT);
add love contract 9bf25a7 julienbrg 11h ago82 }
replace mint with weth-pegged deposit and withdraw 92dc0c7 julienbrg 9h ago83
84 /// @dev `WETH` overrides the default, which only holds on OP-Stack chains.
85 function wethAddress() public view returns (address) {
86 return vm.envOr("WETH", DEFAULT_WETH);
87 }
add love contract 9bf25a7 julienbrg 11h ago88}