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

Prepare bot for public use #1

Merged
merged 30 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3d2c75a
Initial trimming and refactoring
aquarat Jun 17, 2024
c0d2728
Remove typechain
aquarat Jun 17, 2024
fc2cbaf
Further trimming and removal
aquarat Jun 17, 2024
e4e2f8b
Lint fix
aquarat Jun 17, 2024
afd3db8
More triming
aquarat Jun 18, 2024
75e0e33
Fixes, CI fixes, deployment bytecode
aquarat Jun 18, 2024
fd943ec
Add persistence
aquarat Jun 18, 2024
b566482
Refactor, comment docs and README
aquarat Jun 19, 2024
2d9a98f
Add more docs, fix docker build, add quote stripping for mnemonic
aquarat Jun 19, 2024
dd2944f
Remove pointless docs link check
aquarat Jun 19, 2024
78d2d69
Remove HH files from ignores and replace with symlinks
aquarat Jun 19, 2024
0eebfd9
Remove release scripts
aquarat Jun 20, 2024
9a6f550
Refactor orbit-bot directory
aquarat Jun 20, 2024
cb58f67
Minor polishing
aquarat Jun 20, 2024
204635d
More comments and docs
aquarat Jun 20, 2024
0b23a3e
Additional JSDoc
aquarat Jun 20, 2024
7919f97
Add constants for loop sleep
aquarat Jun 21, 2024
e426c55
Add lots of links into the OEV docs
aquarat Jun 24, 2024
ce519f7
Remove Renovate and docker amd64 build command
aquarat Jun 24, 2024
39e620c
Remove JSDoc types, add funding and compilation for liquidator contract
aquarat Jun 24, 2024
1586cca
Refactor fixes
aquarat Jun 24, 2024
cbf8b3f
Add back contracts and HH components
aquarat Jun 24, 2024
d219a33
PR comments: simplify
aquarat Jun 25, 2024
4409cef
Remove unused deps, swap logger for console, remove immer
aquarat Jun 25, 2024
70b9c16
Split account watch function, comment them to explain what they're doing
aquarat Jun 26, 2024
f0d09a8
Add back fat contracts build (fat for consistency)
aquarat Jun 26, 2024
35fc3b3
Swap out contracts with interface-based contract
aquarat Jun 26, 2024
2cfc81e
Integrate upstream changes into accounts to watch
aquarat Jun 26, 2024
c218fd6
Fix linter, add hardhat config
aquarat Jun 26, 2024
b5fb311
Integrate upstream changes, expand interfaces, swap out Orbit functions
aquarat Jun 26, 2024
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
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# NOTE: Keep in sync with .gitignore.
#
# From: https://shisho.dev/blog/posts/how-to-use-dockerignore/
#
# In .gitignore, the file or directory name is ignored in any hierarchy below the .gitignore file, but in .dockerignore,
# all paths must be relative to the way where .dockerignore is located. However, in .dockerignore, all paths must be
# listed relative to the path.
**/.build
**/.env
**/.idea
**/.log
**/.tsbuildinfo
**/.vscode
**/build
**/dist
**/node_modules
**/coverage
**/.DS_Store
**/secrets.env
**/.eslintcache

# Custom ignore files
**/*.ignore
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
LOGGER_ENABLED=true
LOG_COLORIZE=true
LOG_LEVEL=debug
LOG_FORMAT=pretty

# Bot variables
MNEMONIC="test test test test test test test test test test test junk"

# Optional: PERSIST_ACCOUNTS_TO_WATCH=true
# Optional: ETHER_LIQUIDATOR_ADDRESS=0xAb6702A6Fd7f0F2596f70c273376036B44a10709
1 change: 1 addition & 0 deletions .eslintignore
42 changes: 42 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
root: true, // https://github.com/eslint/eslint/issues/13385#issuecomment-641252879
env: {
es6: true,
jest: true,
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./tsconfig.json'],
ecmaVersion: 11,
sourceType: 'module',
},
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
extends: ['./node_modules/@api3/commons/dist/eslint/universal', './node_modules/@api3/commons/dist/eslint/jest'],
plugins: ['@typescript-eslint', 'import', 'jest'],
rules: {
'unicorn/no-process-exit': 'off',
'unicorn/prefer-top-level-await': 'off',

// Typescript
'@typescript-eslint/consistent-return': 'off', // Does not play with no useless undefined when function return type is "T | undefined" and does not have a fixer.
'@typescript-eslint/max-params': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',

// Lodash
'lodash/prefer-immutable-method': 'off',
'lodash/prop-shorthand': 'off',

// Jest
'jest/no-hooks': 'off',
'jest/prefer-importing-jest-globals': 'off',

// Removal of typechain
'@typescript-eslint/no-unsafe-call': 'off',
},
};
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Continuous Build

on:
push:
branches:
- main
pull_request:

jobs:
lint-build:
runs-on: ubuntu-latest
name: Build, lint and test
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8.x
aquarat marked this conversation as resolved.
Show resolved Hide resolved
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Lint
run: pnpm run prettier:check && pnpm run eslint:check
- name: Lint Typescript
run: pnpm run tsc

# Leaving this as we may want to re-add tests and docs later
aquarat marked this conversation as resolved.
Show resolved Hide resolved
required-checks-passed:
name: All required checks passed
runs-on: ubuntu-latest
needs: [lint-build]
steps:
- run: exit 0
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.build
.env
.idea
.log
.tsbuildinfo
.vscode
artifacts
cache
build
dist
node_modules
coverage
.DS_Store
secrets.env
.eslintcache

# Custom ignore files
*.ignore
hardhat.config.ts
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm run prettier:check && pnpm run eslint:check
1 change: 1 addition & 0 deletions .prettierignore
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"bracketSpacing": true,
"printWidth": 120,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"overrides": [
{
"files": "*.md",
"options": {
"parser": "markdown",
"proseWrap": "always"
}
}
]
}
36 changes: 36 additions & 0 deletions Dockerfile
aquarat marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# =============================================================================================
# Base image
# =============================================================================================
FROM node:20-slim AS base
WORKDIR /app

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# Fetch all packages into a virtual store (specifically intended for Docker images)
# See: https://pnpm.io/cli/fetch
COPY pnpm-lock.yaml /app
RUN pnpm fetch

# Install and build dependencies
COPY . /app
RUN pnpm install --prefer-offline --recursive
RUN pnpm run build

# =============================================================================================
# OEV Bot image
# =============================================================================================
# Prepare the app image
FROM base AS oev-bot
ENV name="oev-bot"
LABEL application="oev-bot" description="OEV Bot container"
WORKDIR /app

# "node" Docker images come with a built-in, least-privileged user called "node"
USER node
COPY --chown=node:node --from=base /app/ .

ENV NODE_ENV=production

ENTRYPOINT ["node", "dist/src/index.js"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 API3

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading