Skip to content

Commit bf9e652

Browse files
author
cryptofish
committed
jTokenBalance to use jToken.balanceOf() instead of jToken.getAccountSnapShot()
1 parent 30bd881 commit bf9e652

File tree

5 files changed

+207
-46
lines changed

5 files changed

+207
-46
lines changed

contracts/Lens/JoeLens.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ contract JoeLens is Exponential {
170170
vars.underlyingTokenAllowance = underlying.allowance(account, address(jToken));
171171
}
172172

173-
(, vars.jTokenBalance, , ) = jToken.getAccountSnapshot(account);
173+
vars.jTokenBalance = jToken.balanceOf(account);
174174
vars.borrowBalanceCurrent = jToken.borrowBalanceCurrent(account);
175175

176176
vars.balanceOfUnderlyingCurrent = jToken.balanceOfUnderlying(account);

deployments/avalanche/JoeLens.json

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

deployments/avalanche/Maximillion.json

Lines changed: 13 additions & 13 deletions
Large diffs are not rendered by default.

deployments/avalanche/solcInputs/57021528ca194e7ebe5a8306f27ce312.json

Lines changed: 160 additions & 0 deletions
Large diffs are not rendered by default.

out/JoeLens_flat.sol

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -917,12 +917,12 @@ contract UnitrollerAdminStorage {
917917
/**
918918
* @notice Active brains of Unitroller
919919
*/
920-
address public joetrollerImplementation;
920+
address public implementation;
921921

922922
/**
923923
* @notice Pending brains of Unitroller
924924
*/
925-
address public pendingJoetrollerImplementation;
925+
address public pendingImplementation;
926926
}
927927

928928
contract JoetrollerV1Storage is UnitrollerAdminStorage {
@@ -1508,7 +1508,7 @@ contract JWrappedNativeInterface is JErc20Interface {
15081508
/**
15091509
* @notice Flash loan fee ratio
15101510
*/
1511-
uint256 public constant flashFeeBips = 3;
1511+
uint256 public constant flashFeeBips = 8;
15121512

15131513
/*** Market Events ***/
15141514

@@ -1550,7 +1550,7 @@ contract JCapableErc20Interface is JErc20Interface, JSupplyCapStorage {
15501550
/**
15511551
* @notice Flash loan fee ratio
15521552
*/
1553-
uint256 public constant flashFeeBips = 3;
1553+
uint256 public constant flashFeeBips = 8;
15541554

15551555
/*** Market Events ***/
15561556

@@ -3916,17 +3916,17 @@ contract RewardDistributor is RewardDistributorStorage, Exponential {
39163916

39173917
/**
39183918
* @title JoetrollerCore
3919-
* @dev Storage for the joetroller is at this address, while execution is delegated to the `joetrollerImplementation`.
3919+
* @dev Storage for the joetroller is at this address, while execution is delegated to the `implementation`.
39203920
* JTokens should reference this contract as their joetroller.
39213921
*/
39223922
contract Unitroller is UnitrollerAdminStorage, JoetrollerErrorReporter {
39233923
/**
3924-
* @notice Emitted when pendingJoetrollerImplementation is changed
3924+
* @notice Emitted when pendingImplementation is changed
39253925
*/
39263926
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
39273927

39283928
/**
3929-
* @notice Emitted when pendingJoetrollerImplementation is accepted, which means joetroller implementation is updated
3929+
* @notice Emitted when pendingImplementation is accepted, which means joetroller implementation is updated
39303930
*/
39313931
event NewImplementation(address oldImplementation, address newImplementation);
39323932

@@ -3951,11 +3951,11 @@ contract Unitroller is UnitrollerAdminStorage, JoetrollerErrorReporter {
39513951
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);
39523952
}
39533953

3954-
address oldPendingImplementation = pendingJoetrollerImplementation;
3954+
address oldPendingImplementation = pendingImplementation;
39553955

3956-
pendingJoetrollerImplementation = newPendingImplementation;
3956+
pendingImplementation = newPendingImplementation;
39573957

3958-
emit NewPendingImplementation(oldPendingImplementation, pendingJoetrollerImplementation);
3958+
emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);
39593959

39603960
return uint256(Error.NO_ERROR);
39613961
}
@@ -3967,20 +3967,20 @@ contract Unitroller is UnitrollerAdminStorage, JoetrollerErrorReporter {
39673967
*/
39683968
function _acceptImplementation() public returns (uint256) {
39693969
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
3970-
if (msg.sender != pendingJoetrollerImplementation || pendingJoetrollerImplementation == address(0)) {
3970+
if (msg.sender != pendingImplementation || pendingImplementation == address(0)) {
39713971
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
39723972
}
39733973

39743974
// Save current values for inclusion in log
3975-
address oldImplementation = joetrollerImplementation;
3976-
address oldPendingImplementation = pendingJoetrollerImplementation;
3975+
address oldImplementation = implementation;
3976+
address oldPendingImplementation = pendingImplementation;
39773977

3978-
joetrollerImplementation = pendingJoetrollerImplementation;
3978+
implementation = pendingImplementation;
39793979

3980-
pendingJoetrollerImplementation = address(0);
3980+
pendingImplementation = address(0);
39813981

3982-
emit NewImplementation(oldImplementation, joetrollerImplementation);
3983-
emit NewPendingImplementation(oldPendingImplementation, pendingJoetrollerImplementation);
3982+
emit NewImplementation(oldImplementation, implementation);
3983+
emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);
39843984

39853985
return uint256(Error.NO_ERROR);
39863986
}
@@ -4043,7 +4043,7 @@ contract Unitroller is UnitrollerAdminStorage, JoetrollerErrorReporter {
40434043
*/
40444044
function() external payable {
40454045
// delegate all other functions to current implementation
4046-
(bool success, ) = joetrollerImplementation.delegatecall(msg.data);
4046+
(bool success, ) = implementation.delegatecall(msg.data);
40474047

40484048
assembly {
40494049
let free_mem_ptr := mload(0x40)
@@ -5414,7 +5414,7 @@ contract Joetroller is JoetrollerV1Storage, JoetrollerInterface, JoetrollerError
54145414
* @notice Checks caller is admin, or this contract is becoming the new implementation
54155415
*/
54165416
function adminOrInitializing() internal view returns (bool) {
5417-
return msg.sender == admin || msg.sender == joetrollerImplementation;
5417+
return msg.sender == admin || msg.sender == implementation;
54185418
}
54195419

54205420
/*** Reward distribution functions ***/
@@ -5624,7 +5624,8 @@ contract JoeLens is Exponential {
56245624
vars.underlyingTokenAllowance = underlying.allowance(account, address(jToken));
56255625
}
56265626

5627-
(, vars.jTokenBalance, , ) = jToken.getAccountSnapshot(account);
5627+
// (, vars.jTokenBalance, , ) = jToken.getAccountSnapshot(account);
5628+
vars.jTokenBalance = jToken.balanceOf(account);
56285629
vars.borrowBalanceCurrent = jToken.borrowBalanceCurrent(account);
56295630

56305631
vars.balanceOfUnderlyingCurrent = jToken.balanceOfUnderlying(account);

0 commit comments

Comments
 (0)