@gooddollar/goodprotocol 2.0.25-beta.1 → 2.0.25-beta.3

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.
Files changed (182) hide show
  1. package/artifacts/abis/FuseStakingV3.min.json +1 -1
  2. package/artifacts/abis/InvitesV2.min.json +1 -1
  3. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  4. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  5. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  6. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  7. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  8. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  9. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  10. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  11. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  12. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  13. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  28. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  29. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  30. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  31. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  32. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
  33. package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  34. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
  35. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  36. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  37. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  38. package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
  39. package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
  40. package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
  41. package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
  42. package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  43. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  44. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  45. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  46. package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
  47. package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
  48. package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  49. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
  50. package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.json +15 -2
  51. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  52. package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
  53. package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
  54. package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  56. package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
  57. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  58. package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
  59. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
  60. package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
  61. package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
  62. package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
  63. package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
  64. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  65. package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
  66. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  67. package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
  68. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  69. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  70. package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
  71. package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
  72. package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
  73. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  74. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  75. package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
  76. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  77. package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
  78. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  79. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  80. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  81. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  82. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
  83. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
  84. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  85. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  86. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  87. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  88. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  89. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  90. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  91. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  92. package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
  93. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  94. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  95. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  96. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  97. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  98. package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
  99. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  100. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
  101. package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +7 -2
  102. package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
  103. package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
  104. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  105. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  106. package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
  107. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  108. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  109. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  110. package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
  111. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  112. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  113. package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
  114. package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
  115. package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
  116. package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
  117. package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
  118. package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
  119. package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
  120. package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
  121. package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
  122. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
  123. package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
  124. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
  125. package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
  126. package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
  127. package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
  128. package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
  129. package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
  130. package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
  131. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
  132. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
  133. package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
  134. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  135. package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
  136. package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
  137. package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
  138. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  139. package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
  140. package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
  141. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
  142. package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
  143. package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
  144. package/artifacts/contracts/utils/BuyGDClone.sol/IQuoterV2.dbg.json +1 -1
  145. package/artifacts/contracts/utils/BuyGDClone.sol/ISwapRouter.dbg.json +1 -1
  146. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  147. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  148. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  149. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  150. package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
  151. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
  152. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
  153. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
  154. package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
  155. package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
  156. package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
  157. package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
  158. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  159. package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
  160. package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
  161. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  162. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  163. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  164. package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
  165. package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
  166. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  167. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  168. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  169. package/contracts/invite/InvitesV2.sol +41 -4
  170. package/contracts/staking/FuseStakingV3.sol +4 -2
  171. package/dist/test-sdk/deploySuperGoodDollar.js +1 -1
  172. package/package.json +3 -2
  173. package/scripts/analytics/activeWalletsStats.ts +51 -38
  174. package/scripts/analytics/checkBridgeBalances.ts +442 -0
  175. package/test/invite/InvitesV2.test.ts +139 -271
  176. package/test/staking/FuseStaking.test.ts +23 -54
  177. package/types/contracts/invite/InvitesV2.ts +32 -0
  178. package/types/contracts/staking/FuseStakingV3.sol/FuseStakingV3.ts +7 -2
  179. package/types/factories/contracts/invite/InvitesV2__factory.ts +14 -1
  180. package/types/factories/contracts/staking/FuseStakingV3.sol/FuseStakingV3__factory.ts +6 -1
  181. package/contracts/utils/.DS_Store +0 -0
  182. package/yarn.lock +0 -23715
@@ -0,0 +1,442 @@
1
+ import { groupBy, range, sortBy } from "lodash";
2
+ import PromisePool from "async-promise-pool";
3
+ import fs from "fs";
4
+ import { Provider, setMulticallAddress } from "ethers-multicall";
5
+
6
+ import { ethers } from "hardhat";
7
+ import { Retrier } from "@jsier/retrier";
8
+ import { BigNumber } from "ethers";
9
+ import EthDater from "ethereum-block-by-date";
10
+
11
+ setMulticallAddress(122, "0x3CE6158b7278Bf6792e014FA7B4f3c6c46fe9410");
12
+ // "https://celo-mainnet-archive.allthatnode.com" : "https://explorer-node.fuse.io"
13
+
14
+ const celoProvider = new ethers.providers.JsonRpcProvider("https://celo-mainnet-archive.allthatnode.com");
15
+ const fuseProvider = new ethers.providers.JsonRpcProvider("https://explorer-node.fuse.io");
16
+ const ethProvider = new ethers.providers.JsonRpcProvider("https://ethereum-mainnet-archive.allthatnode.com");
17
+
18
+ const GD_CELO = "0x62B8B11039FcfE5aB0C56E502b1C372A3d2a9c7A";
19
+ const GD_FUSE = "0x495d133B938596C9984d462F007B676bDc57eCEC";
20
+ const GD_ETH = "0x67C5870b4A41D4Ebef24d2456547A03F1f3e094B";
21
+ const ETH_BRIDGES = [
22
+ "0xd17652350cfd2a37ba2f947c910987a3b1a1c60d",
23
+ "0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5",
24
+ "0xD5D11eE582c8931F336fbcd135e98CEE4DB8CCB0",
25
+ "0x17B09b22823F00BB9b8ee2d4632E332cadC29458"
26
+ ];
27
+
28
+ const CELO_MULTIBRIDGE = "0xf27Ee99622C3C9b264583dACB2cCE056e194494f";
29
+ const CELO_MPBBRIDGE = "0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5";
30
+ let gd = new ethers.Contract(
31
+ GD_CELO,
32
+ [
33
+ "event Transfer(address indexed from, address indexed to, uint amount)",
34
+ "function balanceOf(address) view returns(uint256)",
35
+ "function totalSupply() view returns(uint256)"
36
+ ],
37
+ celoProvider
38
+ );
39
+
40
+ const multiBridge = new ethers.Contract(
41
+ CELO_MULTIBRIDGE,
42
+ [
43
+ "event LogAnySwapOut(address indexed token,address indexed from,address indexed to,uint256 amount,uint256 fromChainID,uint256 toChainID)",
44
+ "event LogAnySwapIn(bytes32 indexed txhash,address indexed token,address indexed to,uint256 amount,uint256 fromChainID, uint256 toChainID)"
45
+ ],
46
+ celoProvider
47
+ );
48
+
49
+ const mpbBridge = new ethers.Contract(
50
+ CELO_MPBBRIDGE,
51
+ [
52
+ "event BridgeRequest(address indexed from,address indexed to,uint256 targetChainId,uint256 normalizedAmount,uint256 timestamp,uint8 bridge,uint256 indexed id)",
53
+ "event ExecutedTransfer(address indexed from,address indexed to,uint256 normalizedAmount,uint256 fee,uint256 sourceChainId,uint8 bridge,uint256 indexed id)"
54
+ ],
55
+ celoProvider
56
+ );
57
+ const main = async () => {
58
+ console.log("starting...");
59
+
60
+ // let mintFuse = await getTransferEvents(
61
+ // gd.connect(new ethers.providers.JsonRpcProvider("https://rpc.fuse.io")).attach(GD_FUSE),
62
+ // ethers.constants.AddressZero,
63
+ // 6000000,
64
+ // undefined
65
+ // );
66
+ // fs.writeFileSync("mintFuse.json", JSON.stringify(mintFuse, null, 2));
67
+ // mintFuse.forEach(log => (log.amount = log.args.amount.toString()));
68
+
69
+ // const mintFuse = JSON.parse(fs.readFileSync("mintFuse.json").toString());
70
+
71
+ // let mintCelo = await getTransferEvents(gd, ethers.constants.AddressZero, 17000000, undefined);
72
+ // fs.writeFileSync("mintCelo.json", JSON.stringify(mintCelo, null, 2));
73
+
74
+ if (false) {
75
+ let multiOut = await fetch(
76
+ "https://explorer.celo.org/mainnet/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xf27Ee99622C3C9b264583dACB2cCE056e194494f&topic0=0x97116cf6cd4f6412bb47914d6db18da9e16ab2142f543b86e207c24fbd16b23a&topic1=0x0000000000000000000000005566b6e4962ba83e05a426ad89031ec18e9cadd3&topic0_1_opr=and"
77
+ )
78
+ .then(_ => _.json())
79
+ .then(_ => _.result);
80
+
81
+ console.log("multiOut");
82
+ let multiIn = await fetch(
83
+ "https://explorer.celo.org/mainnet/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xf27Ee99622C3C9b264583dACB2cCE056e194494f&topic0=0xaac9ce45fe3adf5143598c4f18a369591a20a3384aedaf1b525d29127e1fcd55&topic2=0x0000000000000000000000005566b6e4962ba83e05a426ad89031ec18e9cadd3&topic0_2_opr=and"
84
+ )
85
+ .then(_ => _.json())
86
+ .then(_ => _.result);
87
+
88
+ console.log("multiIn");
89
+ let multiInFuse = await fetch(
90
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0x735aBE48e8782948a37C7765ECb76b98CdE97B0F&topic0=0xaac9ce45fe3adf5143598c4f18a369591a20a3384aedaf1b525d29127e1fcd55&topic2=0x000000000000000000000000031b2b7c7854dd8ee9c4a644d7e54ad17f56e3cb&topic0_2_opr=and"
91
+ )
92
+ .then(_ => _.json())
93
+ .then(_ => _.result);
94
+
95
+ console.log("multiInFuse");
96
+ let multiOutFuse = await fetch(
97
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0x735aBE48e8782948a37C7765ECb76b98CdE97B0F&topic0=0x97116cf6cd4f6412bb47914d6db18da9e16ab2142f543b86e207c24fbd16b23a&topic1=0x000000000000000000000000031b2b7c7854dd8ee9c4a644d7e54ad17f56e3cb&topic0_1_opr=and"
98
+ )
99
+ .then(_ => _.json())
100
+ .then(_ => _.result);
101
+
102
+ console.log("multiOutFuse");
103
+ let mpbOut = await fetch(
104
+ "https://explorer.celo.org/mainnet/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5&topic0=0xabeeb7182c7294cd8efcd40e9ff952c1b759c2165b3634aac589429de5d55ad0"
105
+ )
106
+ .then(_ => _.json())
107
+ .then(_ => _.result);
108
+
109
+ console.log("mpbOut");
110
+ let mpbIn = await fetch(
111
+ "https://explorer.celo.org/mainnet/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5&topic0=0x6cf712ce908185c8c38a073b7315f79687e7440fb057d9d1ca76a2509a1282ee"
112
+ )
113
+ .then(_ => _.json())
114
+ .then(_ => _.result);
115
+
116
+ console.log("mpbIn");
117
+ let mpbOutFuse = await fetch(
118
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5&topic0=0xabeeb7182c7294cd8efcd40e9ff952c1b759c2165b3634aac589429de5d55ad0"
119
+ )
120
+ .then(_ => _.json())
121
+ .then(_ => _.result);
122
+
123
+ console.log("mpbOutFuse");
124
+ let mpbInFuse = await fetch(
125
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5&topic0=0x6cf712ce908185c8c38a073b7315f79687e7440fb057d9d1ca76a2509a1282ee"
126
+ )
127
+ .then(_ => _.json())
128
+ .then(_ => _.result);
129
+
130
+ console.log("mpbInFuse");
131
+ let outFuse = await fetch(
132
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0x495d133B938596C9984d462F007B676bDc57eCEC&topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&topic1=0x000000000000000000000000d39021db018e2caeadb4b2e6717d31550e7918d0&topic2=0x0000000000000000000000000000000000000000000000000000000000000000&topic1_2_opr=and&topic0_1_opr=and&topic0_2_opr=and"
133
+ )
134
+ .then(_ => _.json())
135
+ .then(_ => _.result);
136
+
137
+ console.log("outFuse");
138
+ let inFuse = await fetch(
139
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xD39021DB018E2CAEadb4B2e6717D31550e7918D0&topic0=0x2f9a6098d4503a127779ba975f5f6b04f842362b1809f346989e9abc0b4dedb6"
140
+ )
141
+ .then(_ => _.json())
142
+ .then(_ => _.result);
143
+
144
+ console.log("inFuse");
145
+
146
+ let outFuse2 = await fetch(
147
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0x495d133B938596C9984d462F007B676bDc57eCEC&topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef&topic1=0x000000000000000000000000e24957CB0f0001A03314C72E6EBC331436e2f7F60&topic2=0x0000000000000000000000000000000000000000000000000000000000000000&topic1_2_opr=and&topic0_1_opr=and&topic0_2_opr=and"
148
+ )
149
+ .then(_ => _.json())
150
+ .then(_ => _.result);
151
+
152
+ console.log("outFuse");
153
+ let inFuse2 = await fetch(
154
+ "https://explorer.fuse.io/api?module=logs&action=getLogs&fromBlock=0&toBlock=latest&address=0xe24957CB0f0001A03314C72E6EBC331436e2f7F6&topic0=0x6fc115a803b8703117d9a3956c5a15401cb42401f91630f015eb6b043fa76253"
155
+ )
156
+ .then(_ => _.json())
157
+ .then(_ => _.result);
158
+
159
+ mpbIn.forEach(log => {
160
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256", "uint8"], log.data);
161
+ log.amount = log.params[0];
162
+ });
163
+ mpbOut.forEach(log => {
164
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256", "uint8"], log.data);
165
+ log.amountOut = log.params[1];
166
+ });
167
+ mpbInFuse.forEach(log => {
168
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256", "uint8"], log.data);
169
+ log.amount = log.params[0];
170
+ });
171
+ mpbOutFuse.forEach(log => {
172
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256", "uint8"], log.data);
173
+ log.amountOut = log.params[1];
174
+ });
175
+
176
+ multiIn.forEach(log => {
177
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256"], log.data);
178
+ log.amount = log.params[0];
179
+ });
180
+ multiOut.forEach(log => {
181
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256"], log.data);
182
+ log.amountOut = log.params[0];
183
+ });
184
+
185
+ multiInFuse.forEach(log => {
186
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256"], log.data);
187
+ log.amount = log.params[0];
188
+ });
189
+ multiOutFuse.forEach(log => {
190
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256", "uint256", "uint256"], log.data);
191
+ log.amountOut = log.params[0];
192
+ });
193
+
194
+ inFuse.forEach(log => {
195
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256"], log.data);
196
+ log.amount = log.params[0];
197
+ });
198
+ outFuse.forEach(log => {
199
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256"], log.data);
200
+ log.amountOut = log.params[0];
201
+ });
202
+
203
+ outFuse2.forEach(log => {
204
+ log.params = ethers.utils.defaultAbiCoder.decode(["uint256"], log.data);
205
+ log.amountOut = log.params[0];
206
+ });
207
+ inFuse2.forEach(log => {
208
+ log.params = ethers.utils.defaultAbiCoder.decode(["address", "uint256", "bytes32"], log.data);
209
+ log.amount = log.params[1];
210
+ });
211
+
212
+ // console.log({
213
+ // mpbOut: mpbOut.length,
214
+ // mpbIn: mpbIn.length,
215
+ // multiOut: multiOut.length,
216
+ // multiIn: multiIn.length,
217
+ // multiInFuse: multiInFuse.length,
218
+ // multiOutFuse: multiOutFuse.length,
219
+ // mpbInFuse: mpbInFuse.length,
220
+ // mpbOutFuse: mpbOutFuse.length,
221
+ // inFuse: inFuse.length,
222
+ // outFuse: outFuse.length,
223
+ // inFuse2: inFuse2.length,
224
+ // outFuse2: outFuse2.length
225
+ // // mintFuse: mintFuse.length
226
+ // });
227
+
228
+ // // const found = []
229
+ // // .concat(mpbIn, multiIn, multiInFuse, mpbInFuse, inFuse)
230
+ // // .filter(_ => _.params[0].gt(ethers.constants.WeiPerEther.mul(180000000)));
231
+
232
+ // const found = [].concat(mpbIn, multiIn, multiInFuse, mpbInFuse, inFuse, inFuse2);
233
+
234
+ // const bytx = Object.entries(groupBy(found, _ => _.transactionHash)).filter((k, v) => (v as any).length > 1);
235
+
236
+ // console.log({ bytx });
237
+
238
+ // // const bridgeMintsTxs = found.map(_ => _.transactionHash);
239
+ // // const nonBridgeMints = mintCelo.filter(l => !bridgeMintsTxs.includes(l.transactionHash));
240
+ // // console.log(
241
+ // // "nonbridgemints celo:",
242
+ // // nonBridgeMints.map(_ => _.transactionHash)
243
+ // // );
244
+ // // return;
245
+
246
+ // let totalMpbOut = mpbOut
247
+ // .filter(_ => _.params[0].eq(1))
248
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[1])), ethers.constants.Zero);
249
+
250
+ // let totalMpbIn = mpbIn
251
+ // .filter(_ => _.params[2].eq(1))
252
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])), ethers.constants.Zero);
253
+
254
+ // totalMpbOut = mpbOutFuse
255
+ // .filter(_ => _.params[0].eq(1))
256
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[1])), totalMpbOut);
257
+
258
+ // totalMpbIn = mpbInFuse
259
+ // .filter(_ => _.params[2].eq(1))
260
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])), totalMpbIn);
261
+
262
+ // let totalMultiOut = multiOut
263
+ // .filter(l => l.params[2].eq(1))
264
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])), ethers.constants.Zero);
265
+
266
+ // let totalMultiIn = multiIn
267
+ // .filter(l => l.params[1].eq(1))
268
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])), ethers.constants.Zero);
269
+
270
+ // totalMultiOut = multiOutFuse
271
+ // .filter(l => l.params[2].eq(1))
272
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])), totalMultiOut);
273
+ // totalMultiIn = multiInFuse
274
+ // .filter(l => l.params[1].eq(1))
275
+ // .reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])), totalMultiIn);
276
+
277
+ // let totalInFuse = inFuse.reduce((prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])), ethers.constants.Zero);
278
+
279
+ // let totalOutFuse = outFuse.reduce(
280
+ // (prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])),
281
+ // ethers.constants.Zero
282
+ // );
283
+
284
+ // let totalInFuse2 = inFuse2.reduce(
285
+ // (prev, cur) => prev.add(ethers.BigNumber.from(cur.params[0])),
286
+ // ethers.constants.Zero
287
+ // );
288
+
289
+ // let totalOutFuse2 = outFuse2.reduce(
290
+ // (prev, cur) => prev.add(ethers.BigNumber.from(cur.params[1])),
291
+ // ethers.constants.Zero
292
+ // );
293
+
294
+ // console.log({
295
+ // totalMpbOut,
296
+ // totalMpbIn,
297
+ // totalMultiOut,
298
+ // totalMultiIn,
299
+ // totalInFuse,
300
+ // totalOutFuse,
301
+ // totalInFuse2,
302
+ // totalOutFuse2
303
+ // });
304
+
305
+ // const all = [].concat(
306
+ // mpbIn.filter(_ => _.params[2].eq(1)),
307
+ // mpbOut.filter(_ => _.params[0].eq(1)),
308
+ // multiIn.filter(l => l.params[1].eq(1)),
309
+ // multiOut.filter(l => l.params[2].eq(1)),
310
+ // multiInFuse.filter(l => l.params[1].eq(1)),
311
+ // multiOutFuse.filter(l => l.params[2].eq(1)),
312
+ // mpbInFuse.filter(_ => _.params[2].eq(1)),
313
+ // mpbOutFuse.filter(_ => _.params[0].eq(1)),
314
+ // inFuse,
315
+ // outFuse,
316
+ // outFuse2,
317
+ // inFuse2
318
+ // );
319
+
320
+ // fs.writeFileSync("allBridgeEvents.json", JSON.stringify(all));
321
+ }
322
+ const all = JSON.parse(fs.readFileSync("allBridgeEvents.json").toString());
323
+
324
+ let counter = 0;
325
+ let total = ethers.constants.Zero;
326
+ const gdEth = gd.connect(ethProvider).attach(GD_ETH);
327
+ const sorted = sortBy(all, _ => Number(_.timeStamp));
328
+ console.log(sorted.slice(0, 10));
329
+
330
+ const ethDater = new EthDater(ethProvider);
331
+ const fuseDater = new EthDater(fuseProvider);
332
+ const celoDater = new EthDater(celoProvider);
333
+
334
+ for (let log of sorted) {
335
+ if (log.amountOut) {
336
+ log.amountOut = ethers.BigNumber.from(log.amountOut.hex);
337
+ total = total.sub(
338
+ log.amountOut.gte(ethers.constants.WeiPerEther)
339
+ ? log.amountOut.div(ethers.constants.WeiPerEther)
340
+ : log.amountOut.div(100)
341
+ );
342
+ }
343
+ if (log.amount) {
344
+ log.amount = ethers.BigNumber.from(log.amount.hex);
345
+ total = total.add(
346
+ log.amount.gte(ethers.constants.WeiPerEther)
347
+ ? log.amount.div(ethers.constants.WeiPerEther)
348
+ : log.amount.div(100)
349
+ );
350
+ }
351
+ counter++;
352
+ if (
353
+ counter >= 1040 ||
354
+ (counter >= 950 && counter % 10 === 0) ||
355
+ counter % 100 === 0 ||
356
+ counter >= sorted.length - 1
357
+ ) {
358
+ // const [tx, tx2] = await Promise.all([
359
+ // fuseProvider.getTransaction(log.transactionHash),
360
+ // celoProvider.getTransaction(log.transactionHash)
361
+ // ]);
362
+ const timestamp = Number(log.timeStamp);
363
+ const [ethBlock, fuseBlock, celoBlock] = await Promise.all([
364
+ ethDater.getDate(timestamp * 1000, false, false),
365
+ fuseDater.getDate(timestamp * 1000, true, false),
366
+ celoDater.getDate(timestamp * 1000, true, false)
367
+ ]);
368
+ console.log("counter:", counter, timestamp, { ethBlock, fuseBlock, celoBlock });
369
+
370
+ const res = await Promise.all(
371
+ ETH_BRIDGES.map(b => gdEth.balanceOf(b, { blockTag: ethBlock.block }).catch(_ => ethers.constants.Zero))
372
+ );
373
+ const [onFuse, onCelo] = await Promise.all([
374
+ gd
375
+ .connect(fuseProvider)
376
+ .attach(GD_FUSE)
377
+ .totalSupply({ blockTag: fuseBlock.block })
378
+ .catch(_ => ethers.constants.Zero),
379
+ gd.totalSupply({ blockTag: celoBlock.block }).catch(_ => ethers.constants.Zero)
380
+ ]);
381
+ const onBridges = res.reduce((prev, cur) => prev.add(cur), ethers.constants.Zero).div(100);
382
+ console.log(
383
+ "bridged:" + total.toString(),
384
+ "on bridges:" + onBridges.toString(),
385
+ "on chains:",
386
+ onCelo.div(ethers.constants.WeiPerEther).add(onFuse.div(100)).toString(),
387
+ "time:",
388
+ timestamp,
389
+ {
390
+ onFuse,
391
+ onCelo
392
+ },
393
+ res.map(_ => _.toString())
394
+ );
395
+ }
396
+ }
397
+ //
398
+
399
+ // console.log(txs.length);
400
+ // fs.writeFileSync("stuckgd.json", JSON.stringify(txs));
401
+ };
402
+
403
+ const getTransferEvents = async (gd, from, fromBlock, toBlock) => {
404
+ const curBlock = toBlock || (await gd.provider.getBlockNumber());
405
+ let txs = [];
406
+ const f = gd.filters.Transfer(from, null);
407
+ const STEP_SIZE = 10000;
408
+ const fromBlocks = range(fromBlock, curBlock, STEP_SIZE);
409
+ const pool = new PromisePool({ concurrency: 2 });
410
+ console.log({ curBlock });
411
+ fromBlocks.forEach(start => {
412
+ pool.add(async () => {
413
+ const options = { limit: 3, delay: 2000 };
414
+ const retrier = new Retrier(options);
415
+
416
+ const results = await retrier
417
+ .resolve(() => gd.queryFilter(f, start, start + STEP_SIZE))
418
+ .catch(e => console.warn("queryfilter failed:", { start }));
419
+ if (!results) return;
420
+
421
+ txs = txs.concat(results);
422
+ console.log({ start }, results.length);
423
+ });
424
+ });
425
+
426
+ await pool.all();
427
+ return txs;
428
+ };
429
+
430
+ // const analyze = () => {
431
+ // const txs = JSON.parse(fs.readFileSync("stuckgd.json").toString());
432
+ // let value = 0;
433
+ // console.log(txs[0]);
434
+ // txs.forEach(tx => {
435
+ // value += Number(tx.args[2].hex);
436
+ // console.log(`erc20,${GD_CELO},${tx.args[0]},${Number(tx.args[2].hex) / 1e18},`);
437
+ // });
438
+ // console.log(txs.length, { value });
439
+ // };
440
+ // analyze();
441
+
442
+ main().catch(e => console.error("Error:", e.message));