@@ -9,92 +9,15 @@ import {IVotingToken} from "src/interfaces/IVotingToken.sol";
99import {FlexVotingClient} from "src/FlexVotingClient.sol " ;
1010import {FlexVotingDelegatable} from "src/FlexVotingDelegatable.sol " ;
1111
12- contract MockFlexVotingDelegatableClient is FlexVotingDelegatable {
13- using Checkpoints for Checkpoints.Trace208;
12+ import {MockFlexVotingClient} from "test/MockFlexVotingClient.sol " ;
1413
15- /// @notice The governance token held and lent by this pool.
16- ERC20Votes public immutable TOKEN;
14+ contract MockFlexVotingDelegatableClient is MockFlexVotingClient , FlexVotingDelegatable {
15+ constructor ( address _governor ) MockFlexVotingClient (_governor) {}
1716
18- /// @notice Map depositor to deposit amount.
19- mapping (address => uint208 ) public deposits;
20-
21- /// @notice Map borrower to total amount borrowed.
22- mapping (address => uint256 ) public borrowTotal;
23-
24- constructor (address _governor ) FlexVotingClient (_governor) {
25- TOKEN = ERC20Votes (GOVERNOR.token ());
26- _selfDelegate ();
27- }
28-
29- function _rawBalanceOf (address _user ) internal view override returns (uint208 ) {
30- return deposits[_user];
31- }
32-
33- // Test hooks
34- // ---------------------------------------------------------------------------
35- function exposed_rawBalanceOf (address _user ) external view returns (uint208 ) {
36- return _rawBalanceOf (_user);
37- }
38-
39- function exposed_latestTotalBalance () external view returns (uint208 ) {
40- return totalBalanceCheckpoints.latest ();
41- }
42-
43- function exposed_checkpointTotalBalance (int256 _delta ) external {
44- return _checkpointTotalBalance (_delta);
45- }
46-
47- function exposed_castVoteReasonString () external returns (string memory ) {
48- return _castVoteReasonString ();
49- }
50-
51- function exposed_selfDelegate () external {
52- return _selfDelegate ();
53- }
54-
55- function exposed_setDeposits (address _user , uint208 _amount ) external {
56- deposits[_user] = _amount;
57- }
58-
59- function exposed_checkpointRawBalanceOf (address _user ) external {
60- return _checkpointRawBalanceOf (_user);
61- }
62- // End test hooks
63- // ---------------------------------------------------------------------------
64-
65- /// @notice Allow a holder of the governance token to deposit it into the pool.
66- /// @param _amount The amount to be deposited.
67- function deposit (uint208 _amount ) public {
68- deposits[msg .sender ] += _amount;
69-
70- FlexVotingClient._checkpointTotalBalance (int256 (uint256 (_amount)));
71-
72- address _delegate = delegates (msg .sender );
73- FlexVotingDelegatable._updateDelegateBalance (address (0 ), _delegate, _amount);
74-
75- // Assumes revert on failure.
76- TOKEN.transferFrom (msg .sender , address (this ), _amount);
77- }
78-
79- /// @notice Allow a depositor to withdraw funds previously deposited to the pool.
80- /// @param _amount The amount to be withdrawn.
81- function withdraw (uint208 _amount ) public {
82- // Overflows & reverts if user does not have sufficient deposits.
83- deposits[msg .sender ] -= _amount;
84-
85- FlexVotingClient._checkpointTotalBalance (- 1 * int256 (uint256 (_amount)));
86-
87- address _delegate = delegates (msg .sender );
88- FlexVotingDelegatable._updateDelegateBalance (_delegate, address (0 ), _amount);
89-
90- TOKEN.transfer (msg .sender , _amount); // Assumes revert on failure.
91- }
92-
93- /// @notice Arbitrarily remove tokens from the pool. This is to simulate a borrower, hence the
94- /// method name. Since this is just a proof-of-concept, nothing else is actually done here.
95- /// @param _amount The amount to "borrow."
96- function borrow (uint256 _amount ) public {
97- borrowTotal[msg .sender ] += _amount;
98- TOKEN.transfer (msg .sender , _amount);
17+ function _checkpointRawBalanceOf (
18+ address _user ,
19+ int256 _delta
20+ ) internal override (FlexVotingClient, FlexVotingDelegatable) {
21+ return FlexVotingDelegatable._checkpointRawBalanceOf (_user, _delta);
9922 }
10023}
0 commit comments