Skip to content

Commit

Permalink
jTokenBalance to use jToken.balanceOf() instead of jToken.getAccountS…
Browse files Browse the repository at this point in the history
…napShot()
  • Loading branch information
cryptofish7 committed Oct 16, 2021
1 parent 30bd881 commit bf9e652
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 46 deletions.
2 changes: 1 addition & 1 deletion contracts/Lens/JoeLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ contract JoeLens is Exponential {
vars.underlyingTokenAllowance = underlying.allowance(account, address(jToken));
}

(, vars.jTokenBalance, , ) = jToken.getAccountSnapshot(account);
vars.jTokenBalance = jToken.balanceOf(account);
vars.borrowBalanceCurrent = jToken.borrowBalanceCurrent(account);

vars.balanceOfUnderlyingCurrent = jToken.balanceOfUnderlying(account);
Expand Down
24 changes: 12 additions & 12 deletions deployments/avalanche/JoeLens.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions deployments/avalanche/Maximillion.json

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions deployments/avalanche/solcInputs/57021528ca194e7ebe5a8306f27ce312.json

Large diffs are not rendered by default.

41 changes: 21 additions & 20 deletions out/JoeLens_flat.sol
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,12 @@ contract UnitrollerAdminStorage {
/**
* @notice Active brains of Unitroller
*/
address public joetrollerImplementation;
address public implementation;

/**
* @notice Pending brains of Unitroller
*/
address public pendingJoetrollerImplementation;
address public pendingImplementation;
}

contract JoetrollerV1Storage is UnitrollerAdminStorage {
Expand Down Expand Up @@ -1508,7 +1508,7 @@ contract JWrappedNativeInterface is JErc20Interface {
/**
* @notice Flash loan fee ratio
*/
uint256 public constant flashFeeBips = 3;
uint256 public constant flashFeeBips = 8;

/*** Market Events ***/

Expand Down Expand Up @@ -1550,7 +1550,7 @@ contract JCapableErc20Interface is JErc20Interface, JSupplyCapStorage {
/**
* @notice Flash loan fee ratio
*/
uint256 public constant flashFeeBips = 3;
uint256 public constant flashFeeBips = 8;

/*** Market Events ***/

Expand Down Expand Up @@ -3916,17 +3916,17 @@ contract RewardDistributor is RewardDistributorStorage, Exponential {

/**
* @title JoetrollerCore
* @dev Storage for the joetroller is at this address, while execution is delegated to the `joetrollerImplementation`.
* @dev Storage for the joetroller is at this address, while execution is delegated to the `implementation`.
* JTokens should reference this contract as their joetroller.
*/
contract Unitroller is UnitrollerAdminStorage, JoetrollerErrorReporter {
/**
* @notice Emitted when pendingJoetrollerImplementation is changed
* @notice Emitted when pendingImplementation is changed
*/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);

/**
* @notice Emitted when pendingJoetrollerImplementation is accepted, which means joetroller implementation is updated
* @notice Emitted when pendingImplementation is accepted, which means joetroller implementation is updated
*/
event NewImplementation(address oldImplementation, address newImplementation);

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

address oldPendingImplementation = pendingJoetrollerImplementation;
address oldPendingImplementation = pendingImplementation;

pendingJoetrollerImplementation = newPendingImplementation;
pendingImplementation = newPendingImplementation;

emit NewPendingImplementation(oldPendingImplementation, pendingJoetrollerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);

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

// Save current values for inclusion in log
address oldImplementation = joetrollerImplementation;
address oldPendingImplementation = pendingJoetrollerImplementation;
address oldImplementation = implementation;
address oldPendingImplementation = pendingImplementation;

joetrollerImplementation = pendingJoetrollerImplementation;
implementation = pendingImplementation;

pendingJoetrollerImplementation = address(0);
pendingImplementation = address(0);

emit NewImplementation(oldImplementation, joetrollerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingJoetrollerImplementation);
emit NewImplementation(oldImplementation, implementation);
emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);

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

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

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

(, vars.jTokenBalance, , ) = jToken.getAccountSnapshot(account);
// (, vars.jTokenBalance, , ) = jToken.getAccountSnapshot(account);
vars.jTokenBalance = jToken.balanceOf(account);
vars.borrowBalanceCurrent = jToken.borrowBalanceCurrent(account);

vars.balanceOfUnderlyingCurrent = jToken.balanceOfUnderlying(account);
Expand Down

0 comments on commit bf9e652

Please sign in to comment.