2024-03-18 12:42:30 +01:00
|
|
|
pragma solidity ^0.8.19;
|
2023-11-21 21:06:21 +01:00
|
|
|
|
|
|
|
|
import "forge-std/Script.sol";
|
2024-03-12 20:22:10 +01:00
|
|
|
import {TwabController} from "pt-v5-twab-controller/TwabController.sol";
|
2024-03-14 17:31:16 +01:00
|
|
|
import "@uniswap-v3-core/interfaces/IUniswapV3Factory.sol";
|
2024-06-25 09:38:23 +02:00
|
|
|
import "@uniswap-v3-core/interfaces/IUniswapV3Pool.sol";
|
2024-07-18 07:35:39 +02:00
|
|
|
import "../src/Harberg.sol";
|
2024-02-23 22:01:23 +01:00
|
|
|
import "../src/Stake.sol";
|
2024-11-07 15:33:40 +00:00
|
|
|
import "../src/Sentimenter.sol";
|
|
|
|
|
import "../src/helpers/UniswapHelpers.sol";
|
2024-07-13 18:33:47 +02:00
|
|
|
import {LiquidityManager} from "../src/LiquidityManager.sol";
|
2024-11-07 15:33:40 +00:00
|
|
|
import {ERC1967Proxy} from "@openzeppelin/proxy/ERC1967/ERC1967Proxy.sol";
|
2023-11-21 21:06:21 +01:00
|
|
|
|
2024-03-14 12:48:14 +01:00
|
|
|
uint24 constant FEE = uint24(10_000);
|
2024-03-14 12:40:57 +01:00
|
|
|
|
2024-09-17 15:48:59 +02:00
|
|
|
contract DeployScript is Script {
|
2024-11-07 15:33:40 +00:00
|
|
|
using UniswapHelpers for IUniswapV3Pool;
|
|
|
|
|
|
2024-06-25 09:38:23 +02:00
|
|
|
bool token0isWeth;
|
2024-09-17 15:48:59 +02:00
|
|
|
address feeDest;
|
|
|
|
|
address weth;
|
|
|
|
|
address v3Factory;
|
|
|
|
|
address twabc;
|
2023-11-21 21:06:21 +01:00
|
|
|
|
|
|
|
|
function run() public {
|
|
|
|
|
string memory seedPhrase = vm.readFile(".secret");
|
|
|
|
|
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
|
|
|
|
|
vm.startBroadcast(privateKey);
|
2024-11-13 16:37:23 +01:00
|
|
|
//address sender = vm.addr(privateKey);
|
2023-11-21 21:06:21 +01:00
|
|
|
|
2024-09-17 15:48:59 +02:00
|
|
|
TwabController tc;
|
|
|
|
|
if (twabc == address(0)) {
|
|
|
|
|
tc = TwabController(twabc);
|
|
|
|
|
} else {
|
|
|
|
|
// in case you want to deploy an new TwabController
|
|
|
|
|
tc = new TwabController(60 * 60, uint32(block.timestamp));
|
|
|
|
|
}
|
2024-07-18 07:35:39 +02:00
|
|
|
Harberg harb = new Harberg("Harbergerger Tax", "HARB", tc);
|
2024-09-17 15:48:59 +02:00
|
|
|
token0isWeth = address(weth) < address(harb);
|
2024-03-12 11:38:16 +01:00
|
|
|
Stake stake = new Stake(address(harb));
|
|
|
|
|
harb.setStakingPool(address(stake));
|
2024-09-17 15:48:59 +02:00
|
|
|
IUniswapV3Factory factory = IUniswapV3Factory(v3Factory);
|
|
|
|
|
address liquidityPool = factory.createPool(weth, address(harb), FEE);
|
2024-11-07 15:33:40 +00:00
|
|
|
IUniswapV3Pool(liquidityPool).initializePoolFor1Cent(token0isWeth);
|
2024-06-19 10:33:28 +02:00
|
|
|
harb.setLiquidityPool(liquidityPool);
|
2024-11-07 15:33:40 +00:00
|
|
|
Sentimenter sentimenter = new Sentimenter();
|
|
|
|
|
bytes memory params = abi.encodeWithSignature("initialize(address,address)", address(harb),address(stake));
|
|
|
|
|
ERC1967Proxy proxy = new ERC1967Proxy(address(sentimenter), params);
|
|
|
|
|
LiquidityManager liquidityManager = new LiquidityManager(v3Factory, weth, address(harb), address(proxy));
|
2024-09-17 15:48:59 +02:00
|
|
|
liquidityManager.setFeeDestination(feeDest);
|
2024-07-13 18:33:47 +02:00
|
|
|
// note: this delayed initialization is not a security issue.
|
2024-04-11 22:32:47 +02:00
|
|
|
harb.setLiquidityManager(address(liquidityManager));
|
2024-06-25 10:33:33 +02:00
|
|
|
(bool sent, ) = address(liquidityManager).call{value: 0.1 ether}("");
|
2024-06-25 09:38:23 +02:00
|
|
|
require(sent, "Failed to send Ether");
|
2024-07-16 20:47:06 +02:00
|
|
|
//TODO: wait few minutes and call recenter
|
2023-11-21 21:06:21 +01:00
|
|
|
vm.stopBroadcast();
|
|
|
|
|
}
|
2024-03-12 20:22:10 +01:00
|
|
|
}
|