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

Release on main branch #406

Open
wants to merge 16 commits into
base: main
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
67 changes: 67 additions & 0 deletions .github/workflows/docker-ghostnet-front-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Docker ghostnet front staging

on:
push:
branches:
- 'release-ghostnet-staging'
- 'release-ghostnet-beta'
pull_request:
branches:
- 'release-ghostnet-staging'
- 'release-ghostnet-beta'
types:
- closed
workflow_dispatch:

jobs:
ui:
strategy:
matrix:
network: [ghostnet]
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
submodules: true

- name: Set outputs
id: vars
run: |
echo "date=$(date +%Y-%m-%dT%H-%M-%S)" >> "${GITHUB_OUTPUT}"
echo "sha_short=$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}"

- name: Set up Docker Buildx
uses: docker/Setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push ui version release-ghostnet-staging
if: github.ref == 'refs/heads/release-ghostnet-staging'
uses: docker/build-push-action@v3
with:
file: ./batcher-ui/Dockerfile.${{ matrix.network }}
context: ./batcher-ui/
push: ${{ github.ref == 'refs/heads/release-ghostnet-staging' }}
tags: |
ghcr.io/marigold-dev/batcher-${{ matrix.network }}:staging
ghcr.io/marigold-dev/batcher-${{ matrix.network }}:${{ steps.vars.outputs.date }}-${{ steps.vars.outputs.sha_short }}-staging
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push ui version on release-ghostnet-beta
if: github.ref == 'refs/heads/release-ghostnet-beta'
uses: docker/build-push-action@v3
with:
file: ./batcher-ui/Dockerfile.${{ matrix.network }}
context: ./batcher-ui/
push: ${{ github.ref == 'refs/heads/release-ghostnet-beta' }}
tags: |
ghcr.io/marigold-dev/batcher-${{ matrix.network }}:beta
ghcr.io/marigold-dev/batcher-${{ matrix.network }}:${{ steps.vars.outputs.date }}-${{ steps.vars.outputs.sha_short }}-beta
cache-from: type=gha
cache-to: type=gha,mode=max
10 changes: 9 additions & 1 deletion .github/workflows/docker-ghostnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ on:
push:
branches:
- 'release-ghostnet'
pull_request:
branches:
- 'release-ghostnet'
types:
- closed
workflow_dispatch:

jobs:
ui:
# Only run this job if it's a direct push or a *merged* pull request
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
strategy:
matrix:
network: [ghostnet]
Expand All @@ -32,7 +40,7 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push release version
- name: Build and push release version of ui
uses: docker/build-push-action@v3
with:
file: ./batcher-ui/Dockerfile.${{ matrix.network }}
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/release-bots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release Liquidity Bots

on:
workflow_dispatch: # adding the workflow_dispatch so it can be triggered manually
push:
tags:
- 'bots-v*'

defaults:
run:
working-directory: batcher-bot/liquidity
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install modules
run: npm install
- name: Build
run: npm run build
- name: Package
run: npm run package
- name: Tar compress
run: tar -cvf batcher-liquidity-bot.tar.xz dist/*
- name: Hash Tar
run: echo $(md5sum batcher-liquidity-bot.tar.xz) > batcher-liquidity-bot.tar.hash.md
- name: Zip compress
run: zip -r batcher-liquidity-bot.zip dist/*
- name: Hash Tar
run: echo $(md5sum batcher-liquidity-bot.zip) > batcher-liquidity-bot.zip.hash.md
- name: Release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
files: |
./batcher-bot/liquidity/batcher-liquidity-bot.tar.xz
./batcher-bot/liquidity/batcher-liquidity-bot.tar.hash.md
./batcher-bot/liquidity/batcher-liquidity-bot.zip
./batcher-bot/liquidity/batcher-liquidity-bot.zip.hash.md
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ USDT_token_storage.tz
# Tezos client artefacts
.tezos-client/

node_modules
./*/node_modules/
dist
batcher-bot/notifications/node_modules/
batcher-bot/liquidity/node_modules/
3 changes: 2 additions & 1 deletion Dockerfile.tick.ghostnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ WORKDIR /etc/run

COPY ./tick.sh /etc/run/

CMD [ "/etc/run/tick.sh", "-b", "KT1VbeN9etQe5c2b6EAFfCZVaSTpiieHj5u1", "-f", "150" ]
CMD [ "/etc/run/tick.sh", "-b", "KT1Txkbx4sDc3qXQubG48vL3ojoTK4HH8Ci8", "-f", "150" ]

2 changes: 2 additions & 0 deletions batcher-bot/liquidity/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/*.js
lib/*.d.ts
126 changes: 126 additions & 0 deletions batcher-bot/liquidity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Liquidity Bot

## Pre-requisites

To run the bot you will need to have an environment that has Node.js installed.

> The releases were developed and tested with v18.14.0 of Node.

## Installation

The release package can be downloaded from the releases pages of the repo in either zip or tar.xz formats. A hash.md for each format is supplied so that the contents of the file can be verified.

## Operation

Once the release has been downloaded and unpacked it can be run from the command line.

### Liquidity Modes

The liquidity bot allows deposits to be made automatically based on configuration. There are two specific modes of liquidity:

- JIT (just-in-time): This mode listens for trades in each batch and places an opposing deposit.
- ALWAYS-ON : This mode supplies a given deposit at batch open.

To run the bot simply specify the mode as the first argument. The second argument should be the path to the configuration file:

Jit mode:
```bash
node index.js jit <path to config>
```

Alwys-on mode:
```bash
node index.js always-on <path to config>
```

### Liquidity configuration

Both modes use a configuration file that supplies rules for the deposits for one or more pairs. Examples of config files for mainnet and ghostnet are bundled with the release; they include the variables for the Batcher contract address, the address of a Tezos node and the relevant tzkt api address.

Example of ghostnet config file.

```json
{
"batcher_address": "KT1VbeN9etQe5c2b6EAFfCZVaSTpiieHj5u1",
"tezos_node_uri": "https://ghostnet.tezos.marigold.dev",
"tzkt_uri_api": "https://api.ghostnet.tzkt.io",
"token_pairs": [
{
"name": "tzBTC/USDT",
"side": "both",
"buy_limit_per_batch": 0.02,
"buy_tolerance": "worse",
"sell_limit_per_batch": 200,
"sell_tolerance": "oracle"
},
{
"name": "tzBTC/EURL",
"side": "either",
"buy_limit_per_batch": 0.02,
"buy_tolerance": "oracle",
"sell_limit_per_batch": 220,
"sell_tolerance": "better"
}
]


}

```

More importantly, they contain the configuration of the liquidity provision for the token pairs.

```json
"token_pairs": [
{
"name": "tzBTC/USDT",
"side": "both",
"buy_limit_per_batch": 0.02,
"buy_tolerance": "worse",
"sell_limit_per_batch": 200,
"sell_tolerance": "oracle"
},
{
"name": "tzBTC/EURL",
"side": "either",
"buy_limit_per_batch": 0.02,
"buy_tolerance": "oracle",
"sell_limit_per_batch": 220,
"sell_tolerance": "better"
}
]

```

When running the bot, a user is free to only include the pairs they are interested in. For each pair, the configuration should include the name of the pair, the side one wishes to supply liquidity for, and the amount limit per batch and tolerance for each side.

### Name

The name of the pair should be the same as that specified in the `valid_swap` item in the Batcher contract storage. At the time of writing this is either *tzBTC/USDT* or *tzBTC/EURL*.

### Side

The 'side' configuration is the side that a user is interested in trading. These can be:

- both - one can supply liquidity to both sides of a trade if one should choose.
- either - one can supply either side of a trade; *this is only a valid option for the 'jit' mode*.
- buy - only supply liquidity for the buy side of a given pair
- sell - only supply liquidity for the sell side of a given pair

### Limit Per Batch

The `buy_limit_per_batch` and `sell_limit_per_batch` configurations define the deposit size that will occur in any given batch.

### Tolerance

With the `buy_tolerance` and `sell_tolerance`, one can set their choice of price level for a given batch that one is willing to trade at. These follow the usual Batcher conventions:

- worse - A worse price but a better chance of the order being filled
- oracle - Trade at the Oracle price accepted after the batch has closed
- better - A better price but less chance of being filled.

> The tolerances are ten basis points off a given future Oracle price.

## Redemption

In either mode the bot will redeem any holdings once a batch is cleared.
Loading
Loading