diff --git a/tdex/caddy-data/Caddyfile b/tdex/caddy-data/Caddyfile new file mode 100644 index 00000000..3dcb728d --- /dev/null +++ b/tdex/caddy-data/Caddyfile @@ -0,0 +1,6 @@ +:8080 { + handle_path /api/* { + reverse_proxy tdex_tdexd_1:9090 + } + reverse_proxy tdex_dashboard_1:8080 +} diff --git a/tdex/docker-compose.yml b/tdex/docker-compose.yml new file mode 100644 index 00000000..2c6cca00 --- /dev/null +++ b/tdex/docker-compose.yml @@ -0,0 +1,49 @@ +version: "3.7" + +services: + app_proxy: + environment: + APP_HOST: tdex_caddy_1 + APP_PORT: 8080 + + tdexd: + image: ghcr.io/tdex-network/tdexd:v0.9.1@sha256:5078897b9a505fc3dfac5b3d51537150941c075f5279ae81de1c6b1c21112544 + tty: true + restart: on-failure + stop_grace_period: 1m + volumes: + - ${APP_DATA_DIR}/tdex-data:/home/tdex/.tdex-daemon + environment: + TDEX_LOG_LEVEL: 5 + TDEX_OPERATOR_LISTENING_PORT: "${APP_TDEX_PORT}" + TDEX_TRADE_LISTENING_PORT: "${APP_TDEX_PORT}" + TDEX_NO_OPERATOR_TLS: "true" + # these vars are used to generate the connect URL + # we assume to always show the external endpoint + # reachable remotely by other dashboards via Tor + TDEX_CONNECT_ADDR: "${APP_TDEX_DAEMON_HIDDEN_SERVICE}" + TDEX_CONNECT_PROTO: http + + dashboard: + image: ghcr.io/tdex-network/dashboard:v0.1.55@sha256:dfa7cdb75117c97e671285fc9754a6cabafc7f74760c314e6625c33067509beb + restart: on-failure + environment: + USE_PROXY: "false" + IS_PACKAGED: "true" + TRADER_HIDDEN_SERVICE: "${APP_TDEX_DAEMON_HIDDEN_SERVICE}" + + caddy: + image: caddy:2.6.4-alpine@sha256:4dfec6c3b22c36b63ea4a3633c7cdbdaa9926d1324c27db2b0e2b70ef9cd105a + restart: on-failure + volumes: + - ${APP_DATA_DIR}/caddy-data/Caddyfile:/etc/caddy/Caddyfile + + tor: + image: getumbrel/tor:0.4.7.8@sha256:2ace83f22501f58857fa9b403009f595137fa2e7986c4fda79d82a8119072b6a + user: "1000:1000" + restart: on-failure + volumes: + - ${APP_DATA_DIR}/torrc:/etc/tor/torrc:ro + - ${TOR_DATA_DIR}:/data + environment: + HOME: "/tmp" diff --git a/tdex/exports.sh b/tdex/exports.sh new file mode 100644 index 00000000..1c784600 --- /dev/null +++ b/tdex/exports.sh @@ -0,0 +1,7 @@ +export APP_TDEX_PORT="9090" + +daemon_hidden_service_file="${EXPORTS_TOR_DATA_DIR}/app-${EXPORTS_APP_ID}-daemon/hostname" +export APP_TDEX_DAEMON_HIDDEN_SERVICE="$(cat "${daemon_hidden_service_file}" 2>/dev/null || echo "daemon_not_yet_set.onion")" + +# Necessary for the tdexd daemon to be able to write to the volume +sudo chmod -R 777 "${UMBREL_ROOT}/app-data/tdex/tdex-data" diff --git a/tdex/hooks/pre-start b/tdex/hooks/pre-start new file mode 100755 index 00000000..95b96992 --- /dev/null +++ b/tdex/hooks/pre-start @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Delay booting TDEX until the Tor Hidden Service is ready +HIDDEN_SERVICE_FILE="${TOR_DATA_DIR}/app-${APP_ID}-daemon/hostname" +if [[ -f "${HIDDEN_SERVICE_FILE}" ]]; then + exit +fi + +"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" up --detach tdexd +"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" up --detach tor + +echo "App: ${APP_ID} - Generating Tor Hidden Service..." +for attempt in $(seq 1 100); do + if [[ -f "${HIDDEN_SERVICE_FILE}" ]]; then + echo "App: ${APP_ID} - Hidden service file created successfully!" + break + fi + sleep 0.1 +done + +if [[ ! -f "${HIDDEN_SERVICE_FILE}" ]]; then + echo "App: ${APP_ID} - Hidden service file wasn't created" +fi diff --git a/tdex/tdex-data/.gitkeep b/tdex/tdex-data/.gitkeep new file mode 100755 index 00000000..e69de29b diff --git a/tdex/torrc.template b/tdex/torrc.template new file mode 100644 index 00000000..94d05ac3 --- /dev/null +++ b/tdex/torrc.template @@ -0,0 +1,3 @@ +# TDEX Public Trader Interface Hidden Service +HiddenServiceDir /data/app-$APP_ID-daemon +HiddenServicePort 80 tdex_tdexd_1:$APP_TDEX_PORT diff --git a/tdex/umbrel-app.yml b/tdex/umbrel-app.yml new file mode 100644 index 00000000..ee0ca339 --- /dev/null +++ b/tdex/umbrel-app.yml @@ -0,0 +1,34 @@ +manifestVersion: 1.1 +id: tdex +category: Finance +name: TDEX Provider +version: "0.9.1" +tagline: Provide liquidity on the TDEX Network, an open protocol to trade Liquid Network assets. +description: >- + A liquidity provider holds Liquid reserves of both a BASE_ASSET-QUOTE_ASSET in his non-custodial Liquid hot-wallet, + running automated market-making strategies, either with or without an oracle. Providers are incentivized to + be always on and need to expose a public reachable endpoint either via clearnet or using an Onion hidden service. + + + A small provider's fee can be taken out of each trade and added to the reserves. A liquidity provider has full control + over the market making strategy needed to calculate the market rate at which to accept trades. That being said, + there is a possibility to apply an automated market-making strategy relying only on the reserves balances and the amount requested + by the trader, without the need to connect to an external price feed. The default strategy of the alpha daemond is the + constant product market-making. In short, this model generates a full order-book based on an initial price for the market. + Every transaction that occurs on this market will adjust the prices of the market accordingly. +dependencies: [] +developer: TDEX Network +website: https://dev.tdex.network +repo: https://github.com/tdex-network/tdex-daemon +support: https://t.me/tdexnetwork +submitter: TDEX Network (tiero) +submission: https://github.com/getumbrel/umbrel-apps/pull/151 +port: 9094 +torOnly: false +gallery: + - 1.jpg + - 2.jpg + - 3.jpg +path: "" +defaultUsername: "" +defaultPassword: ""