-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d7284c0
Showing
8 changed files
with
2,065 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export CHAIN_ID='' | ||
export JSON_RPC_URI='' | ||
export COVALENT_API_KEY='' | ||
export MIN_PROFIT_THRESHOLD_USD='' | ||
export CUSTOM_RELAYER_PRIVATE_KEY= | ||
|
||
### DRAW AUCTION SPECIFIC: | ||
|
||
export REWARD_RECIPIENT='' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: CronJob | ||
on: | ||
schedule: | ||
- cron: "*/5 * * * *" # ie. 4:10pm, 4:15pm, 4:20pm, etc. | ||
push: | ||
env: | ||
CHAIN_ID: ${{secrets.CHAIN_ID}} | ||
JSON_RPC_URI: ${{secrets.JSON_RPC_URI}} | ||
COVALENT_API_KEY: ${{secrets.COVALENT_API_KEY}} | ||
USE_FLASHBOTS: ${{secrets.USE_FLASHBOTS}} | ||
MIN_PROFIT_THRESHOLD_USD: ${{secrets.MIN_PROFIT_THRESHOLD_USD}} | ||
CUSTOM_RELAYER_PRIVATE_KEY: ${{secrets.CUSTOM_RELAYER_PRIVATE_KEY}} | ||
SWAP_RECIPIENT: ${{secrets.SWAP_RECIPIENT}} | ||
NODE_OPTIONS: "--max_old_space_size=32768" | ||
permissions: write-all | ||
jobs: | ||
runCLI: | ||
name: Winners Compute | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
node: ["20.11.1"] | ||
os: [ubuntu-latest] | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Use Node ${{ matrix.node }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Run bot | ||
id: runBot | ||
run: | | ||
npm install | ||
npm run start | ||
# 7. Commit | ||
# - name: Commit Optimism Sepolia | ||
# if: steps.vaultAccountsOptimismSepolia.outputs.runStatus == 'true' | ||
# continue-on-error: true | ||
# run: | | ||
# git config pull.rebase false | ||
# git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
# git config --local user.name "github-actions[bot]" | ||
# git pull | ||
# git add ./winners | ||
# git commit -m "Add testnet winner results for Optimism Sepolia draw #${{steps.vaultAccountsOptimismSepolia.outputs.drawId}}" | ||
|
||
# 8. Push | ||
# - name: Push changes (if required) | ||
# uses: ad-m/github-push-action@master | ||
# if: steps.vaultAccountsOptimismSepolia.outputs.runStatus == 'true' | ||
# with: | ||
# github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# branch: ${{ github.ref }} | ||
# force: true | ||
|
||
# Optionally: | ||
# - name: Comment Error | ||
# id: commentError | ||
# if: steps.vaultAccountsOptimismSepolia.outputs.exitcode == 1 | ||
# uses: actions/github-script@v5 | ||
# continue-on-error: true | ||
# with: | ||
# script: | | ||
# await github.rest.issues.create({ | ||
# owner: context.repo.owner, | ||
# repo: context.repo.repo, | ||
# title: `Draw #${{steps.vaultAccountsOptimismSepolia.outputs.drawId}} Winner Calc Failed: Exit Code 1` | ||
# }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.yalc | ||
yalc.lock | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# pt-v5-draw-auction-gh-action-bot | ||
|
||
This is two simple scripts (`index.ts` and `.github/cron.testnet.yml`) to run the PoolTogether V5 Draw Auction bot using GitHub Actions. | ||
|
||
You can simply fork this repo, set up your environment variables properly in your GitHub Settings, and run the bot periodically (using the cron directive found in `.github/cron.testnet.yml`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import nodeFetch from 'node-fetch'; | ||
import { BaseProvider } from '@ethersproject/providers'; | ||
import { downloadContractsBlob, ContractsBlob } from '@generationsoftware/pt-v5-utils-js'; | ||
import { | ||
getProvider, | ||
instantiateRelayerAccount, | ||
loadDrawAuctionEnvVars, | ||
runDrawAuction, | ||
DrawAuctionEnvVars, | ||
DrawAuctionConfig, | ||
RelayerAccount, | ||
} from '@generationsoftware/pt-v5-autotasks-library'; | ||
|
||
|
||
const main = async () =>{ | ||
const envVars: DrawAuctionEnvVars = loadDrawAuctionEnvVars(); | ||
|
||
const provider: BaseProvider = getProvider(envVars); | ||
|
||
const relayerAccount: RelayerAccount = await instantiateRelayerAccount( | ||
provider, | ||
envVars.CUSTOM_RELAYER_PRIVATE_KEY, | ||
); | ||
|
||
const drawAuctionConfig: DrawAuctionConfig = { | ||
chainId: Number(envVars.CHAIN_ID), | ||
provider, | ||
covalentApiKey: envVars.COVALENT_API_KEY, | ||
rewardRecipient: envVars.REWARD_RECIPIENT, | ||
minProfitThresholdUsd: Number(envVars.MIN_PROFIT_THRESHOLD_USD), | ||
customRelayerPrivateKey: process.env.CUSTOM_RELAYER_PRIVATE_KEY, | ||
|
||
signer: relayerAccount.signer, | ||
wallet: relayerAccount.wallet, | ||
relayerAddress: relayerAccount.relayerAddress, | ||
}; | ||
|
||
try { | ||
const rngContracts: ContractsBlob = await downloadContractsBlob(drawAuctionConfig.chainId, nodeFetch); | ||
|
||
await runDrawAuction(rngContracts, drawAuctionConfig); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
|
||
main() |
Oops, something went wrong.