new deployment scripts

This commit is contained in:
JulesCrown 2024-09-17 15:48:59 +02:00
parent 18a57c0ead
commit b4dfb03590
5 changed files with 54 additions and 31 deletions

View file

@ -1,89 +0,0 @@
pragma solidity ^0.8.19;
import "forge-std/Script.sol";
import {TwabController} from "pt-v5-twab-controller/TwabController.sol";
import "@uniswap-v3-core/interfaces/IUniswapV3Factory.sol";
import "@uniswap-v3-core/interfaces/IUniswapV3Pool.sol";
import "../src/Harberg.sol";
import "../src/Stake.sol";
import {LiquidityManager} from "../src/LiquidityManager.sol";
// Base Sepolia data
address constant FEE_DEST = 0xf6a3eef9088A255c32b6aD2025f83E57291D9011;
address constant WETH = 0x4200000000000000000000000000000000000006;
address constant V3_FACTORY = 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24;
address constant TWABC = 0xFCFa3b066981027516121bd27a9B1cBb9C00c5Fd;
// Sepolia data
// address constant WETH = 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14; //Sepolia
// address constant V3_FACTORY = 0x0227628f3F023bb0B980b67D528571c95c6DaC1c; //Sepolia
// address constant TWABC = 0x64ddA11815B883C589AFeD914666ef2D63C8C338; //new TwabController(60 * 60 * 24, uint32(block.timestamp));
uint24 constant FEE = uint24(10_000);
contract BaseSepoliaScript is Script {
bool token0isWeth;
function setUp() public {}
function sqrt(uint256 y) internal pure returns (uint256 z) {
if (y > 3) {
z = y;
uint256 x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
// z is now the integer square root of y, or the closest integer to the square root of y.
}
function initializePoolFor1Cent(address _pool) public {
uint256 price;
if (token0isWeth) {
// ETH as token0, so we are setting the price of 1 ETH in terms of token1 (USD cent)
price = 3000 * 10**20; // 1 ETH = 3700 USD, scaled by 10^18 for precision
} else {
// Token (valued at 1 USD cent) as token0, ETH as token1
// We invert the logic to represent the price of 1 token in terms of ETH
price = uint256(10**16) / 3700; // Adjust for 18 decimal places
}
uint160 sqrtPriceX96 = uint160(sqrt(price) * 2**96 / 10**9); // Adjust sqrt value to 96-bit precision
console.log(uint160(sqrt(3000 * 10**20) * 2**96 / 10**9));
// Initialize pool with the calculated sqrtPriceX96
IUniswapV3Pool(_pool).initialize(sqrtPriceX96);
}
function run() public {
string memory seedPhrase = vm.readFile(".secret");
uint256 privateKey = vm.deriveKey(seedPhrase, 0);
vm.startBroadcast(privateKey);
address sender = vm.addr(privateKey);
console.log(sender);
TwabController tc = TwabController(TWABC);
// in case you want to deploy an new TwabController
//TwabController tc = new TwabController(60 * 60, uint32(block.timestamp));
Harberg harb = new Harberg("Harbergerger Tax", "HARB", tc);
token0isWeth = address(WETH) < address(harb);
Stake stake = new Stake(address(harb));
harb.setStakingPool(address(stake));
IUniswapV3Factory factory = IUniswapV3Factory(V3_FACTORY);
address liquidityPool = factory.createPool(WETH, address(harb), FEE);
initializePoolFor1Cent(liquidityPool);
harb.setLiquidityPool(liquidityPool);
LiquidityManager liquidityManager = new LiquidityManager(V3_FACTORY, WETH, address(harb));
liquidityManager.setFeeDestination(FEE_DEST);
// note: this delayed initialization is not a security issue.
harb.setLiquidityManager(address(liquidityManager));
(bool sent, ) = address(liquidityManager).call{value: 0.1 ether}("");
require(sent, "Failed to send Ether");
//TODO: wait few minutes and call recenter
vm.stopBroadcast();
}
}