-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: workflows for public and main * chore: added changelog * added strategies goerli job * improved logs with metadata * chore(release): 1.0.0 Co-authored-by: 0xng <[email protected]> Co-authored-by: wei3erHase <[email protected]>
- Loading branch information
1 parent
7f8cd56
commit 37c7d66
Showing
15 changed files
with
203 additions
and
43 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
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,24 @@ | ||
name: Build, tag, and publish a release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
name: Build and publish | ||
runs-on: ubuntu-latest | ||
needs: tag | ||
if: needs.tag.outputs.tag_name | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: "14.x" | ||
registry-url: "https://registry.npmjs.org" | ||
- run: yarn | ||
- run: yarn build | ||
- run: npm publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,29 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
|
||
## 1.0.0 (2022-01-03) | ||
|
||
|
||
### Features | ||
|
||
* added strategies test job and improved logs | ||
|
||
|
||
### Bug Fixes | ||
|
||
* workflows for public and main | ||
|
||
## 1.0.0-beta.1 (2021-12-14) | ||
|
||
### Features | ||
|
||
* Out-of-the-box jobs for mainnet | ||
* DCA | ||
* Harvest V2 | ||
* Tend V2 | ||
* Tend V2 (Beta) | ||
* Out-of-the-box jobs for goerli | ||
* Job A | ||
* Job A Stealth | ||
* Lots of documentation |
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
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,10 @@ | ||
[ | ||
{ "inputs": [{ "internalType": "address", "name": "_governor", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, | ||
{ "inputs": [], "name": "OnlyGovernor", "type": "error" }, | ||
{ "inputs": [{ "internalType": "address", "name": "_job", "type": "address" }], "name": "addJob", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, | ||
{ "inputs": [{ "internalType": "address[]", "name": "_jobsList", "type": "address[]" }], "name": "addJobs", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, | ||
{ "inputs": [{ "internalType": "address", "name": "strategy", "type": "address" }], "name": "execute", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, | ||
{ "inputs": [], "name": "governor", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, | ||
{ "inputs": [], "name": "jobs", "outputs": [{ "internalType": "address[]", "name": "_jobsList", "type": "address[]" }], "stateMutability": "view", "type": "function" }, | ||
{ "stateMutability": "payable", "type": "receive" } | ||
] |
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
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
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,16 @@ | ||
# Job A Stealth | ||
|
||
This is the most complex of the test jobs despite not using a stealth relayer. The complexity comes due to the fact that this job contains strategies, each which is a job of their own. This job works as a sort of relayer containing the different strategies and providing functions to execute each one of them. | ||
|
||
## Config path | ||
|
||
`node_modules/@keep3r-network/cli-sample-jobs/dist/goerli/job-strategies` | ||
|
||
## Keeper Requirements | ||
|
||
- Must be a valid Keeper on Keep3r V1 | ||
|
||
## Useful Links | ||
|
||
- [Job](https://goerli.etherscan.io/address/0x8CeA64dc82515D56c22d072167Da44Abd3211B6f) | ||
- [Keep3r V1](https://goerli.etherscan.io/address/0x3364bf0a8dcb15e463e6659175c90a57ee3d4288) |
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,96 @@ | ||
import { createForks, GanacheFork, Job, JobWorkableGroup, makeid, prelog, TransactionError } from '@keep3r-network/cli-utils'; | ||
import { Contract } from 'ethers'; | ||
import StrategyABI from '../../abi/Strategy.json'; | ||
import metadata from './metadata.json'; | ||
|
||
const jobAddress = '0x8CeA64dc82515D56c22d072167Da44Abd3211B6f'; | ||
const expectedErrors: string[] = ['V2Keep3rJob::work:not-workable', '!authorized', '!healthcheck']; | ||
const maxStrategiesPerFork = 5; | ||
|
||
const getWorkableTxs: Job['getWorkableTxs'] = async (args) => { | ||
const logMetadata = { | ||
job: metadata.name, | ||
block: args.advancedBlock, | ||
logId: makeid(5), | ||
}; | ||
|
||
const logConsole = prelog(logMetadata); | ||
|
||
logConsole.log(`Trying to work`); | ||
|
||
const job = new Contract(jobAddress, StrategyABI, args.fork.ethersProvider); | ||
const strategies: string[] = args.retryId ? [args.retryId] : await job.jobs(); | ||
|
||
logConsole.log(args.retryId ? `Retrying strategy` : `Simulating ${strategies.length} strategies`); | ||
|
||
const forksToCreate = Math.ceil(strategies.length / maxStrategiesPerFork) - 1; | ||
const forks: GanacheFork[] = [args.fork, ...(await createForks(forksToCreate, args))]; | ||
logConsole.debug(`Created ${forks.length} forks in order to work in parellel`); | ||
|
||
const workPromises = forks.map(async (fork, forkIndex) => { | ||
const job = new Contract(jobAddress, StrategyABI, fork.ethersProvider); | ||
const forkStrategies = strategies.slice(forkIndex * maxStrategiesPerFork, forkIndex * maxStrategiesPerFork + maxStrategiesPerFork); | ||
|
||
for (const [index, strategy] of forkStrategies.entries()) { | ||
const strategyIndex = forkIndex * maxStrategiesPerFork + index; | ||
|
||
const strategyLogId = `${logMetadata.logId}-${makeid(5)}`; | ||
const strategyConsole = prelog({ ...logMetadata, logId: strategyLogId }); | ||
|
||
if (args.skipIds.includes(strategy)) { | ||
strategyConsole.info('Skipping strategy', { strategy }); | ||
continue; | ||
} | ||
|
||
try { | ||
await job.connect(args.keeperAddress).callStatic.execute(strategy, { | ||
blockTag: args.advancedBlock, | ||
}); | ||
|
||
strategyConsole.log(`Strategy #${strategyIndex} is workable`, { strategy }); | ||
|
||
const workableGroups: JobWorkableGroup[] = []; | ||
|
||
for (let index = 0; index < args.bundleBurst; index++) { | ||
const tx = await job.connect(args.keeperAddress).populateTransaction.execute(strategy, { | ||
nonce: args.keeperNonce, | ||
gasLimit: 5_000_000, | ||
type: 2, | ||
}); | ||
|
||
workableGroups.push({ | ||
targetBlock: args.targetBlock + index, | ||
txs: [tx], | ||
logId: `${strategyLogId}-${makeid(5)}`, | ||
}); | ||
} | ||
|
||
args.subject.next({ | ||
workableGroups, | ||
correlationId: strategy, | ||
}); | ||
} catch (err: any) { | ||
const isExpectedError = expectedErrors.find((expectedError) => { | ||
return (err as TransactionError).message?.includes(expectedError); | ||
}); | ||
|
||
if (!isExpectedError) { | ||
strategyConsole.warn(`Strategy #${strategyIndex} failed with unknown error`, { | ||
strategy, | ||
message: err.message, | ||
}); | ||
} else { | ||
strategyConsole.log(`Strategy #${strategyIndex} is not workable`, { strategy }); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
await Promise.all(workPromises); | ||
|
||
args.subject.complete(); | ||
}; | ||
|
||
module.exports = { | ||
getWorkableTxs, | ||
} as Job; |
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,3 @@ | ||
{ | ||
"name": "Job Strategies" | ||
} |
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
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
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
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
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 |
---|---|---|
|
@@ -505,10 +505,10 @@ | |
resolved "https://registry.yarnpkg.com/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz#98c23c950a3d9b6c8f0daed06da6c3af06981340" | ||
integrity sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q== | ||
|
||
"@keep3r-network/[email protected]-beta.1": | ||
version "1.0.0-beta.1" | ||
resolved "https://registry.yarnpkg.com/@keep3r-network/cli-utils/-/cli-utils-1.0.0-beta.1.tgz#53ed1bd81896b8505be39d9ef87480c901d75864" | ||
integrity sha512-/yDOCJRmVvIhSHiaHpwrFpt0hm6SZTFVXwVke1uTN5RfIoadUGQ/I+Yomirf+4KhDKzrhlY0H859H49DU5rkLg== | ||
"@keep3r-network/[email protected]": | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/@keep3r-network/cli-utils/-/cli-utils-1.0.0.tgz#a45ff02f002e6dcdb50af66e6c4c7d76540fc729" | ||
integrity sha512-9ZPK8enMFxUvhlj8W5tXC8yyokfbHGVVNBQKysEUu0EJt0HZE58F4MZJuoiojP75yMbkMHyh9ljqctGDTFdWPA== | ||
dependencies: | ||
"@ethersproject/abstract-provider" "5.5.1" | ||
bigint-buffer "1.1.5" | ||
|