diff --git a/script/DeployUniV4MerklRewards.s.sol b/script/DeployUniV4MerklRewards.s.sol new file mode 100644 index 0000000..8ab58b5 --- /dev/null +++ b/script/DeployUniV4MerklRewards.s.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import {Script} from "forge-std/Script.sol"; +import "forge-std/console2.sol"; + +import "src/UniV4MerklRewards.sol"; + +contract DeployUniV4MerklRewards is Script { + address constant GOVERNANCE_ADDRESS = 0x807DEf5E7d057DF05C796F4bc75C3Fe82Bd6EeE1; + address constant BOLD_TOKEN_ADDRESS = 0x6440f144b7e50D6a8439336510312d2F54beB01D; + uint256 constant CAMPAIGN_BOLD_AMOUNT_THRESHOLD = 100e18; + bytes32 constant UNIV4_POOL_ID = 0x5d0ed52610c76d7bf729130ce7ddc0488b2f4bd0a0db1f12adbe6a32deaff893; + uint32 constant WEIGHT_FEES = 7500; // 75% liquidity contribution + uint32 constant WEIGHT_TOKEN_0 = 2000; // 20% BOLD + uint32 constant WEIGHT_TOKEN_1 = 500; // 5% USDC + + address deployer; + + function run() external { + if (vm.envBytes("DEPLOYER").length == 20) { + // address + deployer = vm.envAddress("DEPLOYER"); + vm.startBroadcast(deployer); + } else { + // private key + uint256 privateKey = vm.envUint("DEPLOYER"); + deployer = vm.addr(privateKey); + vm.startBroadcast(privateKey); + } + + console2.log("deployer: ", deployer); + console2.log("Chain Id: ", block.chainid); + + UniV4MerklRewards uniV4MerklRewards = new UniV4MerklRewards( + GOVERNANCE_ADDRESS, + BOLD_TOKEN_ADDRESS, + CAMPAIGN_BOLD_AMOUNT_THRESHOLD, + UNIV4_POOL_ID, + WEIGHT_FEES, + WEIGHT_TOKEN_0, + WEIGHT_TOKEN_1 + ); + + console2.log("Deployed UniV4MerklRewards: ", address(uniV4MerklRewards)); + } +} diff --git a/script/DeployUniV4MerklRewardsTester.s.sol b/script/DeployUniV4MerklRewardsTester.s.sol new file mode 100644 index 0000000..84c7a24 --- /dev/null +++ b/script/DeployUniV4MerklRewardsTester.s.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import {Script} from "forge-std/Script.sol"; +import "forge-std/console2.sol"; + +import "test/mocks/UniV4MerklRewardsWrapper.sol"; + +contract DeployUniV4MerklRewardsTester is Script { + address constant GOVERNANCE_ADDRESS = 0x807DEf5E7d057DF05C796F4bc75C3Fe82Bd6EeE1; + address constant BOLD_TOKEN_ADDRESS = 0x6440f144b7e50D6a8439336510312d2F54beB01D; + uint256 constant CAMPAIGN_BOLD_AMOUNT_THRESHOLD = 100e18; + bytes32 constant UNIV4_POOL_ID = 0x5d0ed52610c76d7bf729130ce7ddc0488b2f4bd0a0db1f12adbe6a32deaff893; + uint32 constant WEIGHT_FEES = 1500; + uint32 constant WEIGHT_TOKEN_0 = 4500; + uint32 constant WEIGHT_TOKEN_1 = 4000; + + address deployer; + + function run() external { + if (vm.envBytes("DEPLOYER").length == 20) { + // address + deployer = vm.envAddress("DEPLOYER"); + vm.startBroadcast(deployer); + } else { + // private key + uint256 privateKey = vm.envUint("DEPLOYER"); + deployer = vm.addr(privateKey); + vm.startBroadcast(privateKey); + } + + console2.log("deployer: ", deployer); + console2.log("Chain Id: ", block.chainid); + + UniV4MerklRewardsWrapper uniV4MerklRewardsWrapper = new UniV4MerklRewardsWrapper( + GOVERNANCE_ADDRESS, + BOLD_TOKEN_ADDRESS, + CAMPAIGN_BOLD_AMOUNT_THRESHOLD, + UNIV4_POOL_ID, + WEIGHT_FEES, + WEIGHT_TOKEN_0, + WEIGHT_TOKEN_1 + ); + + console2.log("Deployed UniV4MerklRewardsWrapper: ", address(uniV4MerklRewardsWrapper)); + } +} diff --git a/src/UniV4MerklRewards.sol b/src/UniV4MerklRewards.sol index def938b..b30028a 100644 --- a/src/UniV4MerklRewards.sol +++ b/src/UniV4MerklRewards.sol @@ -122,7 +122,7 @@ contract UniV4MerklRewards is IInitiative { /// @param _bold Amount of BOLD that was distributed function onClaimForInitiative(uint256 _claimEpoch, uint256 _bold) external override onlyGovernance {} - function createCampaign(uint256 _amount) internal { + function _createCampaign(uint256 _amount) internal { // Avoid if rewards too low if (_amount < CAMPAIGN_BOLD_AMOUNT_THRESHOLD) return; @@ -153,6 +153,6 @@ contract UniV4MerklRewards is IInitiative { assert(amount >= claimableAmount); require(amount > 0, "UniV4MerklInitiative: no funds for campaign"); - createCampaign(amount); + _createCampaign(amount); } } diff --git a/test/mocks/UniV4MerklRewardsWrapper.sol b/test/mocks/UniV4MerklRewardsWrapper.sol new file mode 100644 index 0000000..1efd3fb --- /dev/null +++ b/test/mocks/UniV4MerklRewardsWrapper.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.24; + +import "src/UniV4MerklRewards.sol"; + +contract UniV4MerklRewardsWrapper is UniV4MerklRewards { + constructor( + address _governanceAddress, + address _boldTokenAddress, + uint256 _campaignBoldAmountThreshold, + bytes32 _uniV4PoolId, + uint32 _weightFees, + uint32 _weightToken0, + uint32 _weightToken1 + ) + UniV4MerklRewards( + _governanceAddress, + _boldTokenAddress, + _campaignBoldAmountThreshold, + _uniV4PoolId, + _weightFees, + _weightToken0, + _weightToken1 + ) + {} + + function createCampaignWrapper(uint256 _amount) external { + uint256 balance = boldToken.balanceOf(address(this)); + require(balance >= _amount, "Not enough balance"); + require(_amount >= CAMPAIGN_BOLD_AMOUNT_THRESHOLD, "Below threshold"); + + _createCampaign(_amount); + } +}