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

feat: add mellow-vaults bot scaffold #555

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
40885fb
feat: add mellow-vaults bot scaffold
katamarinaki Jun 2, 2024
38206fd
feat: add some alerts and tests:
BATMAH69 Jun 10, 2024
d52beb4
feat: change owners
BATMAH69 Jun 10, 2024
c798523
feat: uncomment handleTransaction
BATMAH69 Jun 10, 2024
19f19ca
feat: add storage watcher
BATMAH69 Jun 10, 2024
40d2057
feat: fix some pr comments
BATMAH69 Jun 10, 2024
bf5a71d
feat: revert old notice logic
BATMAH69 Jun 10, 2024
48178fd
feat: alert once
BATMAH69 Jun 10, 2024
d48c42d
feat: fix README.md
BATMAH69 Jun 10, 2024
7284c1a
feat: fix provider rpc
BATMAH69 Jun 10, 2024
3faa0a9
feat: fix import
BATMAH69 Jun 10, 2024
19cace8
feat: fix types
BATMAH69 Jun 10, 2024
9c69451
feat: fix imports
BATMAH69 Jun 10, 2024
bbe74fd
feat: separate multisig watchers
BATMAH69 Jun 11, 2024
3750735
feat: rollback multisig bot
BATMAH69 Jun 11, 2024
bb7a822
feat: update feat: fix README.md
BATMAH69 Jun 11, 2024
0d70416
feat: move acl check to this bot, rollback changes in ethethereum-gov…
BATMAH69 Jun 11, 2024
1692d01
feat: add readme
BATMAH69 Jun 11, 2024
f7d1a29
feat: add alert, cleanup description
BATMAH69 Jun 11, 2024
a34cd9d
feat: filter max Supply event, add symbiotic limit watcher
BATMAH69 Jun 17, 2024
8bb1b26
feat: add limit reached alert, fix critical alert number
BATMAH69 Jun 17, 2024
feb9bee
feat: add curators alerts
BATMAH69 Jun 20, 2024
ccc3846
feat: change type for VAULT-WSTETH-LIMIT-REACHED
BATMAH69 Jun 20, 2024
021c9a8
feat: improve withdrawals alert logic
BATMAH69 Jun 20, 2024
066a546
feat: change period for notifications
BATMAH69 Jun 20, 2024
a98a7be
feat: add Vault name, fix handle multicall tx, add condition to 48h a…
BATMAH69 Jun 24, 2024
84cecdb
feat: add new Vaults
BATMAH69 Jun 28, 2024
66e876c
feat: test for forta
BATMAH69 Jun 30, 2024
dc729fc
feat: update test blocks aft adding new vaults
BATMAH69 Jul 1, 2024
5ca1dd0
fix: distribute vault config check by block number to solve slow Fort…
Ivan-Feofanov Jul 3, 2024
b9ac5f0
feat: update handleEventsOfNotice
BATMAH69 Jul 14, 2024
394c08a
feat: add multicall
BATMAH69 Jul 15, 2024
fbee818
feat: remove multicall, it works slow
BATMAH69 Jul 15, 2024
3de8767
feat: change connect position
BATMAH69 Jul 15, 2024
9da7e7f
fix: fix typo
BATMAH69 Jul 16, 2024
8b7c300
feat: move vault-watcher spec, change interfaces to last version
BATMAH69 Jul 16, 2024
b806315
feat: move acl-changes and multisig-changes spec, change test interfa…
BATMAH69 Jul 17, 2024
588079b
feat: add test for slot change
BATMAH69 Jul 17, 2024
15b407e
feat: update acl snapshot
BATMAH69 Jul 17, 2024
fd2c3bd
cln: remove unused and format
BATMAH69 Jul 17, 2024
5f08277
fix: resolve conflict
BATMAH69 Jul 17, 2024
0d784a1
Merge branch 'main' into feat/mellow-alerts
BATMAH69 Jul 17, 2024
0dd291d
fix: fix pr comments
BATMAH69 Jul 23, 2024
8be29ae
fix: fix pr comments
BATMAH69 Jul 23, 2024
04a1912
fix: change work with keys
BATMAH69 Jul 23, 2024
f767351
fix: change cast to lower case
BATMAH69 Jul 23, 2024
63b109c
cln: lint
BATMAH69 Jul 23, 2024
f95fe36
cln: removed await
BATMAH69 Jul 23, 2024
27a7e51
feat: change divide multi vault handler into 2 methods add loggers
BATMAH69 Jul 24, 2024
252b402
feat: divide historical query by 5 min one after another
BATMAH69 Jul 24, 2024
2c97999
test: added test for withdrawal event
BATMAH69 Jul 24, 2024
32e9e57
fix: remove spam logs
BATMAH69 Jul 25, 2024
f417353
feat: add new vault, add fix for tests, remove empty initialize
BATMAH69 Aug 12, 2024
ea6b5ed
fix: vault config to lower case
BATMAH69 Aug 12, 2024
d6e828f
fix: remove DVstETH vault
BATMAH69 Aug 12, 2024
8d39107
fix: fix DVSTETH vault address
BATMAH69 Aug 12, 2024
351a73e
feat: add custom limits option
BATMAH69 Aug 12, 2024
e961463
feat: add alert for vault with 2 tokens, add period for notification …
BATMAH69 Aug 19, 2024
c532ea7
fix: inc warning limit
BATMAH69 Sep 8, 2024
ff08525
fix: inc warning limit
BATMAH69 Sep 12, 2024
cff80e5
fix: inc warning limit, add more info to description
BATMAH69 Sep 25, 2024
d46ae9d
fix: inc warning limit
BATMAH69 Oct 16, 2024
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/ethereum-financial/ @lidofinance/lido-eth-protocol
/arb-subgraph/ @lidofinance/lido-si
/ethereum-governance/ @lidofinance/lido-dao-ops-team
/ethereum-governance-v2/ @lidofinance/lido-dao-ops-team
/mellow-vaults/ @lidofinance/lido-dao-ops-team
/multisig-watcher/ @lidofinance/lido-dao-ops-team
/voting-watcher/ @lidofinance/lido-dao-ops-team
/ethereum-validators-set/ @lidofinance/lido-valset-tech
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('AclChangesSrv', () => {
jest.spyOn(ethProvider, 'getContractOwner').mockResolvedValue(E.left(new Error('Test error')))
const finding = networkAlert(
new Error('Test error'),
`Error in AclChangesSrv.handleOwnerChange (uid:790dc305)`,
`Error in AclChangesSrv.handleOwnerChange (uid:3197e652)`,
`Could not call ethProvider.getOwner for address - ${dsAddress}`,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class AclChangesSrv {
out.push(
networkAlert(
curOwner.left,
`Error in ${AclChangesSrv.name}.${this.handleOwnerChange.name} (uid:790dc305)`,
`Error in ${AclChangesSrv.name}.${this.handleOwnerChange.name} (uid:3197e652)`,
`Could not call ethProvider.getOwner for address - ${address}`,
),
)
Expand Down
2 changes: 1 addition & 1 deletion ethereum-governance/tests/e2e/agent-acl-changes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { roleByName } from '../../src/shared/string'
import { App } from '../../src/app'
import { createTransactionEvent } from './utils'
import * as E from 'fp-ts/Either'
import { ORACLE_DAEMON_CONFIG_ADDRESS } from 'constants/common'
import { ORACLE_DAEMON_CONFIG_ADDRESS } from '../../src/shared/constants/common/mainnet'

const TEST_TIMEOUT = 60_000 // ms

Expand Down
3 changes: 3 additions & 0 deletions mellow-vaults/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
forta.config.json
14 changes: 14 additions & 0 deletions mellow-vaults/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"parser": "@typescript-eslint/parser",
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"plugins": ["@typescript-eslint", "prettier"],
"env": {
"node": true,
"es6": true
},
"rules": {
"prettier/prettier": "error",
"curly": "error",
"semi": "off"
}
}
10 changes: 10 additions & 0 deletions mellow-vaults/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
dist
forta.config.json
.yarn/*
!.yarn/releases/
*.log
version.json
.DS_Store
/coverage/
/src/generated/
1 change: 1 addition & 0 deletions mellow-vaults/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.10.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless. Just look on CI file

Copy link
Contributor

@BATMAH69 BATMAH69 Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is help to change env without looking in file

7 changes: 7 additions & 0 deletions mellow-vaults/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2
}
22 changes: 22 additions & 0 deletions mellow-vaults/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Build stage: compile Typescript to Javascript
FROM node:20.10.0-alpine3.18 AS builder

WORKDIR /app

COPY . .
RUN yarn install --immutable && yarn run build
# Build app
RUN yarn run build

# Final stage: copy compiled Javascript from previous stage and run the app
FROM node:20.10.0-alpine3.18 as production
LABEL "network.forta.settings.agent-logs.enable"="true"
ENV NODE_ENV=production
WORKDIR /app

COPY package*.json yarn.lock ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./src
COPY version.json ./

CMD ["yarn", "run", "start:prod"]
69 changes: 69 additions & 0 deletions mellow-vaults/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Lido x Mellow Detection Bot for Forta

## Supported chains

- Ethereum mainnet

## Alerts

1. Vault operations
1. HandleBlock
1. 🚨🚨🚨 Vault vaultTotalSupply and vaultUnderlyingTvl is not the same
2. 🚨🚨🚨 Vault totalSupply more than maximalTotalSupply
3. 🚨🚨🚨 Vault critical storage slot value changed
4. 🚨 Vault critical storage not loaded
5. ⚠️ Vault withdrawals haven’t been called for at least 48 hours
6. ⚠️ Vault totalSupply close to maximalTotalSupply (every 1800 blocks)
7. ⚠️ Vault totalSupply reached maximalTotalSupply (every 1800 blocks)
2. HandleTransaction
1. 🚨 Vault: Role Admin changed
2. 🚨 Vault: Role revoked
3. 🚨 Vault: Role granted
4. ⚠️ Vault: Symbiotic limit increased
5. ⚠️ Vault: Symbiotic limit reached
6. ⚠️ Vault: Withdrawals haven’t been called for at least 48 hours
7. ⚠️ Vault: Withdrawal partial
8. ℹ️ Vault: Withdrawal all
2. Multisig
1. HandleTransaction
1. 🚨 Gnosis Safe: Owner added
2. 🚨 Gnosis Safe: Owner removed
3. 🚨 Gnosis Safe: Fallback handler changed
4. 🚨 Gnosis Safe: Guard changed
5. 🚨 Gnosis Safe: Threshold changed
6. 🚨 Gnosis Safe: Module disabled
7. 🚨 Gnosis Safe: Module enabled
8. ❌ Gnosis Safe: TX Execution faile
9. ✅ Gnosis Safe: TX Executed
10. ❌ Gnosis Safe: Execution failed from module
11. ✅ Gnosis Safe: Execution success from module
3. ACL
1. HandleBlock
1. 🚨 Vault Contract owner set to address not in whitelist
2. 🚨🚨🚨 Vault Contract owner set to EOA 🚨🚨🚨

## Development

Install deps:

```
yarn install
```

### Mainnet

Edit `alerting-forta/<SUBMODULE>/forta.config.json` and set `jsonRpcUrl` to your Mainnet JSON-RPC provider.

Running in a live mode:

```
yarn start:dev
```

Testing on a specific block/range/transaction:

```
yarn block 20061166
yarn range '20061165..20061166'
yarn tx 0xb8b96ee47cadb80ec41dafceba1fe5b10b1d50b75e7ad9114ee16180bda2d2b4
```
10 changes: 10 additions & 0 deletions mellow-vaults/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import("ts-jest").JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['dist'],
moduleNameMapper: {
'constants/common': '<rootDir>/src/shared/constants/common/mainnet',
'constants/acl-changes': '<rootDir>/src/shared/constants/acl-changes/mainnet',
},
}
97 changes: 97 additions & 0 deletions mellow-vaults/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"name": "lido-mellow-vaults-forta-bot",
"version": "1.0.0",
"description": "Forta Bot for Mellow Vault",
"repository": {
"type": "git",
"directory": "https://github.com/lidofinance/alerting-forta/tree/main/mellow-vaults"
},
"license": "MIT",
"chainIds": [
1
],
"chainSettings": {
"default": {
"shards": 1,
"target": 5
}
},
"husky": {
"hooks": {
"pre-commit": "yarn run lint"
}
},
"scripts": {
"update-version": "node ../utils/write-version.js",
"build": "tsc && tsc-alias && yarn run copy-version",
"copy-version": "cp version.json dist",
"start": "yarn run update-version && yarn run start:dev",
"start:dev": "nodemon --watch src --watch forta.config.json -e js,ts,json --exec \"yarn run build && yarn run copy-version && forta-agent run\"",
"start:prod": "forta-agent run --prod",
"tx": "yarn run build && forta-agent run --tx",
"block": "yarn run build && forta-agent run --block",
"range": "yarn run build && forta-agent run --range",
"alert": "yarn run build && forta-agent run --alert",
"sequence": "yarn run build && forta-agent run --sequence",
"file": "yarn run build && forta-agent run --file",
"publish": "yarn run update-version && forta-agent publish",
"info": "forta-agent info",
"logs": "forta-agent logs",
"push": "yarn run update-version && forta-agent push",
"disable": "forta-agent disable",
"enable": "forta-agent enable",
"keyfile": "forta-agent keyfile",
"stake": "forta-agent stake",
"test": "jest",
"generate-types": "typechain --target=ethers-v5 --out-dir=./src/generated ./src/abi/*",
"eslint:lint": "eslint ./src",
"eslint:format": "eslint ./src --fix",
"prettier:check": "prettier --check ./src",
"prettier:format": "prettier --write ./src README.md",
"lint": "yarn run prettier:check && yarn run eslint:lint",
"format": "yarn run eslint:format && yarn run prettier:format",
"postinstall": "yarn generate-types"
},
"dependencies": {
"@ethersproject/abi": "^5.0.0",
"@ethersproject/providers": "^5.0.0",
"@types/lodash": "^4.14.202",
"async-mutex": "^0.4.0",
"bignumber.js": "^9.1.2",
"ethereum-multicall": "^2.24.0",
"ethers": "^5.5.1",
"forta-agent": "^0.1.48",
"fp-ts": "^2.16.1",
"knex": "^3.1.0",
"lodash": "^4.17.21",
"ts-retry": "^4.2.4",
"winston": "^3.11.0"
},
"devDependencies": {
"@faker-js/faker": "^8.3.1",
"@jest/globals": "^29.7.0",
"@tsconfig/node20": "^20.1.2",
"@typechain/ethers-v5": "^11.1.2",
"@types/jest": "^29.5.11",
"@types/nodemon": "^1.19.0",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-resolve": "^29.7.0",
"nodemon": "^3.0.1",
"postinstall": "^0.8.0",
"prettier": "^3.1.0",
"ts-generator": "^0.1.1",
"ts-jest": "^29.1.2",
"tsc-alias": "^1.8.8",
"typechain": "^8.3.2",
"typescript": "^5.3.2"
},
"packageManager": "[email protected]"
}
Loading
Loading