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
2b5df12
commit 46f4580
Showing
13 changed files
with
1,656 additions
and
198 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#! /bin/bash | ||
|
||
source lib/utils/helpers/common.sh | ||
|
||
function main { | ||
if [ ! -f .env ]; then | ||
echo ".env not found!" | ||
exit 1 | ||
fi | ||
source .env | ||
|
||
echo "Which chain would you like to fork ?" | ||
echo "- 1: Ethereum Mainnet" | ||
echo "- 2: Arbitrum" | ||
echo "- 3: Polygon" | ||
echo "- 4: Gnosis" | ||
echo "- 5: Avalanche" | ||
echo "- 6: Base" | ||
echo "- 7: Binance Smart Chain" | ||
echo "- 8: Celo" | ||
echo "- 9: Polygon ZkEvm" | ||
echo "- 10: Optimism" | ||
echo "- 11: Linea" | ||
|
||
read option | ||
|
||
uri=$(chain_to_uri $option) | ||
if [ -z "$uri" ]; then | ||
echo "Unknown network" | ||
exit 1 | ||
fi | ||
|
||
echo "Forking $uri" | ||
anvil --fork-url $uri | ||
} | ||
|
||
main |
Submodule forge-std
updated
41 files
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 |
---|---|---|
@@ -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, 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 CreateCampaign 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 = 100 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(block.timestamp + 600); | ||
bytes32 campaignId = distributionCreator.createCampaign( | ||
CampaignParameters({ | ||
campaignId: bytes32(0), | ||
creator: deployer, | ||
rewardToken: address(rewardToken), | ||
amount: amount, | ||
campaignType: 1, | ||
startTimestamp: startTimestamp, | ||
duration: 3600 * 24, | ||
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); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Oops, something went wrong.