@gooddollar/goodprotocol 2.0.5-beta.9 → 2.0.6

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,7 +1,10 @@
1
1
  {
2
2
  "name": "@gooddollar/goodprotocol",
3
- "version": "2.0.5-beta.9",
3
+ "version": "2.0.6",
4
4
  "description": "GoodDollar Protocol",
5
+ "engines": {
6
+ "node": "18.x"
7
+ },
5
8
  "scripts": {
6
9
  "prepack": "npm run minimize",
7
10
  "build": "scripts/build.sh deploy",
@@ -17,8 +20,8 @@
17
20
  "runNode": "hardhat node &",
18
21
  "testDAOUpgrade": "yarn runNode & yarn compile && yarn deployOldDAO --network develop-mainnet && yarn daoUpgrade --network develop-mainnet",
19
22
  "testDAOUpgradeFuse": "yarn runNode & yarn compile && yarn deployOldDAO --network develop && yarn daoUpgrade --network develop",
20
- "deployTestOld": "yarn runNode & yarn compile && hardhat run scripts/test/singleOldDaoDeploy.ts --network dapptest && yarn daoUpgrade --network dapptest && yarn daoUpgrade --network dapptest-mainnet && hardhat run scripts/test/simulateInterest.ts --network dapptest",
21
- "deployTest": "yarn runNode & yarn compile && hardhat run scripts/deployFullDAO.ts --network dapptest && hardhat run scripts/deployFullDAO.ts --network dapptest-mainnet && hardhat run scripts/test/simulateInterest.ts --network dapptest"
23
+ "deployTestOld": "yarn compile && hardhat run scripts/test/singleOldDaoDeploy.ts --network dapptest && yarn daoUpgrade --network dapptest && yarn daoUpgrade --network dapptest-mainnet && hardhat run scripts/test/simulateInterest.ts --network dapptest",
24
+ "deployTest": "yarn compile && hardhat run scripts/deployFullDAO.ts --network dapptest && hardhat run scripts/deployFullDAO.ts --network dapptest-mainnet && hardhat run scripts/test/simulateInterest.ts --network dapptest"
22
25
  },
23
26
  "files": [
24
27
  "artifacts/contracts",
@@ -60,6 +63,7 @@
60
63
  "@jsier/retrier": "^1.2.4",
61
64
  "@openzeppelin/contracts": "^4.8.0",
62
65
  "@openzeppelin/contracts-upgradeable": "^4.8.0",
66
+ "@openzeppelin/upgrades-core": "1.18.0",
63
67
  "@superfluid-finance/ethereum-contracts": "^1.4.3",
64
68
  "@superfluid-finance/sdk-core": "^0.5.8",
65
69
  "@typechain/hardhat": "^6.1.5",
@@ -1,6 +1,5 @@
1
1
  import { range, chunk, uniq } from "lodash";
2
2
  import { ethers as Ethers } from "hardhat";
3
- import fetch from "node-fetch";
4
3
 
5
4
  const ONE_DAY = 24 * 60 * 60;
6
5
  const ONE_HOUR = 60 * 60;
@@ -1,5 +1,4 @@
1
1
  import { range, sortBy } from "lodash";
2
- import fetch from "node-fetch";
3
2
  import PromisePool from "async-promise-pool";
4
3
  import fs from "fs";
5
4
  import { ethers } from "hardhat";
@@ -33,9 +32,7 @@ const main = async () => {
33
32
  // );
34
33
  // fs.writeFileSync("activeWalletsBalances.json", JSON.stringify(balances));
35
34
 
36
- balances = JSON.parse(
37
- fs.readFileSync("activeWalletsBalances.json").toString()
38
- );
35
+ balances = JSON.parse(fs.readFileSync("activeWalletsBalances.json").toString());
39
36
 
40
37
  const EPOCH = 60 * 60 * 6;
41
38
  const pool = new PromisePool({ concurrency: 30 });
@@ -44,9 +41,7 @@ const main = async () => {
44
41
 
45
42
  const graphQuery = async (start, skip) => {
46
43
  const query = `{
47
- walletStats(first: 1000 skip:${skip} where: { dateAppeared_gte: ${start} dateAppeared_lt:${
48
- start + EPOCH
49
- } }) {
44
+ walletStats(first: 1000 skip:${skip} where: { dateAppeared_gte: ${start} dateAppeared_lt:${start + EPOCH} }) {
50
45
  id
51
46
  dateAppeared
52
47
  balance
@@ -57,16 +52,13 @@ const main = async () => {
57
52
  }`;
58
53
  // console.log({ query });
59
54
  try {
60
- const { data = {}, errors } = await fetch(
61
- "https://api.thegraph.com/subgraphs/name/gooddollar/gooddollarfuse",
62
- {
63
- method: "POST",
64
- headers: {
65
- "Content-Type": "application/json"
66
- },
67
- body: JSON.stringify({ query })
68
- }
69
- ).then(_ => _.json());
55
+ const { data = {}, errors } = await fetch("https://api.thegraph.com/subgraphs/name/gooddollar/gooddollarfuse", {
56
+ method: "POST",
57
+ headers: {
58
+ "Content-Type": "application/json"
59
+ },
60
+ body: JSON.stringify({ query })
61
+ }).then(_ => _.json());
70
62
  errors && console.log({ errors });
71
63
  if (data?.walletStats?.length === 1000) {
72
64
  return data.walletStats.concat(await graphQuery(start, skip + 1000));
@@ -116,9 +108,7 @@ const etl = async () => {
116
108
  .join("\r\n"); // rows starting on new lines
117
109
  }
118
110
 
119
- const balances = JSON.parse(
120
- fs.readFileSync("activeWalletsLastUsed.json").toString()
121
- );
111
+ const balances = JSON.parse(fs.readFileSync("activeWalletsLastUsed.json").toString());
122
112
 
123
113
  let result = [];
124
114
 
@@ -131,24 +121,18 @@ const etl = async () => {
131
121
  }
132
122
  const top100 = result.slice(0, 100);
133
123
  const pool = new PromisePool({ concurrency: 30 });
134
- const provider = new ethers.providers.JsonRpcBatchProvider(
135
- "https://rpc.fuse.io"
136
- );
124
+ const provider = new ethers.providers.JsonRpcBatchProvider("https://rpc.fuse.io");
137
125
 
138
126
  for (let idx in top100) {
139
127
  pool.add(async () => {
140
128
  const record = top100[idx];
141
- let isContract =
142
- (await provider.getCode(record[0]).catch(e => "0x")) !== "0x";
129
+ let isContract = (await provider.getCode(record[0]).catch(e => "0x")) !== "0x";
143
130
  record[3] = isContract;
144
131
  });
145
132
  }
146
133
  await pool.all();
147
134
  console.log({ top100 });
148
- fs.writeFileSync(
149
- "activeWalletsLastUsed.csv",
150
- arrayToCsv(sortBy(result, _ => -Number(_[1])))
151
- );
135
+ fs.writeFileSync("activeWalletsLastUsed.csv", arrayToCsv(sortBy(result, _ => -Number(_[1]))));
152
136
  };
153
137
  // main().catch(e => console.log(e));
154
138
  etl();
@@ -1,6 +1,5 @@
1
1
  import { countBy, chunk, difference, flatten, sortBy } from "lodash";
2
2
  import fs from "fs";
3
- import fetch from "node-fetch";
4
3
  import { network, ethers, upgrades } from "hardhat";
5
4
  import { Contract, Provider, setMulticallAddress } from "ethers-multicall";
6
5
  import Identity from "../../artifacts/contracts/Interfaces.sol/IIdentity.json";
@@ -54,16 +53,11 @@ const hasRefunded = async wallets => {
54
53
  let startBlock = CLAIM_START_BLOCK;
55
54
  while (startBlock <= curBlock) {
56
55
  const events = await gd.queryFilter(
57
- gd.filters.Transfer(
58
- undefined,
59
- "0xd253A5203817225e9768C05E5996d642fb96bA86"
60
- ),
56
+ gd.filters.Transfer(undefined, "0xd253A5203817225e9768C05E5996d642fb96bA86"),
61
57
  startBlock,
62
58
  toBlock
63
59
  );
64
- const accounts = events
65
- .filter(e => e.args.amount >= 9622260)
66
- .map(_ => _.args.from.toLowerCase());
60
+ const accounts = events.filter(e => e.args.amount >= 9622260).map(_ => _.args.from.toLowerCase());
67
61
  refunded.push(...accounts);
68
62
  console.log("has refunded:", {
69
63
  startBlock,
@@ -81,10 +75,7 @@ const whereIsTheMoney = async noBalance => {
81
75
  for (let batch of chunk(noBalance, 100)) {
82
76
  const tos = await Promise.all(
83
77
  batch.map(async a => {
84
- const e = await gd.queryFilter(
85
- gd.filters.Transfer(a),
86
- CLAIM_START_BLOCK
87
- );
78
+ const e = await gd.queryFilter(gd.filters.Transfer(a), CLAIM_START_BLOCK);
88
79
  const tos = e.filter(_ => _.args.amount > 1000000).map(_ => _.args.to);
89
80
  return tos;
90
81
  })
@@ -92,24 +83,14 @@ const whereIsTheMoney = async noBalance => {
92
83
  targets.push(...flatten(tos));
93
84
  }
94
85
  const targetCounter = countBy(targets, _ => _);
95
- console.log(
96
- "transfer targets:",
97
- sortBy(Object.entries(targetCounter), "1").reverse()
98
- );
86
+ console.log("transfer targets:", sortBy(Object.entries(targetCounter), "1").reverse());
99
87
  };
100
88
  const main = async () => {
101
- const wallets = JSON.parse(fs.readFileSync("torefund.json").toString()).map(
102
- _ => _.toLowerCase()
103
- );
89
+ const wallets = JSON.parse(fs.readFileSync("torefund.json").toString()).map(_ => _.toLowerCase());
104
90
  console.log("Total Claimed:", wallets.length);
105
91
  const refunded = await hasRefunded(wallets);
106
92
  const notRefunded = difference(wallets, refunded);
107
- console.log(
108
- "refunded:",
109
- refunded.length,
110
- "not refunded:",
111
- notRefunded.length
112
- );
93
+ console.log("refunded:", refunded.length, "not refunded:", notRefunded.length);
113
94
 
114
95
  const noBalanceToRefund = await hasBalanceToRefund(notRefunded);
115
96
  await whereIsTheMoney(noBalanceToRefund);
@@ -1,5 +1,4 @@
1
1
  import { range, sortBy, toPairs } from "lodash";
2
- import fetch from "node-fetch";
3
2
  import PromisePool from "async-promise-pool";
4
3
  import fs from "fs";
5
4
  import { ethers } from "hardhat";
@@ -37,14 +36,7 @@ const main = async () => {
37
36
  const dailyBalance = [];
38
37
  for (let day of days) {
39
38
  dailyBalance.push(
40
- (
41
- await archive.getBalance(
42
- "0x01ab5966C1d742Ae0CFF7f14cC0F4D85156e83d9",
43
- day
44
- )
45
- )
46
- .div(1e10)
47
- .toNumber() / 1e8
39
+ (await archive.getBalance("0x01ab5966C1d742Ae0CFF7f14cC0F4D85156e83d9", day)).div(1e10).toNumber() / 1e8
48
40
  );
49
41
  }
50
42
  let curBlock = startBlock;
@@ -60,19 +52,15 @@ const main = async () => {
60
52
  const toBlock = Math.min(fromBlock + blockStep, endBlock);
61
53
  pool.add(async () => {
62
54
  const f = faucet.filters.WalletTopped();
63
- const events = await faucet
64
- .queryFilter(f, fromBlock, toBlock)
65
- .catch(e => {
66
- console.log("failed", { fromBlock, toBlock });
67
- return [];
68
- });
55
+ const events = await faucet.queryFilter(f, fromBlock, toBlock).catch(e => {
56
+ console.log("failed", { fromBlock, toBlock });
57
+ return [];
58
+ });
69
59
  events.forEach(e => {
70
60
  totalToppings += 1;
71
61
  totalAmount += Number(e.args.amount);
72
- toppingsByAddress[e.args.user] =
73
- (toppingsByAddress[e.args.user] || 0) + 1;
74
- toppingsByAmount[e.args.amount] =
75
- (toppingsByAmount[e.args.amount] || 0) + 1;
62
+ toppingsByAddress[e.args.user] = (toppingsByAddress[e.args.user] || 0) + 1;
63
+ toppingsByAmount[e.args.amount] = (toppingsByAmount[e.args.amount] || 0) + 1;
76
64
  });
77
65
  console.log("fetched events", {
78
66
  fromBlock,
@@ -1,5 +1,4 @@
1
1
  import { maxBy, range, sortBy, uniq, sum, flatten, countBy } from "lodash";
2
- import fetch from "node-fetch";
3
2
  import PromisePool from "async-promise-pool";
4
3
  import fs from "fs";
5
4
  import { ethers } from "hardhat";
@@ -39,10 +38,9 @@ const main = async () => {
39
38
  const incomingTxs = result
40
39
  .filter(
41
40
  _ =>
42
- [
43
- "0xca2f09c3ccfd7ad5cb9276918bd1868f2b922ea0",
44
- "0xd253a5203817225e9768c05e5996d642fb96ba86"
45
- ].includes(_.from) === false
41
+ ["0xca2f09c3ccfd7ad5cb9276918bd1868f2b922ea0", "0xd253a5203817225e9768c05e5996d642fb96ba86"].includes(
42
+ _.from
43
+ ) === false
46
44
  )
47
45
  .filter(_ => _.to === address.toLowerCase());
48
46
  const totalEarned = sum(incomingTxs.map(_ => Number(_.value))) / 100;
@@ -1,5 +1,4 @@
1
1
  import { last, range, sortBy } from "lodash";
2
- import fetch from "node-fetch";
3
2
  import PromisePool from "async-promise-pool";
4
3
  import fs from "fs";
5
4
  import { ethers } from "hardhat";
@@ -19,16 +18,13 @@ const main = async () => {
19
18
  }`;
20
19
  // console.log({ query });
21
20
  try {
22
- const { data = {}, errors } = await fetch(
23
- "https://api.thegraph.com/subgraphs/name/gooddollar/gooddollarfuse2",
24
- {
25
- method: "POST",
26
- headers: {
27
- "Content-Type": "application/json"
28
- },
29
- body: JSON.stringify({ query })
30
- }
31
- ).then(_ => _.json());
21
+ const { data = {}, errors } = await fetch("https://api.thegraph.com/subgraphs/name/gooddollar/gooddollarfuse2", {
22
+ method: "POST",
23
+ headers: {
24
+ "Content-Type": "application/json"
25
+ },
26
+ body: JSON.stringify({ query })
27
+ }).then(_ => _.json());
32
28
  errors && console.log({ errors });
33
29
  if (data?.goodBalances?.length === 1000) {
34
30
  const nextAddr = last(data?.goodBalances).id;
@@ -1,5 +1,4 @@
1
1
  import { maxBy, range, sortBy, flatten, uniq } from "lodash";
2
- import fetch from "node-fetch";
3
2
  import PromisePool from "async-promise-pool";
4
3
  import fs from "fs";
5
4
  import { Contract, Provider, setMulticallAddress } from "ethers-multicall";
@@ -487,9 +486,7 @@ const allProtocolAddresses: Array<string> = [
487
486
  ];
488
487
 
489
488
  setMulticallAddress(122, "0x3CE6158b7278Bf6792e014FA7B4f3c6c46fe9410");
490
- const fuseProvider = new ethers.providers.WebSocketProvider(
491
- "wss://rpc.gooddollar.org"
492
- );
489
+ const fuseProvider = new ethers.providers.WebSocketProvider("wss://rpc.gooddollar.org");
493
490
  const ethcallProvider = new Provider(fuseProvider, 122);
494
491
 
495
492
  const GD_FUSE = "0x495d133b938596c9984d462f007b676bdc57ecec";
@@ -534,31 +531,16 @@ const main = async () => {
534
531
  )
535
532
  );
536
533
 
537
- const checkWhitelisted = uniq(
538
- flatten(
539
- clean.map(_ => [_.args.from.toLowerCase(), _.args.to.toLowerCase()])
540
- )
541
- );
542
- const calls = checkWhitelisted.map(d =>
543
- identityContract.isWhitelisted(d)
544
- );
534
+ const checkWhitelisted = uniq(flatten(clean.map(_ => [_.args.from.toLowerCase(), _.args.to.toLowerCase()])));
535
+ const calls = checkWhitelisted.map(d => identityContract.isWhitelisted(d));
545
536
  const result = await ethcallProvider.all(calls);
546
537
  const whitelisted = checkWhitelisted.filter((v, i) => result[i]);
547
538
  const p2p = clean.filter(
548
- _ =>
549
- whitelisted.includes(_.args.to.toLowerCase()) ||
550
- whitelisted.includes(_.args.from.toLowerCase())
539
+ _ => whitelisted.includes(_.args.to.toLowerCase()) || whitelisted.includes(_.args.from.toLowerCase())
551
540
  );
552
541
  p2pTxs = p2pTxs.concat(p2p);
553
542
  uniques = uniques.concat(whitelisted);
554
- console.log(
555
- { fromBlock },
556
- results.length,
557
- clean.length,
558
- checkWhitelisted.length,
559
- whitelisted.length,
560
- p2p.length
561
- );
543
+ console.log({ fromBlock }, results.length, clean.length, checkWhitelisted.length, whitelisted.length, p2p.length);
562
544
  });
563
545
  });
564
546
 
@@ -1,5 +1,4 @@
1
1
  import { maxBy, range, sortBy } from "lodash";
2
- import fetch from "node-fetch";
3
2
  import PromisePool from "async-promise-pool";
4
3
  import fs from "fs";
5
4
  import { ethers } from "hardhat";
@@ -43,10 +42,7 @@ const main = async () => {
43
42
  ins.push(r);
44
43
  }
45
44
  });
46
- fs.writeFileSync(
47
- "tokenInOut.json",
48
- JSON.stringify({ incoming, outgoing, ins })
49
- );
45
+ fs.writeFileSync("tokenInOut.json", JSON.stringify({ incoming, outgoing, ins }));
50
46
  };
51
47
 
52
48
  main().catch(e => console.log(e));