|
4 | 4 | This is an extension of the ATokenWithDelegation with added getters. |
5 | 5 | */ |
6 | 6 |
|
7 | | - |
8 | | - |
9 | 7 | pragma solidity ^0.8.0; |
10 | 8 |
|
11 | 9 | import {ATokenWithDelegationInstance} from 'certora/atoken-with-delegation/munged/src/contracts/instances/ATokenWithDelegationInstance.sol'; |
12 | 10 | import {ScaledBalanceTokenBase} from 'certora/atoken-with-delegation/munged/src/contracts/protocol/tokenization/base/ScaledBalanceTokenBase.sol'; |
13 | 11 |
|
14 | | -import {IPool} from 'certora/atoken-with-delegation/munged/src/contracts/interfaces/IPool.sol'; |
| 12 | +import {IPool} from 'certora/atoken-with-delegation/munged/src/contracts/interfaces/IPool.sol'; |
15 | 13 |
|
16 | 14 | import {IScaledBalanceToken} from 'certora/atoken-with-delegation/munged/src/contracts/interfaces/IScaledBalanceToken.sol'; |
17 | 15 | import {WadRayMath} from 'certora/atoken-with-delegation/munged/src/contracts/protocol/libraries/math/WadRayMath.sol'; |
18 | 16 | import {DelegationMode} from 'certora/atoken-with-delegation/munged/src/contracts/protocol/tokenization/base/DelegationMode.sol'; |
19 | 17 | import {BaseDelegation} from 'certora/atoken-with-delegation/munged/src/contracts/protocol/tokenization/delegation/BaseDelegation.sol'; |
20 | 18 |
|
21 | | - |
22 | | - |
23 | 19 | contract ATokenWithDelegation_Harness is ATokenWithDelegationInstance { |
24 | | - using WadRayMath for uint256; |
25 | | - |
26 | | - constructor(IPool pool, address rewardsController, address treasury) ATokenWithDelegationInstance(pool,rewardsController,treasury) {} |
27 | | - |
28 | | - function getBalance(address user) public view returns (uint120) { |
29 | | - return _userState[user].balance; |
30 | | - } |
31 | | - |
32 | | - // returns user's delegated proposition balance |
33 | | - function getDelegatedPropositionBalance(address user) public view returns (uint72) { |
34 | | - return _getDelegationState(user).delegatedPropositionBalance; |
35 | | - } |
36 | | - |
37 | | - // returns user's delegated voting balance |
38 | | - function getDelegatedVotingBalance(address user) public view returns (uint72) { |
39 | | - return _getDelegationState(user).delegatedVotingBalance; |
40 | | - } |
41 | | - |
42 | | - //returns user's delegating proposition status |
43 | | - function isDelegatingProposition(address user) public view returns (bool) { |
44 | | - return |
45 | | - _userState[user].delegationMode == DelegationMode.PROPOSITION_DELEGATED || |
46 | | - _userState[user].delegationMode == DelegationMode.FULL_POWER_DELEGATED; |
47 | | - } |
48 | | - |
49 | | - // returns user's delegating voting status |
50 | | - function isDelegatingVoting(address user) public view returns (bool) { |
51 | | - return |
52 | | - _userState[user].delegationMode == DelegationMode.VOTING_DELEGATED || |
53 | | - _userState[user].delegationMode == DelegationMode.FULL_POWER_DELEGATED; |
54 | | - } |
55 | | - |
56 | | - // returns user's voting delegate |
57 | | - function getVotingDelegatee(address user) public view returns (address) { |
58 | | - return _votingDelegatee[user]; |
59 | | - } |
60 | | - |
61 | | - // returns user's proposition delegate |
62 | | - function getPropositionDelegatee(address user) public view returns (address) { |
63 | | - return _propositionDelegatee[user]; |
64 | | - } |
65 | | - |
66 | | - // returns user's delegation state |
67 | | - function getDelegationMode(address user) public view returns (DelegationMode) { |
68 | | - return _userState[user].delegationMode; |
69 | | - } |
70 | | - |
71 | | - |
72 | | - function scaledTotalSupply() public view override(IScaledBalanceToken,ScaledBalanceTokenBase) returns (uint256) { |
73 | | - uint256 val = super.scaledTotalSupply(); |
74 | | - return val; |
75 | | - } |
76 | | - |
77 | | - function additionalData(address user) public view returns (uint128) { |
78 | | - return _userState[user].additionalData; |
79 | | - } |
80 | | - |
81 | | - function scaledBalance_to_balance(uint256 bal) public view returns (uint256) { |
82 | | - return bal.rayMul(POOL.getReserveNormalizedIncome(_underlyingAsset)); |
83 | | - } |
84 | | - |
85 | | - |
86 | | - //The following are for the comuunity rules |
87 | | - function ecrecoverWrapper( |
88 | | - bytes32 hash, |
89 | | - uint8 v, |
90 | | - bytes32 r, |
91 | | - bytes32 s |
92 | | - ) public pure returns (address) { |
93 | | - return ecrecover(hash, v, r, s); |
94 | | - } |
95 | | - /* |
| 20 | + using WadRayMath for uint256; |
| 21 | + |
| 22 | + constructor( |
| 23 | + IPool pool, |
| 24 | + address rewardsController, |
| 25 | + address treasury |
| 26 | + ) ATokenWithDelegationInstance(pool, rewardsController, treasury) {} |
| 27 | + |
| 28 | + function getBalance(address user) public view returns (uint120) { |
| 29 | + return _userState[user].balance; |
| 30 | + } |
| 31 | + |
| 32 | + // returns user's delegated proposition balance |
| 33 | + function getDelegatedPropositionBalance(address user) public view returns (uint72) { |
| 34 | + return _getDelegationState(user).delegatedPropositionBalance; |
| 35 | + } |
| 36 | + |
| 37 | + // returns user's delegated voting balance |
| 38 | + function getDelegatedVotingBalance(address user) public view returns (uint72) { |
| 39 | + return _getDelegationState(user).delegatedVotingBalance; |
| 40 | + } |
| 41 | + |
| 42 | + //returns user's delegating proposition status |
| 43 | + function isDelegatingProposition(address user) public view returns (bool) { |
| 44 | + return |
| 45 | + _userState[user].delegationMode == DelegationMode.PROPOSITION_DELEGATED || |
| 46 | + _userState[user].delegationMode == DelegationMode.FULL_POWER_DELEGATED; |
| 47 | + } |
| 48 | + |
| 49 | + // returns user's delegating voting status |
| 50 | + function isDelegatingVoting(address user) public view returns (bool) { |
| 51 | + return |
| 52 | + _userState[user].delegationMode == DelegationMode.VOTING_DELEGATED || |
| 53 | + _userState[user].delegationMode == DelegationMode.FULL_POWER_DELEGATED; |
| 54 | + } |
| 55 | + |
| 56 | + // returns user's voting delegate |
| 57 | + function getVotingDelegatee(address user) public view returns (address) { |
| 58 | + return _votingDelegatee[user]; |
| 59 | + } |
| 60 | + |
| 61 | + // returns user's proposition delegate |
| 62 | + function getPropositionDelegatee(address user) public view returns (address) { |
| 63 | + return _propositionDelegatee[user]; |
| 64 | + } |
| 65 | + |
| 66 | + // returns user's delegation state |
| 67 | + function getDelegationMode(address user) public view returns (DelegationMode) { |
| 68 | + return _userState[user].delegationMode; |
| 69 | + } |
| 70 | + |
| 71 | + function scaledTotalSupply() |
| 72 | + public |
| 73 | + view |
| 74 | + override(IScaledBalanceToken, ScaledBalanceTokenBase) |
| 75 | + returns (uint256) |
| 76 | + { |
| 77 | + uint256 val = super.scaledTotalSupply(); |
| 78 | + return val; |
| 79 | + } |
| 80 | + |
| 81 | + function additionalData(address user) public view returns (uint128) { |
| 82 | + return _userState[user].additionalData; |
| 83 | + } |
| 84 | + |
| 85 | + function scaledBalance_to_balance(uint256 bal) public view returns (uint256) { |
| 86 | + return bal.rayMul(POOL.getReserveNormalizedIncome(_underlyingAsset)); |
| 87 | + } |
| 88 | + |
| 89 | + //The following are for the comuunity rules |
| 90 | + function ecrecoverWrapper( |
| 91 | + bytes32 hash, |
| 92 | + uint8 v, |
| 93 | + bytes32 r, |
| 94 | + bytes32 s |
| 95 | + ) public pure returns (address) { |
| 96 | + return ecrecover(hash, v, r, s); |
| 97 | + } |
| 98 | + /* |
96 | 99 | function computeMetaDelegateHash(address delegator, address delegatee, uint256 deadline, uint256 nonce) |
97 | 100 | public view returns (bytes32) { |
98 | 101 | bytes32 digest = |
@@ -127,15 +130,21 @@ contract ATokenWithDelegation_Harness is ATokenWithDelegationInstance { |
127 | 130 | return digest; |
128 | 131 | } |
129 | 132 | */ |
130 | | - function getPowerCurrent_BaseDelegation(address user, GovernancePowerType delegationType) |
131 | | - public view virtual returns (uint256) { |
132 | | - return BaseDelegation.getPowerCurrent(user,delegationType); |
133 | | - } |
134 | | - |
135 | | - function getNonce(address user) public view returns (uint256) { |
136 | | - return _nonces[user]; |
137 | | - } |
138 | | - |
139 | | - function rayMul_WRP(uint256 a, uint256 b) external returns (uint256) {return a.rayMul(b);} |
140 | | - function rayDiv_WRP(uint256 a, uint256 b) external returns (uint256) {return a.rayDiv(b);} |
| 133 | + function getPowerCurrent_BaseDelegation( |
| 134 | + address user, |
| 135 | + GovernancePowerType delegationType |
| 136 | + ) public view virtual returns (uint256) { |
| 137 | + return BaseDelegation.getPowerCurrent(user, delegationType); |
| 138 | + } |
| 139 | + |
| 140 | + function getNonce(address user) public view returns (uint256) { |
| 141 | + return _nonces[user]; |
| 142 | + } |
| 143 | + |
| 144 | + function rayMul_WRP(uint256 a, uint256 b) external returns (uint256) { |
| 145 | + return a.rayMul(b); |
| 146 | + } |
| 147 | + function rayDiv_WRP(uint256 a, uint256 b) external returns (uint256) { |
| 148 | + return a.rayDiv(b); |
| 149 | + } |
141 | 150 | } |
0 commit comments