Skip to content

Commit d75ec99

Browse files
Fix tests
1 parent 15be595 commit d75ec99

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

contracts/staking/token/DoubleSidePool.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ contract DoubleSidePool is Initializable, AccessControl, IOnBlockListener {
5656
uint stakedAt;
5757
}
5858

59-
uint constant public MILLION = 1_000_000;
59+
uint constant public BILLION = 1_000_000_000;
6060

6161
LockKeeper public lockKeeper;
6262
RewardsBank public rewardsBank;
@@ -287,7 +287,7 @@ contract DoubleSidePool is Initializable, AccessControl, IOnBlockListener {
287287
function _addInterestMainSide() internal {
288288
if (mainSideInfo.lastInterestUpdate + mainSideConfig.interestRate > block.timestamp) return;
289289
uint timePassed = block.timestamp - mainSideInfo.lastInterestUpdate;
290-
uint newRewards = mainSideInfo.totalStake * mainSideConfig.interest * timePassed / MILLION / mainSideConfig.interestRate;
290+
uint newRewards = mainSideInfo.totalStake * mainSideConfig.interest * timePassed / BILLION / mainSideConfig.interestRate;
291291

292292
mainSideInfo.totalRewards += newRewards;
293293
mainSideInfo.lastInterestUpdate = block.timestamp;
@@ -364,7 +364,7 @@ contract DoubleSidePool is Initializable, AccessControl, IOnBlockListener {
364364
mainSideInfo.totalRewards -= rewardsAmount;
365365
_updateRewardsDebt(false, user, _calcRewards(false, mainSideStakers[user].stake));
366366

367-
uint penalty = amount * mainSideConfig.fastUnstakePenalty / MILLION;
367+
uint penalty = amount * mainSideConfig.fastUnstakePenalty / BILLION;
368368
if (mainSideConfig.token == address(0)) {
369369
payable(msg.sender).transfer(amount - penalty);
370370
} else {
@@ -382,7 +382,7 @@ contract DoubleSidePool is Initializable, AccessControl, IOnBlockListener {
382382
function _addInterestDependantSide() internal {
383383
if (dependantSideInfo.lastInterestUpdate + dependantSideConfig.interestRate > block.timestamp) return;
384384
uint timePassed = block.timestamp - dependantSideInfo.lastInterestUpdate;
385-
uint newRewards = dependantSideInfo.totalStake * dependantSideConfig.interest * timePassed / MILLION / dependantSideConfig.interestRate;
385+
uint newRewards = dependantSideInfo.totalStake * dependantSideConfig.interest * timePassed / BILLION / dependantSideConfig.interestRate;
386386

387387
dependantSideInfo.totalRewards += newRewards;
388388
dependantSideInfo.lastInterestUpdate = block.timestamp;
@@ -462,7 +462,7 @@ contract DoubleSidePool is Initializable, AccessControl, IOnBlockListener {
462462
dependantSideInfo.totalRewards -= rewardsAmount;
463463
_updateRewardsDebt(true, user, _calcRewards(true, dependantSideStakers[user].stake));
464464

465-
uint penalty = amount * dependantSideConfig.fastUnstakePenalty / MILLION;
465+
uint penalty = amount * dependantSideConfig.fastUnstakePenalty / BILLION;
466466
if (dependantSideConfig.token == address(0)) {
467467
payable(msg.sender).transfer(amount - penalty);
468468
} else {
@@ -476,7 +476,7 @@ contract DoubleSidePool is Initializable, AccessControl, IOnBlockListener {
476476
}
477477

478478
function _maxUserStakeValue(address user) internal view returns (uint) {
479-
return mainSideStakers[user].stake * dependantSideConfig.stakeLimitsMultiplier / MILLION;
479+
return mainSideStakers[user].stake * dependantSideConfig.stakeLimitsMultiplier / BILLION;
480480
}
481481

482482
//COMMON METHODS

contracts/staking/token/SingleSidePool.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import "../../LockKeeper.sol";
1111
import "hardhat/console.sol";
1212

1313
contract SingleSidePool is Initializable, AccessControl, IOnBlockListener {
14-
uint constant public MILLION = 1_000_000;
1514

1615
struct Config {
1716
IERC20 token;
@@ -39,6 +38,8 @@ contract SingleSidePool is Initializable, AccessControl, IOnBlockListener {
3938
uint lockedWithdrawal;
4039
}
4140

41+
uint constant public BILLION = 1_000_000_000;
42+
4243
bool public active;
4344
RewardsBank rewardsBank;
4445
LockKeeper lockKeeper;
@@ -157,7 +158,7 @@ contract SingleSidePool is Initializable, AccessControl, IOnBlockListener {
157158

158159
_unstake(msg.sender, amount);
159160

160-
uint penalty = amount * config.fastUnstakePenalty / MILLION;
161+
uint penalty = amount * config.fastUnstakePenalty / BILLION;
161162
SafeERC20.safeTransfer(config.token, msg.sender, amount - penalty);
162163

163164
_claimRewards(msg.sender);
@@ -212,7 +213,7 @@ contract SingleSidePool is Initializable, AccessControl, IOnBlockListener {
212213
function _addInterest() internal {
213214
if (info.lastInterestUpdate + config.interestRate > block.timestamp) return;
214215
uint timePassed = block.timestamp - info.lastInterestUpdate;
215-
uint newRewards = info.totalStake * config.interest * timePassed / MILLION / config.interestRate;
216+
uint newRewards = info.totalStake * config.interest * timePassed / BILLION / config.interestRate;
216217

217218
info.totalRewards += newRewards;
218219
info.lastInterestUpdate = block.timestamp;

test/staking/token/SingleSidePool.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "../../../typechain-types";
1414

1515
const D1 = 24 * 60 * 60;
16+
const BILLION = 1000000000;
1617

1718
import { expect } from "chai";
1819
describe("SingleSidePool", function () {
@@ -32,19 +33,17 @@ describe("SingleSidePool", function () {
3233

3334
const singleSidePoolParams: SingleSidePool.ConfigStruct = {
3435
token: token.address,
35-
rewardsBank: rewardsBank.address,
36-
lockKeeper: lockKeeper.address,
3736
name: "Test",
3837
minStakeValue: 10,
39-
fastUnstakePenalty: 100000, // 10%
40-
interest: 100000, // 10%
38+
fastUnstakePenalty: 0.10 * BILLION, // 10%
39+
interest: 0.10 * BILLION, // 10%
4140
interestRate: D1, // 1 day
4241
lockPeriod: D1, // 1 day
4342
rewardToken: token.address,
4443
rewardTokenPrice: 1,
4544
};
4645

47-
const singleSidePool = (await upgrades.deployProxy(singleSidePoolFactory, [singleSidePoolParams])) as SingleSidePool;
46+
const singleSidePool = (await upgrades.deployProxy(singleSidePoolFactory, [rewardsBank.address, lockKeeper.address, singleSidePoolParams])) as SingleSidePool;
4847

4948
await (await rewardsBank.grantRole(await rewardsBank.DEFAULT_ADMIN_ROLE(), singleSidePool.address)).wait();
5049
await (await token.grantRole(await token.MINTER_ROLE(), owner.address)).wait();

0 commit comments

Comments
 (0)