Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions script/DeployUniV4MerklRewards.s.sol
Original file line number Diff line number Diff line change
@@ -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));
}
}
47 changes: 47 additions & 0 deletions script/DeployUniV4MerklRewardsTester.s.sol
Original file line number Diff line number Diff line change
@@ -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));
}
}
4 changes: 2 additions & 2 deletions src/UniV4MerklRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was changed before mainnet contract deployment I suppose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. See here what Etherscan verification got automatically:
https://etherscan.io/address/0xB42448852A1BFc99d66ed53C65e2B49cF954f615#code

// Avoid if rewards too low
if (_amount < CAMPAIGN_BOLD_AMOUNT_THRESHOLD) return;

Expand Down Expand Up @@ -153,6 +153,6 @@ contract UniV4MerklRewards is IInitiative {
assert(amount >= claimableAmount);
require(amount > 0, "UniV4MerklInitiative: no funds for campaign");

createCampaign(amount);
_createCampaign(amount);
}
}
34 changes: 34 additions & 0 deletions test/mocks/UniV4MerklRewardsWrapper.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}