Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
52 changes: 41 additions & 11 deletions claim_contracts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ help: ## 📚 Show help for each of the Makefile recipes

RPC_URL?=http://localhost:8545
PRIVATE_KEY?=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a

deploy-all: ## 🚀 Deploy all contracts
cd script && \
forge script DeployAll.s.sol \
--sig "run(string)" \
$(CONFIG) \
--private-key $(PRIVATE_KEY) \
--rpc-url $(RPC_URL) \
--broadcast \
-vvv

CONFIG?=example
deploy-token: ## 🚀 Deploy the token contract
cd script && \
Expand All @@ -40,6 +29,34 @@ deploy-token-prod: ## 🚀 Deploy the token contract
--broadcast \
--verbosity 3

deploy-claimable-local: ## 🚀 Deploy the airdrop contract in localnet
cd script && \
forge script DeployClaimableAirdrop.s.sol \
--sig "run(string)" example \
--private-key $(PRIVATE_KEY) \
--rpc-url http://localhost:8545 \
--broadcast

deploy-claimable-testnet: ## 🚀 Deploy the airdrop contract in Sepolia
cd script && \
forge script DeployClaimableAirdrop.s.sol \
--sig "run(string)" sepolia \
--private-key $(PRIVATE_KEY) \
--rpc-url $(RPC_URL) \
--broadcast \
--verify \
--etherscan-api-key $(ETHERSCAN_API_KEY)

deploy-claimable-mainnet: ## 🚀 Deploy the airdrop contract in Mainnet
cd script && \
forge script DeployClaimableAirdrop.s.sol \
--sig "run(string)" mainnet \
--keystore $(KEYSTORE_PATH) \
--rpc-url https://eth.llamarpc.com \
--broadcast \
--verify \
--etherscan-api-key $(ETHERSCAN_API_KEY)


update_token_proxy:
@NEW_TOKEN_PROXY=$$(jq -r '.tokenProxy' "script-out/deployed_token_addresses.json") && \
Expand All @@ -56,6 +73,15 @@ upgrade-token: ## 🚀 Upgrade the token contract
--broadcast \
--verbosity 3

# Approve

approve-claimable: ## 🚀 Approve the claimable airdrop contract to spend the token
cast send \
--rpc-url http://localhost:8545 \
--private-key $(PRIVATE_KEY) \
$(TOKEN) \
'approve(address,uint256)' $(AIRDROP) 2600000000000000000000000000

# Upgrades

upgrade-aligned-token-implementation: ## 🚀 Upgrade the AlignedToken implementation contract
Expand Down Expand Up @@ -86,6 +112,10 @@ test-claimed:

OWNER_PRIVATE_KEY?=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

test-airdrop:
cast call $(AIRDROP) "paused()(bool)" --rpc-url $(RPC_URL)
cast call $(AIRDROP) "owner()(address)" --rpc-url $(RPC_URL)

test-pause:
cast send $(AIRDROP) --private-key $(OWNER_PRIVATE_KEY) "pause()" --rpc-url $(RPC_URL)

Expand Down
28 changes: 28 additions & 0 deletions claim_contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#

## Local

### Requisites

- Foundry

### Run

1. Run anvil in one terminal:
```
anvil
```
2. Deploy the token
```
make deploy-token
```
3. Write down the token proxy address that is printed in the console output.
4. Deploy the claimable contract
```
make deploy-claimable-local
```
5. Write down the claimable contract proxy address that is printed in the console output.
6. Approve the claimable contract to spend the token from the distributor
```
make approve-claimable TOKEN=<token-proxy-address> AIRDROP=<claimable-proxy-address> PRIVATE_KEY=<distributor-private-key>
```
2 changes: 0 additions & 2 deletions claim_contracts/script-config/config.example.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
"deployer": "0x4e59b44847b379578588920cA78FbF26c0B4956C",
"foundation": "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
"tokenDistributor": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"limitTimestampToClaim": 2733427549,
Expand Down
5 changes: 3 additions & 2 deletions claim_contracts/script-config/config.mainnet.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"salt": "0xb254f45e54b7faa70154efcd4fc206f1ca27235419244dd07d64afdc4cc10b1e",
"deployer": "0x4e59b44847b379578588920cA78FbF26c0B4956C",
"foundation": "",
"tokenDistributor": "",

"limitTimestampToClaim": 2733427549,
"claimMerkleRoot": "",
"tokenProxy": "0x0000000000000000000000000000000000000000"
}
81 changes: 21 additions & 60 deletions claim_contracts/script/DeployAlignedToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,30 @@ contract DeployAlignedToken is Script {
);
string memory config_json = vm.readFile(path);

bytes32 _salt = stdJson.readBytes32(config_json, ".salt");
address _deployer = stdJson.readAddress(config_json, ".deployer");
address _foundation = stdJson.readAddress(config_json, ".foundation");
address _tokenDistributor = stdJson.readAddress(
config_json,
".tokenDistributor"
);

TransparentUpgradeableProxy _tokenProxy = deployAlignedTokenProxy(
_foundation,
_salt,
_deployer,
_foundation,
_tokenDistributor
);
vm.broadcast();
AlignedToken _token = new AlignedToken();

console.log("Aligned Token deployed at address:", address(_token));

vm.broadcast();
TransparentUpgradeableProxy _tokenProxy = new TransparentUpgradeableProxy(
address(_token),
_foundation,
Utils.alignedTokenInitData(_foundation, _tokenDistributor)
);

bytes memory _alignedTokenProxyConstructorData = Utils
.alignedTokenProxyConstructorData(
address(_token),
_foundation,
_tokenDistributor
);

console.log(
string.concat(
Expand All @@ -43,58 +52,10 @@ contract DeployAlignedToken is Script {
" with proxy admin: ",
vm.toString(Utils.getAdminAddress(address(_tokenProxy))),
" and owner: ",
vm.toString(_foundation)
vm.toString(_foundation),
" with constructor args: ",
vm.toString(_alignedTokenProxyConstructorData)
)
);

string memory deployedAddressesJson = "deployedAddressesJson";
string memory finalJson = vm.serializeAddress(
deployedAddressesJson,
"tokenProxy",
address(_tokenProxy)
);

vm.writeJson(
finalJson,
_getOutputPath("deployed_token_addresses.json")
);
}

function _getOutputPath(
string memory fileName
) internal returns (string memory) {
string memory outputDir = "script-out/";

// Create output directory if it doesn't exist
if (!vm.exists(outputDir)) {
vm.createDir(outputDir, true);
}

return string.concat(outputDir, fileName);
}

function deployAlignedTokenProxy(
address _proxyAdminOwner,
bytes32 _salt,
address _deployer,
address _foundation,
address _claim
) internal returns (TransparentUpgradeableProxy) {
vm.broadcast();
AlignedToken _token = new AlignedToken();

bytes memory _alignedTokenDeploymentData = Utils
.alignedTokenProxyDeploymentData(
_proxyAdminOwner,
address(_token),
_foundation,
_claim
);
address _alignedTokenProxy = Utils.deployWithCreate2(
_alignedTokenDeploymentData,
_salt,
_deployer
);
return TransparentUpgradeableProxy(payable(_alignedTokenProxy));
}
}
Loading