@gooddollar/goodprotocol 1.0.24 → 1.0.26
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/FuseFaucet.min.json +1 -0
- package/artifacts/abis/FuseStakingV3.min.json +1 -0
- package/artifacts/abis/IConsensus.min.json +1 -0
- package/artifacts/abis/InvitesV1.min.json +1 -0
- package/artifacts/abis/PegSwap.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/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/ILendingPool.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/FuseFaucet.sol/FuseFaucet.dbg.json +4 -0
- package/artifacts/contracts/fuseFaucet/FuseFaucet.sol/FuseFaucet.json +325 -0
- 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/invite/InvitesV1.sol/InvitesV1.dbg.json +4 -0
- package/artifacts/contracts/invite/InvitesV1.sol/InvitesV1.json +492 -0
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.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/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.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/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/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 +4 -0
- package/artifacts/contracts/staking/FuseStakingV3.sol/FuseStakingV3.json +733 -0
- package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.dbg.json +4 -0
- package/artifacts/contracts/staking/FuseStakingV3.sol/IConsensus.json +104 -0
- package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.dbg.json +4 -0
- package/artifacts/contracts/staking/FuseStakingV3.sol/PegSwap.json +34 -0
- 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/ubi/UBIScheme.sol/UBIScheme.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/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/NameService.sol/NameService.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/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/contracts/fuseFaucet/FuseFaucet.sol +172 -0
- package/contracts/invite/InvitesV1.sol +316 -0
- package/contracts/staking/FuseStakingV3.sol +641 -0
- package/hardhat.config.ts +7 -0
- package/package.json +5 -5
- package/scripts/misc/faucetStats.ts +103 -0
- package/scripts/upgradeToV2/upgradeToV2.ts +22 -7
- package/test/FuseFaucet.test.ts +168 -0
- package/test/InvitesV1.test.ts +354 -0
- package/test/staking/FuseStaking.test.ts +152 -0
- package/types/FuseFaucet.ts +498 -0
- package/types/FuseStakingV3.ts +1234 -0
- package/types/IConsensus.ts +225 -0
- package/types/InvitesV1.ts +797 -0
- package/types/OwnableUpgradeable.ts +166 -0
- package/types/PegSwap.ts +112 -0
- package/types/factories/FuseFaucet__factory.ts +373 -0
- package/types/factories/FuseStakingV3__factory.ts +781 -0
- package/types/factories/IConsensus__factory.ts +116 -0
- package/types/factories/InvitesV1__factory.ts +540 -0
- package/types/factories/OwnableUpgradeable__factory.ts +78 -0
- package/types/factories/PegSwap__factory.ts +46 -0
- package/types/hardhat.d.ts +54 -0
- package/types/index.ts +12 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "IConsensus",
|
|
4
|
+
"sourceName": "contracts/staking/FuseStakingV3.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"internalType": "address",
|
|
10
|
+
"name": "_validator",
|
|
11
|
+
"type": "address"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"name": "delegate",
|
|
15
|
+
"outputs": [],
|
|
16
|
+
"stateMutability": "payable",
|
|
17
|
+
"type": "function"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"inputs": [
|
|
21
|
+
{
|
|
22
|
+
"internalType": "address",
|
|
23
|
+
"name": "_address",
|
|
24
|
+
"type": "address"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"internalType": "address",
|
|
28
|
+
"name": "_validator",
|
|
29
|
+
"type": "address"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"name": "delegatedAmount",
|
|
33
|
+
"outputs": [
|
|
34
|
+
{
|
|
35
|
+
"internalType": "uint256",
|
|
36
|
+
"name": "",
|
|
37
|
+
"type": "uint256"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"stateMutability": "view",
|
|
41
|
+
"type": "function"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"inputs": [
|
|
45
|
+
{
|
|
46
|
+
"internalType": "address",
|
|
47
|
+
"name": "_validator",
|
|
48
|
+
"type": "address"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"name": "delegators",
|
|
52
|
+
"outputs": [
|
|
53
|
+
{
|
|
54
|
+
"internalType": "address[]",
|
|
55
|
+
"name": "",
|
|
56
|
+
"type": "address[]"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"stateMutability": "view",
|
|
60
|
+
"type": "function"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"inputs": [
|
|
64
|
+
{
|
|
65
|
+
"internalType": "address",
|
|
66
|
+
"name": "_address",
|
|
67
|
+
"type": "address"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"name": "stakeAmount",
|
|
71
|
+
"outputs": [
|
|
72
|
+
{
|
|
73
|
+
"internalType": "uint256",
|
|
74
|
+
"name": "",
|
|
75
|
+
"type": "uint256"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"stateMutability": "view",
|
|
79
|
+
"type": "function"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"inputs": [
|
|
83
|
+
{
|
|
84
|
+
"internalType": "address",
|
|
85
|
+
"name": "_validator",
|
|
86
|
+
"type": "address"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"internalType": "uint256",
|
|
90
|
+
"name": "_amount",
|
|
91
|
+
"type": "uint256"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"name": "withdraw",
|
|
95
|
+
"outputs": [],
|
|
96
|
+
"stateMutability": "nonpayable",
|
|
97
|
+
"type": "function"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"bytecode": "0x",
|
|
101
|
+
"deployedBytecode": "0x",
|
|
102
|
+
"linkReferences": {},
|
|
103
|
+
"deployedLinkReferences": {}
|
|
104
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "PegSwap",
|
|
4
|
+
"sourceName": "contracts/staking/FuseStakingV3.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [
|
|
8
|
+
{
|
|
9
|
+
"internalType": "uint256",
|
|
10
|
+
"name": "sourceAmount",
|
|
11
|
+
"type": "uint256"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"internalType": "address",
|
|
15
|
+
"name": "source",
|
|
16
|
+
"type": "address"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"internalType": "address",
|
|
20
|
+
"name": "target",
|
|
21
|
+
"type": "address"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"name": "swap",
|
|
25
|
+
"outputs": [],
|
|
26
|
+
"stateMutability": "nonpayable",
|
|
27
|
+
"type": "function"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"bytecode": "0x",
|
|
31
|
+
"deployedBytecode": "0x",
|
|
32
|
+
"linkReferences": {},
|
|
33
|
+
"deployedLinkReferences": {}
|
|
34
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
//SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
6
|
+
import "../Interfaces.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title DonationStaking contract that receives funds in ETH/DAI
|
|
10
|
+
* and stake them in the SimpleStaking contract
|
|
11
|
+
*/
|
|
12
|
+
contract FuseFaucet is Initializable {
|
|
13
|
+
event WalletTopped(address indexed user, uint256 amount);
|
|
14
|
+
|
|
15
|
+
uint256 public perDayRoughLimit;
|
|
16
|
+
uint256 public toppingAmount;
|
|
17
|
+
uint256 public gasRefund;
|
|
18
|
+
uint256 public startTime;
|
|
19
|
+
uint256 public currentDay;
|
|
20
|
+
|
|
21
|
+
IIdentity public identity;
|
|
22
|
+
|
|
23
|
+
mapping(uint256 => mapping(address => uint256)) public toppings;
|
|
24
|
+
mapping(address => bool) public notFirstTime;
|
|
25
|
+
|
|
26
|
+
struct Wallet {
|
|
27
|
+
uint128 lastDayTopped;
|
|
28
|
+
uint32 dailyToppingCount;
|
|
29
|
+
uint128[7] lastWeekToppings;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
mapping(address => Wallet) public wallets;
|
|
33
|
+
uint32 public maxDailyToppings;
|
|
34
|
+
uint32 public gasPrice;
|
|
35
|
+
uint32 public maxPerWeekMultiplier;
|
|
36
|
+
uint32 public maxSwapAmount;
|
|
37
|
+
address public goodDollar;
|
|
38
|
+
|
|
39
|
+
function initialize(address _identity) public initializer {
|
|
40
|
+
toppingAmount = 600000 * 1e9; //0.6M gwei
|
|
41
|
+
perDayRoughLimit = 2 * toppingAmount;
|
|
42
|
+
maxDailyToppings = 3;
|
|
43
|
+
gasPrice = 1e9;
|
|
44
|
+
startTime = block.timestamp;
|
|
45
|
+
identity = IIdentity(_identity);
|
|
46
|
+
maxPerWeekMultiplier = 2;
|
|
47
|
+
maxSwapAmount = 1000;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
modifier reimburseGas() {
|
|
51
|
+
uint256 _gasRefund = gasleft();
|
|
52
|
+
_;
|
|
53
|
+
_gasRefund = _gasRefund - gasleft() + 42000;
|
|
54
|
+
payable(msg.sender).transfer(_gasRefund * gasPrice); //gas price assumed 1e9 = 1gwei
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function upgrade1() public {
|
|
58
|
+
toppingAmount = 600000 * 1e9; //1M gwei
|
|
59
|
+
perDayRoughLimit = 2 * toppingAmount;
|
|
60
|
+
maxDailyToppings = 3;
|
|
61
|
+
gasPrice = 1e9;
|
|
62
|
+
maxPerWeekMultiplier = 2;
|
|
63
|
+
maxSwapAmount = 1000;
|
|
64
|
+
goodDollar = address(0x495d133B938596C9984d462F007B676bDc57eCEC);
|
|
65
|
+
cERC20(goodDollar).approve(
|
|
66
|
+
address(0xE3F85aAd0c8DD7337427B9dF5d0fB741d65EEEB5),
|
|
67
|
+
type(uint256).max
|
|
68
|
+
); //voltage swap
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
receive() external payable {}
|
|
72
|
+
|
|
73
|
+
modifier toppingLimit(address _user) {
|
|
74
|
+
setDay();
|
|
75
|
+
require(
|
|
76
|
+
wallets[_user].lastDayTopped != uint128(currentDay) ||
|
|
77
|
+
wallets[_user].dailyToppingCount < maxDailyToppings,
|
|
78
|
+
"max daily toppings"
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
require(
|
|
82
|
+
identity.isWhitelisted(_user) || notFirstTime[_user] == false,
|
|
83
|
+
"User not whitelisted or not first time"
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
//reset inactive days
|
|
87
|
+
uint256 dayOfWeek = currentDay % 7;
|
|
88
|
+
uint256 dayDiff = (currentDay - wallets[_user].lastDayTopped);
|
|
89
|
+
dayDiff = dayDiff > 7 ? 7 : dayDiff;
|
|
90
|
+
dayDiff = dayDiff > dayOfWeek ? dayOfWeek + 1 : dayDiff;
|
|
91
|
+
for (uint256 day = dayOfWeek + 1 - dayDiff; day <= dayOfWeek; day++) {
|
|
92
|
+
wallets[_user].lastWeekToppings[day] = 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
uint128 weekTotal = 0;
|
|
96
|
+
for (uint256 i = 0; i <= dayOfWeek; i++) {
|
|
97
|
+
weekTotal += wallets[_user].lastWeekToppings[uint256(i)];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
require(
|
|
101
|
+
weekTotal < perDayRoughLimit * maxPerWeekMultiplier,
|
|
102
|
+
"User wallet has been topped too many times this week"
|
|
103
|
+
);
|
|
104
|
+
_;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* @dev Internal function that sets current day
|
|
108
|
+
*/
|
|
109
|
+
function setDay() internal {
|
|
110
|
+
currentDay = (block.timestamp - startTime) / 1 days;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function canTop(address _user) public view returns (bool) {
|
|
114
|
+
uint256 _currentDay = (block.timestamp - startTime) / 1 days;
|
|
115
|
+
bool can = (wallets[_user].lastDayTopped != uint128(currentDay) ||
|
|
116
|
+
wallets[_user].dailyToppingCount < 3) &&
|
|
117
|
+
(identity.isWhitelisted(_user) || notFirstTime[_user] == false);
|
|
118
|
+
|
|
119
|
+
uint128 weekTotal = 0;
|
|
120
|
+
uint256 dayOfWeek = currentDay % 7;
|
|
121
|
+
for (uint256 i = 0; i <= dayOfWeek; i++) {
|
|
122
|
+
weekTotal += wallets[_user].lastWeekToppings[uint256(i)];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
can = can && weekTotal < perDayRoughLimit * maxPerWeekMultiplier;
|
|
126
|
+
return can;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* @dev Function to top given address with amount of G$ given in constructor
|
|
130
|
+
* can only be done by admin the amount of times specified in constructor per day
|
|
131
|
+
* @param _user The address to transfer to
|
|
132
|
+
*/
|
|
133
|
+
function topWallet(address payable _user)
|
|
134
|
+
public
|
|
135
|
+
reimburseGas
|
|
136
|
+
toppingLimit(_user)
|
|
137
|
+
{
|
|
138
|
+
_topWallet(_user);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function _topWallet(address payable _wallet) internal {
|
|
142
|
+
require(toppingAmount > address(_wallet).balance);
|
|
143
|
+
uint256 toTop = toppingAmount - address(_wallet).balance;
|
|
144
|
+
|
|
145
|
+
uint256 dayOfWeek = currentDay % 7;
|
|
146
|
+
|
|
147
|
+
if (wallets[_wallet].lastDayTopped == uint128(currentDay))
|
|
148
|
+
wallets[_wallet].dailyToppingCount += 1;
|
|
149
|
+
else wallets[_wallet].dailyToppingCount = 1;
|
|
150
|
+
wallets[_wallet].lastDayTopped = uint128(currentDay);
|
|
151
|
+
wallets[_wallet].lastWeekToppings[dayOfWeek] += uint128(toTop);
|
|
152
|
+
|
|
153
|
+
notFirstTime[_wallet] = true;
|
|
154
|
+
_wallet.transfer(toTop);
|
|
155
|
+
emit WalletTopped(_wallet, toTop);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function onTokenTransfer(
|
|
159
|
+
address payable _from,
|
|
160
|
+
uint256 amount,
|
|
161
|
+
bytes calldata
|
|
162
|
+
) external returns (bool) {
|
|
163
|
+
require(msg.sender == address(goodDollar), "not G$");
|
|
164
|
+
require(amount <= maxSwapAmount, "slippage");
|
|
165
|
+
Uniswap uniswap = Uniswap(0xE3F85aAd0c8DD7337427B9dF5d0fB741d65EEEB5);
|
|
166
|
+
address[] memory path = new address[](2);
|
|
167
|
+
path[0] = address(msg.sender);
|
|
168
|
+
path[1] = uniswap.WETH();
|
|
169
|
+
uniswap.swapExactTokensForETH(amount, 0, path, _from, block.timestamp);
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
}
|