@gooddollar/goodprotocol 2.1.4 → 2.2.0-beta.1
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/IdentityV4.min.json +1 -0
- 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/IUniswapV3.sol/INonfungiblePositionManager.dbg.json +1 -1
- package/artifacts/contracts/IUniswapV3.sol/IUniswapV3Pool.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/IQuoterV2.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ISwapRouter.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/MentoInterfaces.sol/IBancorExchangeProvider.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IBroker.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExchangeProvider.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IGoodDollarExpansionController.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/IMentoReserve.dbg.json +1 -1
- package/artifacts/contracts/MentoInterfaces.sol/ITradingLimits.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/fuseFaucet/SuperfluidFacuet.sol/SuperfluidFaucet.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/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/identity/IdentityV3.sol/IdentityV3.dbg.json +1 -1
- package/artifacts/contracts/identity/IdentityV3.sol/IdentityV3.json +2 -2
- package/artifacts/contracts/identity/IdentityV4.sol/IdentityV4.dbg.json +4 -0
- package/artifacts/contracts/identity/IdentityV4.sol/IdentityV4.json +1162 -0
- 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/invite/OneTimeReward.sol/OneTimeReward.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/CeloDistributionHelperTest.sol/CeloDistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/CeloDistributionHelperTest.sol/CeloDistributionHelperTestHelper.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/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/GenericDistributionHelperTest.sol/GenericDistributionHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GenericDistributionHelperTest.sol/GenericDistributionHelperTestHelper.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.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/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/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/CeloDistributionHelper.sol/CeloDistributionHelper.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/GenericDistributionHelper.sol/GenericDistributionHelper.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/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/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/GoodDollar2.sol/GoodDollar2.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/BulkWhitelist.sol/BulkWhitelist.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyAndBridgeHelper.sol/BuyAndBridgeHelper.dbg.json +1 -1
- package/artifacts/contracts/utils/BuyFromReserveHelper.sol/BuyFromReserveHelper.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/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/FuseOldBridgeKill.sol/EternalStorage.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/FuseOldBridgeKill.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/IUpgradeabilityOwnerStorage.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Initializable.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Ownable.dbg.json +1 -1
- package/artifacts/contracts/utils/FuseOldBridgeKill.sol/Upgradeable.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/ProtoclUpgradeV4Mento.sol/MentoExchange.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtoclUpgradeV4Mento.sol/ProtocolUpgradeV4Mento.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/identity/IdentityV3.sol +0 -3
- package/contracts/identity/IdentityV4.sol +578 -0
- package/hardhat.config.ts +3 -4
- package/package.json +8 -4
- package/releases/deployment.json +691 -1
- package/test/governance/ClaimersDistribution.test.ts +1 -1
- package/test/governance/CompoundVotingMachine.castvote.test.ts +30 -30
- package/test/helpers.ts +76 -195
- package/test/identity/IdentityV3.test.ts +53 -129
- package/test/identity/IdentityV4.test.ts +454 -0
- package/test/reserve/GenericDistributionHelper.e2e.test.ts +445 -0
- package/test/utils/AdminWallet.test.ts +14 -15
- package/types/contracts/identity/IdentityV4.ts +2001 -0
- package/types/contracts/identity/index.ts +1 -0
- package/types/contracts/utils/UpdateReserveRatio.sol/MentoExchange.ts +81 -0
- package/types/contracts/utils/UpdateReserveRatio.sol/UpdateReserveRatio.ts +134 -0
- package/types/contracts/utils/UpdateReserveRatio.sol/index.ts +5 -0
- package/types/contracts/utils/UpdateReserveRatioAfterXDC.sol/UpdateReserveRatioAfterXDC.ts +7 -2
- package/types/contracts/utils/index.ts +2 -0
- package/types/factories/contracts/identity/IdentityV3__factory.ts +1 -1
- package/types/factories/contracts/identity/IdentityV4__factory.ts +1213 -0
- package/types/factories/contracts/identity/index.ts +1 -0
- package/types/factories/contracts/utils/UpdateReserveRatio.sol/MentoExchange__factory.ts +39 -0
- package/types/factories/contracts/utils/UpdateReserveRatio.sol/UpdateReserveRatio__factory.ts +113 -0
- package/types/factories/contracts/utils/UpdateReserveRatio.sol/index.ts +5 -0
- package/types/factories/contracts/utils/UpdateReserveRatioAfterXDC.sol/UpdateReserveRatioAfterXDC__factory.ts +9 -15
- package/types/factories/contracts/utils/index.ts +1 -0
- package/types/hardhat.d.ts +27 -0
- package/types/index.ts +4 -0
- package/scripts/ProxyFactory.json +0 -4425
- package/scripts/analytics/activeGDStakers.ts +0 -188
- package/scripts/analytics/activeStakers.ts +0 -25
- package/scripts/analytics/activeUsersCount.ts +0 -156
- package/scripts/analytics/activeWalletsStats.ts +0 -301
- package/scripts/analytics/checkActiveWallets.ts +0 -60
- package/scripts/analytics/checkBridgeBalances.ts +0 -442
- package/scripts/analytics/claimIncidentStats.ts +0 -98
- package/scripts/analytics/faucetStats.ts +0 -130
- package/scripts/analytics/gdinflow.ts +0 -57
- package/scripts/analytics/goodHolders.ts +0 -46
- package/scripts/analytics/goodgiveback.ts +0 -64
- package/scripts/analytics/p2pTxs.ts +0 -564
- package/scripts/analytics/stuckgd.ts +0 -70
- package/scripts/analytics/tokenInOutStats.ts +0 -48
- package/scripts/analytics/whitelistsyncIssue.ts +0 -87
- package/scripts/bulkProof.ts +0 -202
- package/scripts/bulkWhitelist.ts +0 -31
- package/scripts/deployGnosisSafe.ts +0 -111
- package/scripts/fetchOrDeployProxyFactory.ts +0 -46
- package/scripts/fv.ts +0 -263
- package/scripts/gdx/gdxAirdropCalculation.ts +0 -479
- package/scripts/getFounders.ts +0 -32
- package/scripts/governance/README.md +0 -70
- package/scripts/governance/airdropCalculation.ts +0 -1119
- package/scripts/governance/airdropCalculationRecover.ts +0 -416
- package/scripts/governance/airdropCalculationSorted.ts +0 -438
- package/scripts/governance/goodCheckpointSorted.ts +0 -300
- package/scripts/keeper/fishInactive.ts +0 -47
- package/scripts/minimize.sh +0 -17
- package/scripts/multichain-deploy/0_proxyFactory-deploy.ts +0 -131
- package/scripts/multichain-deploy/1_basicdao-deploy.ts +0 -294
- package/scripts/multichain-deploy/2_helpers-deploy.ts +0 -152
- package/scripts/multichain-deploy/2b_otp-deploy.ts +0 -73
- package/scripts/multichain-deploy/3_gdSavings-deploy.ts +0 -190
- package/scripts/multichain-deploy/4_ubi-deploy.ts +0 -129
- package/scripts/multichain-deploy/5_gov-deploy.ts +0 -179
- package/scripts/multichain-deploy/6_testnetFaucet.ts +0 -85
- package/scripts/multichain-deploy/7_superfluidfaucet-deploy.ts +0 -123
- package/scripts/multichain-deploy/8_disthelper-deploy.ts +0 -152
- package/scripts/multichain-deploy/createUniswapTestPools.ts +0 -163
- package/scripts/multichain-deploy/flattened/Avatar.sol +0 -913
- package/scripts/multichain-deploy/flattened/Controller.sol +0 -1891
- package/scripts/multichain-deploy/flattened/FeeFormula.sol +0 -1290
- package/scripts/multichain-deploy/fulldeploy.sh +0 -26
- package/scripts/multichain-deploy/helpers.ts +0 -647
- package/scripts/multichain-deploy/multichainWrapper-deploy.ts +0 -59
- package/scripts/multichain-deploy/verifyEtherscan.ts +0 -177
- package/scripts/proposals/gip-14_1.ts +0 -251
- package/scripts/proposals/gip-15.ts +0 -427
- package/scripts/proposals/gip-25-xdc-upgrade-ubi.ts +0 -746
- package/scripts/proposals/gips-14_1.md +0 -29
- package/scripts/proposals/hack-ubi-recovery.ts +0 -414
- package/scripts/proposals/identityAuthPeriod.ts +0 -229
- package/scripts/proposals/reserveRestore.ts +0 -474
- package/scripts/proposals/updateDistHelper.ts +0 -180
- package/scripts/proposals/v4Upgrade.ts +0 -845
- package/scripts/releaser.js +0 -24
- package/scripts/staking/stakersGdRewardsCalculation.ts +0 -64
- package/scripts/upgradeScheme.ts +0 -97
- package/scripts/upgradeToV2/upgradeToV2.ts +0 -853
- package/scripts/upgradeToV2/upgradeToV2Recover.ts +0 -939
- package/scripts/upgradeToV3/v3-fix.ts +0 -120
- package/scripts/upgradeToV3/v3-fuse-multichain.ts +0 -117
- package/scripts/upgradeToV3/v3-upgrade.ts +0 -219
- package/scripts/upgrades/celo-defi-ubi-deploy.ts +0 -184
- package/scripts/upgrades/identity-upgrade.ts +0 -126
- package/scripts/upgrades/multichain-formula-upgrade.ts +0 -143
- package/scripts/upgrades/multichain-temp-fix.ts +0 -129
- package/scripts/upgrades/restoreFunds.ts +0 -91
- package/scripts/upgrades/superfluid-nft-celo-gas-token.ts +0 -159
- package/scripts/upgrades/transferDaoToGuardians.ts +0 -80
- package/scripts/upgrades/upgradeAdminWallet.ts +0 -29
- package/scripts/upgrades/upgradeFaucet.ts +0 -46
- package/scripts/utils.ts +0 -50
- package/scripts/verify.ts +0 -67
- package/scripts/voltageswaps.ts +0 -46
|
@@ -1,1119 +0,0 @@
|
|
|
1
|
-
import { get, range, chunk, flatten, mergeWith, sortBy, uniq } from "lodash";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import MerkleTree, { checkProof, checkProofOrdered } from "merkle-tree-solidity";
|
|
4
|
-
import coreContracts from "@gooddollar/goodcontracts/releases/deployment.json";
|
|
5
|
-
import stakingContracts from "@gooddollar/goodcontracts/stakingModel/releases/deployment.json";
|
|
6
|
-
import upgradablesContracts from "@gooddollar/goodcontracts/upgradables/releases/deployment.json";
|
|
7
|
-
import SimpleDAIStaking from "@gooddollar/goodcontracts/stakingModel/build/contracts/SimpleDAIStaking.min.json";
|
|
8
|
-
import { ethers as Ethers } from "hardhat";
|
|
9
|
-
import { request, gql } from "graphql-request";
|
|
10
|
-
import { Retrier } from "@jsier/retrier";
|
|
11
|
-
import PromisePool from "async-promise-pool";
|
|
12
|
-
|
|
13
|
-
const GD_FUSE = "0x495d133b938596c9984d462f007b676bdc57ecec";
|
|
14
|
-
const GD_MAINNET = "0x67c5870b4a41d4ebef24d2456547a03f1f3e094b";
|
|
15
|
-
const DAI = "0x6b175474e89094c44da98b954eedeac495271d0f";
|
|
16
|
-
type Balances = {
|
|
17
|
-
[key: string]: {
|
|
18
|
-
isNotContract: boolean;
|
|
19
|
-
balance: number;
|
|
20
|
-
claims: number;
|
|
21
|
-
stake: number;
|
|
22
|
-
gdRepShare: number;
|
|
23
|
-
claimRepShare: number;
|
|
24
|
-
stakeRepShare: number;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type Tree = {
|
|
29
|
-
[key: string]: {
|
|
30
|
-
hash: string;
|
|
31
|
-
rep: number;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
const DefaultBalance = {
|
|
35
|
-
balance: 0,
|
|
36
|
-
claims: 0,
|
|
37
|
-
gdRepShare: 0,
|
|
38
|
-
claimRepShare: 0,
|
|
39
|
-
stake: 0,
|
|
40
|
-
stakeRepShare: 0,
|
|
41
|
-
isNotContract: true
|
|
42
|
-
};
|
|
43
|
-
const otherContracts = [
|
|
44
|
-
"0x8d441C2Ff54C015A1BE22ad88e5D42EFBEC6C7EF", //fuseswap
|
|
45
|
-
"0x0bf36731724f0baceb0748a9e71cd4883b69c533", //fuseswap usdc
|
|
46
|
-
"0x17b09b22823f00bb9b8ee2d4632e332cadc29458", //old bridge
|
|
47
|
-
"0xd5d11ee582c8931f336fbcd135e98cee4db8ccb0", //new bridge
|
|
48
|
-
"0xa56A281cD8BA5C083Af121193B2AaCCaAAC9850a", //mainnet uniswap
|
|
49
|
-
"0x66c0f5449ba4ff4fba0b05716705a4176bbdb848", //defender automation
|
|
50
|
-
"0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11" //"uniswap DAI"
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
const systemContracts = {};
|
|
54
|
-
const allContracts = flatten(
|
|
55
|
-
[coreContracts, stakingContracts, upgradablesContracts].map(_ => Object.values(_).map(_ => Object.values(_)))
|
|
56
|
-
);
|
|
57
|
-
flatten(
|
|
58
|
-
[].concat(
|
|
59
|
-
...[otherContracts, allContracts]
|
|
60
|
-
.map(Object.values)
|
|
61
|
-
.map(arr => arr.map(x => (typeof x === "object" ? Object.values(x) : x)))
|
|
62
|
-
)
|
|
63
|
-
)
|
|
64
|
-
.filter(x => typeof x === "string" && x.startsWith("0x"))
|
|
65
|
-
.map(addr => (systemContracts[addr.toLowerCase()] = true));
|
|
66
|
-
|
|
67
|
-
const isSystemContract = addr => systemContracts[addr.toLowerCase()] === true;
|
|
68
|
-
|
|
69
|
-
const updateBalance = (balance, update) => {
|
|
70
|
-
return Object.assign({}, DefaultBalance, balance, update);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const quantile = (sorted, q) => {
|
|
74
|
-
const pos = (sorted.length - 1) * q;
|
|
75
|
-
const base = Math.floor(pos);
|
|
76
|
-
|
|
77
|
-
let sum = 0;
|
|
78
|
-
for (let i = 0; i < base; i++) sum += sorted[i];
|
|
79
|
-
|
|
80
|
-
return sum;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
let FUSE_SNAPSHOT_BLOCK = 13175510; //September-29-2021 03:00:00 PM +3 UTC
|
|
84
|
-
let ETH_SNAPSHOT_BLOCK = 13320531; //first blocka after 12pm Sep-29-2021 12:00:20 PM +UTC
|
|
85
|
-
|
|
86
|
-
export const airdrop = (ethers: typeof Ethers, ethplorer_key, etherscan_key) => {
|
|
87
|
-
const fusePoktProvider = new ethers.providers.JsonRpcProvider({
|
|
88
|
-
url: "https://fuse-mainnet.gateway.pokt.network/v1/lb/60ee374fc6318362996a1fb0",
|
|
89
|
-
user: "",
|
|
90
|
-
password: "d57939c260bdf0a6f22550e2350b4312" //end point will be removed, so its ok to keep clear text password
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const fuseProvider = new ethers.providers.JsonRpcProvider("https://rpc.fuse.io");
|
|
94
|
-
|
|
95
|
-
const fuseGDProvider = new ethers.providers.JsonRpcProvider("https://gooddollar-rpc.fuse.io");
|
|
96
|
-
const fuseArchiveProvider = new ethers.providers.JsonRpcBatchProvider("https://explorer-node.fuse.io/");
|
|
97
|
-
|
|
98
|
-
const poktArchiveProvider = new ethers.providers.JsonRpcProvider({
|
|
99
|
-
url: "https://eth-trace.gateway.pokt.network/v1/lb/6130bad2dc57c50036551041",
|
|
100
|
-
user: "",
|
|
101
|
-
password: "15439e4f4aeceb469b6b38e319f4f2a5" //end point will be removed, so its ok to keep clear text password
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
console.log({ systemContracts });
|
|
105
|
-
let gd = new ethers.Contract(
|
|
106
|
-
GD_FUSE,
|
|
107
|
-
[
|
|
108
|
-
"event Transfer(address indexed from, address indexed to, uint amount)",
|
|
109
|
-
"function balanceOf(address) view returns(uint256)"
|
|
110
|
-
],
|
|
111
|
-
fuseArchiveProvider
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
let gdMainnet = new ethers.Contract(
|
|
115
|
-
GD_MAINNET,
|
|
116
|
-
[
|
|
117
|
-
"event Transfer(address indexed from, address indexed to, uint256 value)",
|
|
118
|
-
"function balanceOf(address) view returns(uint256)"
|
|
119
|
-
],
|
|
120
|
-
poktArchiveProvider //we need balances at specific time so we use archive node
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
let dai = new ethers.Contract(
|
|
124
|
-
DAI,
|
|
125
|
-
[
|
|
126
|
-
"event Transfer(address indexed from, address indexed to, uint256 value)",
|
|
127
|
-
"function balanceOf(address) view returns(uint256)"
|
|
128
|
-
],
|
|
129
|
-
new ethers.providers.InfuraProvider()
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
const ubi = new ethers.Contract(
|
|
133
|
-
"0xAACbaaB8571cbECEB46ba85B5981efDB8928545e",
|
|
134
|
-
["event UBIClaimed(address indexed from, uint amount)"],
|
|
135
|
-
fuseProvider
|
|
136
|
-
);
|
|
137
|
-
const ubinew = new ethers.Contract(
|
|
138
|
-
"0xD7aC544F8A570C4d8764c3AAbCF6870CBD960D0D",
|
|
139
|
-
["event UBIClaimed(address indexed from, uint amount)"],
|
|
140
|
-
fuseProvider
|
|
141
|
-
);
|
|
142
|
-
const usdcgdYieldFarming = new ethers.Contract(
|
|
143
|
-
"0x04Ee5DE43332aF99eeC2D40de19962AA1cC583EC",
|
|
144
|
-
[
|
|
145
|
-
"event Staked(address indexed staker, uint256 value, uint256 _globalYieldPerToken)",
|
|
146
|
-
"function interestData() view returns(uint256,uint256,uint256)",
|
|
147
|
-
"function getStakerData(address) public view returns(uint256, uint256)"
|
|
148
|
-
],
|
|
149
|
-
fuseArchiveProvider
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const getStakersBalance = async (): Promise<Balances> => {
|
|
153
|
-
const staking = new ethers.Contract(
|
|
154
|
-
"0xEa12bB3917cf6aE2FDE97cE4756177703426d41F",
|
|
155
|
-
SimpleDAIStaking.abi,
|
|
156
|
-
new ethers.providers.InfuraProvider()
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
//calculate staking period * stake value (already in $=DAI)
|
|
160
|
-
const events = await staking.queryFilter(
|
|
161
|
-
staking.filters.DAIStaked(),
|
|
162
|
-
10575628, //block contract was created,
|
|
163
|
-
Math.max(ETH_SNAPSHOT_BLOCK, 10575628)
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const nowBlock = ETH_SNAPSHOT_BLOCK; //await staking.provider.getBlockNumber();
|
|
167
|
-
let toAggregate = events.map(_ => [
|
|
168
|
-
_.args.staker.toLowerCase(),
|
|
169
|
-
parseFloat(ethers.utils.formatEther(_.args.daiValue)) * (nowBlock - _.blockNumber), //value staked multiplied by time staked (there where no withdraws so far besides foundation account)
|
|
170
|
-
parseFloat(ethers.utils.formatEther(_.args.daiValue))
|
|
171
|
-
]);
|
|
172
|
-
|
|
173
|
-
const stakers = uniq(events.map(_ => _.args.staker));
|
|
174
|
-
|
|
175
|
-
//get dai donations
|
|
176
|
-
const daiDonationEvents = await dai.queryFilter(
|
|
177
|
-
dai.filters.Transfer(null, "0x93FB057EeC37aBc11D955d1C09e6A0d218F35CfF"),
|
|
178
|
-
11512056, //donation staking contract creation block,
|
|
179
|
-
Math.max(ETH_SNAPSHOT_BLOCK, 11512056)
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
const daiDonationsToAggregate = daiDonationEvents
|
|
183
|
-
.filter(_ => !isSystemContract(_.args.from))
|
|
184
|
-
.map(e => [
|
|
185
|
-
e.args.from.toLowerCase(),
|
|
186
|
-
parseFloat(ethers.utils.formatEther(e.args.value)) * (nowBlock - e.blockNumber),
|
|
187
|
-
parseFloat(ethers.utils.formatEther(e.args.value))
|
|
188
|
-
]);
|
|
189
|
-
|
|
190
|
-
//read eth donations and calculate period * $ value
|
|
191
|
-
let provider = new ethers.providers.EtherscanProvider("homestead", etherscan_key);
|
|
192
|
-
|
|
193
|
-
//use etherscan to read past eth transfers to the donation contract
|
|
194
|
-
let historyPromises = (
|
|
195
|
-
await provider.getHistory(
|
|
196
|
-
"0x93FB057EeC37aBc11D955d1C09e6A0d218F35CfF",
|
|
197
|
-
11512056,
|
|
198
|
-
Math.max(ETH_SNAPSHOT_BLOCK, 11512056)
|
|
199
|
-
)
|
|
200
|
-
)
|
|
201
|
-
.filter(_ => _.value.gt(ethers.constants.Zero))
|
|
202
|
-
.map(async _ => {
|
|
203
|
-
const data = await fetch(
|
|
204
|
-
`https://poloniex.com/public?command=returnChartData¤cyPair=USDT_ETH&start=${_.timestamp}&end=${
|
|
205
|
-
_.timestamp + 30000
|
|
206
|
-
}&period=300`
|
|
207
|
-
).then(_ => _.json());
|
|
208
|
-
const price = data[0].weightedAverage || data[0].open;
|
|
209
|
-
if (price == 0) console.error("error 0 price", { data });
|
|
210
|
-
return {
|
|
211
|
-
from: _.from.toLowerCase(),
|
|
212
|
-
value: ethers.utils.formatEther(_.value),
|
|
213
|
-
timestamp: _.timestamp,
|
|
214
|
-
price,
|
|
215
|
-
usdvalue: price * parseFloat(ethers.utils.formatEther(_.value)),
|
|
216
|
-
share: price * parseFloat(ethers.utils.formatEther(_.value)) * (nowBlock - _.blockNumber) //value staked multiplied by time staked
|
|
217
|
-
};
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
let ethDonations = await Promise.all(historyPromises);
|
|
221
|
-
|
|
222
|
-
let donationsToAggregate = daiDonationsToAggregate.concat(ethDonations.map(_ => [_.from, _.share, _.usdvalue]));
|
|
223
|
-
|
|
224
|
-
const stakerToTotal: { [key: string]: number } = {};
|
|
225
|
-
toAggregate = toAggregate.concat(donationsToAggregate);
|
|
226
|
-
|
|
227
|
-
let totalStakedAndDonated = 0;
|
|
228
|
-
toAggregate.forEach(_ => {
|
|
229
|
-
stakerToTotal[_[0]] = (stakerToTotal[_[0]] || 0) + _[1];
|
|
230
|
-
totalStakedAndDonated += _[2];
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// deduct withdrawn stakes
|
|
234
|
-
const withdrawevents = await staking.queryFilter(
|
|
235
|
-
staking.filters.DAIStakeWithdraw(),
|
|
236
|
-
10575628,
|
|
237
|
-
Math.max(ETH_SNAPSHOT_BLOCK, 10575628)
|
|
238
|
-
);
|
|
239
|
-
withdrawevents.forEach(
|
|
240
|
-
_ =>
|
|
241
|
-
(stakerToTotal[_.args.staker.toLowerCase()] -=
|
|
242
|
-
parseFloat(ethers.utils.formatEther(_.args.daiValue)) * (nowBlock - _.blockNumber))
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
//filter contracts + calculate total shares
|
|
246
|
-
let totalShares = 0;
|
|
247
|
-
for (let k in stakerToTotal) {
|
|
248
|
-
if (isSystemContract(k)) {
|
|
249
|
-
//filter the donationstaking contract
|
|
250
|
-
delete stakerToTotal[k];
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
totalShares += stakerToTotal[k];
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const result: Balances = {};
|
|
257
|
-
//calculate relative share
|
|
258
|
-
for (let k in stakerToTotal) {
|
|
259
|
-
result[k] = {
|
|
260
|
-
...DefaultBalance,
|
|
261
|
-
stakeRepShare: stakerToTotal[k] / totalShares,
|
|
262
|
-
isNotContract: true
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
console.log("stakers and donator shares:", {
|
|
267
|
-
stakerToTotal,
|
|
268
|
-
totalStakedAndDonated
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
return result;
|
|
272
|
-
// const ps = stakers.map(async s => {
|
|
273
|
-
// return {
|
|
274
|
-
// balance: (await staking.stakers(s)).stakedDAI.toString(),
|
|
275
|
-
// isNotContract:
|
|
276
|
-
// (await staking.provider.getCode(s).catch(e => "0x")) === "0x",
|
|
277
|
-
// s
|
|
278
|
-
// };
|
|
279
|
-
// });
|
|
280
|
-
// const res = await Promise.all(ps);
|
|
281
|
-
|
|
282
|
-
// console.log({
|
|
283
|
-
// stakers,
|
|
284
|
-
// toAggregate,
|
|
285
|
-
// stakerToTotal,
|
|
286
|
-
// totalShares,
|
|
287
|
-
// ethDonations,
|
|
288
|
-
// donationsToAggregate,
|
|
289
|
-
// totalStakedAndDonated
|
|
290
|
-
// });
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
const getUniswapBalances = async (addresses: Balances = {}) => {
|
|
294
|
-
const query = gql`
|
|
295
|
-
{
|
|
296
|
-
liquidityPositions(
|
|
297
|
-
orderDirection: desc
|
|
298
|
-
orderBy: liquidityTokenBalance
|
|
299
|
-
where: { pair: "0xa56a281cd8ba5c083af121193b2aaccaaac9850a", liquidityTokenBalance_gt: 0 }
|
|
300
|
-
) {
|
|
301
|
-
id
|
|
302
|
-
user {
|
|
303
|
-
id
|
|
304
|
-
}
|
|
305
|
-
pair {
|
|
306
|
-
reserve0
|
|
307
|
-
totalSupply
|
|
308
|
-
}
|
|
309
|
-
liquidityTokenBalance
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
`;
|
|
313
|
-
|
|
314
|
-
let pair = await ethers.getContractAt("UniswapPair", "0xa56a281cd8ba5c083af121193b2aaccaaac9850a");
|
|
315
|
-
pair = pair.connect(poktArchiveProvider);
|
|
316
|
-
|
|
317
|
-
const pairTotalSupply = await pair
|
|
318
|
-
.totalSupply({
|
|
319
|
-
blockTag: ETH_SNAPSHOT_BLOCK
|
|
320
|
-
})
|
|
321
|
-
.then(_ => _.toNumber());
|
|
322
|
-
const [reserve0] = await pair.getReserves({
|
|
323
|
-
blockTag: ETH_SNAPSHOT_BLOCK
|
|
324
|
-
});
|
|
325
|
-
console.log("uniswap pair data:", { reserve0, pairTotalSupply });
|
|
326
|
-
|
|
327
|
-
//TODO: read supplier balance at snapshot
|
|
328
|
-
const { liquidityPositions } = await request("https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2", query);
|
|
329
|
-
|
|
330
|
-
const gdHoldings = liquidityPositions.map(async pos => {
|
|
331
|
-
const uAddress = pos.user.id.toLowerCase();
|
|
332
|
-
|
|
333
|
-
const providerBalance = await pair.balanceOf(uAddress, {
|
|
334
|
-
blockTag: ETH_SNAPSHOT_BLOCK
|
|
335
|
-
});
|
|
336
|
-
const share = providerBalance.toNumber() / pairTotalSupply;
|
|
337
|
-
const gdShare = parseInt((share * reserve0).toFixed(0)); //parseInt((pos.pair.reserve0 * share * 100).toFixed(0)); //to G$ cents
|
|
338
|
-
const isNotContract = get(
|
|
339
|
-
addresses,
|
|
340
|
-
`${uAddress}.isNotContract`,
|
|
341
|
-
(await gdMainnet.provider.getCode(uAddress).catch(e => "0x")) === "0x"
|
|
342
|
-
);
|
|
343
|
-
const newBalance = (get(addresses, `${uAddress}.balance`, 0) as number) + gdShare;
|
|
344
|
-
console.log("uniswap position:", {
|
|
345
|
-
pos,
|
|
346
|
-
newBalance,
|
|
347
|
-
uAddress,
|
|
348
|
-
share,
|
|
349
|
-
gdShare
|
|
350
|
-
});
|
|
351
|
-
addresses[uAddress] = updateBalance(addresses[uAddress], {
|
|
352
|
-
balance: newBalance,
|
|
353
|
-
isNotContract
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
return [uAddress, gdShare];
|
|
357
|
-
});
|
|
358
|
-
await Promise.all(gdHoldings);
|
|
359
|
-
return addresses;
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
const getFuseSwapBalances = async (graphqlUrl, tokenId, addresses: Balances = {}) => {
|
|
363
|
-
const _calcHoldings = async (pair, addresses: Balances = {}) => {
|
|
364
|
-
const { liquidityPositions, reserve0: isReserve0, id } = pair;
|
|
365
|
-
let pairContract = await ethers.getContractAt("UniswapPair", id);
|
|
366
|
-
pairContract = pairContract.connect(fuseArchiveProvider);
|
|
367
|
-
|
|
368
|
-
try {
|
|
369
|
-
const pairTotalSupply = await pairContract
|
|
370
|
-
.totalSupply({
|
|
371
|
-
blockTag: FUSE_SNAPSHOT_BLOCK
|
|
372
|
-
})
|
|
373
|
-
.then(_ => _.toNumber());
|
|
374
|
-
const [reserve0, reserve1] = await pairContract.getReserves({
|
|
375
|
-
blockTag: FUSE_SNAPSHOT_BLOCK
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
const reserve = isReserve0 ? reserve0.toNumber() : reserve1.toNumber();
|
|
379
|
-
|
|
380
|
-
console.log("fuseswap pair data:", {
|
|
381
|
-
id,
|
|
382
|
-
reserve0,
|
|
383
|
-
reserve1,
|
|
384
|
-
pairTotalSupply
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
liquidityPositions.map(async pos => {
|
|
388
|
-
const uAddress = pos.user.id.toLowerCase();
|
|
389
|
-
|
|
390
|
-
const providerBalance = await pairContract.balanceOf(uAddress, {
|
|
391
|
-
blockTag: FUSE_SNAPSHOT_BLOCK
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
const share = providerBalance.toNumber() / pairTotalSupply;
|
|
395
|
-
const gdShare = parseInt((share * reserve).toFixed(0));
|
|
396
|
-
if (gdShare > 0) {
|
|
397
|
-
console.log("liquidity provider:", {
|
|
398
|
-
uAddress,
|
|
399
|
-
pair: id,
|
|
400
|
-
share,
|
|
401
|
-
gdShare,
|
|
402
|
-
reserve: reserve
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
const newBalance = (get(addresses, `${uAddress}.balance`, 0) as number) + gdShare;
|
|
406
|
-
|
|
407
|
-
addresses[uAddress] = updateBalance(addresses[uAddress], {
|
|
408
|
-
balance: newBalance
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
} catch (e) {
|
|
413
|
-
console.error("failed fuseswap pair", id, e);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
const query = gql`
|
|
419
|
-
{
|
|
420
|
-
t0: pairs(
|
|
421
|
-
where: {
|
|
422
|
-
token0: "${tokenId}"
|
|
423
|
-
reserve0_gt: 1
|
|
424
|
-
}
|
|
425
|
-
) {
|
|
426
|
-
id
|
|
427
|
-
reserve0
|
|
428
|
-
totalSupply
|
|
429
|
-
liquidityPositions(where: { liquidityTokenBalance_gt: 0 }) {
|
|
430
|
-
user {
|
|
431
|
-
id
|
|
432
|
-
}
|
|
433
|
-
liquidityTokenBalance
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
t1: pairs(
|
|
438
|
-
where: {
|
|
439
|
-
token1: "${tokenId}"
|
|
440
|
-
reserve1_gt: 1
|
|
441
|
-
}
|
|
442
|
-
) {
|
|
443
|
-
id
|
|
444
|
-
reserve1
|
|
445
|
-
totalSupply
|
|
446
|
-
liquidityPositions(where: { liquidityTokenBalance_gt: 0 }) {
|
|
447
|
-
user {
|
|
448
|
-
id
|
|
449
|
-
}
|
|
450
|
-
liquidityTokenBalance
|
|
451
|
-
pair {
|
|
452
|
-
totalSupply
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
`;
|
|
458
|
-
|
|
459
|
-
const { t0, t1 } = await request(graphqlUrl, query);
|
|
460
|
-
const t0Promises = t0.map(pair => {
|
|
461
|
-
return _calcHoldings(pair, addresses);
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
const t1Promises = t1.map(pair => {
|
|
465
|
-
return _calcHoldings(pair, addresses);
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
await Promise.all([...t0Promises, ...t1Promises]);
|
|
469
|
-
//get liquidity miners for 0x04Ee5DE43332aF99eeC2D40de19962AA1cC583EC, fuse G$ liquidity farmin rewards
|
|
470
|
-
const staked = await usdcgdYieldFarming.queryFilter(
|
|
471
|
-
usdcgdYieldFarming.filters.Staked(),
|
|
472
|
-
10560021,
|
|
473
|
-
Math.max(FUSE_SNAPSHOT_BLOCK, 10560021)
|
|
474
|
-
);
|
|
475
|
-
|
|
476
|
-
const farmers = {};
|
|
477
|
-
const yieldFarmingRep = addresses[usdcgdYieldFarming.address.toLowerCase()]?.balance || 0;
|
|
478
|
-
if (yieldFarmingRep > 0) {
|
|
479
|
-
const [totalStaked, ,] = await usdcgdYieldFarming.interestData({
|
|
480
|
-
blockTag: FUSE_SNAPSHOT_BLOCK
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
await Promise.all(
|
|
484
|
-
staked.map(async e => {
|
|
485
|
-
const [balance] = await usdcgdYieldFarming.getStakerData(e.args.staker, { blockTag: FUSE_SNAPSHOT_BLOCK });
|
|
486
|
-
|
|
487
|
-
if (balance > 0) {
|
|
488
|
-
const share = balance.toNumber() / totalStaked.toNumber();
|
|
489
|
-
const uAddress = e.args.staker;
|
|
490
|
-
const repShare = parseInt((share * yieldFarmingRep).toFixed(0));
|
|
491
|
-
farmers[uAddress] = [share, repShare];
|
|
492
|
-
const newBalance = (get(addresses, `${uAddress}.balance`, 0) as number) + share * yieldFarmingRep;
|
|
493
|
-
|
|
494
|
-
addresses[uAddress] = updateBalance(addresses[uAddress], {
|
|
495
|
-
balance: newBalance
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
})
|
|
499
|
-
);
|
|
500
|
-
console.log("got fuseswap yield farmers:", {
|
|
501
|
-
farmers,
|
|
502
|
-
contract: usdcgdYieldFarming.address.toLowerCase(),
|
|
503
|
-
yieldFarmingRep,
|
|
504
|
-
totalStaked: totalStaked.toNumber(),
|
|
505
|
-
totalFarmers: Object.values(farmers).length,
|
|
506
|
-
totalShares: Object.values(farmers)
|
|
507
|
-
.map(_ => _[0])
|
|
508
|
-
.reduceRight((x: number, y: number) => x + y)
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
//dont send rep to the yield farming contract
|
|
512
|
-
delete addresses[usdcgdYieldFarming.address.toLowerCase()];
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
return addresses;
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
const getFuseHolders = async (addresses: Balances = {}, onlyBalances = false, onlyFailed = false) => {
|
|
519
|
-
console.log("getFuseHolders", { onlyBalances, onlyFailed }, Object.keys(addresses).length);
|
|
520
|
-
const toFetch = {};
|
|
521
|
-
|
|
522
|
-
const step = 1000;
|
|
523
|
-
const gdNonArchive = gd.connect(fuseProvider);
|
|
524
|
-
|
|
525
|
-
const contracts = [gdNonArchive, gd.connect(fuseGDProvider)];
|
|
526
|
-
const latestBlock = FUSE_SNAPSHOT_BLOCK; //await ubiContract.provider.getBlockNumber();
|
|
527
|
-
const blocks = range(6400000, latestBlock, step);
|
|
528
|
-
const filter = gdNonArchive.filters.Transfer();
|
|
529
|
-
|
|
530
|
-
const pool = new PromisePool({ concurrency: 70 });
|
|
531
|
-
let addrs;
|
|
532
|
-
|
|
533
|
-
let idx = 0;
|
|
534
|
-
if (!onlyBalances) {
|
|
535
|
-
blocks.forEach(bc => {
|
|
536
|
-
pool.add(async () => {
|
|
537
|
-
const options = { limit: 20, delay: 2000 };
|
|
538
|
-
const retrier = new Retrier(options);
|
|
539
|
-
// Query the filter (the latest could be omitted)
|
|
540
|
-
const logs = await retrier.resolve(attempt => {
|
|
541
|
-
console.log("fetching block transfer logs", { attempt, bc });
|
|
542
|
-
|
|
543
|
-
return contracts[idx++ % contracts.length].queryFilter(filter, bc, Math.min(bc + step - 1, latestBlock));
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
logs.forEach(l => (toFetch[l.args.to.toLowerCase()] = true));
|
|
547
|
-
console.log("found Transfer logs in block:", { bc }, logs.length);
|
|
548
|
-
});
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
await pool.all();
|
|
552
|
-
addrs = Object.keys(toFetch);
|
|
553
|
-
fs.writeFileSync("airdrop/addrs.tmp", JSON.stringify(addrs));
|
|
554
|
-
} else {
|
|
555
|
-
if (onlyFailed) {
|
|
556
|
-
addrs = JSON.parse(fs.readFileSync("airdrop/failed.tmp").toString());
|
|
557
|
-
console.log(
|
|
558
|
-
"existing failed",
|
|
559
|
-
addrs.map(addr => addresses[addr])
|
|
560
|
-
);
|
|
561
|
-
} else {
|
|
562
|
-
addrs = JSON.parse(fs.readFileSync("airdrop/addrs.tmp").toString());
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
// for (let blockChunk of chunk(blocks, 30)) {
|
|
566
|
-
// // Get the filter (the second null could be omitted)
|
|
567
|
-
// const ps = blockChunk.map(async bc => {
|
|
568
|
-
// const options = { limit: 10, delay: 2000 };
|
|
569
|
-
// const retrier = new Retrier(options);
|
|
570
|
-
// // Query the filter (the latest could be omitted)
|
|
571
|
-
// const logs = await retrier.resolve(attempt => {
|
|
572
|
-
// console.log("fetching block transfer logs", { attempt, bc });
|
|
573
|
-
// return gdNonArchive.queryFilter(
|
|
574
|
-
// filter,
|
|
575
|
-
// bc,
|
|
576
|
-
// Math.min(bc + step - 1, latestBlock)
|
|
577
|
-
// );
|
|
578
|
-
// });
|
|
579
|
-
|
|
580
|
-
// logs.forEach(l => (toFetch[l.args.to.toLowerCase()] = true));
|
|
581
|
-
// console.log("found Transfer logs in block:", { bc }, logs.length);
|
|
582
|
-
// });
|
|
583
|
-
// await Promise.all(ps);
|
|
584
|
-
// }
|
|
585
|
-
|
|
586
|
-
console.log("found G$ holders, fetching balacnes...:", addrs.length);
|
|
587
|
-
|
|
588
|
-
let fetched = 0;
|
|
589
|
-
const balancesPool = new PromisePool({ concurrency: 10 });
|
|
590
|
-
|
|
591
|
-
let failed = [];
|
|
592
|
-
for (let addrChunk of chunk(addrs, 50)) {
|
|
593
|
-
balancesPool.add(async () => {
|
|
594
|
-
const ps = addrChunk.map(async (uAddress: string) => {
|
|
595
|
-
const curBalance = onlyFailed ? 0 : get(addresses, `${uAddress}.balance`, 0);
|
|
596
|
-
const isNotContract = get(
|
|
597
|
-
addresses,
|
|
598
|
-
`${uAddress}.isNotContract`,
|
|
599
|
-
(await gdNonArchive.provider.getCode(uAddress).catch(e => "0x")) === "0x"
|
|
600
|
-
);
|
|
601
|
-
const balance = await gd
|
|
602
|
-
.balanceOf(uAddress)
|
|
603
|
-
.then(_ => _.toNumber(), { blockTag: FUSE_SNAPSHOT_BLOCK })
|
|
604
|
-
.catch(e => {
|
|
605
|
-
failed.push(uAddress);
|
|
606
|
-
return 0;
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
addresses[uAddress] = updateBalance(addresses[uAddress], {
|
|
610
|
-
balance: curBalance + balance,
|
|
611
|
-
isNotContract
|
|
612
|
-
});
|
|
613
|
-
});
|
|
614
|
-
await Promise.all(ps);
|
|
615
|
-
fetched += addrChunk.length;
|
|
616
|
-
console.log("fetched fuse balances:", fetched);
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
await balancesPool.all();
|
|
621
|
-
console.log("fuseHolders failed:", failed.length);
|
|
622
|
-
if (!onlyFailed) fs.writeFileSync("airdrop/failed.tmp", JSON.stringify(failed));
|
|
623
|
-
return addresses;
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
const getBlockScoutHolders = async (addresses: Balances = {}) => {
|
|
627
|
-
let initialUrl = `https://explorer.fuse.io/tokens/${gd.address}/token-holders?type=JSON`;
|
|
628
|
-
const pool = new PromisePool({ concurrency: 30 });
|
|
629
|
-
const gdNonArchive = gd.connect(fuseProvider);
|
|
630
|
-
|
|
631
|
-
let analyzedPages = 0;
|
|
632
|
-
let analyzedBalances = 0;
|
|
633
|
-
let failedAccounts = [];
|
|
634
|
-
let toFetch = [];
|
|
635
|
-
|
|
636
|
-
const fetchBalances = async foundBalances => {
|
|
637
|
-
const ps = foundBalances
|
|
638
|
-
.filter(b => isSystemContract(b[0]) === false)
|
|
639
|
-
.map(async b => {
|
|
640
|
-
const uAddress = b[0].toLowerCase();
|
|
641
|
-
const curBalance = get(addresses, `${uAddress}.balance`, 0);
|
|
642
|
-
const isNotContract = get(
|
|
643
|
-
addresses,
|
|
644
|
-
`${uAddress}.isNotContract`,
|
|
645
|
-
(await gdNonArchive.provider.getCode(b[0]).catch(e => "0x")) === "0x"
|
|
646
|
-
);
|
|
647
|
-
const cleanBalance = await gdNonArchive
|
|
648
|
-
.balanceOf(uAddress, { blockTag: FUSE_SNAPSHOT_BLOCK })
|
|
649
|
-
.catch(e =>
|
|
650
|
-
gd.balanceOf(uAddress, {
|
|
651
|
-
blockTag: FUSE_SNAPSHOT_BLOCK
|
|
652
|
-
})
|
|
653
|
-
)
|
|
654
|
-
.then(_ => _.toNumber())
|
|
655
|
-
.catch(e => failedAccounts.push(uAddress));
|
|
656
|
-
// const cleanBalance = parseFloat(b[3].replace(/[,G$\s]/g, "")) * 100; //in G$ cents
|
|
657
|
-
addresses[uAddress] = updateBalance(addresses[uAddress], {
|
|
658
|
-
balance: curBalance + cleanBalance,
|
|
659
|
-
isNotContract
|
|
660
|
-
});
|
|
661
|
-
});
|
|
662
|
-
await Promise.all(ps);
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
const analyzeUrl = async url => {
|
|
666
|
-
console.log("fetching:", url);
|
|
667
|
-
const { items, next_page_path } = await fetch(url).then(_ => _.json());
|
|
668
|
-
if (next_page_path) {
|
|
669
|
-
let [, path] = next_page_path.match(/\?(.*$)/);
|
|
670
|
-
const params = path + "&type=JSON";
|
|
671
|
-
let nextUrl = `https://explorer.fuse.io/tokens/${gd.address}/token-holders?${params}`;
|
|
672
|
-
pool.add(() => analyzeUrl(nextUrl));
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
if (items && items.length) {
|
|
676
|
-
const foundBalances = items.map(i => i.match(/(0x\w{20,})|([0-9\.,]+ G\$)/g));
|
|
677
|
-
analyzedPages++;
|
|
678
|
-
analyzedBalances += foundBalances.length;
|
|
679
|
-
toFetch = toFetch.concat(foundBalances);
|
|
680
|
-
// await fetchBalances(foundBalances);
|
|
681
|
-
}
|
|
682
|
-
console.log("fetched blockscout url:", {
|
|
683
|
-
url,
|
|
684
|
-
next_page_path,
|
|
685
|
-
analyzedBalances,
|
|
686
|
-
analyzedPages
|
|
687
|
-
});
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
pool.add(() => analyzeUrl(initialUrl));
|
|
691
|
-
await pool.all();
|
|
692
|
-
|
|
693
|
-
console.log("fetching fuse balances....", toFetch.length);
|
|
694
|
-
let fetched = 0;
|
|
695
|
-
const balancesPool = new PromisePool({ concurrency: 10 });
|
|
696
|
-
|
|
697
|
-
for (let addrChunk of chunk(toFetch, 50)) {
|
|
698
|
-
balancesPool.add(async () => {
|
|
699
|
-
await fetchBalances(addrChunk);
|
|
700
|
-
fetched += 500;
|
|
701
|
-
console.log("fetched fuse balances:", fetched);
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
await balancesPool.all();
|
|
705
|
-
console.log("refetching fuse balances failed:", failedAccounts.length);
|
|
706
|
-
await fetchBalances(failedAccounts);
|
|
707
|
-
};
|
|
708
|
-
|
|
709
|
-
const getEthPlorerHolders = async (addresses: Balances = {}) => {
|
|
710
|
-
let nextUrl = `https://api.ethplorer.io/getTopTokenHolders/${gdMainnet.address}?limit=1000&apiKey=${ethplorer_key}`;
|
|
711
|
-
|
|
712
|
-
const { holders } = await fetch(nextUrl).then(_ => _.json());
|
|
713
|
-
console.log("getEthplorerHolders got holders:", { holders });
|
|
714
|
-
let failedAccounts = [];
|
|
715
|
-
|
|
716
|
-
const _fetchBalances = holders => {
|
|
717
|
-
const ps: Array<Promise<any>> = holders
|
|
718
|
-
.filter(address => isSystemContract(address) === false)
|
|
719
|
-
.map(async address => {
|
|
720
|
-
const uAddress = address.toLowerCase();
|
|
721
|
-
const cleanBalance = await gdMainnet
|
|
722
|
-
.balanceOf(uAddress, { blockTag: ETH_SNAPSHOT_BLOCK })
|
|
723
|
-
.catch(e =>
|
|
724
|
-
gdMainnet.balanceOf(uAddress, {
|
|
725
|
-
blockTag: ETH_SNAPSHOT_BLOCK
|
|
726
|
-
})
|
|
727
|
-
)
|
|
728
|
-
.then(_ => _.toNumber())
|
|
729
|
-
.catch(e => failedAccounts.push(uAddress));
|
|
730
|
-
|
|
731
|
-
const newBalance = get(addresses, `${uAddress}.balance`, 0) + cleanBalance;
|
|
732
|
-
const isNotContract = get(
|
|
733
|
-
addresses,
|
|
734
|
-
`${uAddress}.isNotContract`,
|
|
735
|
-
(await gdMainnet.provider.getCode(uAddress).catch(e => "0x")) === "0x"
|
|
736
|
-
);
|
|
737
|
-
addresses[uAddress] = updateBalance(addresses[uAddress], {
|
|
738
|
-
balance: newBalance,
|
|
739
|
-
isNotContract
|
|
740
|
-
});
|
|
741
|
-
});
|
|
742
|
-
return ps;
|
|
743
|
-
};
|
|
744
|
-
console.log("getEthplorerHolders fetching snapshot balances...");
|
|
745
|
-
|
|
746
|
-
await Promise.all(_fetchBalances(holders.map(_ => _.address)));
|
|
747
|
-
|
|
748
|
-
console.log("refetching eth balances failed:", failedAccounts.length);
|
|
749
|
-
await Promise.all(_fetchBalances(failedAccounts));
|
|
750
|
-
|
|
751
|
-
return addresses;
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
const getClaimsPerAddress = async (balances: Balances = {}, ubiContract = ubi) => {
|
|
755
|
-
const ubiFuse = ubiContract.connect(fuseProvider);
|
|
756
|
-
const ubiPokt = ubiContract.connect(fusePoktProvider);
|
|
757
|
-
const ubiGD = ubiContract.connect(fuseGDProvider);
|
|
758
|
-
|
|
759
|
-
const pool = new PromisePool({ concurrency: 50 });
|
|
760
|
-
const step = 1000;
|
|
761
|
-
const latestBlock = FUSE_SNAPSHOT_BLOCK; //await ubiContract.provider.getBlockNumber();
|
|
762
|
-
const blocks = range(ubiContract === ubi ? 6276288 : 9376522, ubiContract === ubi ? 9497482 : latestBlock, step);
|
|
763
|
-
const filter = ubiContract.filters.UBIClaimed();
|
|
764
|
-
const contracts = [ubiFuse, ubiGD];
|
|
765
|
-
let idx = 0;
|
|
766
|
-
blocks.forEach(bc => {
|
|
767
|
-
pool.add(async () => {
|
|
768
|
-
const options = { limit: 20, delay: 2000 };
|
|
769
|
-
const retrier = new Retrier(options);
|
|
770
|
-
// Query the filter (the latest could be omitted)
|
|
771
|
-
const logs = await retrier.resolve(attempt => {
|
|
772
|
-
console.log("fetching block ubiclaimed logs", { attempt, bc });
|
|
773
|
-
|
|
774
|
-
return contracts[idx++ % contracts.length].queryFilter(filter, bc, Math.min(bc + step - 1, latestBlock));
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
console.log("found claim logs in block:", { bc }, logs.length);
|
|
778
|
-
// Print out all the values:
|
|
779
|
-
logs.map(log => {
|
|
780
|
-
const uAddress = log.args.from.toLowerCase();
|
|
781
|
-
const claims = (get(balances, `${uAddress}.claims`, 0) as number) + 1;
|
|
782
|
-
balances[uAddress] = updateBalance(balances[uAddress], {
|
|
783
|
-
claims
|
|
784
|
-
});
|
|
785
|
-
});
|
|
786
|
-
});
|
|
787
|
-
});
|
|
788
|
-
await pool.all();
|
|
789
|
-
return balances;
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
const calcRelativeRep = (balances: Balances) => {
|
|
793
|
-
const totalSupply = Object.values(balances).reduce((cur, data) => cur + data.balance, 0);
|
|
794
|
-
const totalClaims = Object.values(balances).reduce((cur, data) => cur + (data.claims || 0), 0);
|
|
795
|
-
|
|
796
|
-
for (let addr in balances) {
|
|
797
|
-
balances[addr].gdRepShare = totalSupply > 0 ? balances[addr].balance / totalSupply : 0;
|
|
798
|
-
balances[addr].claimRepShare = totalClaims > 0 ? balances[addr].claims / totalClaims : 0;
|
|
799
|
-
}
|
|
800
|
-
return { totalSupply, totalClaims, balances };
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
const collectAirdropData = async (fuseBlock, ethBlock) => {
|
|
804
|
-
FUSE_SNAPSHOT_BLOCK = parseInt(fuseBlock || FUSE_SNAPSHOT_BLOCK);
|
|
805
|
-
ETH_SNAPSHOT_BLOCK = parseInt(ethBlock || ETH_SNAPSHOT_BLOCK);
|
|
806
|
-
|
|
807
|
-
console.log({
|
|
808
|
-
FUSE_SNAPSHOT_BLOCK,
|
|
809
|
-
ETH_SNAPSHOT_BLOCK,
|
|
810
|
-
GD_FUSE,
|
|
811
|
-
GD_MAINNET,
|
|
812
|
-
DAI
|
|
813
|
-
});
|
|
814
|
-
const ps = [];
|
|
815
|
-
|
|
816
|
-
ps[0] = _timer(
|
|
817
|
-
"getFuseSwapBalances",
|
|
818
|
-
getFuseSwapBalances("https://graph.fuse.io/subgraphs/name/fuseio/fuseswap", GD_FUSE).then(r =>
|
|
819
|
-
fs.writeFileSync("airdrop/fuseswapBalances.json", JSON.stringify(r))
|
|
820
|
-
)
|
|
821
|
-
);
|
|
822
|
-
|
|
823
|
-
ps[1] = _timer(
|
|
824
|
-
"getUniswapBalances",
|
|
825
|
-
getUniswapBalances().then(r => fs.writeFileSync("airdrop/uniswapBalances.json", JSON.stringify(r)))
|
|
826
|
-
);
|
|
827
|
-
|
|
828
|
-
ps[2] = _timer(
|
|
829
|
-
"getClaimsPerAddress",
|
|
830
|
-
getClaimsPerAddress()
|
|
831
|
-
.then(r => getClaimsPerAddress(r, ubinew))
|
|
832
|
-
.then(r => fs.writeFileSync("airdrop/claimBalances.json", JSON.stringify(r)))
|
|
833
|
-
);
|
|
834
|
-
|
|
835
|
-
ps[3] = _timer(
|
|
836
|
-
"getEthPlorerHolders",
|
|
837
|
-
getEthPlorerHolders().then(r => fs.writeFileSync("airdrop/ethBalances.json", JSON.stringify(r)))
|
|
838
|
-
);
|
|
839
|
-
|
|
840
|
-
// ps[4] = _timer(
|
|
841
|
-
// "getBlockScoutHolders",
|
|
842
|
-
// getBlockScoutHolders().then(r =>
|
|
843
|
-
// fs.writeFileSync("fuseBalances.json", JSON.stringify(r))
|
|
844
|
-
// ));
|
|
845
|
-
|
|
846
|
-
// const balances = JSON.parse(
|
|
847
|
-
// fs.readFileSync("airdrop/fuseBalances.json").toString()
|
|
848
|
-
// );
|
|
849
|
-
ps[4] = _timer(
|
|
850
|
-
"getFuseHolders",
|
|
851
|
-
getFuseHolders({}).then(r => fs.writeFileSync("airdrop/fuseBalances.json", JSON.stringify(r)))
|
|
852
|
-
);
|
|
853
|
-
|
|
854
|
-
ps[5] = _timer(
|
|
855
|
-
"getStakersBalance",
|
|
856
|
-
getStakersBalance().then(r => fs.writeFileSync("airdrop/stakersBalances.json", JSON.stringify(r)))
|
|
857
|
-
);
|
|
858
|
-
|
|
859
|
-
await Promise.all(ps);
|
|
860
|
-
};
|
|
861
|
-
|
|
862
|
-
const buildMerkleTree = () => {
|
|
863
|
-
// const files = ["test/testnetBalances.json"].map(f =>
|
|
864
|
-
// JSON.parse(fs.readFileSync(f).toString())
|
|
865
|
-
// );
|
|
866
|
-
|
|
867
|
-
const folder = "airdrop";
|
|
868
|
-
const files = [
|
|
869
|
-
`${folder}/claimBalances.json`,
|
|
870
|
-
`${folder}/ethBalances.json`,
|
|
871
|
-
`${folder}/fuseBalances.json`,
|
|
872
|
-
`${folder}/uniswapBalances.json`,
|
|
873
|
-
`${folder}/fuseswapBalances.json`,
|
|
874
|
-
`${folder}/stakersBalances.json`
|
|
875
|
-
].map(f => JSON.parse(fs.readFileSync(f).toString()));
|
|
876
|
-
|
|
877
|
-
const merge = (obj1, obj2, key) => {
|
|
878
|
-
obj1 = { ...DefaultBalance, ...obj1 };
|
|
879
|
-
obj1.claims = get(obj1, "claims", 0) + get(obj2, "claims", 0);
|
|
880
|
-
obj1.balance = get(obj1, "balance", 0) + get(obj2, "balance", 0);
|
|
881
|
-
obj1.stake = get(obj1, "stake", 0) + get(obj2, "stake", 0);
|
|
882
|
-
obj1.stakeRepShare = get(obj1, "stakeRepShare") || get(obj2, "stakeRepShare", 0);
|
|
883
|
-
obj1.isNotContract = get(obj1, "isNotContract", get(obj2, "isNotContract"));
|
|
884
|
-
return obj1;
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
const data: Balances = mergeWith(files[0], ...files.slice(1), merge);
|
|
888
|
-
|
|
889
|
-
//switch shoppingio wallet
|
|
890
|
-
const shoppingio = data["0x2a18975b0bc72e28e09381cae19451aaaf4b771b"];
|
|
891
|
-
delete data["0x2a18975b0bc72e28e09381cae19451aaaf4b771b"];
|
|
892
|
-
data["0xAA0ded62E992F8FE5Dd184fCa9B468C6060f9683"] = shoppingio;
|
|
893
|
-
|
|
894
|
-
let { totalSupply, totalClaims, balances } = calcRelativeRep(data);
|
|
895
|
-
|
|
896
|
-
const CLAIMER_REP_ALLOCATION = 48000000;
|
|
897
|
-
const HOLDER_REP_ALLOCATION = 24000000;
|
|
898
|
-
const STAKER_REP_ALLOCATION = 24000000;
|
|
899
|
-
|
|
900
|
-
const ETORO = ["0xf79b804bae955ae4cd8e8b0331c4bc437104804f", "0x61ec01ad0937ebc10d448d259a2bbb1556b61e38"];
|
|
901
|
-
const EtoroOfficial = "0x61ec01ad0937ebc10d448d259a2bbb1556b61e38".toLowerCase();
|
|
902
|
-
const FoundationOfficial = "0x66582D24FEaD72555adaC681Cc621caCbB208324".toLowerCase();
|
|
903
|
-
|
|
904
|
-
const TEAM = [
|
|
905
|
-
"0x5AeE2397b39B479B72bcfbDA114512BD3329E5aC",
|
|
906
|
-
"0x330a78895b150007d1c00a471202ce0A9df046f2",
|
|
907
|
-
"0x642ADC7965938D649192FF634e5Ab40df728b1bB",
|
|
908
|
-
"0xA8Eb8eFeAcF45623816Eb2D1B1653BAC4245a358",
|
|
909
|
-
"0x18C532F20C3a916b3989fCe4A3C6693F936a16C6",
|
|
910
|
-
"0xA5eb500FcD5f85d30b38A84B433F343F100267d9",
|
|
911
|
-
"0x9BA0721F9a83A8d90bA52Eaa1799ec08d164B7A0",
|
|
912
|
-
"0xEFe1890bE2AAdaDF74FE3EaE72904Bd2FC926A63",
|
|
913
|
-
"0xA48840D89a761502A4a7d995c74f3864D651A87F",
|
|
914
|
-
"0x884e76001F9A807E0bA3b6d4574539D2FC0fcC4f",
|
|
915
|
-
"0x75A57224f7b7380b92B0e04f7358775203058Eb2",
|
|
916
|
-
"0xDEb250aDD368b74ebCCd59862D62fa4Fb57E09D4",
|
|
917
|
-
"0x18C0416357937cf576e8277e3C3d806095D071B7",
|
|
918
|
-
"0x7982D1883d43B2EF4a341fCFffc5e72f9e8D365b",
|
|
919
|
-
"0x2CD2645dAe0ebC45642d131E4be1ea9e0Dc28e4A",
|
|
920
|
-
"0xdBB617A5E3e21695058Ae4AbfAe4f2793775D3E3",
|
|
921
|
-
"0x647481c033A4A2E816175cE115a0804adf793891",
|
|
922
|
-
"0x3abdC9ed5f5dE6A74CFeb42a82087C853E160E76"
|
|
923
|
-
].map(_ => _.toLowerCase());
|
|
924
|
-
|
|
925
|
-
const eToroRep = ETORO.map(addr => {
|
|
926
|
-
const data = balances[addr];
|
|
927
|
-
console.log("Found eToro record for redistribution", data);
|
|
928
|
-
let rep =
|
|
929
|
-
data.claimRepShare * CLAIMER_REP_ALLOCATION +
|
|
930
|
-
data.gdRepShare * HOLDER_REP_ALLOCATION +
|
|
931
|
-
data.stakeRepShare * STAKER_REP_ALLOCATION;
|
|
932
|
-
return rep;
|
|
933
|
-
}).reduce((acc, rep) => acc + rep, 0);
|
|
934
|
-
|
|
935
|
-
ETORO.forEach(addr => delete balances[addr]);
|
|
936
|
-
|
|
937
|
-
let toTree: Array<[string, number, boolean, number, number, number, number]> = Object.entries(balances).map(
|
|
938
|
-
([addr, data]) => {
|
|
939
|
-
let rep =
|
|
940
|
-
data.claimRepShare * CLAIMER_REP_ALLOCATION +
|
|
941
|
-
data.gdRepShare * HOLDER_REP_ALLOCATION +
|
|
942
|
-
data.stakeRepShare * STAKER_REP_ALLOCATION;
|
|
943
|
-
|
|
944
|
-
return [
|
|
945
|
-
addr,
|
|
946
|
-
rep,
|
|
947
|
-
!data.isNotContract,
|
|
948
|
-
data.claimRepShare * CLAIMER_REP_ALLOCATION,
|
|
949
|
-
data.gdRepShare * HOLDER_REP_ALLOCATION,
|
|
950
|
-
data.stakeRepShare * STAKER_REP_ALLOCATION,
|
|
951
|
-
0
|
|
952
|
-
];
|
|
953
|
-
}
|
|
954
|
-
);
|
|
955
|
-
|
|
956
|
-
//split etoro's rep between team,etoro and foundation
|
|
957
|
-
const foundationEtoroRepShare = 8640000;
|
|
958
|
-
const teamRepShare = (eToroRep - 8640000 * 2) / TEAM.length;
|
|
959
|
-
const foundationRecord = toTree.find(x => x[0] === FoundationOfficial);
|
|
960
|
-
foundationRecord[1] += foundationEtoroRepShare;
|
|
961
|
-
foundationRecord[6] = foundationEtoroRepShare;
|
|
962
|
-
console.log("Foundation updated record:", foundationRecord);
|
|
963
|
-
|
|
964
|
-
const etoroRecord: [string, number, boolean, number, number, number, number] = [
|
|
965
|
-
EtoroOfficial,
|
|
966
|
-
foundationEtoroRepShare,
|
|
967
|
-
false,
|
|
968
|
-
0,
|
|
969
|
-
0,
|
|
970
|
-
0,
|
|
971
|
-
foundationEtoroRepShare
|
|
972
|
-
];
|
|
973
|
-
|
|
974
|
-
console.log("eToro updated record:", etoroRecord);
|
|
975
|
-
|
|
976
|
-
toTree.push(etoroRecord);
|
|
977
|
-
|
|
978
|
-
TEAM.forEach(addr => {
|
|
979
|
-
let record = toTree.find(x => x[0] === addr);
|
|
980
|
-
if (!record) {
|
|
981
|
-
record = [addr, 0, false, 0, 0, 0, 0];
|
|
982
|
-
toTree.push(record);
|
|
983
|
-
console.log("added TEAM missing record:", addr);
|
|
984
|
-
}
|
|
985
|
-
record[1] += teamRepShare;
|
|
986
|
-
record[6] = teamRepShare;
|
|
987
|
-
console.log("TEAM updated record:", record);
|
|
988
|
-
});
|
|
989
|
-
|
|
990
|
-
toTree = sortBy(toTree, "1")
|
|
991
|
-
.reverse()
|
|
992
|
-
.filter(x => x[1] > 0);
|
|
993
|
-
|
|
994
|
-
console.log({ toTree });
|
|
995
|
-
const topContracts = toTree.filter(_ => _[2] === true);
|
|
996
|
-
const totalReputationAirdrop = toTree.reduce((c, a) => c + a[1], 0);
|
|
997
|
-
console.log({
|
|
998
|
-
topContracts,
|
|
999
|
-
totalReputationAirdrop,
|
|
1000
|
-
numberOfAccounts: toTree.length,
|
|
1001
|
-
totalGDSupply: totalSupply,
|
|
1002
|
-
totalClaims
|
|
1003
|
-
});
|
|
1004
|
-
|
|
1005
|
-
const sorted = toTree.map(_ => _[1]);
|
|
1006
|
-
fs.writeFileSync(`${folder}/reptree.json`, JSON.stringify(toTree));
|
|
1007
|
-
console.log("Reputation Distribution");
|
|
1008
|
-
[0.001, 0.01, 0.1, 0.5].forEach(q =>
|
|
1009
|
-
console.log({
|
|
1010
|
-
precentile: q * 100 + "%",
|
|
1011
|
-
addresses: (sorted.length * q).toFixed(0),
|
|
1012
|
-
rep: quantile(sorted, q) / (CLAIMER_REP_ALLOCATION + HOLDER_REP_ALLOCATION + STAKER_REP_ALLOCATION)
|
|
1013
|
-
})
|
|
1014
|
-
);
|
|
1015
|
-
|
|
1016
|
-
const treeData = {};
|
|
1017
|
-
|
|
1018
|
-
const elements = toTree.map(e => {
|
|
1019
|
-
const repInWei = (e[1] * 1e18)
|
|
1020
|
-
.toLocaleString("fullwide", {
|
|
1021
|
-
useGrouping: false
|
|
1022
|
-
})
|
|
1023
|
-
.split(".")[0];
|
|
1024
|
-
const hash = ethers.utils.keccak256(
|
|
1025
|
-
ethers.utils.defaultAbiCoder.encode(["address", "uint256"], [e[0], repInWei])
|
|
1026
|
-
);
|
|
1027
|
-
treeData[e[0]] = {
|
|
1028
|
-
rep: repInWei,
|
|
1029
|
-
hash
|
|
1030
|
-
};
|
|
1031
|
-
return Buffer.from(hash.slice(2), "hex");
|
|
1032
|
-
});
|
|
1033
|
-
|
|
1034
|
-
console.log("creating merkletree...", elements.length);
|
|
1035
|
-
//NOTICE: we use a non sorted merkletree to save generation time, this requires also a different proof verification algorithm which
|
|
1036
|
-
//is not in the default openzeppelin library
|
|
1037
|
-
|
|
1038
|
-
const merkleTree = new MerkleTree(elements, true);
|
|
1039
|
-
// get the merkle root
|
|
1040
|
-
// returns 32 byte buffer
|
|
1041
|
-
const merkleRoot = merkleTree.getRoot().toString("hex");
|
|
1042
|
-
// generate merkle proof
|
|
1043
|
-
// returns array of 32 byte buffers
|
|
1044
|
-
|
|
1045
|
-
const proof = merkleTree.getProof(elements[0]).map(_ => _.toString("hex"));
|
|
1046
|
-
const validProof = checkProofOrdered(
|
|
1047
|
-
proof.map(_ => Buffer.from(_, "hex")),
|
|
1048
|
-
merkleTree.getRoot(),
|
|
1049
|
-
elements[0],
|
|
1050
|
-
1
|
|
1051
|
-
);
|
|
1052
|
-
|
|
1053
|
-
const lastProof = merkleTree.getProof(elements[elements.length - 1]).map(_ => _.toString("hex"));
|
|
1054
|
-
const lastValidProof = checkProofOrdered(
|
|
1055
|
-
lastProof.map(_ => Buffer.from(_, "hex")),
|
|
1056
|
-
merkleTree.getRoot(),
|
|
1057
|
-
elements[elements.length - 1],
|
|
1058
|
-
elements.length
|
|
1059
|
-
);
|
|
1060
|
-
|
|
1061
|
-
console.log({
|
|
1062
|
-
merkleRoot,
|
|
1063
|
-
proof,
|
|
1064
|
-
validProof,
|
|
1065
|
-
lastProof,
|
|
1066
|
-
lastValidProof,
|
|
1067
|
-
proofFor: toTree[0],
|
|
1068
|
-
lastProofFor: toTree[toTree.length - 1]
|
|
1069
|
-
});
|
|
1070
|
-
fs.writeFileSync(
|
|
1071
|
-
`${folder}/airdrop.json`,
|
|
1072
|
-
JSON.stringify({
|
|
1073
|
-
treeData,
|
|
1074
|
-
merkleRoot,
|
|
1075
|
-
ETH_SNAPSHOT_BLOCK,
|
|
1076
|
-
FUSE_SNAPSHOT_BLOCK
|
|
1077
|
-
})
|
|
1078
|
-
);
|
|
1079
|
-
};
|
|
1080
|
-
|
|
1081
|
-
const getProof = addr => {
|
|
1082
|
-
const { treeData, merkleRoot } = JSON.parse(
|
|
1083
|
-
fs.readFileSync("airdrop/airdrop.json").toString()
|
|
1084
|
-
// fs.readFileSync("airdrop/airdropPrev.json").toString()
|
|
1085
|
-
);
|
|
1086
|
-
|
|
1087
|
-
let entries = Object.entries(treeData as Tree);
|
|
1088
|
-
let elements = entries.map(e => Buffer.from(e[1].hash.slice(2), "hex"));
|
|
1089
|
-
|
|
1090
|
-
console.log("creating merkletree...", elements.length);
|
|
1091
|
-
const merkleTree = new MerkleTree(elements, true);
|
|
1092
|
-
|
|
1093
|
-
const calcMerkleRoot = merkleTree.getRoot().toString("hex");
|
|
1094
|
-
console.log("merkleroots:", {
|
|
1095
|
-
fromFile: merkleRoot,
|
|
1096
|
-
calculated: calcMerkleRoot
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
const addrData = treeData[addr] || treeData[addr.toLowerCase()];
|
|
1100
|
-
const proofFor = Buffer.from(addrData.hash.slice(2), "hex");
|
|
1101
|
-
|
|
1102
|
-
const proof = merkleTree.getProof(proofFor);
|
|
1103
|
-
const proofIndex = entries.findIndex(_ => _[1].hash === addrData.hash) + 1;
|
|
1104
|
-
|
|
1105
|
-
console.log("checkProof:", checkProofOrdered(proof, merkleTree.getRoot(), proofFor, proofIndex));
|
|
1106
|
-
const hexProof = proof.map(_ => "0x" + _.toString("hex"));
|
|
1107
|
-
console.log({ proofIndex, proof: hexProof, [addr]: addrData });
|
|
1108
|
-
};
|
|
1109
|
-
|
|
1110
|
-
return { buildMerkleTree, collectAirdropData, getProof };
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
const _timer = async (name, promise) => {
|
|
1114
|
-
const start = Date.now();
|
|
1115
|
-
const res = await promise;
|
|
1116
|
-
const milis = Date.now() - start;
|
|
1117
|
-
console.log(`done task ${name} in ${milis / 1000} seconds`);
|
|
1118
|
-
return res;
|
|
1119
|
-
};
|