Skip to content

Commit

Permalink
chore(release): 1.0.0
Browse files Browse the repository at this point in the history
* 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
3 people authored Jan 3, 2022
1 parent 7f8cd56 commit 37c7d66
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- public

jobs:
tag:
Expand Down Expand Up @@ -34,20 +35,3 @@ jobs:
release_name: ${{ needs.tag.outputs.tag_name }}
draft: false
prerelease: false

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 }}
24 changes: 24 additions & 0 deletions .github/workflows/npm-release.yml
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 }}
29 changes: 29 additions & 0 deletions CHANGELOG.md
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keep3r-network/cli-sample-jobs",
"version": "1.0.0-beta.1",
"version": "1.0.0",
"description": "Keep3r CLI Sample Jobs",
"keywords": [
"keep3r",
Expand Down Expand Up @@ -28,7 +28,7 @@
"pre-release": "yarn build && standard-version --prerelease rc"
},
"dependencies": {
"@keep3r-network/cli-utils": "1.0.0-beta.1",
"@keep3r-network/cli-utils": "1.0.0",
"ethers": "5.5.1"
},
"devDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions src/abi/Strategy.json
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" }
]
11 changes: 5 additions & 6 deletions src/goerli/job-a-stealth/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ const stealthRelayerAddress = '0xD44A48001A4BAd6f23aD8750eaD0036765A35d4b';

const getWorkableTxs: Job['getWorkableTxs'] = async (args) => {
const correlationId = toKebabCase(metadata.name);
if (args.skipIds.includes(correlationId)) {
console.log(`${metadata.name} in progress, avoid running`);
return args.subject.complete();
}

const logMetadata = {
job: metadata.name,
block: args.advancedBlock,
logId: makeid(5),
};

const logConsole = prelog(logMetadata);

if (args.skipIds.includes(correlationId)) {
logConsole.log(`Job in progress, avoid running`);
return args.subject.complete();
}

logConsole.log(`Trying to work`);

const job = new Contract(jobAddress, TestJobABI, args.fork.ethersProvider);
Expand Down
11 changes: 5 additions & 6 deletions src/goerli/job-a/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ const jobAddress = '0xd50345ca88e0B2cF9a6f5eD29C1F1f9d76A16C3c';

const getWorkableTxs: Job['getWorkableTxs'] = async (args) => {
const correlationId = toKebabCase(metadata.name);
if (args.skipIds.includes(correlationId)) {
console.log(`${metadata.name} in progress, avoid running`);
return args.subject.complete();
}

const logMetadata = {
job: metadata.name,
block: args.advancedBlock,
logId: makeid(5),
};

const logConsole = prelog(logMetadata);

if (args.skipIds.includes(correlationId)) {
logConsole.log(`Job in progress, avoid running`);
return args.subject.complete();
}

logConsole.log(`Trying to work`);

const job = new Contract(jobAddress, TestJobABI, args.fork.ethersProvider);
Expand Down
16 changes: 16 additions & 0 deletions src/goerli/job-strategies/README.md
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)
96 changes: 96 additions & 0 deletions src/goerli/job-strategies/job.ts
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;
3 changes: 3 additions & 0 deletions src/goerli/job-strategies/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "Job Strategies"
}
10 changes: 5 additions & 5 deletions src/mainnet/dca/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ const jobAddress = '0xEcbA21E26466727d705d48cb0a8DE42B11767Bf7';

const getWorkableTxs: Job['getWorkableTxs'] = async (args) => {
const correlationId = toKebabCase(metadata.name);
if (args.skipIds.includes(correlationId)) {
console.log(`${metadata.name} in progress, avoid running`);
return args.subject.complete();
}
const logMetadata = {
job: metadata.name,
block: args.advancedBlock,
logId: makeid(5),
};

const logConsole = prelog(logMetadata);

if (args.skipIds.includes(correlationId)) {
logConsole.log(`Job in progress, avoid running`);
return args.subject.complete();
}

logConsole.log(`Trying to work`);

const job = new Contract(jobAddress, DCAKeep3rJobABI, args.fork.ethersProvider);
Expand Down
2 changes: 1 addition & 1 deletion src/mainnet/harvest-v2/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const getWorkableTxs: Job['getWorkableTxs'] = async (args) => {
const job = new Contract(jobAddress, HarvestV2Keep3rStealthJobABI, args.fork.ethersProvider);
const strategies: string[] = args.retryId ? [args.retryId] : await job.strategies();

logConsole.log(`Simulating ${strategies.length} strategies`);
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))];
Expand Down
2 changes: 1 addition & 1 deletion src/mainnet/tend-v2-2/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getWorkableTxs: Job['getWorkableTxs'] = async (args) => {
const job = new Contract(jobAddress, TendV2Keep3rJob2ABI, args.fork.ethersProvider);
const strategies: string[] = args.retryId ? [args.retryId] : await job.strategies();

logConsole.log(`Simulating ${strategies.length} strategies`);
logConsole.log(args.retryId ? `Retrying strategy` : `Simulating ${strategies.length} strategies`);

for (const [index, strategy] of strategies.entries()) {
const strategyLogId = `${logMetadata.logId}-${makeid(5)}`;
Expand Down
2 changes: 1 addition & 1 deletion src/mainnet/tend-v2/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getWorkableTxs: Job['getWorkableTxs'] = async (args) => {
const job = new Contract(jobAddress, TendV2Keep3rJobABI, args.fork.ethersProvider);
const strategies: string[] = args.retryId ? [args.retryId] : await job.strategies();

logConsole.log(`Simulating ${strategies.length} strategies`);
logConsole.log(args.retryId ? `Retrying strategy` : `Simulating ${strategies.length} strategies`);

for (const [index, strategy] of strategies.entries()) {
const strategyLogId = `${logMetadata.logId}-${makeid(5)}`;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 37c7d66

Please sign in to comment.