Skip to content

Commit

Permalink
feat: first working version (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: 0xng <[email protected]>
Co-authored-by: gotzenx <[email protected]>
  • Loading branch information
3 people authored Oct 1, 2022
1 parent c073bc8 commit 99ddd2f
Show file tree
Hide file tree
Showing 23 changed files with 6,020 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RPC_WSS_URI=
TX_SIGNER_PRIVATE_KEY=
BUNDLE_SIGNER_PRIVATE_KEY=
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: ""
assignees: ""
---

**Describe the bug**

[//]: # (A clear and concise description of what the bug is.)

**Reproduction steps**

[//]: # (1. Go to '...')

[//]: # (2. Click on '....')

[//]: # (3. Scroll down to '....')

[//]: # (4. See error)

**Expected behavior**

[//]: # (A clear and concise description of what you expected to happen.)

**Screenshots**

[//]: # (If applicable, add screenshots to help explain your problem.)

**System Specs:**

[//]: # (- OS:)

[//]: # (- Package Version &#40;or commit hash&#41;:)

**Additional context**

[//]: # (Add any other context about the problem here.)
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**

[//]: # (A clear and concise description of what the problem is. Ex. I'm always frustrated when [...])

**Describe the solution you'd like**

[//]: # (A clear and concise description of what you want to happen.)

**Describe alternatives you've considered**

[//]: # (A clear and concise description of any alternative solutions or features you've considered.)

**Additional context**

[//]: # (Add any other context or screenshots about the feature request here.)
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**Description**

[//]: # (A clear and concise description of the features you're adding in this pull request.)

**Metadata**

- Fixes #[Link to Issue]
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint and test

on: [push, pull_request]

jobs:
build_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14', '16' ]
fail-fast: false
name: Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3

# https://github.com/actions/setup-node
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn lint
# - run: yarn test
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build, tag, and publish a release

on:
push:
branches:
- main
- public

jobs:
tag:
name: Create tag for new version
runs-on: ubuntu-latest
if: "!github.event.created"
outputs:
tag_name: ${{ steps.create_new_tag.outputs.tag }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- uses: salsify/action-detect-and-tag-new-version@v2
id: create_new_tag

release:
name: Create release
runs-on: ubuntu-latest
needs: tag
if: needs.tag.outputs.tag_name
steps:
- uses: actions/checkout@v2
- uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.tag.outputs.tag_name }}
release_name: ${{ needs.tag.outputs.tag_name }}
draft: false
prerelease: false
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
build
lib
dist
docs
.idea/*

.DS_Store
coverage
*.log
.eslintcache

*.env
logs

eth-sdk/abis
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
22 changes: 22 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"overrides": [
{
"files": ["**.ts", "**.js"],
"options": {
"printWidth": 145,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"useTabs": false,
"endOfLine": "auto"
}
},
{
"files": "**.json",
"options": {
"tabWidth": 2,
"printWidth": 200
}
}
]
}
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright 2022 Phuture Finance

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.
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
# Phuture Keeper Scripts
# Phuture Keeper Script

This script enables keepers of the Keep3r Network to execute Phuture's job on Ethereum.

## How to run

1. Clone the repository
```
git clone https://github.com/Phuture-Finance/keeper-scripts
```

2. Install dependencies
```
yarn install
```

3. Create and complete the `.env` file using `env.example` as an example

4. Fine-tune the constants in `src/constants.ts` to your liking. Read [the docs](https://docs.keep3r.network/keeper-scripts) for a technical in-depth explanation.

5. Try out the script
```
yarn start
```

## Run in production

1. Build the typescript into javascript
```
yarn build
```

2. Run the job directly from javascript. Using [PM2](https://github.com/Unitech/pm2) is highly recommended
```
node dist/job.js
```




## Keeper Requirements

* Must be a valid (activated) Keeper on [Keep3r V2](https://etherscan.io/address/0xeb02addCfD8B773A5FFA6B9d1FE99c566f8c44CC)

## Useful Links

* [Job](https://etherscan.io/address/0x133A4273589c2eE5F9Fe28898B68aC1B4B1BA9B0)
9 changes: 9 additions & 0 deletions eth-sdk/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {defineConfig} from '@dethcrypto/eth-sdk';

export default defineConfig({
contracts: {
mainnet: {
job: '0x133A4273589c2eE5F9Fe28898B68aC1B4B1BA9B0',
},
},
});
64 changes: 64 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "@phuture/keeper-scripts",
"version": "0.0.1",
"description": "Phuture's keeper script for The Keep3r Network",
"keywords": [
"keep3r",
"job",
"ethereum",
"phuture"
],
"license": "MIT",
"author": "Phuture Finance",
"contributors": [
"0xng (https://github.com/0xng)",
"gotzenx (https://github.com/gotzenx)",
"0xGorilla (https://github.com/0xGorilla)",
"jn-lp (https://github.com/jn-lp)"
],
"private": true,
"scripts": {
"start": "ts-node src/job.ts",
"build": "eth-sdk && tsc",
"prod": "node dist/tsc/src/job.js",
"lint": "xo",
"lint:fix": "xo --fix"
},
"lint-staged": {
"*.ts": "yarn lint"
},
"dependencies": {
"@keep3r-network/keeper-scripting-utils": "0.0.0-2a18fa83",
"dotenv": "16.0.3",
"ethers": "5.6.9",
"lodash.isequal": "4.5.0",
"undici": "5.10.0"
},
"devDependencies": {
"@dethcrypto/eth-sdk": "0.3.3",
"@dethcrypto/eth-sdk-client": "0.1.6",
"@types/lodash.isequal": "4.5.6",
"husky": ">=6",
"lint-staged": ">=10",
"ts-node": "10.9.1",
"typescript": "4.8.4",
"xo": "0.52.3"
},
"xo": {
"prettier": true,
"rules": {
"unicorn/prefer-module": 0,
"import/extensions": 0,
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": [
"camelCase",
"UPPER_CASE"
]
}
]
}
}
}
14 changes: 14 additions & 0 deletions src/contants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Ethereum Mainnet
export const CHAIN_ID = 1;

// Size of our batch of bundles
export const BURST_SIZE = 3;

// Blocks into the future to send our first batch of bundles
export const FUTURE_BLOCKS = 0;

// Priority fee to use
export const PRIORITY_FEE = 2;

export const FLASHBOTS_RPC = 'https://relay.flashbots.net';
export const ORDER_API_URL = 'https://validator.phuture.finance/api/v1/order';
Loading

0 comments on commit 99ddd2f

Please sign in to comment.