-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathdeploy_yield_farming.sh
More file actions
executable file
Β·149 lines (128 loc) Β· 4.96 KB
/
deploy_yield_farming.sh
File metadata and controls
executable file
Β·149 lines (128 loc) Β· 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
set -e
echo "π Deploying Yield Farming Contract to Testnet"
echo "=============================================="
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Configuration
NETWORK="testnet"
SOURCE_ACCOUNT="puzzle_deployer"
echo -e "${BLUE}π¦ Building contract...${NC}"
soroban contract build --package yield_farming
if [ ! -f "target/wasm32-unknown-unknown/release/yield_farming.wasm" ]; then
echo "β Build failed - WASM file not found"
exit 1
fi
echo -e "${GREEN}β
Build successful${NC}"
echo ""
echo -e "${BLUE}π Optimizing WASM...${NC}"
soroban contract optimize \
--wasm target/wasm32-unknown-unknown/release/yield_farming.wasm
echo -e "${GREEN}β
Optimization complete${NC}"
echo ""
echo -e "${BLUE}π€ Deploying to ${NETWORK}...${NC}"
CONTRACT_ID=$(soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/yield_farming.wasm \
--source ${SOURCE_ACCOUNT} \
--network ${NETWORK})
if [ -z "$CONTRACT_ID" ]; then
echo "β Deployment failed"
exit 1
fi
echo -e "${GREEN}β
Contract deployed successfully!${NC}"
echo ""
echo "π Contract Details:"
echo "ββββββββββββββββββββββββββββββββββββββββ"
echo -e "Contract ID: ${YELLOW}${CONTRACT_ID}${NC}"
echo -e "Network: ${YELLOW}${NETWORK}${NC}"
echo -e "Source: ${YELLOW}${SOURCE_ACCOUNT}${NC}"
echo ""
# Get admin address
ADMIN_ADDRESS=$(soroban keys address ${SOURCE_ACCOUNT})
echo -e "${BLUE}π§ Initializing contract...${NC}"
echo "Please provide the reward token address:"
read -p "Reward Token Address: " REWARD_TOKEN
if [ -z "$REWARD_TOKEN" ]; then
echo -e "${YELLOW}β οΈ No reward token provided. Skipping initialization.${NC}"
echo "You can initialize later with:"
echo ""
echo "soroban contract invoke \\"
echo " --id ${CONTRACT_ID} \\"
echo " --source ${SOURCE_ACCOUNT} \\"
echo " --network ${NETWORK} \\"
echo " -- initialize \\"
echo " --admin ${ADMIN_ADDRESS} \\"
echo " --reward_token <REWARD_TOKEN_ADDRESS>"
else
soroban contract invoke \
--id ${CONTRACT_ID} \
--source ${SOURCE_ACCOUNT} \
--network ${NETWORK} \
-- initialize \
--admin ${ADMIN_ADDRESS} \
--reward_token ${REWARD_TOKEN}
echo -e "${GREEN}β
Contract initialized${NC}"
echo ""
echo -e "${BLUE}π Creating example pool...${NC}"
echo "Create a token pool? (y/n)"
read -p "> " CREATE_POOL
if [ "$CREATE_POOL" = "y" ]; then
echo "Enter token address for the pool:"
read -p "Token Address: " TOKEN_ADDRESS
if [ ! -z "$TOKEN_ADDRESS" ]; then
POOL_ID=$(soroban contract invoke \
--id ${CONTRACT_ID} \
--source ${SOURCE_ACCOUNT} \
--network ${NETWORK} \
-- create_pool \
--asset_address ${TOKEN_ADDRESS} \
--asset_type '{"Token":{}}' \
--apy_basis_points 1000 \
--lock_period_days 30 \
--early_withdrawal_penalty_bp 500 \
--multiplier_bp 10000 \
--auto_compound false)
echo -e "${GREEN}β
Pool created with ID: ${POOL_ID}${NC}"
fi
fi
fi
echo ""
echo "ββββββββββββββββββββββββββββββββββββββββ"
echo -e "${GREEN}π Deployment Complete!${NC}"
echo "ββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "π Next Steps:"
echo "1. Create staking pools with create_pool"
echo "2. Fund contract with reward tokens"
echo "3. Users can stake tokens/NFTs"
echo "4. Monitor pool statistics"
echo ""
echo "π Useful Commands:"
echo ""
echo "# Create a pool"
echo "soroban contract invoke --id ${CONTRACT_ID} --source ${SOURCE_ACCOUNT} --network ${NETWORK} \\"
echo " -- create_pool --asset_address <TOKEN> --asset_type '{\"Token\":{}}' \\"
echo " --apy_basis_points 1000 --lock_period_days 30 --early_withdrawal_penalty_bp 500 \\"
echo " --multiplier_bp 10000 --auto_compound false"
echo ""
echo "# Stake tokens"
echo "soroban contract invoke --id ${CONTRACT_ID} --source <USER> --network ${NETWORK} \\"
echo " -- stake_tokens --staker <USER_ADDRESS> --pool_id 1 --amount 10000"
echo ""
echo "# Check rewards"
echo "soroban contract invoke --id ${CONTRACT_ID} --network ${NETWORK} \\"
echo " -- calculate_rewards --staker <USER_ADDRESS> --stake_id 1"
echo ""
echo "# Claim rewards"
echo "soroban contract invoke --id ${CONTRACT_ID} --source <USER> --network ${NETWORK} \\"
echo " -- claim_rewards --staker <USER_ADDRESS> --stake_id 1"
echo ""
echo "# View pool stats"
echo "soroban contract invoke --id ${CONTRACT_ID} --network ${NETWORK} \\"
echo " -- get_pool_stats --pool_id 1"
echo ""
echo "π Explorer: https://stellar.expert/explorer/${NETWORK}/contract/${CONTRACT_ID}"
echo ""