From 2caef7ecb2d9a27468169a4c32e7b491d845cd27 Mon Sep 17 00:00:00 2001 From: JulesCrown Date: Tue, 10 Sep 2024 19:13:43 +0200 Subject: [PATCH] small cleanup --- onchain/README.md | 38 +++++--------------------------- onchain/script/Deploy.sol | 18 +++++++++++---- onchain/src/LiquidityManager.sol | 4 +--- 3 files changed, 21 insertions(+), 39 deletions(-) diff --git a/onchain/README.md b/onchain/README.md index d7be127..7e90dba 100644 --- a/onchain/README.md +++ b/onchain/README.md @@ -125,40 +125,14 @@ address: 0x0360c20822a7298e9061248b39fe475a78d4de48 ## References -- take percentage math from here: https://github.com/attestate/libharberger/tree/master -- add this function: https://github.com/721labs/partial-common-ownership/blob/3e7713bc60b6bb2e103320036ec5aeaaaceb7d2b/contracts/token/modules/Taxation.sol#L260 -- limit discovery position growth to max_issuance / day - open features: -- token minting limit / limit on discovery position growth -- ERC721 & ERC4907, user/owner separation, influencer incentives -- token contract not visible in uniswap sepolia -- snatch collision -- previousTotalSupply at beginning? +- reduce snatch collision - profit for staking position - tax paid for staking position -- partially snatched -- liquidation bot -- shift/slide bot -- ubi claim bot - deployment on L2 -- make minStake a gov param -- prep for audit - - clean up TODOs - - clean up magic numbers - - coverage - - overflows - - reentry - - HARB - - mint - limit supply to 2^96? - - Stake - - what if someone calls payTax and exitPosition in the same transaction? - - LiquidityManager - - what to do with stuck funds if slide/shift become inoperable? - - _isPriceStable - // Handle try catch, possibly by trying with a different time interval or providing a default response\ - - test wraparound of vwap - - -- NFT support of etherscan - https://etherscan.io/nft/0xe12edaab53023c75473a5a011bdb729ee73545e8/4218 \ No newline at end of file +todos: +- write unit test for capital exit function +- recenter bot +- put ownerOnly restriction on recenter, remove it later. gives more control to the team initally, but keeps it decentralized +- liquidation bot diff --git a/onchain/script/Deploy.sol b/onchain/script/Deploy.sol index 9301f78..b302843 100644 --- a/onchain/script/Deploy.sol +++ b/onchain/script/Deploy.sol @@ -8,12 +8,19 @@ import "../src/Harberg.sol"; import "../src/Stake.sol"; import {LiquidityManager} from "../src/LiquidityManager.sol"; -address constant WETH = 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14; //Sepolia -address constant V3_FACTORY = 0x0227628f3F023bb0B980b67D528571c95c6DaC1c; //Sepolia -address constant TWABC = 0x64ddA11815B883C589AFeD914666ef2D63C8C338; //new TwabController(60 * 60 * 24, uint32(block.timestamp)); +// 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 SepoliaScript is Script { +contract BaseSepoliaScript is Script { bool token0isWeth; function setUp() public {} @@ -56,6 +63,8 @@ contract SepoliaScript is Script { 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 @@ -69,6 +78,7 @@ contract SepoliaScript is Script { 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}(""); diff --git a/onchain/src/LiquidityManager.sol b/onchain/src/LiquidityManager.sol index 460e15e..6d209d9 100644 --- a/onchain/src/LiquidityManager.sol +++ b/onchain/src/LiquidityManager.sol @@ -155,8 +155,6 @@ contract LiquidityManager { receive() external payable { } - - /// @notice Calculates the Uniswap V3 tick corresponding to a given price ratio between Harberg and ETH. /// @param t0isWeth Boolean flag indicating if token0 is WETH. /// @param tokenAmount Amount of the Harberg token. @@ -459,7 +457,7 @@ contract LiquidityManager { // center tick can be calculated positive and negative numbers the same int24 centerTick = token0isWeth ? anchorTickLower + ANCHOR_SPACING : anchorTickUpper - ANCHOR_SPACING; - uint256 minAmplitude = uint256(uint24((anchorTickUpper - anchorTickLower) * 3 / 20)); + uint256 minAmplitude = uint24(TICK_SPACING) * 2; // Determine the correct comparison direction based on token0isWeth isUp = token0isWeth ? currentTick < centerTick : currentTick > centerTick;