diff --git a/.gitignore b/.gitignore index ba8a4329..d25a73d0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/src/jupiter/README.md b/src/jupiter/README.md new file mode 100644 index 00000000..c4f886da --- /dev/null +++ b/src/jupiter/README.md @@ -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 \ No newline at end of file diff --git a/src/jupiter/install_jupiter.sh b/src/jupiter/install_jupiter.sh new file mode 100755 index 00000000..6a135f95 --- /dev/null +++ b/src/jupiter/install_jupiter.sh @@ -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" diff --git a/src/jupiter/jupiterConfig.yaml b/src/jupiter/jupiterConfig.yaml new file mode 100644 index 00000000..6be3483f --- /dev/null +++ b/src/jupiter/jupiterConfig.yaml @@ -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-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 \ No newline at end of file diff --git a/src/jupiter/run_jupiter.sh b/src/jupiter/run_jupiter.sh new file mode 100755 index 00000000..0a3a9899 --- /dev/null +++ b/src/jupiter/run_jupiter.sh @@ -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