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

Support a self-hosted jupiter on keeper-bots #118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ src/**.js
src/**.js.map
.idea

# 6 mb+ binary file that needs to be downloaded
jupiter-swap-api

.env
lib
yarn.lock
7 changes: 7 additions & 0 deletions src/jupiter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Setting up Jupiter

Set up requires installing: https://github.com/mikefarah/yq and wget

First run the installer called install_jupiter.sh.
Next you can either run the program using run_jupiter.sh and the jupiterConfig.yaml or you can follow the guide here:
https://station.jup.ag/docs/apis/self-hosted
35 changes: 35 additions & 0 deletions src/jupiter/install_jupiter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# URL of the zip file
url="https://github.com/jup-ag/jupiter-swap-api/releases/download/v6.0.5/jupiter-swap-api-x86_64-unknown-linux-gnu.zip"


FILE_DIR="$(dirname "$(realpath "$0")")"

# Directory where the zip file will be downloaded and unzipped
dir=$FILE_DIR

# Download the zip file using wget
wget -P "$dir" "$url"

# Extract the name of the zip file from the URL
zip_file=$(basename "$url")

# Full path to the downloaded zip file
zip_path="$dir/$zip_file"

# Unzip the zip file
unzip "$zip_path" -d "$dir"

# Remove the zip file after unzipping
rm "$zip_path"

# Assume that the unzipped file is a script with a .sh extension
# Extract the name of the script from the name of the zip file
script="${zip_file%.zip}"

# Full path to the script
script_path="$dir/jupiter-swap-api"

# Make the script executable
chmod +x "$script_path"
10 changes: 10 additions & 0 deletions src/jupiter/jupiterConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# market-cache: Jupiter market cache file path [env: MARKET_CACHE=]
rpc-url: http://127.0.0.1:8899
# yellowstone-grpc-endpoint: <YELLOWSTONE_GRPC_ENDPOINT>
# yellowstone-grpc-x-token: --yellowstone-grpc-x-token
# snapshot-poll-interval-ms: 200
# sentry-dsn:
# expose-quote-and-simulate:
# limit-order:
host: 127.0.0.1
port: 8080
28 changes: 28 additions & 0 deletions src/jupiter/run_jupiter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash


FILE_DIR="$(dirname "$(realpath "$0")")"

commands="$FILE_DIR/jupiter-swap-api "
# Read the YAML file line by line
while read -r line; do
# Check if the line starts with a # using grep. If it does, skip to the next iteration.
if echo "$line" | grep -q '^#'; then
continue
fi


# Use yq to parse the line and store the result in a variable

variable=$(echo "$line" | yq 'to_entries | from_entries')


#Use IFS as yq o=shell coerces the - to be _
IFS=': ' read -r key value <<< "$variable"

commands+="--$key=$value "
# Use the variable in your script
done < jupiterConfig.yaml

echo $commands
$commands