Files
mint_ore/claim.sh
2024-04-07 23:29:53 +08:00

61 lines
2.3 KiB
Bash

#!/bin/bash
# 检查参数数量是否正确
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <monitor_value>"
exit 1
fi
# 从参数中获取密钥文件和监控数值
monitor_value=${1:-0.1}
#export http_proxy="http://10.3.255.132:51837"
#export https_proxy="http://10.3.255.132:51837"
# 定义RPC URL数组
rpcurls=(
"https://solana-mainnet.core.chainstack.com/b366b2ab269b22f4b6dd521c59079618"
"https://prettiest-multi-scion.solana-mainnet.quiknode.pro/879eb32f3cd556cfff80973ff6a51b9e8b7a81ec/"
"https://silent-tiniest-diamond.solana-mainnet.quiknode.pro/fcef276a3d99aa044e9d7d7193aced24563de630/"
"https://few-billowing-liquid.solana-mainnet.quiknode.pro/85c2480a4641a74c262b93f9a2e4385f9fdd4ab3/"
"https://withered-still-borough.solana-mainnet.quiknode.pro/6568815b3dbf509bb2689d6fba5dd973a7c8cada/"
"https://mainnet.helius-rpc.com/?api-key=fa8414c7-043e-4888-922a-344a2d413ec8"
"https://solana-mainnet.core.chainstack.com/b366b2ab269b22f4b6dd521c59079618"
"https://api.mainnet-beta.solana.com"
"https://linguistic-dulcea-fast-mainnet.helius-rpc.com"
"https://cold-hanni-fast-mainnet.helius-rpc.com"
)
fetch_balance_rpc="https://api.mainnet-beta.solana.com"
toaddress="DefJYX8sJmaLBQGyvWPS3rRgVbJRf9kvKEJ19uJpJQEf"
echo "toaddress=" $toaddress
files=$(find . -maxdepth 2 -type f -name "*.json")
for keyfile in $files; do
# 随机选择一个RPC URL
index=$((RANDOM % ${#rpcurls[@]}))
rpc=${rpcurls[$index]}
#echo "选中rpc=$rpc"
echo $keyfile
rewards=$(ore --rpc $fetch_balance_rpc --keypair "$keyfile" rewards | sed 's/ ORE//')
if [ -z "$rewards" ]; then
echo "Failed to get rewards. Exiting..."
exit 1
fi
#echo "$keyfile Current rewards: $rewards ORE"
if (( $(echo "$rewards > $monitor_value" | bc -l) )); then
echo "claim reward $keyfile"
echo "================================================"
echo "Rewards ($rewards) is greater than monitor value ($monitor_value). Claiming rewards..."
./ore --rpc $rpc --keypair $keyfile --priority-fee 100000000 claim $rewards $toaddress
else
echo "Rewards ($rewards) is less than or equal to monitor value ($monitor_value). No action needed."
fi
done
# 脚本结束
#echo "claim.sh script execution completed."