Skip to content

Commit

Permalink
Merge pull request #104 from unioncredit/feature/uni-696-stakers-stil…
Browse files Browse the repository at this point in the history
…l-accrue-rewards-from

chg: remove repayLoanOverdue return.
  • Loading branch information
maxweng authored Jun 10, 2022
2 parents df12be4 + 46f5c24 commit 597c523
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
3 changes: 1 addition & 2 deletions contracts/interfaces/IUserManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ interface IUserManager {
* @param account User address
* @param token The asset token repaying to
* @param lastRepay Last repay block number
* @return Number of frozen stakers, so we know if repay overdue loan works.
*/
function repayLoanOverdue(
address account,
address token,
uint256 lastRepay
) external returns (uint8);
) external;
}
13 changes: 8 additions & 5 deletions contracts/tests/ComptrollerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
contract ComptrollerMock {
address public unionToken;
uint256 public rewardAmount;
uint256 public frozenCounter;

function __ComptrollerMock_init() public {}

Expand Down Expand Up @@ -38,9 +39,11 @@ contract ComptrollerMock {
}

function addFrozenCoinAge(
address staker,
address token,
uint256 lockedStake,
uint256 lastRepay
) external {}
address,
address,
uint256,
uint256
) external {
frozenCounter++;
}
}
2 changes: 1 addition & 1 deletion contracts/tests/UTokenMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract UTokenMock is ERC20Upgradeable {
address token,
uint256 lastRepay
) external {
frozenCounter = IUserManager(userManager).repayLoanOverdue(account, token, lastRepay);
IUserManager(userManager).repayLoanOverdue(account, token, lastRepay);
}

function updateLockedData(
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/UserManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ contract UserManagerMock {
address account,
address token,
uint256 lastRepay
) external returns (uint8 counter) {}
) external {}

//Only supports sumOfTrust
function debtWriteOff(address borrower, uint256 amount) public {}
Expand Down
4 changes: 1 addition & 3 deletions contracts/user/UserManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -823,21 +823,19 @@ contract UserManager is Controller, IUserManager, ReentrancyGuardUpgradeable {
* @param account User address
* @param token The asset token repaying to
* @param lastRepay Last repay block number
* @return counter Number of frozen stakers, so we know if repay overdue loan works.
*/
function repayLoanOverdue(
address account,
address token,
uint256 lastRepay
) external override whenNotPaused onlyMarketOrAdmin returns (uint8 counter) {
) external override whenNotPaused onlyMarketOrAdmin {
address[] memory stakerAddresses = getStakerAddresses(account);
uint256 addressesLength = stakerAddresses.length;
for (uint256 i = 0; i < addressesLength; i++) {
address staker = stakerAddresses[i];
(, , uint256 lockedStake) = getStakerAsset(account, staker);

comptroller.addFrozenCoinAge(staker, token, lockedStake, lastRepay);
++counter;
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/testUserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,10 @@ describe("User Manager Contract", () => {
await uToken.updateLockedData(userManager.address, TOM.address, creditLimit);
await uToken.updateOverdueInfo(userManager.address, TOM.address, true);

let count = await uToken.frozenCounter();
let count = await comptroller.frozenCounter();
count.toString().should.eq("0");
await uToken.repayLoanOverdue(userManager.address, TOM.address, erc20.address, 0);
count = await uToken.frozenCounter();
count = await comptroller.frozenCounter();
count.toString().should.eq("3");
});
});

0 comments on commit 597c523

Please sign in to comment.