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

@ -61,7 +61,7 @@ $ anvil
forge clean
forge cache clean
source .env
forge script script/Deploy.sol:SepoliaScript --slow --broadcast --verify --rpc-url ${SEPOLIA_RPC_URL}
forge script script/Deploy.sol:BaseXDeploy --slow --broadcast --verify --rpc-url ${X_RPC_URL}
```
if verification fails:
@ -112,27 +112,21 @@ address: 0xCc7467616bBDB574D04C7e9d2B0982c59F33D43c
### Harberg
address: 0x00d5690044cf91fb3fc674c780697d511702f729
address: 0x54838DC097E7fC4736B801bF1c1FCf1597348265
### Stake
address: 0x275403401f9c6f4659b6ffb6ab01798e1de9a912
address: 0xd7728173F73C748944d29EA77b56f09b8FEc8F33
### LP
address: 0x0360c20822a7298e9061248b39fe475a78d4de48
address: 0x00E4da809989f40F5D1B31bE6202A5e512db4212
## References
open features:
- reduce snatch collision
- profit for staking position
- tax paid for staking position
- deployment on L2
todos:
- liquidation bot
- write unit test for capital exit function
- put ownerOnly restriction on recenter, remove it later. gives more control to the team initally, but keeps it decentralized

View file

@ -0,0 +1,15 @@
pragma solidity ^0.8.19;
import {DeployScript} from "./DeployScript.sol";
contract BaseDeploy is DeployScript {
function setUp() public {
// Sepolia data
feeDest = 0x0000000000000000000000000000000000000000;
weth = 0x4200000000000000000000000000000000000006;
v3Factory = 0x33128a8fC17869897dcE68Ed026d694621f6FDfD;
// comment out if new deployment
// twabc = 0xFCFa3b066981027516121bd27a9B1cBb9C00c5Fd;
}
}

View file

@ -0,0 +1,15 @@
pragma solidity ^0.8.19;
import {DeployScript} from "./DeployScript.sol";
contract BaseSepoliaDeploy is DeployScript {
function setUp() public {
// Base Sepolia data
feeDest = 0xf6a3eef9088A255c32b6aD2025f83E57291D9011;
weth = 0x4200000000000000000000000000000000000006;
v3Factory = 0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24;
// comment out if new deployment
twabc = 0xFCFa3b066981027516121bd27a9B1cBb9C00c5Fd;
}
}

View file

@ -8,22 +8,14 @@ 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 {
contract DeployScript is Script {
bool token0isWeth;
function setUp() public {}
address feeDest;
address weth;
address v3Factory;
address twabc;
function sqrt(uint256 y) internal pure returns (uint256 z) {
@ -66,19 +58,23 @@ contract BaseSepoliaScript is Script {
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));
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));
}
Harberg harb = new Harberg("Harbergerger Tax", "HARB", tc);
token0isWeth = address(WETH) < address(harb);
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);
IUniswapV3Factory factory = IUniswapV3Factory(v3Factory);
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);
LiquidityManager liquidityManager = new LiquidityManager(v3Factory, weth, address(harb));
liquidityManager.setFeeDestination(feeDest);
// note: this delayed initialization is not a security issue.
harb.setLiquidityManager(address(liquidityManager));
(bool sent, ) = address(liquidityManager).call{value: 0.1 ether}("");

View file

@ -89,6 +89,8 @@ contract Stake {
/// @dev Internal function to calculate and pay taxes for a position, adjusting shares and handling position liquidation if necessary.
function _payTax(uint256 positionId, StakingPosition storage pos, uint256 taxFloorDuration) private {
// TODO: check if position exits
require(pos.share > 0, "position not found");
// ihet = Implied Holding Expiry Timestamp
uint256 ihet = (block.timestamp - pos.creationTime < taxFloorDuration)
? pos.creationTime + taxFloorDuration
@ -101,6 +103,7 @@ contract Stake {
taxAmountDue = assetsBefore;
}
if (assetsBefore - taxAmountDue > 0) {
require(taxAmountDue > 10**18, "taxAmountDue not worth it");
// if something left over, update storage
uint256 shareAfterTax = assetsToShares(assetsBefore - taxAmountDue);
outstandingStake -= pos.share - shareAfterTax;