generated from AngleProtocol/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0aad840
commit 3833f08
Showing
10 changed files
with
445 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule utils
updated
from d4a8da to 53dafa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
@openzeppelin/=node_modules/@openzeppelin/ | ||
forge-std/=node_modules/forge-std/src | ||
forge-std/=node_modules/forge-std/src | ||
oz/=node_modules/@openzeppelin/contracts/ | ||
utils/=lib/utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.17; | ||
|
||
import { console } from "forge-std/console.sol"; | ||
import { Distributor } from "contracts/Distributor.sol"; | ||
import { MockToken, IERC20 } from "contracts/mock/MockToken.sol"; | ||
import { CommonUtils, ContractType } from "utils/src/CommonUtils.sol"; | ||
import { CHAIN_BASE } from "utils/src/Constants.sol"; | ||
import { StdAssertions } from "forge-std/Test.sol"; | ||
|
||
contract ClaimDistributor is CommonUtils, StdAssertions { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
address deployer = vm.addr(deployerPrivateKey); | ||
|
||
/// TODO: COMPLETE | ||
uint256 chainId = CHAIN_BASE; | ||
IERC20 rewardToken = IERC20(0xC011882d0f7672D8942e7fE2248C174eeD640c8f); | ||
address claimer = 0x15775b23340C0f50E0428D674478B0e9D3D0a759; | ||
uint256 balanceToClaim = 1918683165360; | ||
bytes32[][] memory proofs = new bytes32[][](1); | ||
address[] memory users = new address[](1); | ||
address[] memory tokens = new address[](1); | ||
uint256[] memory amounts = new uint256[](1); | ||
proofs[0] = new bytes32[](17); | ||
proofs[0][0] = bytes32(0xb4273243bd0ec5add5e6d803f13bf6866ed1904d24626766ab2836454ba1ec0a); | ||
proofs[0][1] = bytes32(0x3ee0ead23e2fe3f664ccb5e13683f27e27a4d7fefa8405545fb6421244630375); | ||
proofs[0][2] = bytes32(0x69f54e33351af15236b33bb4695470f1af96cd1a9f154aa511ff16faa6886791); | ||
proofs[0][3] = bytes32(0xa9d77ad46850fbfb8c196c693acdbb0c6241a2e561a8b0073ec71297a565673d); | ||
proofs[0][4] = bytes32(0xe1b57f280e556c7f217e8d375f0cef7977a9467d5496d32bb8ec461f0d4c4f19); | ||
proofs[0][5] = bytes32(0x0fc7ddc7cc9ecc7f7b0be5692f671394f6245ffdabe5c0fd2062eb71b7c11826); | ||
proofs[0][6] = bytes32(0x94445a98fe6679760e5ac2edeacfe0bfa397f805c7adeaf3558a82accb78f201); | ||
proofs[0][7] = bytes32(0x14a6fec66cdfece5c73ec44196f1414326236131ff9a60350cca603e54985c4e); | ||
proofs[0][8] = bytes32(0x84679751230af3e3242ea1cecfc8daee3d2187ab647281cbf8c52e649a43e84c); | ||
proofs[0][9] = bytes32(0xc0fc15960178fe4d542c93e64ec58648e5ff17bd02b27f841bd6ab838fc5ee67); | ||
proofs[0][10] = bytes32(0x9b84efe5d11bc4de32ecd204c3962dd9270694d93a50e2840d763eaeac6c194b); | ||
proofs[0][11] = bytes32(0x5c8025dbe663cf4b4e19fbc7b1e54259af5822fd774fd60a98e7c7a60112efe0); | ||
proofs[0][12] = bytes32(0x301b573f9a6503ebe00ff7031a33cd41170d8b4c09a31fcafb9feb7529400a79); | ||
proofs[0][13] = bytes32(0xc89942ad2dcb0ac96d2620ef9475945bdbe6d40a9f6c4e9f6d9437a953bf881c); | ||
proofs[0][14] = bytes32(0xce6ca90077dc547f9a52a24d2636d659642fbae1d16c81c9e47c5747a472c63f); | ||
proofs[0][15] = bytes32(0xe34667d2e10b515dd1f7b29dcd7990d25ea9caa7a7de571c4fb221c0a8fc82a1); | ||
proofs[0][16] = bytes32(0x8316d6488fd22b823cc35ee673297ea2a753f0a89e5384ef20b38d053c881628); | ||
users[0] = claimer; | ||
tokens[0] = address(rewardToken); | ||
amounts[0] = balanceToClaim; | ||
/// END | ||
|
||
Distributor distributor = Distributor(_chainToContract(chainId, ContractType.Distributor)); | ||
|
||
vm.startBroadcast(claimer); | ||
|
||
distributor.claim(users, tokens, amounts, proofs); | ||
|
||
assertEq(rewardToken.balanceOf(claimer), balanceToClaim); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.17; | ||
|
||
import { console } from "forge-std/console.sol"; | ||
import { DistributionCreator, DistributionParameters, CampaignParameters } from "contracts/DistributionCreator.sol"; | ||
import { MockToken, ERC20 } from "contracts/mock/MockToken.sol"; | ||
import { CommonUtils, ContractType } from "utils/src/CommonUtils.sol"; | ||
import { Constants } from "utils/src/Constants.sol"; | ||
import { StdAssertions } from "forge-std/Test.sol"; | ||
|
||
contract CreateTestCampaign is CommonUtils, StdAssertions { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
address deployer = vm.addr(deployerPrivateKey); | ||
|
||
/// TODO: COMPLETE | ||
uint256 chainId = Constants.CHAIN_BASE; | ||
ERC20 rewardToken = ERC20(0xC011882d0f7672D8942e7fE2248C174eeD640c8f); | ||
uint256 amount = 1000 ether; | ||
/// END | ||
|
||
DistributionCreator distributionCreator = DistributionCreator( | ||
_chainToContract(chainId, ContractType.DistributionCreator) | ||
); | ||
|
||
vm.startBroadcast(deployer); | ||
|
||
MockToken(address(rewardToken)).mint(deployer, amount); | ||
rewardToken.approve(address(distributionCreator), amount); | ||
uint32 startTimestamp = uint32(1718253319); | ||
bytes32 campaignId = distributionCreator.createCampaign( | ||
CampaignParameters({ | ||
campaignId: bytes32(0), | ||
creator: deployer, | ||
rewardToken: address(rewardToken), | ||
amount: amount, | ||
campaignType: 1, | ||
startTimestamp: startTimestamp, | ||
duration: 3600 * 24 * 10, | ||
campaignData: abi.encode( | ||
0xbEEfa1aBfEbE621DF50ceaEF9f54FdB73648c92C, | ||
new address[](0), | ||
new address[](0), | ||
"", | ||
new bytes[](0), | ||
new bytes[](0), | ||
hex"" | ||
) | ||
}) | ||
); | ||
|
||
CampaignParameters memory campaign = distributionCreator.campaign(campaignId); | ||
assertEq(campaign.creator, deployer); | ||
assertEq(campaign.rewardToken, address(rewardToken)); | ||
assertEq(campaign.amount, (amount * (1e9 - distributionCreator.defaultFees())) / 1e9); | ||
assertEq(campaign.campaignType, 1); | ||
assertEq(campaign.startTimestamp, startTimestamp); | ||
assertEq(campaign.duration, 3600 * 24 * 10); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.17; | ||
|
||
import { console } from "forge-std/console.sol"; | ||
import { DistributionCreator, DistributionParameters, CampaignParameters } from "contracts/DistributionCreator.sol"; | ||
import { MockToken, IERC20 } from "contracts/mock/MockToken.sol"; | ||
import { CommonUtils, ContractType } from "utils/src/CommonUtils.sol"; | ||
import { CHAIN_BASE } from "utils/src/Constants.sol"; | ||
import { StdAssertions } from "forge-std/Test.sol"; | ||
import { ERC4626 } from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; | ||
|
||
contract ReallocateCampaignRewards is CommonUtils, StdAssertions { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
address deployer = vm.addr(deployerPrivateKey); | ||
|
||
/// TODO: COMPLETE | ||
uint256 chainId = CHAIN_BASE; | ||
IERC20 rewardToken = IERC20(0xC011882d0f7672D8942e7fE2248C174eeD640c8f); | ||
uint256 amount = 97 ether; // after fees | ||
bytes32 campaignId = 0x1d1231a7a6958431a5760b929c56f0e44a20f06e92a52324c19a2e4d2ec529bc; | ||
address to = 0xA9DdD91249DFdd450E81E1c56Ab60E1A62651701; | ||
address[] memory froms = new address[](2); | ||
froms[0] = 0x15775b23340C0f50E0428D674478B0e9D3D0a759; | ||
froms[1] = 0xe4BB74804edf5280c9203f034036f7CB15196078; | ||
/// END | ||
|
||
DistributionCreator distributionCreator = DistributionCreator( | ||
_chainToContract(chainId, ContractType.DistributionCreator) | ||
); | ||
uint32 timestamp = uint32(block.timestamp); | ||
|
||
vm.startBroadcast(deployer); | ||
|
||
distributionCreator.reallocateCampaignRewards(campaignId, froms, to); | ||
|
||
assertEq(distributionCreator.campaignReallocation(campaignId, froms[0]), to); | ||
assertEq(distributionCreator.campaignListReallocation(campaignId, 0), froms[0]); | ||
assertEq(distributionCreator.campaignListReallocation(campaignId, 1), froms[1]); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.17; | ||
|
||
import { console } from "forge-std/console.sol"; | ||
import { DistributionCreator, DistributionParameters, CampaignParameters } from "contracts/DistributionCreator.sol"; | ||
import { MockToken, IERC20 } from "contracts/mock/MockToken.sol"; | ||
import { CommonUtils, ContractType } from "utils/src/CommonUtils.sol"; | ||
import { CHAIN_BASE } from "utils/src/Constants.sol"; | ||
import { StdAssertions } from "forge-std/Test.sol"; | ||
import { ERC4626 } from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; | ||
|
||
contract UpdateCampaign is CommonUtils, StdAssertions { | ||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
address deployer = vm.addr(deployerPrivateKey); | ||
|
||
/// TODO: COMPLETE | ||
uint256 chainId = CHAIN_BASE; | ||
IERC20 rewardToken = IERC20(0xC011882d0f7672D8942e7fE2248C174eeD640c8f); | ||
uint256 amount = 97 ether; // after fees | ||
bytes32 campaignId = 0x6628165d9b509afe46d9009fecc7012c68cc0ce24aafdc4ce11f23a01ccc1a22; | ||
uint32 startTimestamp = uint32(1733155692); | ||
uint32 duration = 3600 * 6; | ||
/// END | ||
|
||
DistributionCreator distributionCreator = DistributionCreator( | ||
_chainToContract(chainId, ContractType.DistributionCreator) | ||
); | ||
uint32 timestamp = uint32(block.timestamp); | ||
|
||
// // Do some mint and deposit to change a lot reward distribution | ||
// vm.startBroadcast(0x0022228a2cc5E7eF0274A7Baa600d44da5aB5776); | ||
// MockToken(address(0x0000206329b97DB379d5E1Bf586BbDB969C63274)).mint(deployer, 100_000 ether); | ||
// vm.stopBroadcast(); | ||
|
||
vm.startBroadcast(deployer); | ||
|
||
// It will be less than that but we don't care | ||
MockToken(address(rewardToken)).mint(deployer, amount); | ||
rewardToken.approve(address(distributionCreator), amount); | ||
|
||
// IERC20(0x0000206329b97DB379d5E1Bf586BbDB969C63274).approve( | ||
// address(0xbEEfa1aBfEbE621DF50ceaEF9f54FdB73648c92C), | ||
// 100_000 ether | ||
// ); | ||
// ERC4626(0xbEEfa1aBfEbE621DF50ceaEF9f54FdB73648c92C).deposit(100_000 ether, deployer); | ||
|
||
// // ERC20 distrib change duration | ||
// uint32 campaignType = 1; | ||
// bytes memory campaignData = abi.encode( | ||
// 0xbEEfa1aBfEbE621DF50ceaEF9f54FdB73648c92C, | ||
// new address[](0), | ||
// new address[](0), | ||
// "", | ||
// new bytes[](0), | ||
// new bytes[](0), | ||
// hex"" | ||
// ); | ||
|
||
// ERC20 distrib | ||
uint32 campaignType = 1; | ||
bytes memory campaignData = abi.encode( | ||
0x70F796946eD919E4Bc6cD506F8dACC45E4539771, | ||
new address[](0), | ||
new address[](0), | ||
"", | ||
new bytes[](0), | ||
new bytes[](0), | ||
hex"" | ||
); | ||
|
||
// // Silo distrib | ||
// address[] memory whitelist = new address[](1); | ||
// whitelist[0] = 0x8095806d8753C0443C118D1C5e5eEC472e30BFeC; | ||
// uint32 campaignType = 5; | ||
// bytes memory campaignData = abi.encode( | ||
// 0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A, | ||
// 2, | ||
// 0xa42001D6d2237d2c74108FE360403C4b796B7170, | ||
// whitelist, | ||
// new address[](0), | ||
// hex"" | ||
// ); | ||
|
||
// // CLAMM distrib | ||
// uint32 campaignType = 2; | ||
// bytes memory campaignData = abi.encode( | ||
// 0x5280d5E63b416277d0F81FAe54Bb1e0444cAbDAA, | ||
// 5100, | ||
// 1700, | ||
// 3200, | ||
// false, | ||
// address(0), | ||
// 1, | ||
// new address[](0), | ||
// new address[](0), | ||
// "", | ||
// new bytes[](0), | ||
// hex"" | ||
// ); | ||
|
||
distributionCreator.overrideCampaign( | ||
campaignId, | ||
CampaignParameters({ | ||
campaignId: campaignId, | ||
creator: deployer, | ||
rewardToken: address(rewardToken), | ||
amount: amount, | ||
campaignType: campaignType, | ||
startTimestamp: startTimestamp, | ||
duration: duration, | ||
campaignData: campaignData | ||
}) | ||
); | ||
|
||
( | ||
, | ||
address campaignCreator, | ||
address campaignRewardToken, | ||
uint256 campaignAmount, | ||
uint256 campaignCampaignType, | ||
uint32 campaignStartTimestamp, | ||
uint32 campaignDuration, | ||
bytes memory campaignCampaignData | ||
) = distributionCreator.campaignOverrides(campaignId); | ||
assertEq(campaignCreator, deployer); | ||
assertEq(campaignRewardToken, address(rewardToken)); | ||
assertEq(campaignAmount, amount); | ||
assertEq(campaignCampaignType, campaignType); | ||
assertEq(campaignStartTimestamp, startTimestamp); | ||
assertEq(campaignDuration, duration); | ||
assertEq(campaignCampaignData, campaignData); | ||
assertLt(distributionCreator.campaignOverridesTimestamp(campaignId, 0), timestamp); | ||
assertLt(distributionCreator.campaignOverridesTimestamp(campaignId, 1), timestamp); | ||
// assertLt(distributionCreator.campaignOverridesTimestamp(campaignId, 2), timestamp); | ||
assertGe(distributionCreator.campaignOverridesTimestamp(campaignId, 2), timestamp); | ||
vm.expectRevert(); | ||
distributionCreator.campaignOverridesTimestamp(campaignId, 3); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Oops, something went wrong.