@gooddollar/goodprotocol 1.0.3-beta.3 → 1.0.3-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddollar/goodprotocol",
3
- "version": "1.0.3-beta.3",
3
+ "version": "1.0.3-beta.4",
4
4
  "description": "GoodDollar Protocol",
5
5
  "scripts": {
6
6
  "build": "scripts/build.sh deploy",
@@ -0,0 +1,52 @@
1
+ import { get, range, chunk, flatten, mergeWith, sortBy, uniq } from "lodash";
2
+ import coreContracts from "../../releases/deployment.json";
3
+ import { ethers as Ethers } from "hardhat";
4
+ import fetch from "node-fetch";
5
+ import { request, gql } from "graphql-request";
6
+ import { Retrier } from "@jsier/retrier";
7
+ import PromisePool from "async-promise-pool";
8
+
9
+ const ONE_DAY = 24 * 60 * 60;
10
+
11
+ const main = async () => {
12
+ const signer = (await Ethers.getSigners())[0];
13
+ console.log("signer:", signer.address);
14
+ const ubiScheme = new Ethers.Contract(
15
+ "0xD7aC544F8A570C4d8764c3AAbCF6870CBD960D0D",
16
+ ["function fishMulti(address[] tofish)"]
17
+ ).connect(signer);
18
+ const twoWeeksAgo =
19
+ parseInt((Date.now() / 1000).toFixed(0)) - 24 * 60 * 60 * 14;
20
+
21
+ const daysAgo: number[] = range(0, 180, 1);
22
+ let curDay = twoWeeksAgo;
23
+ for (let day of daysAgo) {
24
+ const query = gql`
25
+ {
26
+ walletStats(first:1000, where: { lastClaimed_lt: ${curDay},lastClaimed_gt: ${
27
+ curDay - 24 * 60 * 60
28
+ } isActiveUser: true }) {
29
+ id
30
+ }
31
+ }
32
+ `;
33
+
34
+ console.log("fetching inactive users since:", { curDay, day });
35
+ const { walletStats } = await request(
36
+ "https://api.thegraph.com/subgraphs/name/gooddollar/gooddollarfuse",
37
+ query
38
+ );
39
+ console.log("got inactive wallets:", walletStats.length);
40
+ const accounts = walletStats.map(_ => _.id);
41
+ for (let tofish of chunk(accounts, 50)) {
42
+ const tx = await ubiScheme.fishMulti(tofish, { gasLimit: 2000000 });
43
+ console.log("fishing tx:", tx, tofish);
44
+ const res = await tx.wait();
45
+ console.log("fishing tx result:", res);
46
+ }
47
+
48
+ curDay = curDay - ONE_DAY;
49
+ }
50
+ };
51
+
52
+ main();