Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add permission levels #5

Merged
merged 1 commit into from
Dec 13, 2024
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
37 changes: 33 additions & 4 deletions contracts/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

set -e

PRIVATE_KEY=$PRIVATE_KEY
PRIVATE_KEY=$DEPLOYER_PRIVATE_KEY
RPC_URL=$RPC_URL

PREMIUM_USER_ADDRESS=$PREMIUM_USER_ADDRESS
BASIC_USER_ADDRESS=$BASIC_USER_ADDRESS

# Validate environment variables
if [ -z "$PRIVATE_KEY" ]; then
echo "PRIVATE_KEY is not set"
if [ -z "$DEPLOYER_PRIVATE_KEY" ]; then
echo "DEPLOYER_PRIVATE_KEY is not set"
exit 1
fi

Expand All @@ -16,15 +19,27 @@ if [ -z "$RPC_URL" ]; then
exit 1
fi

if [ -z "$PREMIUM_USER_ADDRESS" ]; then
echo "PREMIUM_USER_ADDRESS is not set"
exit 1
fi

if [ -z "$BASIC_USER_ADDRESS" ]; then
echo "BASIC_USER_ADDRESS is not set"
exit 1
fi

extract_deployed_address() {
# Read input from stdin and extract the address after "Deployed to: "
grep "Deployed to:" | cut -d' ' -f3
}


get_address_from_private_key() {
cast wallet address --private-key $1
cast wallet address --private-key $1
}

# List of users. The deployer is the VIP user.
DEPLOYER_ADDRESS=$(get_address_from_private_key $PRIVATE_KEY)

# Build everything
Expand All @@ -35,12 +50,26 @@ dai_address=$(forge create --rpc-url $RPC_URL --private-key $PRIVATE_KEY --zksyn
wbtc_address=$(forge create --rpc-url $RPC_URL --private-key $PRIVATE_KEY --zksync src/TestnetERC20Token.sol:TestnetERC20Token --constructor-args "WBTC" "WBTC" 18 | extract_deployed_address)

# Mint tokens
## VIP User
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $dai_address "mint(address,uint256)" $DEPLOYER_ADDRESS 1000000000000000000000000 # 1 million DAI
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $wbtc_address "mint(address,uint256)" $DEPLOYER_ADDRESS 100000000000000000000000 # 100,000 WBTC

## Premium User
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $dai_address "mint(address,uint256)" $PREMIUM_USER_ADDRESS 100000000000000000000000 # 100,000 DAI
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $wbtc_address "mint(address,uint256)" $PREMIUM_USER_ADDRESS 10000000000000000000000 # 10,000 WBTC

## Basic User
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $dai_address "mint(address,uint256)" $BASIC_USER_ADDRESS 10000000000000000000000 # 10,000 DAI
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $wbtc_address "mint(address,uint256)" $BASIC_USER_ADDRESS 1000000000000000000000 # 1,000 WBTC

# Deploy CPAMM
cpamm_address=$(forge create --rpc-url $RPC_URL --private-key $PRIVATE_KEY --zksync src/CPAMM.sol:CPAMM --constructor-args $dai_address $wbtc_address | extract_deployed_address)

# Set user fee tiers
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $cpamm_address "setUserFeeTier(address,uint256)" $DEPLOYER_ADDRESS 2
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $cpamm_address "setUserFeeTier(address,uint256)" $PREMIUM_USER_ADDRESS 1
cast send --rpc-url $RPC_URL --private-key $PRIVATE_KEY $cpamm_address "setUserFeeTier(address,uint256)" $BASIC_USER_ADDRESS 0

echo "DAI: $dai_address"
echo "WBTC: $wbtc_address"
echo "CPAMM: $cpamm_address"
Loading
Loading