@gooddollar/goodprotocol 2.0.25-beta.1 → 2.0.25-beta.2
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/artifacts/abis/FuseStakingV3.min.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentityV2.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IMultichainRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/GoodDollarStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IGovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/IStakingUpgrade.dbg.json +1 -1
- package/artifacts/contracts/governance/GoodDollarStaking.sol/RewardsMinter.dbg.json +1 -1
- package/artifacts/contracts/governance/GovernanceStaking.sol/GovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
- package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV2.sol/IdentityV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesFuseV2.sol/InvitesFuseV2.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/invite/InvitesV2.sol/InvitesV2.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/AaveUSDMockOracle.sol/AaveUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/BatUSDMockOracle.sol/BatUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/CompUsdMockOracle.sol/CompUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DaiEthPriceMockOracle.sol/DaiEthPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionBridgeMock.sol/DistributionBridgeMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/DistributionHelperTest.sol/DistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/EthUSDMockOracle.sol/EthUSDMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/FeesFormularMock.sol/FeesFormulaMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GasPriceMockOracle.sol/GasPriceMockOracle.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodDollarStakingMock.sol/GoodDollarStakingMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/IdentityMock.sol/IdentityMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/IWrapper.dbg.json +1 -1
- package/artifacts/contracts/mocks/MultichainRouterMock.sol/MultichainRouterMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/IGoodDollarStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
- package/artifacts/contracts/mocks/PayableMock.sol/PayableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/StakingMockFixedAPY.sol/StakingMockFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock3.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock4.dbg.json +1 -1
- package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
- package/artifacts/contracts/reserve/DistributionHelper.sol/DistributionHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +7 -2
- package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +1 -1
- package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +1 -1
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/Math64X64.sol/Math64x64.dbg.json +1 -1
- package/artifacts/contracts/staking/utils/StakingRewardsFixedAPY.sol/StakingRewardsFixedAPY.dbg.json +1 -1
- package/artifacts/contracts/token/ERC20PresetMinterPauserUpgradeable.sol/ERC20PresetMinterPauserUpgradeable.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677.dbg.json +1 -1
- package/artifacts/contracts/token/ERC677.sol/ERC677Receiver.dbg.json +1 -1
- package/artifacts/contracts/token/GoodDollar.sol/GoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/IFeesFormula.sol/IFeesFormula.dbg.json +1 -1
- package/artifacts/contracts/token/MultichainFeeFormula.sol/MultichainFeeFormula.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/ERC20Permit.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ERC20Permit.sol/SelfApprove.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/ISuperToken.sol/ISuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperGoodDollar.sol/SuperGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperToken.sol/SuperToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/SuperfluidToken.sol/SuperfluidToken.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxiable.sol/UUPSProxiable.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/Proxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSProxy.dbg.json +1 -1
- package/artifacts/contracts/token/superfluid/UUPSProxy.sol/UUPSUtils.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBISchemeV2.sol/UBISchemeV2.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWallet.sol/AdminWallet.dbg.json +1 -1
- package/artifacts/contracts/utils/AdminWalletFuse.sol/AdminWalletFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/BulkProof.sol/BulkProof.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/BuyGDCloneFactory.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/DonateGDClone.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/IQuoterV2.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyGDClone.sol/ISwapRouter.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
- package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
- package/artifacts/contracts/utils/GDFaucet.sol/GDFaucet.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/GoodDollarMintBurnWrapper.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/IRouter.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/PausableControl.dbg.json +1 -1
- package/artifacts/contracts/utils/GoodDollarMintBurnWrapper.sol/TokenOperation.dbg.json +1 -1
- package/artifacts/contracts/utils/IdentityFix.sol/IdentityFix.dbg.json +1 -1
- package/artifacts/contracts/utils/MultiCall.sol/Multicall.dbg.json +1 -1
- package/artifacts/contracts/utils/MultichainBridgeHelper.sol/MultichainBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePayments.sol/OneTimePayments.dbg.json +1 -1
- package/artifacts/contracts/utils/OneTimePaymentsV2.sol/OneTimePaymentsV2.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/contracts/staking/FuseStakingV3.sol +4 -2
- package/dist/test-sdk/deploySuperGoodDollar.js +1 -1
- package/package.json +3 -2
- package/scripts/analytics/checkBridgeBalances.ts +442 -0
- package/test/staking/FuseStaking.test.ts +23 -54
- package/types/contracts/staking/FuseStakingV3.sol/FuseStakingV3.ts +7 -2
- package/types/factories/contracts/staking/FuseStakingV3.sol/FuseStakingV3__factory.ts +6 -1
- package/contracts/utils/.DS_Store +0 -0
- 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));
|
|
@@ -12,12 +12,7 @@ describe("FuseStakingV3", () => {
|
|
|
12
12
|
let founder, staker1, staker2;
|
|
13
13
|
let signers;
|
|
14
14
|
|
|
15
|
-
let uniswap: waffle.MockContract,
|
|
16
|
-
uniswapFactory,
|
|
17
|
-
uniswapPair,
|
|
18
|
-
gdusdcPair,
|
|
19
|
-
fusefusdPair,
|
|
20
|
-
ubiMock;
|
|
15
|
+
let uniswap: waffle.MockContract, uniswapFactory, uniswapPair, gdusdcPair, fusefusdPair, ubiMock;
|
|
21
16
|
|
|
22
17
|
const deployMocks = async () => {
|
|
23
18
|
let u = await hre.artifacts.readArtifact("Uniswap");
|
|
@@ -35,24 +30,14 @@ describe("FuseStakingV3", () => {
|
|
|
35
30
|
await uniswap.mock.WETH.returns(signers[3].address);
|
|
36
31
|
await uniswapFactory.mock.getPair.returns(uniswapPair.address);
|
|
37
32
|
await uniswapFactory.mock.getPair
|
|
38
|
-
.withArgs(
|
|
39
|
-
ethers.constants.AddressZero,
|
|
40
|
-
"0x620fd5fa44BE6af63715Ef4E65DDFA0387aD13F5"
|
|
41
|
-
)
|
|
33
|
+
.withArgs(ethers.constants.AddressZero, "0x620fd5fa44BE6af63715Ef4E65DDFA0387aD13F5")
|
|
42
34
|
.returns(gdusdcPair.address);
|
|
43
35
|
|
|
44
36
|
await uniswapFactory.mock.getPair
|
|
45
|
-
.withArgs(
|
|
46
|
-
signers[3].address,
|
|
47
|
-
"0x249BE57637D8B013Ad64785404b24aeBaE9B098B"
|
|
48
|
-
)
|
|
37
|
+
.withArgs(signers[3].address, "0x249BE57637D8B013Ad64785404b24aeBaE9B098B")
|
|
49
38
|
.returns(fusefusdPair.address);
|
|
50
39
|
|
|
51
|
-
await uniswapPair.mock.getReserves.returns(
|
|
52
|
-
ethers.utils.parseEther("1000"),
|
|
53
|
-
"100000",
|
|
54
|
-
"0"
|
|
55
|
-
);
|
|
40
|
+
await uniswapPair.mock.getReserves.returns(ethers.utils.parseEther("1000"), "100000", "0");
|
|
56
41
|
await gdusdcPair.mock.getReserves.returns("4984886100", "10789000000", "0");
|
|
57
42
|
await fusefusdPair.mock.getReserves.returns(
|
|
58
43
|
ethers.utils.parseEther("10000"),
|
|
@@ -67,9 +52,7 @@ describe("FuseStakingV3", () => {
|
|
|
67
52
|
await deployMocks();
|
|
68
53
|
|
|
69
54
|
let network = networkConfig.name;
|
|
70
|
-
staking = (await (
|
|
71
|
-
await ethers.getContractFactory("FuseStakingV3")
|
|
72
|
-
).deploy()) as FuseStakingV3;
|
|
55
|
+
staking = (await (await ethers.getContractFactory("FuseStakingV3")).deploy()) as FuseStakingV3;
|
|
73
56
|
|
|
74
57
|
await staking.initialize(uniswap.address, NULL_ADDRESS);
|
|
75
58
|
await staking.setUBIScheme(ubiMock.address);
|
|
@@ -80,54 +63,42 @@ describe("FuseStakingV3", () => {
|
|
|
80
63
|
});
|
|
81
64
|
|
|
82
65
|
it("should calc quantity with slippage", async () => {
|
|
83
|
-
const res = await staking[
|
|
84
|
-
"
|
|
85
|
-
|
|
66
|
+
const res = await staking["calcMaxTokenWithPriceImpact(uint256,uint256,uint256)"](
|
|
67
|
+
"6917100025787759640000",
|
|
68
|
+
"265724494",
|
|
69
|
+
ethers.utils.parseEther("500")
|
|
70
|
+
);
|
|
86
71
|
|
|
87
72
|
// const fuseQuantity = ethers.utils.formatEther(res);
|
|
88
73
|
expect(res.maxToken).to.gt(0);
|
|
89
|
-
expect(res.maxToken).to.equal(
|
|
90
|
-
|
|
91
|
-
);
|
|
92
|
-
expect(res.tokenOut).to.equal(7717004);
|
|
74
|
+
expect(res.maxToken).to.equal(BigNumber.from("6917100025787759640000").mul(6).div(1000));
|
|
75
|
+
expect(res.tokenOut).to.equal(1580111);
|
|
93
76
|
});
|
|
94
77
|
|
|
95
78
|
it("should calc quantity with uniswap mock", async () => {
|
|
96
|
-
const res = await staking["calcMaxFuseWithPriceImpact(uint256)"](
|
|
97
|
-
ethers.utils.parseEther("500")
|
|
98
|
-
);
|
|
79
|
+
const res = await staking["calcMaxFuseWithPriceImpact(uint256)"](ethers.utils.parseEther("500"));
|
|
99
80
|
|
|
100
81
|
// const fuseQuantity = ethers.utils.formatEther(res);
|
|
101
82
|
expect(res.fuseAmount).to.gt(0);
|
|
102
|
-
expect(res.fuseAmount).to.equal(ethers.utils.parseEther("
|
|
83
|
+
expect(res.fuseAmount).to.equal(ethers.utils.parseEther("6"));
|
|
103
84
|
|
|
104
|
-
await uniswapPair.mock.getReserves.returns(
|
|
105
|
-
|
|
106
|
-
"500000",
|
|
107
|
-
"0"
|
|
108
|
-
);
|
|
109
|
-
const res2 = await staking["calcMaxFuseWithPriceImpact(uint256)"](
|
|
110
|
-
ethers.utils.parseEther("500")
|
|
111
|
-
);
|
|
85
|
+
await uniswapPair.mock.getReserves.returns(ethers.utils.parseEther("100"), "500000", "0");
|
|
86
|
+
const res2 = await staking["calcMaxFuseWithPriceImpact(uint256)"](ethers.utils.parseEther("500"));
|
|
112
87
|
|
|
113
|
-
expect(res2.fuseAmount).to.equal(ethers.utils.parseEther("
|
|
88
|
+
expect(res2.fuseAmount).to.equal(ethers.utils.parseEther("0.6"));
|
|
114
89
|
});
|
|
115
90
|
|
|
116
91
|
it("should calculate gd/usdc quantity with 0 price impact ", async () => {
|
|
117
|
-
const res = await staking["calcMaxFuseUSDCWithPriceImpact(uint256)"](
|
|
118
|
-
ethers.utils.parseEther("10")
|
|
119
|
-
);
|
|
92
|
+
const res = await staking["calcMaxFuseUSDCWithPriceImpact(uint256)"](ethers.utils.parseEther("10"));
|
|
120
93
|
//exchanging 10 fuse which are equal 2$ USDC should have no significant price impact on usdc/gd swap so we should be able to swap the whole 10
|
|
121
94
|
expect(res.maxFuse).to.gt(0);
|
|
122
95
|
expect(res.maxFuse).to.equal(ethers.utils.parseEther("10"));
|
|
123
96
|
});
|
|
124
97
|
|
|
125
98
|
it("should detect gd/usdc price impact", async () => {
|
|
126
|
-
const res = await staking["calcMaxFuseUSDCWithPriceImpact(uint256)"](
|
|
127
|
-
ethers.utils.parseEther("10000")
|
|
128
|
-
);
|
|
99
|
+
const res = await staking["calcMaxFuseUSDCWithPriceImpact(uint256)"](ethers.utils.parseEther("10000"));
|
|
129
100
|
expect(res.maxFuse).to.lt(ethers.utils.parseEther("10000"));
|
|
130
|
-
expect(res.maxFuse).to.equal(ethers.utils.parseEther("
|
|
101
|
+
expect(res.maxFuse).to.equal(ethers.utils.parseEther("323.67")); //on fuse swap it was around 335$ on above gd/usdc reserves that reaches 3% impact, that means 335*5=1675fuse
|
|
131
102
|
});
|
|
132
103
|
|
|
133
104
|
it("should match fuseswap and allow to exchange +-4600 fuse to G$", async () => {
|
|
@@ -141,10 +112,8 @@ describe("FuseStakingV3", () => {
|
|
|
141
112
|
"0"
|
|
142
113
|
);
|
|
143
114
|
|
|
144
|
-
const res = await staking["calcMaxFuseUSDCWithPriceImpact(uint256)"](
|
|
145
|
-
|
|
146
|
-
);
|
|
147
|
-
expect(res.maxFuse).to.lt(ethers.utils.parseEther("5000"));
|
|
148
|
-
expect(res.maxFuse).to.gt(ethers.utils.parseEther("4500"));
|
|
115
|
+
const res = await staking["calcMaxFuseUSDCWithPriceImpact(uint256)"](ethers.utils.parseEther("10000"));
|
|
116
|
+
expect(res.maxFuse).to.lt(ethers.utils.parseEther("1000"));
|
|
117
|
+
expect(res.maxFuse).to.gt(ethers.utils.parseEther("450"));
|
|
149
118
|
});
|
|
150
119
|
});
|
|
@@ -70,7 +70,7 @@ export interface FuseStakingV3Interface extends utils.Interface {
|
|
|
70
70
|
"uniswap()": FunctionFragment;
|
|
71
71
|
"uniswapFactory()": FunctionFragment;
|
|
72
72
|
"uniswapPair()": FunctionFragment;
|
|
73
|
-
"updateSettings(uint256,uint256)": FunctionFragment;
|
|
73
|
+
"updateSettings(uint256,uint256,uint256)": FunctionFragment;
|
|
74
74
|
"upgrade()": FunctionFragment;
|
|
75
75
|
"validators(uint256)": FunctionFragment;
|
|
76
76
|
"withdraw(uint256)": FunctionFragment;
|
|
@@ -245,7 +245,7 @@ export interface FuseStakingV3Interface extends utils.Interface {
|
|
|
245
245
|
): string;
|
|
246
246
|
encodeFunctionData(
|
|
247
247
|
functionFragment: "updateSettings",
|
|
248
|
-
values: [BigNumberish, BigNumberish]
|
|
248
|
+
values: [BigNumberish, BigNumberish, BigNumberish]
|
|
249
249
|
): string;
|
|
250
250
|
encodeFunctionData(functionFragment: "upgrade", values?: undefined): string;
|
|
251
251
|
encodeFunctionData(
|
|
@@ -608,6 +608,7 @@ export interface FuseStakingV3 extends BaseContract {
|
|
|
608
608
|
updateSettings(
|
|
609
609
|
_stakeBackRatio: BigNumberish,
|
|
610
610
|
_communityPoolRatio: BigNumberish,
|
|
611
|
+
_maxSlippageRatio: BigNumberish,
|
|
611
612
|
overrides?: Overrides & { from?: string }
|
|
612
613
|
): Promise<ContractTransaction>;
|
|
613
614
|
|
|
@@ -767,6 +768,7 @@ export interface FuseStakingV3 extends BaseContract {
|
|
|
767
768
|
updateSettings(
|
|
768
769
|
_stakeBackRatio: BigNumberish,
|
|
769
770
|
_communityPoolRatio: BigNumberish,
|
|
771
|
+
_maxSlippageRatio: BigNumberish,
|
|
770
772
|
overrides?: Overrides & { from?: string }
|
|
771
773
|
): Promise<ContractTransaction>;
|
|
772
774
|
|
|
@@ -905,6 +907,7 @@ export interface FuseStakingV3 extends BaseContract {
|
|
|
905
907
|
updateSettings(
|
|
906
908
|
_stakeBackRatio: BigNumberish,
|
|
907
909
|
_communityPoolRatio: BigNumberish,
|
|
910
|
+
_maxSlippageRatio: BigNumberish,
|
|
908
911
|
overrides?: CallOverrides
|
|
909
912
|
): Promise<void>;
|
|
910
913
|
|
|
@@ -1087,6 +1090,7 @@ export interface FuseStakingV3 extends BaseContract {
|
|
|
1087
1090
|
updateSettings(
|
|
1088
1091
|
_stakeBackRatio: BigNumberish,
|
|
1089
1092
|
_communityPoolRatio: BigNumberish,
|
|
1093
|
+
_maxSlippageRatio: BigNumberish,
|
|
1090
1094
|
overrides?: Overrides & { from?: string }
|
|
1091
1095
|
): Promise<BigNumber>;
|
|
1092
1096
|
|
|
@@ -1251,6 +1255,7 @@ export interface FuseStakingV3 extends BaseContract {
|
|
|
1251
1255
|
updateSettings(
|
|
1252
1256
|
_stakeBackRatio: BigNumberish,
|
|
1253
1257
|
_communityPoolRatio: BigNumberish,
|
|
1258
|
+
_maxSlippageRatio: BigNumberish,
|
|
1254
1259
|
overrides?: Overrides & { from?: string }
|
|
1255
1260
|
): Promise<PopulatedTransaction>;
|
|
1256
1261
|
|