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

Refactor liq strat #7

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
80c2f50
Remove unused files, updated deps
carlomazzaferro Feb 8, 2022
9b5ed86
Configs and docs
carlomazzaferro Feb 8, 2022
fef0f26
ts based bot
carlomazzaferro Feb 8, 2022
d2d5b46
remove js file
carlomazzaferro Feb 8, 2022
7d34f7d
Linting deps, linting ts file
carlomazzaferro Feb 8, 2022
fb58564
Fix maths, and add protocol fees
carlomazzaferro Feb 8, 2022
2210551
docker set up and workflow
carlomazzaferro Feb 9, 2022
a224648
zero address refactor, variables refactor
carlomazzaferro Feb 10, 2022
edb6a83
docs
carlomazzaferro Feb 10, 2022
3424b73
moar docs
carlomazzaferro Feb 10, 2022
f570b8b
remove unneeded deps, dotenv for local dev
carlomazzaferro Feb 11, 2022
39d6915
simplify configs
carlomazzaferro Feb 12, 2022
2c9e268
chore
carlomazzaferro Feb 12, 2022
04c3412
refactor into proper package
carlomazzaferro Feb 12, 2022
27f0771
fix dockerfile path
carlomazzaferro Feb 12, 2022
c24f987
refactor functions into their own files
carlomazzaferro Feb 12, 2022
e5afc5a
target chain id
carlomazzaferro Feb 12, 2022
0898049
docs and cleanups
carlomazzaferro Feb 12, 2022
7737cb3
Add missing files in bundle
carlomazzaferro Feb 12, 2022
1db6736
fix conditional that made liquidator not liquidate token pools
carlomazzaferro Feb 14, 2022
4b57ae4
User ethers wallet
carlomazzaferro Feb 16, 2022
e0d9007
Refactor data fetching
carlomazzaferro Feb 21, 2022
48a413a
release new sdk
carlomazzaferro Feb 22, 2022
ad3afef
Merge pull request #1 from Midas-Protocol/fetch-assets-separately
carlomazzaferro Feb 22, 2022
02fd6cf
Merge branch 'main' of https://github.com/Midas-Protocol/fuse-liquida…
carlomazzaferro Feb 22, 2022
824dbcc
release new sdk for bot
carlomazzaferro Mar 3, 2022
b7dcb78
release with sha tag
carlomazzaferro Mar 3, 2022
03cef1b
release new sdk
carlomazzaferro Mar 5, 2022
345f3d2
typechain stuff
carlomazzaferro Mar 22, 2022
fd03921
liquidation strategy and refactor functions into separate files
carlomazzaferro Mar 22, 2022
631c932
remove unused files
carlomazzaferro Mar 25, 2022
093b43e
refactr based on sdk updates
carlomazzaferro Mar 25, 2022
6f1c95a
update deps
carlomazzaferro Apr 15, 2022
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
14 changes: 14 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
WEB3_HTTP_PROVIDER_URL=http://0.0.0.0:8545
#WEB3_HTTP_PROVIDER_URL="https://data-seed-prebsc-1-s1.binance.org:8545"
# Separate by commas--if using your own capital for liquidations, supported currencies to repay.
# Use contract addresses for tokens, zero address for for native chain token
SUPPORTED_INPUT_CURRENCIES="0x0000000000000000000000000000000000000000,0x943832D08C12F1ee006895815E5398d0f7E2DdbA,0x765C058189560e00Dc581Ab5bFF01deBF9f268DF"
#SUPPORTED_INPUT_CURRENCIES="0x0000000000000000000000000000000000000000,0xEC5dCb5Dbf4B114C9d0F65BcCAb49EC54F6A0867"
# Separate by commas--supported currencies to receieve as seized collateral
# (other seized currencies will be exchanged to EXCHANGE_TO_TOKEN_ADDRESS);
# Use contract addresses for tokens, zero address for for native chain token
SUPPORTED_OUTPUT_CURRENCIES="0x0000000000000000000000000000000000000000,0x943832D08C12F1ee006895815E5398d0f7E2DdbA,0x765C058189560e00Dc581Ab5bFF01deBF9f268DF"
#SUPPORTED_OUTPUT_CURRENCIES="0x0000000000000000000000000000000000000000,0xEC5dCb5Dbf4B114C9d0F65BcCAb49EC54F6A0867"
# target chainId to use
#TARGET_CHAIN_ID=97
TARGET_CHAIN_ID=1337
18 changes: 18 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Background

Any information that gives more context as to why this task exists, and why it matters. This might include: links to discussions, documentation, or other Jira issues / tasks

### Linked Issues & Documentation

- List of linked issues, external links, etc

## Definition Of Done

Describes in 1-2 sentences what the output of the Task is, so that it can be verified by another team member easily. “Feature X is implemented as described and can be verified by using it”

## Tasks

- [ ] Task 1
- [ ] Task 2
- [ ] Task 3

29 changes: 29 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Description

<!--- Provide a general summary of your changes in the Title above -->

## Type of change

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Docs change / dependency upgrade
- [ ] Configuration / tooling changes
- [ ] Refactoring
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Requires changes in customer code

## High-level change(s) description - from the user's perspective

<!--- Describe your changes in more detail -->

## Related Issue(s)

Fixes <!--- Please link to the issue here: -->

## Related pull request(s)

<!--- Please link to the PRs here: -->

<!--- adapted from https://github.com/inversify/inversify-basic-example/blob/master/PULL_REQUEST_TEMPLATE.md -->
45 changes: 45 additions & 0 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create and publish a Docker image

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=long

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ dist

# TernJS port file
.tern-port

build/
.idea

/fuse-liquidator-bot/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 100,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false
}
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM node:16.13-alpine as base

RUN apk --no-cache add git

WORKDIR /usr/src/app

COPY package.json ./
COPY tsconfig.json ./
COPY src ./src
COPY index.ts ./

RUN npm install

RUN npm run build


FROM base AS dependencies

WORKDIR /usr/src/app

COPY package.json ./
COPY ecosystem.config.js ./


RUN npm set progress=false && \
npm config set depth 0 && \
npm install --only=production && \
npm install pm2 -g

COPY --from=base /usr/src/app/build ./build


CMD ["pm2-runtime", "ecosystem.config.js", "--env", "development"]
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,28 @@ Install `fuse-liquidator-bot` dependencies: `npm i` or `npm install`

## Usage

Configure your environment in `ecosystem.config.js`.
0. Configure your environment in `ecosystem.config.js` and `.env`

With Docker:

```shell
>>> docker run -it --env-file .env ghcr.io/midas-protocol/fuse-liquidator-bot:main
```

With plain js:

1. Build
```shell
>>> npm run build
```
2. Start the rebalancer with PM2, or Docker
```shell
>>> pm2 start ecosystem.config.js # (for production usage, add `--env production`)
```
3. Stop, check status and logs:
```shell
>>> pm2 stop ecosystem.config.js
>>> pm2 list
>>> cat ~/.pm2/logs
```

Start the rebalancer with PM2: `pm2 start ecosystem.config.js` (for production usage, add `--env production`)

Stop with PM2: `pm2 stop ecosystem.config.js`

Check process status with PM2: `pm2 list`

Find PM2 logs in `~/.pm2/logs`.

## Credits

Fuse is developed by [David Lucid](https://github.com/davidlucid) of Rari Capital. Find out more about Rari Capital at [rari.capital](https://rari.capital).
1 change: 0 additions & 1 deletion abi/ERC20.json

This file was deleted.

1 change: 0 additions & 1 deletion abi/FusePoolDirectory.json

This file was deleted.

Loading