mirror of
https://github.com/0x1d/drift-keeper.git
synced 2025-12-17 03:06:40 +01:00
Multi-Cloud Deployment (#1)
* Introduce instances list to scale bots and add config templating * Use env var for wallet address if not provided as path param * Expose SOL price as metric * Update docs * Add auto-swap * Add Panopticon * implement backoff stategy in autoswap * Add retry logic for withdraw and swap * bump drift-sdk, update ctl.sh and docs * Update filler bot, add tx metrics * Add user-metrics * Update build and dashboard
This commit is contained in:
149
ctl.sh
149
ctl.sh
@@ -5,38 +5,143 @@ API_ENDPOINT=https://api.mainnet-beta.solana.com/
|
||||
|
||||
source .env
|
||||
|
||||
function keeper {
|
||||
function build {
|
||||
##
|
||||
## Usage: ./ctl.sh COMMAND SUBCOMMAND
|
||||
##
|
||||
## ~> build
|
||||
## all Build all images
|
||||
## keeper Build bot image
|
||||
## tracker Build wallet-tracker image
|
||||
## autoswap Build auto-swap image
|
||||
##
|
||||
## ~> push
|
||||
## all Push all images to Docker registry
|
||||
## keeper Push bot image to Docker registry
|
||||
## tracker Push tracker image to Docker registry
|
||||
## autoswap Push auto-swaü image to Docker registry
|
||||
##
|
||||
## ~> run
|
||||
## all Run the complete stack locally
|
||||
## autoswap Run Auto-Swap locally
|
||||
##
|
||||
## ~> infra
|
||||
## plan Plan infrastructure change
|
||||
## provision Provision infrastructure
|
||||
## hosts Show list of servers
|
||||
## connect Connect to a server
|
||||
## playbook Run a maintenance playbook
|
||||
##
|
||||
## ~> balance
|
||||
## sol Show SOL balance
|
||||
## usdc Show USDC balance
|
||||
##
|
||||
|
||||
RED="31"
|
||||
GREEN="32"
|
||||
GREENBLD="\e[1;${GREEN}m"
|
||||
REDBOLD="\e[1;${RED}m"
|
||||
REDITALIC="\e[3;${RED}m"
|
||||
EC="\e[0m"
|
||||
|
||||
function info {
|
||||
printf "\n${GREENBLD}Wallet Address:\t$WALLET_ADDRESS${EC}\n"
|
||||
printf "${GREENBLD}Environment:\t$ENV${EC}\n"
|
||||
sed -n 's/^##//p' ctl.sh
|
||||
}
|
||||
|
||||
function build {
|
||||
function all {
|
||||
build keeper
|
||||
build tracker
|
||||
}
|
||||
function keeper {
|
||||
mkdir -p .build
|
||||
git clone https://github.com/drift-labs/keeper-bots-v2 -b mainnet-beta .build/keeper-bots-v2
|
||||
#pushd .build/keeper-bots-v2
|
||||
# git checkout 21fd791d142490fe033b5e25719927c106a0aaf2
|
||||
#popd
|
||||
docker build -f Dockerfile -t ${DOCKER_IMAGE} .build/keeper-bots-v2
|
||||
rm -rf .build
|
||||
}
|
||||
function push {
|
||||
docker push ${DOCKER_IMAGE}
|
||||
}
|
||||
${@:-}
|
||||
}
|
||||
|
||||
function tracker {
|
||||
function build {
|
||||
function tracker {
|
||||
pushd wallet-tracker
|
||||
docker build -t ${DOCKER_IMAGE_WALLET_TRACKER} .
|
||||
popd
|
||||
}
|
||||
function push {
|
||||
docker push ${DOCKER_IMAGE_WALLET_TRACKER}
|
||||
function autoswap {
|
||||
pushd auto-swap
|
||||
docker build -t ${DOCKER_IMAGE_AUTO_SWAP} .
|
||||
popd
|
||||
}
|
||||
function metrics {
|
||||
pushd user-metrics
|
||||
docker build -t ${DOCKER_IMAGE_USER_METRICS} .
|
||||
popd
|
||||
}
|
||||
${@:-}
|
||||
}
|
||||
|
||||
function droplet {
|
||||
function push {
|
||||
function all {
|
||||
push keeper
|
||||
push tracker
|
||||
}
|
||||
function keeper {
|
||||
docker push ${DOCKER_IMAGE}
|
||||
}
|
||||
function tracker {
|
||||
docker push ${DOCKER_IMAGE_WALLET_TRACKER}
|
||||
}
|
||||
function autoswap {
|
||||
docker push ${DOCKER_IMAGE_AUTO_SWAP}
|
||||
}
|
||||
function metrics {
|
||||
docker push ${DOCKER_IMAGE_USER_METRICS}
|
||||
}
|
||||
${@:-}
|
||||
}
|
||||
|
||||
function run {
|
||||
function all {
|
||||
docker compose up
|
||||
}
|
||||
function autoswap {
|
||||
pushd auto-swap
|
||||
npm start
|
||||
popd
|
||||
}
|
||||
function metircs {
|
||||
pushd user-metrics
|
||||
npm start
|
||||
popd
|
||||
}
|
||||
${@:-}
|
||||
}
|
||||
|
||||
function infra {
|
||||
function plan {
|
||||
terraform init
|
||||
terraform plan
|
||||
}
|
||||
function provision {
|
||||
terraform init
|
||||
terraform apply
|
||||
echo "[bots]" > inventory.cfg
|
||||
terraform output -json | jq --raw-output ' .instances.value | to_entries[] | .value' >> inventory.cfg
|
||||
}
|
||||
function hosts {
|
||||
terraform output -json | jq --raw-output '.instances.value | to_entries[] | [.key, .value] | @tsv'
|
||||
}
|
||||
function connect {
|
||||
ssh root@$(terraform output -raw droplet_ip)
|
||||
infra hosts \
|
||||
| fzf --height=~50 \
|
||||
| awk '{print $2}' \
|
||||
| xargs -o ssh -l root $@
|
||||
}
|
||||
function playbook {
|
||||
pushd ansible
|
||||
ansible-playbook --ssh-common-args='-o StrictHostKeyChecking=accept-new' -i ../inventory.cfg $(fzf --height=~10)
|
||||
popd
|
||||
}
|
||||
${@:-}
|
||||
}
|
||||
@@ -77,4 +182,18 @@ function balance {
|
||||
${@:-}
|
||||
}
|
||||
|
||||
${@:-}
|
||||
function repl {
|
||||
clear
|
||||
cat motd
|
||||
info
|
||||
echo -e "\n${REDBOLD}Enter command...${EC}"
|
||||
read -p '~> ';
|
||||
clear
|
||||
cat motd
|
||||
./ctl.sh ${REPLY}
|
||||
printf "\n"
|
||||
read -p "Press any key to continue."
|
||||
repl
|
||||
}
|
||||
|
||||
${@:-info}
|
||||
Reference in New Issue
Block a user