@gooddollar/goodprotocol 2.0.25-beta.2 → 2.0.25-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/abis/InvitesV2.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/invite/InvitesV2.sol/InvitesV2.json +15 -2
- 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/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/invite/InvitesV2.sol +55 -40
- package/package.json +1 -1
- package/scripts/analytics/activeWalletsStats.ts +51 -38
- package/test/invite/InvitesV2.test.ts +139 -271
- package/types/contracts/invite/InvitesV2.ts +32 -0
- package/types/factories/contracts/invite/InvitesV2__factory.ts +14 -1
|
@@ -57,6 +57,8 @@ contract InvitesV2 is DAOUpgradeableContract {
|
|
|
57
57
|
|
|
58
58
|
bool public levelExpirationEnabled;
|
|
59
59
|
|
|
60
|
+
bytes32 private campaignCode;
|
|
61
|
+
|
|
60
62
|
event InviteeJoined(address indexed inviter, address indexed invitee);
|
|
61
63
|
event InviterBounty(
|
|
62
64
|
address indexed inviter,
|
|
@@ -125,8 +127,10 @@ contract InvitesV2 is DAOUpgradeableContract {
|
|
|
125
127
|
address inviter = codeToUser[_inviterCode];
|
|
126
128
|
//allow user to set inviter if doesnt have one
|
|
127
129
|
require(
|
|
128
|
-
user.
|
|
129
|
-
(user.
|
|
130
|
+
!user.bountyPaid &&
|
|
131
|
+
(user.inviteCode == 0x0 ||
|
|
132
|
+
(user.invitedBy == address(0) && inviter != address(0)) ||
|
|
133
|
+
(campaignCode != 0x0 && campaignCode == _inviterCode)),
|
|
130
134
|
"user already joined"
|
|
131
135
|
);
|
|
132
136
|
if (user.inviteCode == 0x0) {
|
|
@@ -144,6 +148,11 @@ contract InvitesV2 is DAOUpgradeableContract {
|
|
|
144
148
|
user.bountyAtJoin = levels[users[inviter].level].bounty;
|
|
145
149
|
}
|
|
146
150
|
|
|
151
|
+
/** support special campaign code without inviter */
|
|
152
|
+
if (_inviterCode == campaignCode && campaignCode != 0x0) {
|
|
153
|
+
user.bountyAtJoin = levels[0].bounty;
|
|
154
|
+
}
|
|
155
|
+
|
|
147
156
|
if (canCollectBountyFor(msg.sender)) {
|
|
148
157
|
_bountyFor(msg.sender, true);
|
|
149
158
|
}
|
|
@@ -165,19 +174,13 @@ contract InvitesV2 is DAOUpgradeableContract {
|
|
|
165
174
|
|
|
166
175
|
function canCollectBountyFor(address _invitee) public view returns (bool) {
|
|
167
176
|
address invitedBy = users[_invitee].invitedBy;
|
|
168
|
-
uint256 daysToComplete = levels[users[invitedBy].level].daysToComplete;
|
|
169
|
-
bool isLevelExpired = levelExpirationEnabled == true &&
|
|
170
|
-
daysToComplete > 0 &&
|
|
171
|
-
daysToComplete <
|
|
172
|
-
(users[_invitee].joinedAt - users[invitedBy].levelStarted) / 1 days;
|
|
173
177
|
|
|
174
178
|
return
|
|
175
|
-
|
|
179
|
+
users[_invitee].bountyAtJoin > 0 &&
|
|
176
180
|
!users[_invitee].bountyPaid &&
|
|
177
181
|
getIdentity().isWhitelisted(_invitee) &&
|
|
178
|
-
getIdentity().isWhitelisted(invitedBy) &&
|
|
179
|
-
_whitelistedOnChainOrDefault(_invitee) == _chainId()
|
|
180
|
-
isLevelExpired == false;
|
|
182
|
+
(invitedBy == address(0) || getIdentity().isWhitelisted(invitedBy)) &&
|
|
183
|
+
_whitelistedOnChainOrDefault(_invitee) == _chainId();
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
function getInvitees(
|
|
@@ -237,44 +240,51 @@ contract InvitesV2 is DAOUpgradeableContract {
|
|
|
237
240
|
bool isSingleBounty
|
|
238
241
|
) internal returns (uint256 bounty) {
|
|
239
242
|
address invitedBy = users[_invitee].invitedBy;
|
|
240
|
-
uint256 joinedAt = users[_invitee].joinedAt;
|
|
241
|
-
Level memory level = levels[users[invitedBy].level];
|
|
242
243
|
uint256 bountyToPay = users[_invitee].bountyAtJoin;
|
|
244
|
+
bool earnedLevel = false;
|
|
243
245
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
bountyToPay = joinedAt > 1687878272 ? 1000 * precision : 500 * precision;
|
|
248
|
-
}
|
|
246
|
+
if (invitedBy != address(0)) {
|
|
247
|
+
uint256 joinedAt = users[_invitee].joinedAt;
|
|
248
|
+
Level memory level = levels[users[invitedBy].level];
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
//hardcoded for users invited before the bountyAtJoin change
|
|
251
|
+
if (bountyToPay == 0) {
|
|
252
|
+
uint precision = 10 ** goodDollar.decimals();
|
|
253
|
+
bountyToPay = joinedAt > 1687878272
|
|
254
|
+
? 1000 * precision
|
|
255
|
+
: 500 * precision;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// if inviter level is now higher than when invitee joined or the base level has changed
|
|
259
|
+
// we give level bounty if it is higher otherwise the original bounty at the time the user registered
|
|
252
260
|
|
|
253
|
-
|
|
261
|
+
bountyToPay = level.bounty > bountyToPay ? level.bounty : bountyToPay;
|
|
254
262
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
263
|
+
bool isLevelExpired = level.daysToComplete > 0 &&
|
|
264
|
+
joinedAt > users[invitedBy].levelStarted && //prevent overflow in subtraction
|
|
265
|
+
level.daysToComplete <
|
|
266
|
+
(joinedAt - users[invitedBy].levelStarted) / 1 days; //how long after level started did invitee join
|
|
267
|
+
|
|
268
|
+
users[invitedBy].totalApprovedInvites += 1;
|
|
269
|
+
users[invitedBy].totalEarned += bountyToPay;
|
|
270
|
+
|
|
271
|
+
if (
|
|
272
|
+
level.toNext > 0 &&
|
|
273
|
+
users[invitedBy].totalApprovedInvites >= level.toNext &&
|
|
274
|
+
isLevelExpired == false
|
|
275
|
+
) {
|
|
276
|
+
users[invitedBy].level += 1;
|
|
277
|
+
users[invitedBy].levelStarted = block.timestamp;
|
|
278
|
+
earnedLevel = true;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (isSingleBounty) goodDollar.transfer(invitedBy, bountyToPay);
|
|
282
|
+
}
|
|
259
283
|
|
|
260
284
|
users[_invitee].bountyPaid = true;
|
|
261
|
-
users[invitedBy].totalApprovedInvites += 1;
|
|
262
|
-
users[invitedBy].totalEarned += bountyToPay;
|
|
263
285
|
stats.totalApprovedInvites += 1;
|
|
264
286
|
stats.totalBountiesPaid += bountyToPay;
|
|
265
287
|
|
|
266
|
-
bool earnedLevel = false;
|
|
267
|
-
if (
|
|
268
|
-
level.toNext > 0 &&
|
|
269
|
-
users[invitedBy].totalApprovedInvites >= level.toNext &&
|
|
270
|
-
isLevelExpired == false
|
|
271
|
-
) {
|
|
272
|
-
users[invitedBy].level += 1;
|
|
273
|
-
users[invitedBy].levelStarted = block.timestamp;
|
|
274
|
-
earnedLevel = true;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (isSingleBounty) goodDollar.transfer(invitedBy, bountyToPay);
|
|
278
288
|
goodDollar.transfer(_invitee, bountyToPay / 2); //pay invitee half the bounty
|
|
279
289
|
emit InviterBounty(
|
|
280
290
|
invitedBy,
|
|
@@ -322,6 +332,10 @@ contract InvitesV2 is DAOUpgradeableContract {
|
|
|
322
332
|
active = _active;
|
|
323
333
|
}
|
|
324
334
|
|
|
335
|
+
function setCampaignCode(bytes32 _code) public ownerOrAvatar {
|
|
336
|
+
campaignCode = _code;
|
|
337
|
+
}
|
|
338
|
+
|
|
325
339
|
function end() public ownerOrAvatar isActive {
|
|
326
340
|
uint256 gdBalance = goodDollar.balanceOf(address(this));
|
|
327
341
|
goodDollar.transfer(msg.sender, gdBalance);
|
|
@@ -346,8 +360,9 @@ contract InvitesV2 is DAOUpgradeableContract {
|
|
|
346
360
|
* 2 uses uups upgradeable - not compatible upgrade for v1
|
|
347
361
|
* 2.1 prevent multichain claims
|
|
348
362
|
* 2.2 record bounty at join time
|
|
363
|
+
* 2.3 support campaignCode
|
|
349
364
|
*/
|
|
350
365
|
function version() public pure returns (string memory) {
|
|
351
|
-
return "2.
|
|
366
|
+
return "2.3";
|
|
352
367
|
}
|
|
353
368
|
}
|
package/package.json
CHANGED
|
@@ -8,31 +8,10 @@ import { ethers } from "hardhat";
|
|
|
8
8
|
* can be used to create stats about active users and how much G$ isnt active
|
|
9
9
|
*/
|
|
10
10
|
const main = async (chain = "fuse") => {
|
|
11
|
-
let result = [];
|
|
12
|
-
let balances = {};
|
|
13
|
-
let curPage = 1;
|
|
14
|
-
let maxResult;
|
|
15
11
|
const explorer = chain === "fuse" ? "https://explorer.fuse.io" : "https://explorer.celo.org";
|
|
16
12
|
const subgraph = chain === "fuse" ? "https://api.thegraph.com/subgraphs/name/gooddollar/gooddollarfuse" : "https://";
|
|
17
|
-
do {
|
|
18
|
-
const pages = range(curPage, curPage + 5, 1);
|
|
19
|
-
curPage += 5;
|
|
20
|
-
const ps = pages.map(p =>
|
|
21
|
-
fetch(
|
|
22
|
-
`https://explorer.fuse.io/api?module=token&action=getTokenHolders&contractaddress=0x495d133B938596C9984d462F007B676bDc57eCEC&page=${p}&offset=10000`
|
|
23
|
-
)
|
|
24
|
-
.then(_ => _.json())
|
|
25
|
-
.then(_ => _.result)
|
|
26
|
-
);
|
|
27
|
-
const results = await Promise.all(ps);
|
|
28
|
-
result = result.concat(...results);
|
|
29
|
-
maxResult = maxBy(results, "length");
|
|
30
|
-
console.log(maxResult.length, result.length);
|
|
31
|
-
} while (maxResult.length === 10000);
|
|
32
|
-
result.forEach(r => (balances[r.address.toLowerCase()] = { balance: r.value, lastSeen: 0 }));
|
|
33
|
-
fs.writeFileSync("activeWalletsBalances.json", JSON.stringify(balances));
|
|
34
13
|
|
|
35
|
-
|
|
14
|
+
const balances = await getFuseBalances();
|
|
36
15
|
|
|
37
16
|
const EPOCH = 60 * 60 * 6;
|
|
38
17
|
const pool = new PromisePool({ concurrency: 30 });
|
|
@@ -92,22 +71,21 @@ const main = async (chain = "fuse") => {
|
|
|
92
71
|
// console.log({ lastUsed });
|
|
93
72
|
};
|
|
94
73
|
|
|
74
|
+
/** Convert a 2D array into a CSV string
|
|
75
|
+
*/
|
|
76
|
+
function arrayToCsv(data) {
|
|
77
|
+
return data
|
|
78
|
+
.map(
|
|
79
|
+
row =>
|
|
80
|
+
row
|
|
81
|
+
.map(String) // convert every value to String
|
|
82
|
+
.map(v => v.replaceAll('"', '""')) // escape double colons
|
|
83
|
+
.map(v => `"${v}"`) // quote it
|
|
84
|
+
.join(",") // comma-separated
|
|
85
|
+
)
|
|
86
|
+
.join("\r\n"); // rows starting on new lines
|
|
87
|
+
}
|
|
95
88
|
const etl = async () => {
|
|
96
|
-
/** Convert a 2D array into a CSV string
|
|
97
|
-
*/
|
|
98
|
-
function arrayToCsv(data) {
|
|
99
|
-
return data
|
|
100
|
-
.map(
|
|
101
|
-
row =>
|
|
102
|
-
row
|
|
103
|
-
.map(String) // convert every value to String
|
|
104
|
-
.map(v => v.replaceAll('"', '""')) // escape double colons
|
|
105
|
-
.map(v => `"${v}"`) // quote it
|
|
106
|
-
.join(",") // comma-separated
|
|
107
|
-
)
|
|
108
|
-
.join("\r\n"); // rows starting on new lines
|
|
109
|
-
}
|
|
110
|
-
|
|
111
89
|
const balances = JSON.parse(fs.readFileSync("activeWalletsLastUsed.json").toString());
|
|
112
90
|
|
|
113
91
|
let result = [];
|
|
@@ -135,6 +113,40 @@ const etl = async () => {
|
|
|
135
113
|
fs.writeFileSync("activeWalletsLastUsed.csv", arrayToCsv(sortBy(result, _ => -Number(_[1]))));
|
|
136
114
|
};
|
|
137
115
|
|
|
116
|
+
const getFuseBalances = async (refetch = true) => {
|
|
117
|
+
if (refetch === false) {
|
|
118
|
+
const balances = JSON.parse(fs.readFileSync("activeWalletsBalances.json").toString());
|
|
119
|
+
const rows = Object.entries(balances).filter(_ => Number(_[1].balance) > 10000000);
|
|
120
|
+
const sorted = sortBy(rows, _ => -Number(_[1].balance));
|
|
121
|
+
sorted.forEach(_ => (_[1].balance = Number(_[1].balance) / 100));
|
|
122
|
+
console.log(arrayToCsv(sorted.slice(0, 20).map(_ => [_[0], _[1].balance])));
|
|
123
|
+
return balances;
|
|
124
|
+
}
|
|
125
|
+
let result = [];
|
|
126
|
+
let balances = {};
|
|
127
|
+
let curPage = 1;
|
|
128
|
+
let maxResult;
|
|
129
|
+
|
|
130
|
+
do {
|
|
131
|
+
const pages = range(curPage, curPage + 5, 1);
|
|
132
|
+
curPage += 5;
|
|
133
|
+
const ps = pages.map(p =>
|
|
134
|
+
fetch(
|
|
135
|
+
`https://explorer.fuse.io/api?module=token&action=getTokenHolders&contractaddress=0x495d133B938596C9984d462F007B676bDc57eCEC&page=${p}&offset=10000`
|
|
136
|
+
)
|
|
137
|
+
.then(_ => _.json())
|
|
138
|
+
.then(_ => _.result)
|
|
139
|
+
);
|
|
140
|
+
const results = await Promise.all(ps);
|
|
141
|
+
result = result.concat(...results);
|
|
142
|
+
maxResult = maxBy(results, "length");
|
|
143
|
+
console.log(maxResult.length, result.length);
|
|
144
|
+
} while (maxResult.length === 10000);
|
|
145
|
+
result.forEach(r => (balances[r.address.toLowerCase()] = { balance: r.value, lastSeen: 0 }));
|
|
146
|
+
fs.writeFileSync("activeWalletsBalances.json", JSON.stringify(balances));
|
|
147
|
+
return balances;
|
|
148
|
+
};
|
|
149
|
+
|
|
138
150
|
const fundsByLastSeen = async () => {
|
|
139
151
|
const balances = JSON.parse(fs.readFileSync("activeWalletsLastUsed.json").toString());
|
|
140
152
|
let total1Year = 0;
|
|
@@ -163,6 +175,7 @@ const fundsByLastSeen = async () => {
|
|
|
163
175
|
|
|
164
176
|
console.log({ total, total1Year, total2Year });
|
|
165
177
|
};
|
|
178
|
+
getFuseBalances(false).catch(e => console.log(e));
|
|
166
179
|
// main().catch(e => console.log(e));
|
|
167
180
|
// etl();
|
|
168
|
-
fundsByLastSeen();
|
|
181
|
+
// fundsByLastSeen();
|