Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
372 commits
Select commit Hold shift + click to select a range
350b331
dinoswap - moved to dev mode
degenddy Jan 19, 2022
bf7dd08
dino - not dev
degenddy Jan 20, 2022
0a6f73b
updated pool info json from quickswap api
degenddy Jan 25, 2022
94f97be
small fix to quickswap
degenddy Jan 25, 2022
b07c729
added "ended" pools to "position worth" notification to show pools th…
degenddy Jan 29, 2022
2709d2b
alpaca integration
degenddy Jan 31, 2022
721123f
quickswap - custom pools
degenddy Feb 1, 2022
eb54683
small fix to quickswap
degenddy Feb 1, 2022
3def2ff
added optional field
degenddy Feb 1, 2022
befb950
fix quickswap for cache
degenddy Feb 1, 2022
2294fad
opensea integration
degenddy Feb 2, 2022
5163be1
changed opensea integration to "http" type network (instead of web3)
degenddy Feb 3, 2022
a38fcf0
removed quickswap optional field until new app version is in stores
degenddy Feb 3, 2022
518a01e
added optional custom pool field to quickswap
degenddy Feb 4, 2022
13c10dd
open sea new offers
degenddy Feb 6, 2022
10220f1
Trader Joe pending reward notification
degenddy Feb 8, 2022
f9f4749
fixes to alpaca integration
degenddy Feb 8, 2022
4e29582
alpaca additional fix
degenddy Feb 8, 2022
bd686b2
small alpaca fix
degenddy Feb 8, 2022
e60bc8c
removed alpaca from dev mode
degenddy Feb 9, 2022
c57c150
small fix to opensea
degenddy Feb 9, 2022
92b337f
revault fix
degenddy Feb 14, 2022
86aa140
pangolin pending reward integration
degenddy Feb 15, 2022
92581fd
pangolin position-worth integration
degenddy Feb 15, 2022
63e9320
changed pangolin graphics and theme
degenddy Feb 15, 2022
bb450d0
small mistake
degenddy Feb 15, 2022
6204af5
color change for pangolin
degenddy Feb 15, 2022
1723fdb
multi chain support for projects. WIP
degenddy Feb 17, 2022
4797f74
small fix to alpaca
degenddy Feb 17, 2022
b160d18
small fix to ethereum gas price
degenddy Feb 20, 2022
34dd83e
pancakeswap pending-reward notification
degenddy Feb 20, 2022
a4a0027
removed pangolin from dev-mode
degenddy Feb 20, 2022
1cb750a
disabled alpaca fantom notification for now
degenddy Feb 20, 2022
22ae4c7
small fix
degenddy Feb 20, 2022
6a1bd5b
alpaca fantom notification
degenddy Feb 20, 2022
4352c01
ethereum minor fix
degenddy Feb 20, 2022
54802f0
minor fix to ethereum
degenddy Feb 20, 2022
6c0ecc4
changes to opensea notifications
degenddy Feb 22, 2022
4d7e4da
added platformkeys.opensea to the opensea integration
degenddy Feb 22, 2022
35ec8d9
added pancakeswap position-worth notification
degenddy Feb 22, 2022
51b862c
opensea new offers by floor price notification
degenddy Feb 23, 2022
2cc894e
Merge branch 'alpaca-fantom-wip'
degenddy Feb 24, 2022
38275fb
quickswap name fix
degenddy Feb 24, 2022
1ed2c04
pancakeswap fixes
degenddy Mar 3, 2022
e5219ed
minor fix to pancake
degenddy Mar 3, 2022
04a2bd1
small fix to pancake - int 0 was inserted instead of string 0
degenddy Mar 3, 2022
e09b5f3
revault - change strategy notification
degenddy Mar 7, 2022
3f098f3
small revault fix
degenddy Mar 7, 2022
505aa92
minor textual fix
degenddy Mar 8, 2022
cc9101b
pancake logo update
degenddy Mar 9, 2022
c8d9876
pancakeswap syrup pools pending rewards notification
degenddy Mar 9, 2022
00b7384
pancake naming fix
degenddy Mar 9, 2022
35a4cfe
added revault fantom pending reward notification
degenddy Mar 10, 2022
7fc07fd
removed sushi from dev mode
degenddy Mar 10, 2022
342c15a
Notional Debt Settlement notification
hboisselle Mar 12, 2022
ad2f94b
Merge pull request #17 from ShippooorDAO/master
degenddy Mar 13, 2022
3dbe794
trader joe - rocket joe new launch event notification
degenddy Mar 13, 2022
6a713fc
Fix undefined time buffer issue
hboisselle Mar 13, 2022
839e4b0
Fix timezone issue with tests
hboisselle Mar 13, 2022
70419ce
Merge pull request #18 from ShippooorDAO/master
degenddy Mar 13, 2022
8e8525c
small traderjoe fix + notional fixes
degenddy Mar 13, 2022
7c67d2e
notional set dev mode true
degenddy Mar 13, 2022
ad90a28
removed pancakeswap from dev mode
degenddy Mar 14, 2022
dc45d93
wip - pre actual tests
degenddy Mar 22, 2022
86e00ed
fixed eth gas-price notification to support a breaking change in web3…
degenddy Mar 22, 2022
100cf99
another small fix to gas-price notification to support web3 1.7
degenddy Mar 23, 2022
246efcc
Merge commit 'dc45d933fbea18682a309ee0928aeaeb059a5db1'
degenddy Mar 29, 2022
d92eb88
small fix to uniqueId for de-dupp check
degenddy Mar 29, 2022
1b7e779
opensea: added quantity
degenddy Mar 30, 2022
cac3203
removed uniswap from dev
degenddy Mar 31, 2022
0727cdd
uniswap tokens worth notification
degenddy Mar 31, 2022
9757933
minor fix to uniswap and pancakeswap Tokens-Worth to support holding …
degenddy Mar 31, 2022
1c58e86
changed wowswap to http (its api based and not web3)
degenddy Apr 12, 2022
faf2bfa
added pancakeswap masterchef v2 notifications
degenddy May 1, 2022
7fcbd88
spirit swap pending rewards notifications
degenddy May 4, 2022
23f7f9a
fixed spirit logo
degenddy May 4, 2022
c3c9659
removed vault count limit for alpaca (was 5)
degenddy May 6, 2022
1137b91
fix for description on pancakeswap
degenddy May 10, 2022
d804fad
removed opensea from dev mode
degenddy May 16, 2022
5f7dfa1
minor fixes to opensea
degenddy May 19, 2022
0e2af37
changed open sea to be by millis again (they changed the api) - which…
degenddy May 22, 2022
cf313d5
venus integration
degenddy May 22, 2022
a2355fe
orbs minor fix to unique id
degenddy May 22, 2022
fd09c2d
small fix to opensea floor price notification
degenddy May 23, 2022
0eef3c4
orbs - added a days-before field to cooldown-unlock notifications
degenddy May 23, 2022
507aff6
minor fix - fallback for previous orbs subscriptions
degenddy May 23, 2022
20c9a45
added polygon-rewards-claim
May 24, 2022
2e57228
added polygon-rewards-claim
May 24, 2022
fb96434
added auto compounder address
May 24, 2022
146c85c
meshswap pendin rewards notification
degenddy May 30, 2022
91e38e5
Update project.json
degenddy Jun 8, 2022
3a69a65
small fix to naming
degenddy Jun 8, 2022
f82ba57
spirit swap logo change
degenddy Jun 19, 2022
2978bd5
pancakeswap tlv notification
degenddy Jun 19, 2022
d418436
added topic filter with user's address
Jun 20, 2022
00a487e
Merge pull request #21 from open-defi-notification-protocol/auto_comp…
degenddy Jun 20, 2022
37f321e
spookyswap integration
degenddy Jul 7, 2022
db2688f
set spookyswap to dev mode only
degenddy Jul 7, 2022
1a81c92
added usage of web3Cache
degenddy Jul 7, 2022
7ba5b58
added web3 cache for. alpaca & spooky
degenddy Jul 10, 2022
27f27c4
Reverted cache service
degenddy Jul 11, 2022
df10e31
changed venus logo
degenddy Jul 20, 2022
9d2dc3e
removed spookyswap from dev
degenddy Jul 27, 2022
de9be15
aave - health factor notificaiton
degenddy Aug 3, 2022
8d2d496
small improvements to aave
degenddy Aug 3, 2022
8204b09
small fix to aave
degenddy Aug 3, 2022
adcf0d1
another fix to aave to exclude wallets without positions
degenddy Aug 3, 2022
f335b1a
[SingleFinance] add alert for position stoploss/liquidate
Aug 9, 2022
dfaf4f7
[SingleFinance] add test case
Aug 9, 2022
7627696
Merge pull request #22 from singlefinance/master
degenddy Aug 9, 2022
646ed59
set single to dev mode
degenddy Aug 9, 2022
268c28a
compound notification fix
degenddy Aug 18, 2022
3565f8e
removed compound from dev mode
degenddy Aug 18, 2022
a058755
fixes to compound and venus (minor)
degenddy Aug 18, 2022
2af727d
moved single finance to prod
degenddy Aug 23, 2022
a255be1
added quickswap twap notifications
degenddy Aug 31, 2022
496f7e9
added harvest finance pending-rewards notification
degenddy Sep 1, 2022
e407379
harvest and frax notifications
degenddy Sep 1, 2022
24ca709
returned harvest to dev mode
degenddy Sep 1, 2022
3bfc025
twap (separated from quickswap) wip
degenddy Sep 5, 2022
8ef37bd
minor fix to labels
degenddy Sep 6, 2022
44038ae
balancer pending reward integration
degenddy Sep 11, 2022
84bc6e7
splassive
Splassive Sep 16, 2022
c0d4098
Update project.json
degenddy Sep 18, 2022
69493fc
Merge pull request #23 from Splassive/master
degenddy Sep 18, 2022
455a72a
frax inverted logo and colors
degenddy Sep 20, 2022
0abab10
taken splassive out of dev mode
degenddy Sep 22, 2022
4f1a865
frax position-health notification
degenddy Oct 2, 2022
b2e6a8f
changed network on frax position-health to ethereum (default)
degenddy Oct 2, 2022
eaeca27
frax graphics
degenddy Oct 3, 2022
44519af
notification text change
degenddy Oct 3, 2022
b4afb7f
removed harvest from dev mode
degenddy Oct 14, 2022
39d018a
twap notifications fix
DanielZlotin Oct 30, 2022
b593046
Merge pull request #24 from DanielZlotin/master
degenddy Oct 30, 2022
7b2194f
fix to twap notifications
degenddy Nov 2, 2022
0cb7ce5
added test to twap polygon
degenddy Nov 2, 2022
9911d7f
fixed twap network for polygon
degenddy Nov 2, 2022
675744b
stake dao integration
degenddy Nov 21, 2022
dfdc41e
gearbox integration WIP
degenddy Nov 21, 2022
873d08f
stakedao name and logo fix
degenddy Nov 21, 2022
cd757fb
updated twap notification contract address
degenddy Nov 24, 2022
61c80b9
fixed TWAP notifications filtering and refactor
DanielZlotin Nov 29, 2022
b985be3
Merge pull request #25 from DanielZlotin/master
degenddy Nov 30, 2022
41bbd09
added common evm notifcations
degenddy Dec 7, 2022
ae9f2fb
small fix to prevent base class from being read as a notification type
degenddy Dec 7, 2022
d397dd3
small fix to colors
degenddy Dec 7, 2022
2bcd538
balancer veBAL staking unlocked notification
degenddy Dec 19, 2022
e7b0e31
curve staking unlocked notification
degenddy Dec 19, 2022
a6aae61
twap style
degenddy Dec 20, 2022
b90a0ff
convex lock finished notification
degenddy Dec 20, 2022
97c76cb
styling
degenddy Dec 20, 2022
237ca38
styling
degenddy Dec 20, 2022
9978e87
angle health
degenddy Feb 15, 2023
6a979ac
no message
degenddy Feb 15, 2023
feb719f
minor fix
degenddy Feb 15, 2023
2d57e99
add TWAP on Avalanche
DanielZlotin Dec 1, 2022
bde2d73
updated interface
degenddy Feb 15, 2023
0f61d82
update TWAP addresses
DanielZlotin Feb 15, 2023
68a23be
mintyard low health notification
pe-matsushita Feb 20, 2023
6c5c055
mintyard low health notification
pe-matsushita Feb 20, 2023
9d735af
Merge remote-tracking branch 'origin/master'
pe-matsushita Feb 20, 2023
d8208c9
no message
degenddy Feb 27, 2023
da6b4ab
Add files via upload
DanielZlotin Mar 8, 2023
8634663
Add files via upload
DanielZlotin Mar 8, 2023
e73b299
fixed polygon-auto-compound
idan-orbs Mar 13, 2023
2da03d0
updated auto compound test
idan-orbs Mar 13, 2023
0837f76
Merge pull request #28 from idan-orbs/master
degenddy Mar 13, 2023
af17e73
mintyard dev flag
pe-matsushita Mar 13, 2023
ef4dec7
twap prod
DanielZlotin Mar 27, 2023
be923e8
:sparkles: Support dForce lending protocol.
Skyge Mar 27, 2023
6f49ae6
:alembic: Use experimental mode.
Skyge Mar 28, 2023
190c15b
:white_check_mark: Add more test cases.
Skyge Mar 28, 2023
37144d6
:building_construction: Simplify code.
Skyge Mar 28, 2023
18fddaa
Merge pull request #29 from Skyge/dforce
degenddy Mar 28, 2023
685c32d
small fix to dForce causing engine to mistakenly think base class is …
degenddy Mar 28, 2023
5e01636
y2k integration
degenddy Mar 28, 2023
4aa8de3
small fix to y2k
degenddy Mar 29, 2023
c1fe74c
SushiSwap TVL on Ethereum and Arbitrum
DanielZlotin Mar 30, 2023
cc36d0a
y2k epoch created notification
degenddy Apr 3, 2023
15dae54
fix web3 usage
DanielZlotin Apr 4, 2023
123409f
Merge pull request #30 from open-defi-notification-protocol/sushiswap…
degenddy Apr 4, 2023
eb43442
project name has been changed.
pe-matsushita Apr 27, 2023
94229a6
Merge pull request #27 from pe-matsushita/master
degenddy Apr 27, 2023
ba13d40
WIP liquidation notification
degenddy Apr 27, 2023
468263a
contract address has been updated and logo improved.
pe-matsushita Apr 28, 2023
dadb4d0
checking claimedDelegatorRewards value
idan-orbs Apr 30, 2023
32f48d8
Merge pull request #32 from orbs-network/master
degenddy Apr 30, 2023
edb33ab
Merge pull request #31 from pe-matsushita/master
degenddy May 1, 2023
79967bb
twap graphical
degenddy May 1, 2023
977f341
twap graphical
degenddy May 1, 2023
a3e64e6
onSubscription
pe-matsushita May 2, 2023
88cba29
onSubscription
pe-matsushita May 2, 2023
ac84301
Merge remote-tracking branch 'origin/master'
pe-matsushita May 2, 2023
cc18c19
onSubscription
pe-matsushita May 2, 2023
3012dc3
test for auto compound
degenddy May 2, 2023
256c600
no message
degenddy May 4, 2023
9109612
allow-subscribe
pe-matsushita May 8, 2023
0f47455
allow-subscribe
pe-matsushita May 8, 2023
202b059
Merge pull request #33 from pe-matsushita/master
degenddy May 8, 2023
b735b6c
small y2k fix
degenddy May 10, 2023
39872b0
no message
degenddy May 11, 2023
3177e1a
disabled open sea offers notifications (not supported by the new api)
degenddy May 15, 2023
2057c22
level wip
degenddy May 15, 2023
2afee37
minor fix to opensea
degenddy May 15, 2023
a353b24
level liquidation notification
degenddy May 17, 2023
c6ed459
Merge branch 'level-finance-wip'
degenddy May 17, 2023
dbd1762
no message
degenddy May 17, 2023
bda184a
balancer onInit try-catch
degenddy May 22, 2023
0ec6768
removed try catch at the project level (it is now handled on the dete…
degenddy May 22, 2023
cc5fdb1
level limit order executed notification
nikitindenis1 May 30, 2023
263eaec
Merge pull request #34 from denis-orbs/master
degenddy May 31, 2023
b9945ce
no message
degenddy May 31, 2023
c2487d6
taken level out of dev mode
degenddy Jun 12, 2023
5b6ffa3
twap arb + bsc
degenddy Jun 13, 2023
5b927ad
Added Pendle notification
idan-orbs Jun 29, 2023
5876830
Merge pull request #36 from idan-orbs/master
degenddy Jun 29, 2023
c1ffef7
no message
degenddy Jun 29, 2023
c051c06
Pendle dev=true
idan-orbs Jun 29, 2023
14de6e6
Merge branch 'open-defi-notification-protocol:master' into master
idan-orbs Jun 29, 2023
263bb23
Pendle new logo
idan-orbs Jun 29, 2023
6ceb921
Merge remote-tracking branch 'origin/master'
idan-orbs Jun 29, 2023
d69104e
Merge pull request #37 from idan-orbs/master
degenddy Jun 29, 2023
aece5ed
Added BSC to Pendle
idan-orbs Jun 29, 2023
f0a85b3
Merge branch 'open-defi-notification-protocol:master' into master
idan-orbs Jun 29, 2023
5e99557
Merge pull request #38 from idan-orbs/master
degenddy Jun 30, 2023
d9c6291
moved convex to prod
degenddy Jul 2, 2023
efd731d
disabled debug mode
idan-orbs Jul 5, 2023
33fb6ba
Merge pull request #39 from idan-orbs/master
degenddy Jul 5, 2023
ffd5b24
Added Overnight
idan-orbs Jul 6, 2023
a67b910
Overnight dev:true
idan-orbs Jul 6, 2023
9c7613f
splassive icon fix
degenddy Jul 9, 2023
ea44414
added Optimism
idan-orbs Jul 9, 2023
3b2a713
Merge branch 'open-defi-notification-protocol:master' into master
idan-orbs Jul 9, 2023
6110842
no message
degenddy Jul 11, 2023
debb858
no message
degenddy Jul 11, 2023
af4974f
frax , stake dao - moved out of experimental mode
degenddy Jul 11, 2023
bd9f0bc
Merge branch 'open-defi-notification-protocol:master' into master
idan-orbs Jul 12, 2023
f811dce
Merge pull request #40 from idan-orbs/master
degenddy Jul 12, 2023
e1162e2
Overnight: fixed payout, added strategy
idan-orbs Jul 13, 2023
6468f86
Merge pull request #41 from idan-orbs/overnight
degenddy Jul 13, 2023
03723e3
Fixed Overnight strategy
idan-orbs Jul 17, 2023
5941258
Merge pull request #42 from idan-orbs/overnight
degenddy Jul 17, 2023
4a60e34
removed curve from dev mode
degenddy Aug 21, 2023
0af5974
moved opensea to dev
degenddy Sep 26, 2023
8efee71
removed balancer from dev mode
degenddy Feb 12, 2024
53897b5
feat: aave v2 and v3 addresses
defispartan Apr 29, 2024
ddc350a
feat: aave Pool V3 abi
defispartan Apr 29, 2024
3650baf
feat: aave templates
defispartan Apr 29, 2024
1ca7cd8
feat: aave v2 and v3 markets
defispartan Apr 29, 2024
62859e5
feat: tests
defispartan Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
.idea
.idea
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,27 @@ module.exports = LowHealth;

### Documentation and more examples

Formal TypeScript type definitions for the class interface are available [here](projects/interfaces.ts). Explore example integrations to different projects by browsing the different directories in this repo.
Formal TypeScript type definitions for the class interface are available [here](interfaces.ts). Explore example integrations to different projects by browsing the different directories in this repo.

### Testing your integration

Before submitting the PR, you should test your integration manually. Let's assume that you're integrating a new lending project called "SuperLend". You've git cloned this repo locally, created your new integration in the new directory `superlend` and created the following new files:

`/superlend/project.json`

`/superlend/near-liquidation.js`

To test your integration for the near liquidation notification do the following:

1. Make sure you're in the repo root

2. Run `npm install`

3. Create `/_test/dev-keys.json` (see example in that directory) containing your API key for a web3 service like Infura or Alchemy

4. Create `/_test/test-superlend.js` for your test, you can copy one of the other example test files

5. Run `node ./_test/test-superlend.js`

 

Expand Down
170 changes: 170 additions & 0 deletions _maintenance/uniswap_get-all-pools-tvls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
const Web3 = require('web3');
const BN = require("bignumber.js");
const web3 = new Web3(new Web3.providers.HttpProvider(require('../_test/dev-keys.json').web3));
const EthereumMulticall = require('ethereum-multicall');
const fetch = require("node-fetch");
const ABIs = require("../uniswap/abis.json");
const fs = require("fs");

const WETH_TOKEN_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';

const IGNORE_CONTRACTS = [
'0x8c8af24921BF86B23D6418C8674E210aC876Cd2E',
'0x1ADc7DaC48A656552b094eB75D09Fb29b5da9Ade',
'0x659cDebf48EbA64ab0e7Ed049959Ad516bdd2158',
'0xE4610c983877480a50eeA0D53E313eDa423eC678',
'0x6615D8EF7D762878caE51cB18EE647f9c2825536',
'0x5b95dBc3995F36e85b771720083f216a112306A1',
'0x6ab01fb2591f158A3E6A838cD45BFb077BD4690c',
'0xbb41D5F95b45511eD23924144B7348A7Bd50C7ea',
'0xdE7Ad7F64b8D7d369145FA0e9DC76EDcFcd89d68',
'0x18C71Cfab8319cB19137B19c2307BE0500E7DF21',
'0xaEAd6aae17Dfd944513DD60a9809E3941058451E',
'0x260787332F2Fe51356B7F4172D4097e040699696',
'0x9969183D576220b31369aB878260e5BB9BC34743',
'0xe83A969B55cBA46bC84A69DF133Fc539B7278001',
'0x62BAc0626558023639C6526D6971ca046BD1CB78',
'0x89817F9b1fb1BC209911E5c77379721CDAF484Fd',
'0x13Fa9Db82c07eb03dad870f220F23c923CeC89dB',
'0x8ab4dEcd27334DA8dE04AD1038c4a5FDCEDC5b80'
];

async function main() {

const wethContract = new web3.eth.Contract(ABIs.erc20, WETH_TOKEN_ADDRESS);

const wethDecimals = await wethContract.methods.decimals().call();

const response = await fetch('https://raw.githubusercontent.com/jab416171/uniswap-pairtokens/master/uniswap_pair_tokens.json');

const poolsInfo = (await response.json()).tokens;

const processedPools = {};

const multicall = new EthereumMulticall.Multicall({web3Instance: web3, tryAggregate: true});

const chunkSize = 3000;

const allPools = Object.values(poolsInfo)
// .slice(0, 1000);

console.log(`fetching all TVLs of ${allPools.length} pools`);

function sliceIntoChunks(arr, chunkSize) {
const res = [];
for (let i = 0; i < arr.length; i += chunkSize) {
const chunk = arr.slice(i, i + chunkSize);
res.push(chunk);
}
return res;
}

let chunks = sliceIntoChunks(allPools, chunkSize);

let i = 0;

console.log(`get pool info`);

const ethPools = {};

try {

for (const chunk of chunks) {

const contractCallContext = [];

for (const poolInfo of chunk) {

const poolAddress = poolInfo.address;

if (!poolAddress || poolInfo.chainId !== 1 || IGNORE_CONTRACTS.indexOf(poolAddress) > -1) continue;

processedPools[poolAddress] = {
address: poolAddress,
symbol: poolInfo.name.replace('Uniswap V2 - ', '').replace('/', '-'),
decimals: poolInfo.decimals
};

contractCallContext.push({
reference: 'pool-' + poolAddress,
contractAddress: poolAddress,
abi: ABIs.lp,
calls: [
{reference: 'getReservesCall', methodName: 'getReserves'},
{reference: 'token0Call', methodName: 'token0'},
{reference: 'token1Call', methodName: 'token1'}
],
context: {
poolAddress: poolAddress
}
});

}

const results = (await multicall.call(contractCallContext)).results;

for (const result of Object.values(results)) {

const callReturnContext = result.callsReturnContext[0];

const token0 = result.callsReturnContext[1].returnValues[0];
const token1 = result.callsReturnContext[2].returnValues[0];

if (token0 === WETH_TOKEN_ADDRESS || token1 === WETH_TOKEN_ADDRESS) {

const poolAddress = result.originalContractCallContext.context.poolAddress;

const reserve0 = new BN(callReturnContext.returnValues[0].hex).toString(10);
const reserve1 = new BN(callReturnContext.returnValues[1].hex).toString(10);

const processedPool = processedPools[poolAddress];

if (token0 === WETH_TOKEN_ADDRESS) {
processedPool.ethReserve = reserve0;
processedPool.tokenReserve = reserve1;
processedPool.tokenAddress = token1;
} else {
processedPool.ethReserve = reserve1;
processedPool.tokenReserve = reserve0;
processedPool.tokenAddress = token0;
}

processedPool.tvl = new BN(processedPool.ethReserve).dividedBy("1e" + wethDecimals).multipliedBy(2).toString(10);

ethPools[poolAddress] = processedPool;

}

}

i += chunk.length;
console.log(`went over ${i} of ${allPools.length} pools`);

}

let allPoolsByTVLs = Object.values(ethPools);

allPoolsByTVLs.sort((a, b) => {

return new BN(a.tvl).comparedTo(b.tvl);

})

const fs = require('fs');

fs.writeFile('all-pools-tvl.json', JSON.stringify(allPoolsByTVLs), () => {

console.log(`done writing info for ${allPoolsByTVLs.length} pools`);

})


} catch (e) {
console.error(e);
console.log(allPools);
}


}

main();
2 changes: 2 additions & 0 deletions _test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dev-keys.json
api-keys.json
9 changes: 1 addition & 8 deletions _test/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
### Steps to test your monitoring code

1. Add a function to `test-helper.js` that utilized the new code you wrote
2. Make sure to pass the right arguments to `onInit` and to call `onSubscribeForm` if applicable
3. Add `console.assert` to check the value from `onBlock`
4. Empty array will indicates there is no error

Thanks it
See [Testing your integration](../README.md#testing-your-integration) in the main README
3 changes: 0 additions & 3 deletions _test/api-keys.json

This file was deleted.

6 changes: 6 additions & 0 deletions _test/api-keys.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ethereum": "https://mainnet.infura.io/v3/...",
"polygon": "https://polygon-mainnet.g.alchemy.com/v2/...",
"bsc": "https://bsc.getblock.io/mainnet/?api_key=...",
"avalanche": "https://api.avax.network/ext/bc/C/rpc"
}
3 changes: 3 additions & 0 deletions _test/dev-keys.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"web3": "https://eth-mainnet.alchemyapi.io/v2/DslGjjSuMemtGqRv_noH03Y8miuBZZYE"
}
73 changes: 73 additions & 0 deletions _test/test-aave.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const Web3 = require("web3");

async function testV2(network, fromBlock, toBlock, address, threshold) {
const providerUrl = require("./dev-keys.json")[`web3${network}`];

const web3 = new Web3(new Web3.providers.HttpProvider(providerUrl));

const V2Notification = require(`../aave/hf-aave-v2-${network}`);
const v2Notification = new V2Notification();

// simulate init event
await v2Notification.onInit({
web3,
});

// simulate subscribe form event
const form = await v2Notification.onSubscribeForm({ address, subscription: { threshold } });

console.log(form);

// simulate on blocks event
return v2Notification.onBlocks({
web3,
fromBlock,
toBlock,
address,
subscription: { threshold },
});
}

async function testV3(network, fromBlock, toBlock, address, threshold) {
const providerUrl = require("./dev-keys.json")[`web3${network}`];

const web3 = new Web3(new Web3.providers.HttpProvider(providerUrl));

const V3Notification = require(`../aave/hf-aave-v3-${network}`);
const v3Notification = new V3Notification();

// simulate init event
await v3Notification.onInit({
web3,
});

// simulate subscribe form event
const form = await v3Notification.onSubscribeForm({ address, subscription: { threshold } });

console.log(form);

// simulate on blocks event
return v3Notification.onBlocks({
web3,
fromBlock,
toBlock,
address,
subscription: { threshold },
});
}

async function main() {
console.log(await testV2("ethereum", 19757062, 19758062, "0xc94680947CF2114ec8eE43725898EAA7269a98c5", 2));
console.log(await testV2("polygon", 56371996, 56372996, "0x91746d6f9DF58B9807a5BB0e54e4EA86600c2DBa", 2));
console.log(await testV2("avalanche", 44797808, 44798808, "0xfA36b06e5198F07FC1F57B8424273c41390628E4", 6));

console.log(await testV3("ethereum", 19757062, 19758062, "0xe40d278afD00E6187Db21ff8C96D572359Ef03bf", 2));
console.log(await testV3("polygon", 56371996, 56372996, "0x7FccD22712c2E593de30a9806D3b72B2aD9eab15", 2));
console.log(await testV3("avalanche", 44797808, 44797808, "0xCc5B1feF95f632c4A25f95ad88bFe12f928D04cB", 2));
console.log(await testV3("optimism", 119382333, 119383333, "0x790c9422839FD93a3A4E31e531f96cC87F397c00", 3));
console.log(await testV3("metis", 16844265, 16845265, "0xa7bf267a672E3cd2664E73a1A882DE33CDFe49d9", 2));
console.log(await testV3("bnb", 38273370, 38274370, "0x349cFcBd653A124821D6Ada36887d38309A7B6eB", 2));
console.log(await testV3("base", 13786893, 13787893, "0xaf7274d75217ca23d986f2aea6ad9d74a8fd00d5", 2));
}

main().catch(console.error);
64 changes: 64 additions & 0 deletions _test/test-alpaca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const Web3 = require('web3');
const web3bsc = new Web3(new Web3.providers.HttpProvider(require('./dev-keys.json').web3bsc));
const web3fantom = new Web3(new Web3.providers.HttpProvider(require('./dev-keys.json').web3fantom));

async function testGetAllUserVaults(web3, notificationModule, address) {
const PositionHealth = require('../alpaca/' + notificationModule);
const positionHealth = new PositionHealth();

// simulate init event
await positionHealth.onInit({
web3
});

return positionHealth._getAllUserVaults({
web3,
address
});
}

async function testOnBlocks(web3, notificationModule, address, threshold) {
const PositionHealth = require('../alpaca/' + notificationModule);
const positionHealth = new PositionHealth();

// simulate init event
await positionHealth.onInit({
web3
});

// simulate subscribe form event
const form = await positionHealth.onSubscribeForm({
web3,
address
});

// simulate user filling in the subscription form in the app
const subscription = {
vault: form.find(o => o.id === 'vault').values[0].value,
threshold: threshold || form.find(o => o.id === 'threshold').default
};

return positionHealth.onBlocks({
web3,
address,
subscription
});
}

async function main() {

console.log('Running manual test:');

let address = '0xAD9CADe20100B8b945da48e1bCbd805C38d8bE77';

console.log(await testGetAllUserVaults(web3bsc, 'position-health', address));
console.log(await testOnBlocks(web3bsc, 'position-health', address, 17));

address = '0x3dacC571356e7D5dFB3b475d6922442Ec06B9005';

console.log(await testGetAllUserVaults(web3fantom, 'position-health_fantom', address));
console.log(await testOnBlocks(web3fantom, 'position-health_fantom', address, 17));

}

main();
Loading