-
Notifications
You must be signed in to change notification settings - Fork 47
/
FeeSharingCollectorStorage.sol
125 lines (101 loc) · 4.1 KB
/
FeeSharingCollectorStorage.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
pragma solidity ^0.5.17;
pragma experimental ABIEncoderV2;
import "../../openzeppelin/Ownable.sol";
import "../../interfaces/IERC20.sol";
import "../IFeeSharingCollector.sol";
import "../Staking/interfaces/IStaking.sol";
import "../../mixins/EnumerableAddressSet.sol";
import "../../interfaces/IWrbtcERC20.sol";
/**
* @title FeeSharingCollectorStorage contact
* @notice Just the storage part of FeeSharingCollector contract, and FeeSharingCollectorProxy. No functions,
* only constant, variables and required structures (mappings)
* */
contract FeeSharingCollectorStorage is Ownable {
using EnumerableAddressSet for EnumerableAddressSet.AddressSet;
uint256 constant FEE_WITHDRAWAL_INTERVAL = 172800;
IProtocol public protocol;
IStaking public staking;
/// @notice Checkpoints by index per pool token address
mapping(address => mapping(uint256 => Checkpoint)) public tokenCheckpoints;
/// @notice The number of checkpoints for each token address.
mapping(address => uint256) public totalTokenCheckpoints;
/// @notice
/// user => token => processed checkpoints
mapping(address => mapping(address => uint256)) public processedCheckpoints;
/// @notice Last time fees were withdrawn per pool token address:
/// token => time
mapping(address => uint256) public lastFeeWithdrawalTime;
/// @notice Amount of tokens that were transferred, but not saved in checkpoints.
/// token => amount
mapping(address => uint96) public unprocessedAmount;
struct Checkpoint {
uint32 blockNumber;
uint32 timestamp;
uint96 totalWeightedStake;
uint96 numTokens;
}
struct TokenWithSkippedCheckpointsWithdraw {
address tokenAddress;
uint256 fromCheckpoint;
}
/**
* @dev Add extra modifier (Reentrancy) below.
* Because we cannot add any additional storage slot before this storage contract after initial deployment
*/
/// @dev Constant for unlocked guard state - non-zero to prevent extra gas costs.
/// See: https://github.com/OpenZeppelin/openzeppelin-solidity/issues/1056
uint256 internal constant REENTRANCY_GUARD_FREE = 1;
/// @dev Constant for locked guard state
uint256 internal constant REENTRANCY_GUARD_LOCKED = 2;
/**
* @dev We use a single lock for the whole contract.
*/
uint256 internal reentrancyLock = REENTRANCY_GUARD_FREE;
/**
* @dev Additional storage for converter whitelist mechanism.
* @dev Initialization here does not works. We need to create a separate setter & getter.
* @dev Just set the visibility to internal should be fine.
*/
EnumerableAddressSet.AddressSet internal whitelistedConverterList;
mapping(bytes4 => bool) public isFunctionExecuted;
/**
* @dev Wrbtc token address
*/
address public wrbtcTokenAddress;
/**
* @dev iWrbtc loan token address
*/
address public loanTokenWrbtcAddress;
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* If you mark a function `nonReentrant`, you should also
* mark it `external`. Calling one `nonReentrant` function from
* another is not supported. Instead, you can implement a
* `private` function doing the actual work, and an `external`
* wrapper marked as `nonReentrant`.
*/
modifier nonReentrant() {
require(reentrancyLock == REENTRANCY_GUARD_FREE, "nonReentrant");
reentrancyLock = REENTRANCY_GUARD_LOCKED;
_;
reentrancyLock = REENTRANCY_GUARD_FREE;
}
}
/* Interfaces */
interface IProtocol {
/**
*
* @param tokens The array address of the token instance.
* @param receiver The address of the withdrawal recipient.
*
* @return The withdrawn total amount in wRBTC
* */
function withdrawFees(
address[] calldata tokens,
address receiver
) external returns (uint256 totalWRBTCWithdrawn);
function underlyingToLoanPool(address token) external view returns (address);
function wrbtcToken() external view returns (IWrbtcERC20);
function getSovTokenAddress() external view returns (address);
}