From f987fcd0e11a32058acf6b8487aeaac7073ac1ff Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Fri, 6 Oct 2023 09:33:14 +0200 Subject: [PATCH 01/12] SOR | Dockerfile#3 --- Dockerfile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f70864 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +FROM haskell:9.2.8-slim as builder + +ENV LANG C.UTF-8 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + build-essential \ + chrony \ + libncursesw5 \ + liblzma-dev \ + libpq-dev \ + libssl-dev \ + libsystemd-dev \ + libtool \ + pkg-config \ + procps \ + tmux && \ + rm -rf /var/lib/apt/lists/* + +# Libsodium: +RUN git clone https://github.com/input-output-hk/libsodium && \ + cd libsodium && \ + git checkout dbb48cc && \ + ./autogen.sh && \ + ./configure && \ + make && \ + make install + +# Libsecp256k1: +RUN git clone https://github.com/bitcoin-core/secp256k1 && \ + cd secp256k1 && \ + git checkout ac83be33d0956faf6b7f61a60ab524ef7d6a473a && \ + ./autogen.sh && \ + ./configure --prefix=/usr --enable-module-schnorrsig --enable-experimental && \ + make && \ + make install + +ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" +ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" + +# ==================================[ BUILD ]======================================== +WORKDIR /SOR + +COPY . . + +RUN cabal update +RUN cabal build all +RUN cabal test +RUN cabal install --global + +# =============================[ SMART ORDER ROUTER ]================================ +ENTRYPOINT [ "geniusyield-orderbot-exe", "run", "/SOR/config-files/${CONFIG_FILE:=atlas-config-maestro.json}" ] From 551a6a937bb23a20bfa3d02c1ee6df8d6e28b6fd Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Fri, 6 Oct 2023 18:21:07 +0200 Subject: [PATCH 02/12] SOR | Dockerfile#3 --- Dockerfile | 12 +++++++++++- start.sh | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile index 0f70864..74df1a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,4 +51,14 @@ RUN cabal test RUN cabal install --global # =============================[ SMART ORDER ROUTER ]================================ -ENTRYPOINT [ "geniusyield-orderbot-exe", "run", "/SOR/config-files/${CONFIG_FILE:=atlas-config-maestro.json}" ] + +# Default values: +ENV BOTC_FP_NFT_POLICY='compiled-scripts/minting-policy' +ENV BOTC_FP_ORDER_VALIDATOR='compiled-scripts/partial-order' +ENV BOTC_EXECUTION_STRAT='OneSellToManyBuy' +ENV BOTC_RESCAN_DELAY='30000000' +ENV BOTC_MAX_ORDERS_MATCHES='5' +ENV BOTC_MAX_TXS_PER_ITERATION='4' +ENV BOTC_RANDOMIZE_MATCHES_FOUND='True' + +ENTRYPOINT ["/bin/bash", "./start.sh"] diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..1a57904 --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo $BOTC_CONFIG >> ~/config.json +geniusyield-orderbot-exe run ~/config.json From 9f1d5dc208731eb82e727e7031369c8ca81af403 Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sat, 7 Oct 2023 10:34:09 +0200 Subject: [PATCH 03/12] SOR | Dockerfile#3 --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 74df1a9..57f2d0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,5 +60,7 @@ ENV BOTC_RESCAN_DELAY='30000000' ENV BOTC_MAX_ORDERS_MATCHES='5' ENV BOTC_MAX_TXS_PER_ITERATION='4' ENV BOTC_RANDOMIZE_MATCHES_FOUND='True' +ENV BOTC_ASSET_FILTER='[{"commodityAsset":"c6e65ba7878b2f8ea0ad39287d3e2fd256dc5c4160fc19bdf4c4d87e.7447454e53","currencyAsset":"lovelace"},{"commodityAsset":"0254a6ffa78edb03ea8933dbd4ca078758dbfc0fc6bb0d28b7a9c89f.4c454e4649","currencyAsset":"lovelace"},{"commodityAsset":"8cafc9b387c9f6519cacdce48a8448c062670c810d8da4b232e56313.6d4e5458","currencyAsset":"lovelace"},{"commodityAsset":"171163f05e4f30b6be3c22668c37978e7d508b84f83558e523133cdf.74454d50","currencyAsset":"lovelace"}]' +ENV BOTC_POREFS='{"refAddr":"addr_test1wpgexmeunzsykesf42d4eqet5yvzeap6trjnflxqtkcf66g0kpnxt","refNftAC":"fae686ea8f21d567841d703dea4d4221c2af071a6f2b433ff07c0af2.e6a295bb83d06f53fcf91151f54acec0a63fbd6f0d924206d5d012e6da3b72af","refNftUtxoRef":"39f987a6beb9cc4c45bba149a21c28068f640f3593f15f8157f0b6022b431977#0","scriptRef":"39f987a6beb9cc4c45bba149a21c28068f640f3593f15f8157f0b6022b431977#1","nftPolicyRef":"39f987a6beb9cc4c45bba149a21c28068f640f3593f15f8157f0b6022b431977#0"}' ENTRYPOINT ["/bin/bash", "./start.sh"] From bd7984c7171987c9827187f09fc3eb0d76dd0dc3 Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sun, 8 Oct 2023 06:49:16 +0200 Subject: [PATCH 04/12] SOR | CI Pipeline #8 --- .github/workflows/build.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e10378c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,19 @@ +name: build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: false + tags: geniusyield/sor:latest \ No newline at end of file From 3128bb69f495d437ac3284d98cffb03e4b4418f2 Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sun, 8 Oct 2023 06:59:44 +0200 Subject: [PATCH 05/12] SOR | CI Pipeline#8 --- .github/workflows/build.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e10378c..195be18 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,13 +7,16 @@ on: branches: [ "main" ] jobs: - docker: + build: runs-on: ubuntu-latest + permissions: + packages: write + contents: read steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push + - name: ${{ github.ref == 'refs/heads/main' && 'Build and Push Docker image' || 'Build Docker image' }} uses: docker/build-push-action@v5 with: - push: false - tags: geniusyield/sor:latest \ No newline at end of file + push: ${{ github.ref == 'refs/heads/main'}} + tags: geniusyield/sor:latest From 174849610d135a1bd660dccb2c22f289ed63660f Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sun, 8 Oct 2023 07:14:50 +0200 Subject: [PATCH 06/12] SOR | CI Pipeline#8 --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 195be18..397a9ec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,8 +15,14 @@ jobs: steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: ${{ github.ref == 'refs/heads/main' && 'Build and Push Docker image' || 'Build Docker image' }} uses: docker/build-push-action@v5 with: push: ${{ github.ref == 'refs/heads/main'}} - tags: geniusyield/sor:latest + tags: geniusyield/smart-order-router:latest From 59220ca92fb25819cea2167951f3046f8da367c6 Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sun, 8 Oct 2023 08:24:53 +0200 Subject: [PATCH 07/12] SOR | CI Pipeline#8 --- .github/workflows/build.yml | 2 +- Dockerfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 397a9ec..171dc11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,4 +25,4 @@ jobs: uses: docker/build-push-action@v5 with: push: ${{ github.ref == 'refs/heads/main'}} - tags: geniusyield/smart-order-router:latest + tags: ghcr.io/geniusyield/smart-order-router:latest diff --git a/Dockerfile b/Dockerfile index 57f2d0e..ebb9e17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,6 +51,7 @@ RUN cabal test RUN cabal install --global # =============================[ SMART ORDER ROUTER ]================================ +LABEL org.opencontainers.image.source="https://github.com/geniusyield/smart-order-router" # Default values: ENV BOTC_FP_NFT_POLICY='compiled-scripts/minting-policy' From 02a11ade21be993457bdeb05676e7317042e530b Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sun, 8 Oct 2023 10:11:22 +0200 Subject: [PATCH 08/12] SOR | Dockerfile#3 --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fa8090..c0e6f75 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,25 @@ using these `18 tokenB` we buy back `9 tokenA` from the buy order, earning `2 to ### Docker -:construction: Coming Soon :construction: +A ready-to-run, containerized version of the Smart Order Router is availabe via the [GitHub Container Registry](ghcr.io/geniusyield/smart-order-router:latest). + +A Smart Order Router container instance can be started by using the following snippet: + +``` bash +# Replace these values with your configuration: +PAYMENT_SIGNING_KEY_CBOR_HEX=5820d682e237a04d43ad011fdecd141acd485f6d3d634466692d58f6d75250f39134 +COLLATERAL_UTXO_REF=7cc7b044d26981d3fc73ae72994f289d99ba113ceefb5b83f4d7643bfb12682a#1 +MAESTRO_API_KEY=some_api_key +CARDANO_NETWORK=testnet-preprod + +docker run -it \ + -e BOTC_SKEY="{\"cborHex\": \"$PAYMENT_SIGNING_KEY_CBOR_HEX\", \"type\": \"PaymentSigningKeyShelley_ed25519\", \"description\": \"Payment Signing Key\"}" \ + -e BOTC_COLLATERAL="$COLLATERAL_UTXO_REF" \ + -e BOTC_CONFIG="{ \"coreProvider\": { \"maestroToken\": \"$MAESTRO_API_KEY\" }, \"networkId\": \"$CARDANO_NETWORK\", \"logging\": [{ \"type\": { \"tag\": \"stderr\" }, \"severity\": \"Info\", \"verbosity\": \"V2\" }],\"utxoCacheEnable\": false }" \ + ghcr.io/geniusyield/smart-order-router:latest +``` + +Please make sure to replace the placeholders with the actual values. ### Local build From 00f99075e053c45a70d85692de975a2fed926eac Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sun, 8 Oct 2023 10:28:06 +0200 Subject: [PATCH 09/12] SOR | Dockerfile#3 --- README.md | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0e6f75..2d13bd9 100644 --- a/README.md +++ b/README.md @@ -128,9 +128,11 @@ using these `18 tokenB` we buy back `9 tokenA` from the buy order, earning `2 to A ready-to-run, containerized version of the Smart Order Router is availabe via the [GitHub Container Registry](ghcr.io/geniusyield/smart-order-router:latest). -A Smart Order Router container instance can be started by using the following snippet: +A Smart Order Router container instance usign the Maestro backend can be started by using the following snippet: ``` bash +# SMART ORDER INSTANCE ROUTER USING MAESTRO +# ========================================= # Replace these values with your configuration: PAYMENT_SIGNING_KEY_CBOR_HEX=5820d682e237a04d43ad011fdecd141acd485f6d3d634466692d58f6d75250f39134 COLLATERAL_UTXO_REF=7cc7b044d26981d3fc73ae72994f289d99ba113ceefb5b83f4d7643bfb12682a#1 @@ -146,6 +148,46 @@ docker run -it \ Please make sure to replace the placeholders with the actual values. +Alternatively the Blockfrost or the Kupo backend could be used. + +This can be accomplished for Blockfrost by using the following commands: + +``` bash +# SMART ORDER ROUTER INSTANCE USING BLOCKFROST +# ============================================ +# Replace these values with your configuration: +PAYMENT_SIGNING_KEY_CBOR_HEX=5820d682e237a04d43ad011fdecd141acd485f6d3d634466692d58f6d75250f39134 +COLLATERAL_UTXO_REF=7cc7b044d26981d3fc73ae72994f289d99ba113ceefb5b83f4d7643bfb12682a#1 +BLOCKFROST_API_KEY=some_api_key +CARDANO_NETWORK=testnet-preprod + +docker run -it \ + -e BOTC_SKEY="{\"cborHex\": \"$PAYMENT_SIGNING_KEY_CBOR_HEX\", \"type\": \"PaymentSigningKeyShelley_ed25519\", \"description\": \"Payment Signing Key\"}" \ + -e BOTC_COLLATERAL="$COLLATERAL_UTXO_REF" \ + -e BOTC_CONFIG="{ \"coreProvider\": { \"blockfrostKey\": \"$BLOCKFROST_API_KEY\" }, \"networkId\": \"$CARDANO_NETWORK\", \"logging\": [{ \"type\": { \"tag\": \"stderr\" }, \"severity\": \"Info\", \"verbosity\": \"V2\" }],\"utxoCacheEnable\": false }" \ + ghcr.io/geniusyield/smart-order-router:latest +``` + +And the following commands can be used to start a Kupo backed instance: + +``` bash +# SMART ORDER ROUTER INSTANCE USING KUPO +# ====================================== +# Replace these values with your configuration: +PAYMENT_SIGNING_KEY_CBOR_HEX=5820d682e237a04d43ad011fdecd141acd485f6d3d634466692d58f6d75250f39134 +COLLATERAL_UTXO_REF=7cc7b044d26981d3fc73ae72994f289d99ba113ceefb5b83f4d7643bfb12682a#1 +KUPO_URL=http://some.url.to.your.kupo.instance:1442 +CARDANO_NODE_SOCKET_PATH=/cardano/node/socket +CARDANO_NETWORK=testnet-preprod + +docker run -it \ + -e BOTC_SKEY="{\"cborHex\": \"$PAYMENT_SIGNING_KEY_CBOR_HEX\", \"type\": \"PaymentSigningKeyShelley_ed25519\", \"description\": \"Payment Signing Key\"}" \ + -e BOTC_COLLATERAL="$COLLATERAL_UTXO_REF" \ + -e BOTC_CONFIG="{\"coreProvider\": { \"socketPath\": \"$CARDANO_NODE_SOCKET_PATH\", \"kupoUrl\": \"$KUPO_URL\" }, \"networkId\": \"testnet-preprod\", \"logging\": [{ \"type\": { \"tag\": \"stderr\" }, \"severity\": \"Info\", \"verbosity\": \"V2\" }], \"utxoCacheEnable\": false }" \ + ghcr.io/geniusyield/smart-order-router:latest +``` + + ### Local build First, you need to setup the necessary tooling to work with [haskell.nix](https://github.com/input-output-hk/haskell.nix). From 895fc26f50f799be074ddc8b39de239cfaa93929 Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Sun, 8 Oct 2023 10:30:09 +0200 Subject: [PATCH 10/12] SOR | Dockerfile#3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d13bd9..067a960 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ using these `18 tokenB` we buy back `9 tokenA` from the buy order, earning `2 to A ready-to-run, containerized version of the Smart Order Router is availabe via the [GitHub Container Registry](ghcr.io/geniusyield/smart-order-router:latest). -A Smart Order Router container instance usign the Maestro backend can be started by using the following snippet: +A Smart Order Router container instance using the Maestro backend can be started by using the following snippet: ``` bash # SMART ORDER INSTANCE ROUTER USING MAESTRO @@ -183,7 +183,7 @@ CARDANO_NETWORK=testnet-preprod docker run -it \ -e BOTC_SKEY="{\"cborHex\": \"$PAYMENT_SIGNING_KEY_CBOR_HEX\", \"type\": \"PaymentSigningKeyShelley_ed25519\", \"description\": \"Payment Signing Key\"}" \ -e BOTC_COLLATERAL="$COLLATERAL_UTXO_REF" \ - -e BOTC_CONFIG="{\"coreProvider\": { \"socketPath\": \"$CARDANO_NODE_SOCKET_PATH\", \"kupoUrl\": \"$KUPO_URL\" }, \"networkId\": \"testnet-preprod\", \"logging\": [{ \"type\": { \"tag\": \"stderr\" }, \"severity\": \"Info\", \"verbosity\": \"V2\" }], \"utxoCacheEnable\": false }" \ + -e BOTC_CONFIG="{\"coreProvider\": { \"socketPath\": \"$CARDANO_NODE_SOCKET_PATH\", \"kupoUrl\": \"$KUPO_URL\" }, \"networkId\": \"$CARDANO_NETWORK\", \"logging\": [{ \"type\": { \"tag\": \"stderr\" }, \"severity\": \"Info\", \"verbosity\": \"V2\" }], \"utxoCacheEnable\": false }" \ ghcr.io/geniusyield/smart-order-router:latest ``` From 9597fb5eb7ef353db02fa290554c47336ec154ba Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Mon, 9 Oct 2023 10:37:49 +0200 Subject: [PATCH 11/12] SOR | Dockerfile#3 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 067a960..40b1d32 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,8 @@ docker run -it \ ghcr.io/geniusyield/smart-order-router:latest ``` +> [!NOTE] +> :construction: Coming Soon: docker-compose :construction: ### Local build From f7baa4dd16b44b5adb9561bd0901e5083ef71bd5 Mon Sep 17 00:00:00 2001 From: 4TT1L4 <2914096+4TT1L4@users.noreply.github.com> Date: Mon, 9 Oct 2023 10:47:51 +0200 Subject: [PATCH 12/12] SOR | Dockerfile#3 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 40b1d32..dda85af 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,8 @@ CARDANO_NETWORK=testnet-preprod docker run -it \ -e BOTC_SKEY="{\"cborHex\": \"$PAYMENT_SIGNING_KEY_CBOR_HEX\", \"type\": \"PaymentSigningKeyShelley_ed25519\", \"description\": \"Payment Signing Key\"}" \ -e BOTC_COLLATERAL="$COLLATERAL_UTXO_REF" \ - -e BOTC_CONFIG="{\"coreProvider\": { \"socketPath\": \"$CARDANO_NODE_SOCKET_PATH\", \"kupoUrl\": \"$KUPO_URL\" }, \"networkId\": \"$CARDANO_NETWORK\", \"logging\": [{ \"type\": { \"tag\": \"stderr\" }, \"severity\": \"Info\", \"verbosity\": \"V2\" }], \"utxoCacheEnable\": false }" \ + -e BOTC_CONFIG="{\"coreProvider\": { \"socketPath\": \"/cardano/node/socket\", \"kupoUrl\": \"$KUPO_URL\" }, \"networkId\": \"$CARDANO_NETWORK\", \"logging\": [{ \"type\": { \"tag\": \"stderr\" }, \"severity\": \"Info\", \"verbosity\": \"V2\" }], \"utxoCacheEnable\": false }" \ + -v $CARDANO_NODE_SOCKET_PATH:/cardano/node/socket ghcr.io/geniusyield/smart-order-router:latest ```