Skip to content

Commit

Permalink
Remove unneeded getters
Browse files Browse the repository at this point in the history
  • Loading branch information
SigismundSchlomo committed Oct 7, 2024
1 parent ad3b93b commit 80835f2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
12 changes: 0 additions & 12 deletions contracts/staking/token/LimitedTokenPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,6 @@ contract LimitedTokenPool is Initializable, AccessControl, IOnBlockListener {
return mainConfig.name;
}

function getMainConfig() public view returns (MainConfig memory) {
return mainConfig;
}

function getLimitsConfig() public view returns (LimitsConfig memory) {
return limitsConfig;
}

function getInfo() public view returns (Info memory) {
return info;
}

function getStaker(address user) public view returns (Staker memory) {
return stakers[user];
}
Expand Down
36 changes: 18 additions & 18 deletions test/staking/token/LimitedTokenPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ describe("LimitedTokenPool", function () {

describe("Initialization", function () {
it("Should initialize with correct main config", async function () {
const config = await limitedPool.getMainConfig();
const config = await limitedPool.mainConfig();
expect(config.name).to.equal("Test Deposited Pool");
expect(config.limitsMultiplierToken).to.equal(limitsMultiplierToken.address);
expect(config.profitableToken).to.equal(profitableToken.address);
expect(config.rewardToken).to.equal(profitableToken.address);
});

it("Should initialize with correct limits config", async function () {
const limits = await limitedPool.getLimitsConfig();
const limits = await limitedPool.limitsConfig();
expect(limits.rewardTokenPrice).to.equal(BILLION);
expect(limits.interest).to.equal(0.10 * BILLION);
expect(limits.interestRate).to.equal(D1);
Expand All @@ -120,7 +120,7 @@ describe("LimitedTokenPool", function () {
.to.emit(limitedPool, "Deposited")
.withArgs(owner.address, depositAmount);

const info = await limitedPool.getInfo();
const info = await limitedPool.info();
expect(info.totalDeposit).to.equal(depositAmount);

const staker = await limitedPool.getStaker(owner.address);
Expand All @@ -144,7 +144,7 @@ describe("LimitedTokenPool", function () {
.to.emit(limitedPool, "Withdrawn")
.withArgs(owner.address, withdrawAmount);

const info = await limitedPool.getInfo();
const info = await limitedPool.info();
expect(info.totalDeposit).to.equal(ethers.utils.parseEther("500"));

const staker = await limitedPool.getStaker(owner.address);
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("LimitedTokenPool", function () {
const stakeAmount = ethers.utils.parseEther("100");
await limitedPool.stake(stakeAmount);

const info = await limitedPool.getInfo();
const info = await limitedPool.info();
expect(info.totalStake).to.equal(stakeAmount);

const staker = await limitedPool.getStaker(owner.address);
Expand All @@ -191,7 +191,7 @@ describe("LimitedTokenPool", function () {
});

it("Should not allow staking above total pool limit", async function () {
const limits= await limitedPool.getLimitsConfig();
const limits= await limitedPool.limitsConfig();
const updatedLimits = {
...limits,
maxTotalStakeValue: ethers.utils.parseEther("100")
Expand All @@ -215,7 +215,7 @@ describe("LimitedTokenPool", function () {
await expect(limitedPool.unstake(stakeAmount))
.to.emit(lockKeeper, "Locked");

const info = await limitedPool.getInfo();
const info = await limitedPool.info();
expect(info.totalStake).to.equal(0);

const staker = await limitedPool.getStaker(owner.address);
Expand All @@ -227,7 +227,7 @@ describe("LimitedTokenPool", function () {
});

it("Should not allow unstaking before stake lock period", async function () {
const limits = await limitedPool.getLimitsConfig();
const limits = await limitedPool.limitsConfig();
const updatedLimits = {
...limits,
stakeLockPeriod: ethers.BigNumber.from(D1 * 2)
Expand Down Expand Up @@ -256,7 +256,7 @@ describe("LimitedTokenPool", function () {
const expectedReturn = stakeAmount.mul(90).div(100); // 90% due to 10% penalty
expect(balanceAfter.sub(balanceBefore)).to.equal(expectedReturn);

const info = await limitedPool.getInfo();
const info = await limitedPool.info();
expect(info.totalStake).to.equal(0);
});
});
Expand Down Expand Up @@ -293,7 +293,7 @@ describe("LimitedTokenPool", function () {

describe("Edge cases", function () {
it("Should handle multiple deposits and stakes correctly", async function () {
const limits = await limitedPool.getLimitsConfig();
const limits = await limitedPool.limitsConfig();
const updatedLimits = {
...limits,
stakeLockPeriod: 0,
Expand All @@ -307,7 +307,7 @@ describe("LimitedTokenPool", function () {
await limitedPool.deposit(depositAmount);
await limitedPool.stake(stakeAmount);

const info = await limitedPool.getInfo();
const info = await limitedPool.info();
expect(info.totalDeposit).to.equal(depositAmount.mul(2));
expect(info.totalStake).to.equal(stakeAmount.mul(2));

Expand All @@ -317,7 +317,7 @@ describe("LimitedTokenPool", function () {
});

it("Should handle rewards correctly after multiple stakes and unstakes", async function () {
const limits = await limitedPool.getLimitsConfig();
const limits = await limitedPool.limitsConfig();
const updatedLimits = {
...limits,
stakeLockPeriod: 0,
Expand Down Expand Up @@ -369,11 +369,11 @@ describe("LimitedTokenPool", function () {

it("Should not add interest if called too frequently", async function () {
await limitedPool.onBlock();
const infoBefore = await limitedPool.getInfo();
const infoBefore = await limitedPool.info();

await time.increase(D1 / 2); // Half a day
await limitedPool.onBlock();
const infoAfter = await limitedPool.getInfo();
const infoAfter = await limitedPool.info();

expect(infoAfter.totalRewards).to.equal(infoBefore.totalRewards);
});
Expand Down Expand Up @@ -407,7 +407,7 @@ describe("LimitedTokenPool", function () {
expect(infoUser2.deposit).to.equal(ethers.utils.parseEther("300"));
expect(infoUser2.stake).to.equal(ethers.utils.parseEther("100"));

const poolInfo = await limitedPool.getInfo();
const poolInfo = await limitedPool.info();
expect(poolInfo.totalDeposit).to.equal(ethers.utils.parseEther("800"));
expect(poolInfo.totalStake).to.equal(ethers.utils.parseEther("300"));
});
Expand Down Expand Up @@ -450,7 +450,7 @@ describe("LimitedTokenPool", function () {
});

it("Should only allow admin to change configurations", async function () {
const limits = await limitedPool.getLimitsConfig();
const limits = await limitedPool.limitsConfig();
const updatedLimits = {
...limits,
rewardTokenPrice: BILLION * 2
Expand Down Expand Up @@ -501,7 +501,7 @@ describe("LimitedTokenPool", function () {
.to.emit(ethPool, "Deposited")
.withArgs(owner.address, depositAmount);

const info = await ethPool.getInfo();
const info = await ethPool.info();
expect(info.totalDeposit).to.equal(depositAmount);
});

Expand Down Expand Up @@ -542,7 +542,7 @@ describe("LimitedTokenPool", function () {
const stakeAmount = ethers.utils.parseEther("1");
await ethPool.stake(stakeAmount, { value: stakeAmount });

const info = await ethPool.getInfo();
const info = await ethPool.info();
expect(info.totalStake).to.equal(stakeAmount);
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/staking/token/LimitedTokenPoolsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("LimitedTokenPoolsManager", function () {
await poolsManager.configurePool(poolAddress, limitsConfig);

const proxyPool = new ethers.Contract(poolAddress, LimitedTokenPoolJson.abi, owner);
const updatedConfig = await proxyPool.getLimitsConfig();
const updatedConfig = await proxyPool.limitsConfig();

expect(updatedConfig.rewardTokenPrice).to.equal(limitsConfig.rewardTokenPrice);
expect(updatedConfig.interest).to.equal(limitsConfig.interest);
Expand Down Expand Up @@ -161,7 +161,7 @@ describe("LimitedTokenPoolsManager", function () {
};

await poolsManager.configurePool(poolAddress, newLimitsConfig);
const updatedConfig = await proxyPool.getLimitsConfig();
const updatedConfig = await proxyPool.limitsConfig();

expect(updatedConfig.rewardTokenPrice).to.equal(newLimitsConfig.rewardTokenPrice);
expect(updatedConfig.interest).to.equal(newLimitsConfig.interest);
Expand Down

0 comments on commit 80835f2

Please sign in to comment.