Skip to content

Commit

Permalink
Fix stakeDeclineTest
Browse files Browse the repository at this point in the history
  • Loading branch information
RickGriff committed Jan 30, 2024
1 parent a2825b3 commit 8d10b08
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions contracts/test/stakeDeclineTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const deploymentHelper = require("../utils/deploymentHelpers.js");
const testHelpers = require("../utils/testHelpers.js");
const TroveManagerTester = artifacts.require("./TroveManagerTester.sol");
// const BoldTokenTester = artifacts.require("./BoldTokenTester.sol");
const BoldTokenTester = artifacts.require("./BoldTokenTester.sol");

const th = testHelpers.TestHelper;
const dec = th.dec;
Expand Down Expand Up @@ -36,8 +36,8 @@ contract("TroveManager", async (accounts) => {

let contracts;

const getOpenTroveLUSDAmount = async (totalDebt) =>
th.getOpenTroveLUSDAmount(contracts, totalDebt);
const getOpenTroveBoldAmount = async (totalDebt) =>
th.getOpenTroveBoldAmount(contracts, totalDebt);

const getSnapshotsRatio = async () => {
const ratio = (await troveManager.totalStakesSnapshot())
Expand All @@ -50,16 +50,11 @@ contract("TroveManager", async (accounts) => {
beforeEach(async () => {
contracts = await deploymentHelper.deployLiquityCore();
contracts.troveManager = await TroveManagerTester.new();
// contracts.boldToken = await BoldTokenTester.new(
// contracts.troveManager.address,
// contracts.stabilityPool.address,
// contracts.borrowerOperations.address
// )
const LQTYContracts = await deploymentHelper.deployLQTYContracts(
bountyAddress,
lpRewardsAddress,
multisig
);
contracts.boldToken = await BoldTokenTester.new(
contracts.troveManager.address,
contracts.stabilityPool.address,
contracts.borrowerOperations.address
)

priceFeed = contracts.priceFeedTestnet;
boldToken = contracts.boldToken;
Expand All @@ -72,13 +67,7 @@ contract("TroveManager", async (accounts) => {
borrowerOperations = contracts.borrowerOperations;
hintHelpers = contracts.hintHelpers;

lqtyStaking = LQTYContracts.lqtyStaking;
lqtyToken = LQTYContracts.lqtyToken;
communityIssuance = LQTYContracts.communityIssuance;

await deploymentHelper.connectCoreContracts(contracts, LQTYContracts);
await deploymentHelper.connectLQTYContracts(LQTYContracts);
await deploymentHelper.connectLQTYContractsToCore(LQTYContracts, contracts);
await deploymentHelper.connectCoreContracts(contracts);
});

it("A given trove's stake decline is negligible with adjustments and tiny liquidations", async () => {
Expand All @@ -87,7 +76,7 @@ contract("TroveManager", async (accounts) => {
// Make 1 mega troves A at ~50% total collateral
await borrowerOperations.openTrove(
th._100pct,
await getOpenTroveLUSDAmount(dec(1, 31)),
await getOpenTroveBoldAmount(dec(1, 31)),
ZERO_ADDRESS,
ZERO_ADDRESS,
{ from: A, value: dec(2, 29) }
Expand All @@ -96,35 +85,35 @@ contract("TroveManager", async (accounts) => {
// Make 5 large troves B, C, D, E, F at ~10% total collateral
await borrowerOperations.openTrove(
th._100pct,
await getOpenTroveLUSDAmount(dec(2, 30)),
await getOpenTroveBoldAmount(dec(2, 30)),
ZERO_ADDRESS,
ZERO_ADDRESS,
{ from: B, value: dec(4, 28) }
);
await borrowerOperations.openTrove(
th._100pct,
await getOpenTroveLUSDAmount(dec(2, 30)),
await getOpenTroveBoldAmount(dec(2, 30)),
ZERO_ADDRESS,
ZERO_ADDRESS,
{ from: C, value: dec(4, 28) }
);
await borrowerOperations.openTrove(
th._100pct,
await getOpenTroveLUSDAmount(dec(2, 30)),
await getOpenTroveBoldAmount(dec(2, 30)),
ZERO_ADDRESS,
ZERO_ADDRESS,
{ from: D, value: dec(4, 28) }
);
await borrowerOperations.openTrove(
th._100pct,
await getOpenTroveLUSDAmount(dec(2, 30)),
await getOpenTroveBoldAmount(dec(2, 30)),
ZERO_ADDRESS,
ZERO_ADDRESS,
{ from: E, value: dec(4, 28) }
);
await borrowerOperations.openTrove(
th._100pct,
await getOpenTroveLUSDAmount(dec(2, 30)),
await getOpenTroveBoldAmount(dec(2, 30)),
ZERO_ADDRESS,
ZERO_ADDRESS,
{ from: F, value: dec(4, 28) }
Expand All @@ -135,7 +124,7 @@ contract("TroveManager", async (accounts) => {
for (account of tinyTroves) {
await borrowerOperations.openTrove(
th._100pct,
await getOpenTroveLUSDAmount(dec(1, 22)),
await getOpenTroveBoldAmount(dec(1, 22)),
ZERO_ADDRESS,
ZERO_ADDRESS,
{ from: account, value: dec(2, 20) }
Expand Down

0 comments on commit 8d10b08

Please sign in to comment.