diff --git a/contracts/src/TestContracts/BorrowerOperationsTester.sol b/contracts/src/TestContracts/BorrowerOperationsTester.sol index 67296a41..66b5b623 100644 --- a/contracts/src/TestContracts/BorrowerOperationsTester.sol +++ b/contracts/src/TestContracts/BorrowerOperationsTester.sol @@ -8,6 +8,23 @@ import "../BorrowerOperations.sol"; for testing the parent's internal functions. */ contract BorrowerOperationsTester is BorrowerOperations { + function getNewICRFromTroveChange + ( + uint _coll, + uint _debt, + uint _collChange, + bool isCollIncrease, + uint _debtChange, + bool isDebtIncrease, + uint _price + ) + external + pure + returns (uint) + { + return _getNewICRFromTroveChange(_coll, _debt, _collChange, isCollIncrease, _debtChange, isDebtIncrease, _price); + } + function getNewTCRFromTroveChange ( uint _collChange, @@ -39,7 +56,6 @@ contract BorrowerOperationsTester is BorrowerOperations { _adjustTrove(_borrower, _collWithdrawal, _debtChange, _isDebtIncrease, 0); } - // Payable fallback function receive() external payable { } } diff --git a/contracts/src/TestContracts/SortedTrovesTester.sol b/contracts/src/TestContracts/SortedTrovesTester.sol index 3a373d16..c66f70a8 100644 --- a/contracts/src/TestContracts/SortedTrovesTester.sol +++ b/contracts/src/TestContracts/SortedTrovesTester.sol @@ -4,31 +4,33 @@ pragma solidity 0.8.18; import "../Interfaces/ISortedTroves.sol"; - +// Used as both a wrapper for SortedTroves functions and a mock TroveManager. contract SortedTrovesTester { ISortedTroves sortedTroves; + // --- SortedTroves external wrapper functions -- function setSortedTroves(address _sortedTrovesAddress) external { sortedTroves = ISortedTroves(_sortedTrovesAddress); } - function insert(address _id, uint256 _NICR, address _prevId, address _nextId) external { - sortedTroves.insert(_id, _NICR, _prevId, _nextId); + function insert(address _id, uint256 _annualInterestRate, address _prevId, address _nextId) external { + sortedTroves.insert(_id, _annualInterestRate, _prevId, _nextId); } function remove(address _id) external { sortedTroves.remove(_id); } - function reInsert(address _id, uint256 _newNICR, address _prevId, address _nextId) external { - sortedTroves.reInsert(_id, _newNICR, _prevId, _nextId); + function reInsert(address _id, uint256 _newAnnualInterestRate, address _prevId, address _nextId) external { + sortedTroves.reInsert(_id, _newAnnualInterestRate, _prevId, _nextId); } - function getNominalICR(address) external pure returns (uint) { + // --- Mock TroveManager functions --- + function getTroveAnnualInterestRate(address) external pure returns (uint) { return 1; } - function getCurrentICR(address, uint) external pure returns (uint) { - return 1; - } + // function getCurrentICR(address, uint) external pure returns (uint) { + // return 1; + // } } diff --git a/contracts/src/TroveManager.sol b/contracts/src/TroveManager.sol index 1358283f..94d35dd5 100644 --- a/contracts/src/TroveManager.sol +++ b/contracts/src/TroveManager.sol @@ -478,6 +478,8 @@ contract TroveManager is LiquityBase, Ownable, CheckContract, ITroveManager { * Liquidate a sequence of troves. Closes a maximum number of n under-collateralized Troves, * starting from the one with the lowest collateral ratio in the system, and moving upwards */ + // TODO: remove this liquidation function, since with ordering by interest rate, it is now redundant: there's no guarantee + // the bottom of the list has Troves with CR < MCR. function liquidateTroves(uint _n) external override { ContractsCache memory contractsCache = ContractsCache( activePool, diff --git a/contracts/test/AccessControlTest.js b/contracts/test/AccessControlTest.js index 1a985ae5..5c7976f6 100644 --- a/contracts/test/AccessControlTest.js +++ b/contracts/test/AccessControlTest.js @@ -67,8 +67,6 @@ contract( // Attempt call from alice try { const tx1 = await borrowerOperations.moveETHGainToTrove( - bob, - bob, bob, { from: bob } ); @@ -93,19 +91,6 @@ contract( } }); - // updateRewardSnapshots - it("updateRewardSnapshots(): reverts when called by an account that is not BorrowerOperations", async () => { - // Attempt call from alice - try { - const txAlice = await troveManager.updateTroveRewardSnapshots(bob, { - from: alice, - }); - } catch (err) { - assert.include(err.message, "revert"); - // assert.include(err.message, "Caller is not the BorrowerOperations contract") - } - }); - // removeStake it("removeStake(): reverts when called by an account that is not BorrowerOperations", async () => { // Attempt call from alice @@ -154,19 +139,6 @@ contract( } }); - // setTroveStatus - it("setTroveStatus(): reverts when called by an account that is not BorrowerOperations", async () => { - // Attempt call from alice - try { - const txAlice = await troveManager.setTroveStatus(bob, 1, { - from: alice, - }); - } catch (err) { - assert.include(err.message, "revert"); - // assert.include(err.message, "Caller is not the BorrowerOperations contract") - } - }); - // increaseTroveColl it("increaseTroveColl(): reverts when called by an account that is not BorrowerOperations", async () => { // Attempt call from alice diff --git a/contracts/test/BorrowerOperationsTest.js b/contracts/test/BorrowerOperationsTest.js index 740613db..8231ab56 100644 --- a/contracts/test/BorrowerOperationsTest.js +++ b/contracts/test/BorrowerOperationsTest.js @@ -136,7 +136,7 @@ contract("BorrowerOperations", async (accounts) => { const collTopUp = 1; // 1 wei top up await assertRevert( - borrowerOperations.addColl(alice, alice, { + borrowerOperations.addColl( { from: alice, value: collTopUp, }), @@ -158,7 +158,7 @@ contract("BorrowerOperations", async (accounts) => { assert.isTrue(activePool_ETH_Before.eq(aliceColl)); assert.isTrue(activePool_RawEther_Before.eq(aliceColl)); - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl( { from: alice, value: dec(1, "ether"), }); @@ -187,7 +187,7 @@ contract("BorrowerOperations", async (accounts) => { assert.equal(status_Before, 1); // Alice adds second collateral - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl( { from: alice, value: dec(1, "ether"), }); @@ -211,7 +211,7 @@ contract("BorrowerOperations", async (accounts) => { assert.equal(aliceTroveInList_Before, true); assert.equal(listIsEmpty_Before, false); - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl( { from: alice, value: dec(1, "ether"), }); @@ -234,7 +234,7 @@ contract("BorrowerOperations", async (accounts) => { assert.isTrue(totalStakes_Before.eq(alice_Stake_Before)); // Alice tops up Trove collateral with 2 ether - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl( { from: alice, value: dec(2, "ether"), }); @@ -324,11 +324,11 @@ contract("BorrowerOperations", async (accounts) => { const aliceTopUp = toBN(dec(5, "ether")); const bobTopUp = toBN(dec(1, "ether")); - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl( { from: alice, value: aliceTopUp, }); - await borrowerOperations.addColl(bob, bob, { + await borrowerOperations.addColl( { from: bob, value: bobTopUp, }); @@ -430,7 +430,7 @@ contract("BorrowerOperations", async (accounts) => { // Carol attempts to add collateral to her non-existent trove try { - const txCarol = await borrowerOperations.addColl(carol, carol, { + const txCarol = await borrowerOperations.addColl( { from: carol, value: dec(1, "ether"), }); @@ -450,7 +450,7 @@ contract("BorrowerOperations", async (accounts) => { // Bob attempts to add collateral to his closed trove try { - const txBob = await borrowerOperations.addColl(bob, bob, { + const txBob = await borrowerOperations.addColl( { from: bob, value: dec(1, "ether"), }); @@ -471,7 +471,7 @@ contract("BorrowerOperations", async (accounts) => { assert.isTrue(await th.checkRecoveryMode(contracts)); const collTopUp = toBN(dec(1, "ether")); - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl( { from: alice, value: collTopUp, }); @@ -500,7 +500,7 @@ contract("BorrowerOperations", async (accounts) => { const collWithdrawal = 1; // 1 wei withdrawal await assertRevert( - borrowerOperations.withdrawColl(1, alice, alice, { from: alice }), + borrowerOperations.withdrawColl(1, { from: alice }), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" ); }); @@ -521,8 +521,7 @@ contract("BorrowerOperations", async (accounts) => { // Bob successfully withdraws some coll const txBob = await borrowerOperations.withdrawColl( dec(100, "finney"), - bob, - bob, + { from: bob } ); assert.isTrue(txBob.receipt.status); @@ -531,8 +530,7 @@ contract("BorrowerOperations", async (accounts) => { try { const txCarol = await borrowerOperations.withdrawColl( dec(1, "ether"), - carol, - carol, + { from: carol } ); assert.isFalse(txCarol.receipt.status); @@ -550,8 +548,7 @@ contract("BorrowerOperations", async (accounts) => { // Withdrawal possible when recoveryMode == false const txAlice = await borrowerOperations.withdrawColl( 1000, - alice, - alice, + { from: alice } ); assert.isTrue(txAlice.receipt.status); @@ -562,7 +559,7 @@ contract("BorrowerOperations", async (accounts) => { //Check withdrawal impossible when recoveryMode == true try { - const txBob = await borrowerOperations.withdrawColl(1000, bob, bob, { + const txBob = await borrowerOperations.withdrawColl(1000, { from: bob, }); assert.isFalse(txBob.receipt.status); @@ -580,7 +577,7 @@ contract("BorrowerOperations", async (accounts) => { const bobColl = await getTroveEntireColl(bob); // Carol withdraws exactly all her collateral await assertRevert( - borrowerOperations.withdrawColl(carolColl, carol, carol, { + borrowerOperations.withdrawColl(carolColl, { from: carol, }), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" @@ -590,8 +587,7 @@ contract("BorrowerOperations", async (accounts) => { try { const txBob = await borrowerOperations.withdrawColl( bobColl.add(toBN(1)), - bob, - bob, + { from: bob } ); assert.isFalse(txBob.receipt.status); @@ -608,7 +604,7 @@ contract("BorrowerOperations", async (accounts) => { // Bob attempts to withdraws 1 wei, Which would leave him with < 110% ICR. try { - const txBob = await borrowerOperations.withdrawColl(1, bob, bob, { + const txBob = await borrowerOperations.withdrawColl(1, { from: bob, }); assert.isFalse(txBob.receipt.status); @@ -636,8 +632,6 @@ contract("BorrowerOperations", async (accounts) => { try { const txData = await borrowerOperations.withdrawColl( "1", - alice, - alice, { from: alice } ); assert.isFalse(txData.receipt.status); @@ -660,7 +654,7 @@ contract("BorrowerOperations", async (accounts) => { // Alice attempts to withdraw all collateral await assertRevert( - borrowerOperations.withdrawColl(aliceColl, alice, alice, { + borrowerOperations.withdrawColl(aliceColl, { from: alice, }), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" @@ -678,7 +672,7 @@ contract("BorrowerOperations", async (accounts) => { assert.isTrue(await sortedTroves.contains(alice)); // Withdraw some collateral - await borrowerOperations.withdrawColl(dec(100, "finney"), alice, alice, { + await borrowerOperations.withdrawColl(dec(100, "finney"), { from: alice, }); @@ -694,7 +688,7 @@ contract("BorrowerOperations", async (accounts) => { const aliceCollBefore = await getTroveEntireColl(alice); // Alice withdraws 1 ether - await borrowerOperations.withdrawColl(dec(1, "ether"), alice, alice, { + await borrowerOperations.withdrawColl(dec(1, "ether"), { from: alice, }); @@ -717,7 +711,7 @@ contract("BorrowerOperations", async (accounts) => { await web3.eth.getBalance(activePool.address) ); - await borrowerOperations.withdrawColl(dec(1, "ether"), alice, alice, { + await borrowerOperations.withdrawColl(dec(1, "ether"), { from: alice, }); @@ -755,7 +749,7 @@ contract("BorrowerOperations", async (accounts) => { assert.isTrue(totalStakes_Before.eq(aliceColl)); // Alice withdraws 1 ether - await borrowerOperations.withdrawColl(dec(1, "ether"), alice, alice, { + await borrowerOperations.withdrawColl(dec(1, "ether"), { from: alice, }); @@ -781,7 +775,7 @@ contract("BorrowerOperations", async (accounts) => { const alice_ETHBalance_Before = toBN( web3.utils.toBN(await web3.eth.getBalance(alice)) ); - await borrowerOperations.withdrawColl(dec(1, "ether"), alice, alice, { + await borrowerOperations.withdrawColl(dec(1, "ether"), { from: alice, gasPrice: 0, }); @@ -866,10 +860,10 @@ contract("BorrowerOperations", async (accounts) => { const aliceCollWithdrawal = toBN(dec(5, "ether")); const bobCollWithdrawal = toBN(dec(1, "ether")); - await borrowerOperations.withdrawColl(aliceCollWithdrawal, alice, alice, { + await borrowerOperations.withdrawColl(aliceCollWithdrawal, { from: alice, }); - await borrowerOperations.withdrawColl(bobCollWithdrawal, bob, bob, { + await borrowerOperations.withdrawColl(bobCollWithdrawal, { from: bob, }); @@ -953,8 +947,6 @@ contract("BorrowerOperations", async (accounts) => { borrowerOperations.withdrawBold( th._100pct, Boldwithdrawal, - alice, - alice, { from: alice } ), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" @@ -969,8 +961,6 @@ contract("BorrowerOperations", async (accounts) => { const txBob = await borrowerOperations.withdrawBold( th._100pct, dec(100, 18), - bob, - bob, { from: bob } ); assert.isTrue(txBob.receipt.status); @@ -980,8 +970,7 @@ contract("BorrowerOperations", async (accounts) => { const txCarol = await borrowerOperations.withdrawBold( th._100pct, dec(100, 18), - carol, - carol, + { from: carol } ); assert.isFalse(txCarol.receipt.status); @@ -998,8 +987,6 @@ contract("BorrowerOperations", async (accounts) => { const txBob = await borrowerOperations.withdrawBold( th._100pct, 1, - bob, - bob, { from: bob } ); assert.isTrue(txBob.receipt.status); @@ -1009,8 +996,6 @@ contract("BorrowerOperations", async (accounts) => { const txAlice = await borrowerOperations.withdrawBold( th._100pct, 0, - alice, - alice, { from: alice } ); assert.isFalse(txAlice.receipt.status); @@ -1030,8 +1015,6 @@ contract("BorrowerOperations", async (accounts) => { const txAlice = await borrowerOperations.withdrawBold( th._100pct, dec(100, 18), - alice, - alice, { from: alice } ); assert.isTrue(txAlice.receipt.status); @@ -1044,9 +1027,7 @@ contract("BorrowerOperations", async (accounts) => { try { const txBob = await borrowerOperations.withdrawBold( th._100pct, - 1, - bob, - bob, + 1, { from: bob } ); assert.isFalse(txBob.receipt.status); @@ -1064,8 +1045,7 @@ contract("BorrowerOperations", async (accounts) => { const txBob = await borrowerOperations.withdrawBold( th._100pct, 1, - bob, - bob, + { from: bob } ); assert.isFalse(txBob.receipt.status); @@ -1091,8 +1071,7 @@ contract("BorrowerOperations", async (accounts) => { const txBob = await borrowerOperations.withdrawBold( th._100pct, dec(1, 18), - bob, - bob, + { from: bob } ); assert.isFalse(txBob.receipt.status); @@ -1116,8 +1095,7 @@ contract("BorrowerOperations", async (accounts) => { const txData = await borrowerOperations.withdrawBold( th._100pct, "200", - alice, - alice, + { from: alice } ); assert.isFalse(txData.receipt.status); @@ -1136,8 +1114,7 @@ contract("BorrowerOperations", async (accounts) => { await borrowerOperations.withdrawBold( th._100pct, await getNetBorrowingAmount(100), - alice, - alice, + { from: alice } ); @@ -1165,8 +1142,7 @@ contract("BorrowerOperations", async (accounts) => { await borrowerOperations.withdrawBold( th._100pct, await getNetBorrowingAmount(dec(10000, 18)), - alice, - alice, + { from: alice } ); @@ -1190,8 +1166,7 @@ contract("BorrowerOperations", async (accounts) => { await borrowerOperations.withdrawBold( th._100pct, dec(10000, 18), - alice, - alice, + { from: alice } ); @@ -1222,7 +1197,7 @@ contract("BorrowerOperations", async (accounts) => { const BoldRepayment = 1; // 1 wei repayment await assertRevert( - borrowerOperations.repayBold(BoldRepayment, alice, alice, { + borrowerOperations.repayBold(BoldRepayment, { from: alice, }), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" @@ -1236,18 +1211,19 @@ contract("BorrowerOperations", async (accounts) => { await getNetBorrowingAmount(MIN_NET_DEBT.add(toBN("2"))), A, A, + 0, { from: A, value: dec(100, 30) } ); - const repayTxA = await borrowerOperations.repayBold(1, A, A, { from: A }); + const repayTxA = await borrowerOperations.repayBold(1, { from: A }); assert.isTrue(repayTxA.receipt.status); - await borrowerOperations.openTrove(th._100pct, dec(20, 25), B, B, { + await borrowerOperations.openTrove(th._100pct, dec(20, 25), B, B, 0, { from: B, value: dec(100, 30), }); - const repayTxB = await borrowerOperations.repayBold(dec(19, 25), B, B, { + const repayTxB = await borrowerOperations.repayBold(dec(19, 25),{ from: B, }); assert.isTrue(repayTxB.receipt.status); @@ -1260,6 +1236,7 @@ contract("BorrowerOperations", async (accounts) => { await getNetBorrowingAmount(MIN_NET_DEBT.add(toBN("1"))), A, A, + 0, { from: A, value: dec(100, 30) } ); @@ -1268,7 +1245,7 @@ contract("BorrowerOperations", async (accounts) => { assert.isTrue(debt.eq(th.toBN(dec(2000, 18)).add(th.toBN("1")))) // Try to repay 2 wei to bring Trove debt to 1 wei below minimum, and expect revert - const repayTxAPromise = borrowerOperations.repayBold(2, A, A, { + const repayTxAPromise = borrowerOperations.repayBold(2, { from: A, }); await assertRevert( @@ -1299,8 +1276,6 @@ contract("BorrowerOperations", async (accounts) => { 0, repayAmount, false, - alice, - alice, { from: alice } ), "SafeMath: subtraction overflow" @@ -1319,7 +1294,7 @@ contract("BorrowerOperations", async (accounts) => { extraParams: { from: bob }, }); // Bob successfully repays some Bold - const txBob = await borrowerOperations.repayBold(dec(10, 18), bob, bob, { + const txBob = await borrowerOperations.repayBold(dec(10, 18), { from: bob, }); assert.isTrue(txBob.receipt.status); @@ -1328,8 +1303,7 @@ contract("BorrowerOperations", async (accounts) => { try { const txCarol = await borrowerOperations.repayBold( dec(10, 18), - carol, - carol, + { from: carol } ); assert.isFalse(txCarol.receipt.status); @@ -1352,7 +1326,7 @@ contract("BorrowerOperations", async (accounts) => { const aliceDebt = await getTroveEntireDebt(alice); // Bob successfully repays some Bold - const txBob = await borrowerOperations.repayBold(dec(10, 18), bob, bob, { + const txBob = await borrowerOperations.repayBold(dec(10, 18), { from: bob, }); assert.isTrue(txBob.receipt.status); @@ -1361,8 +1335,6 @@ contract("BorrowerOperations", async (accounts) => { try { const txAlice = await borrowerOperations.repayBold( aliceDebt.add(toBN(dec(1, 18))), - alice, - alice, { from: alice } ); assert.isFalse(txAlice.receipt.status); @@ -1388,8 +1360,7 @@ contract("BorrowerOperations", async (accounts) => { await borrowerOperations.repayBold( aliceDebtBefore.div(toBN(10)), - alice, - alice, + { from: alice } ); // Repays 1/10 her debt @@ -1422,8 +1393,7 @@ contract("BorrowerOperations", async (accounts) => { await borrowerOperations.repayBold( aliceDebtBefore.div(toBN(10)), - alice, - alice, + { from: alice } ); // Repays 1/10 her debt @@ -1455,8 +1425,7 @@ contract("BorrowerOperations", async (accounts) => { await borrowerOperations.repayBold( aliceDebtBefore.div(toBN(10)), - alice, - alice, + { from: alice } ); // Repays 1/10 her debt @@ -1490,8 +1459,7 @@ contract("BorrowerOperations", async (accounts) => { const tx = await borrowerOperations.repayBold( aliceDebtBefore.div(toBN(10)), - alice, - alice, + { from: alice } ); assert.isTrue(tx.receipt.status); @@ -1531,8 +1499,6 @@ contract("BorrowerOperations", async (accounts) => { // Bob tries to repay 6 Bold const repayBoldPromise_B = borrowerOperations.repayBold( toBN(dec(6, 18)), - B, - B, { from: B } ); @@ -1567,8 +1533,6 @@ contract("BorrowerOperations", async (accounts) => { 0, BoldRepayment, false, - alice, - alice, { from: alice, value: collTopUp } ), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" @@ -1593,8 +1557,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(50, 18), true, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -1604,8 +1567,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(50, 18), true, - carol, - carol, + { from: carol, value: dec(1, "ether") } ); assert.isFalse(txCarol.receipt.status); @@ -1633,8 +1595,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(50, 18), true, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); assert.isTrue(txAlice.receipt.status); @@ -1650,8 +1611,6 @@ contract("BorrowerOperations", async (accounts) => { dec(1, "ether"), 0, false, - alice, - alice, { from: alice } ); assert.isFalse(txAlice.receipt.status); @@ -1666,8 +1625,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(50, 18), true, - bob, - bob, + { from: bob } ); assert.isFalse(txBob.receipt.status); @@ -1681,9 +1639,7 @@ contract("BorrowerOperations", async (accounts) => { th._100pct, 0, dec(111, 18), - true, - bob, - bob, + true, { from: bob, value: dec(1, "ether") } ); assert.isFalse(txBob.receipt.status); @@ -1717,8 +1673,6 @@ contract("BorrowerOperations", async (accounts) => { 1, dec(5000, 18), false, - alice, - alice, { from: alice } ), "BorrowerOps: Collateral withdrawal not permitted Recovery Mode" @@ -1767,8 +1721,6 @@ contract("BorrowerOperations", async (accounts) => { 0, debtIncrease, true, - alice, - alice, { from: alice, value: collIncrease } ), "BorrowerOps: Operation must leave trove with ICR >= CCR" @@ -1822,8 +1774,6 @@ contract("BorrowerOperations", async (accounts) => { 0, aliceDebtIncrease, true, - alice, - alice, { from: alice, value: aliceCollIncrease } ), "BorrowerOps: Cannot decrease your Trove's ICR in Recovery Mode" @@ -1856,8 +1806,7 @@ contract("BorrowerOperations", async (accounts) => { 0, bobDebtIncrease, true, - bob, - bob, + { from: bob, value: bobCollIncrease } ), " BorrowerOps: Operation must leave trove with ICR >= CCR" @@ -1907,8 +1856,7 @@ contract("BorrowerOperations", async (accounts) => { 0, debtIncrease, true, - alice, - alice, + { from: alice, value: collIncrease } ); assert.isTrue(tx.receipt.status); @@ -1960,8 +1908,7 @@ contract("BorrowerOperations", async (accounts) => { 0, debtIncrease, true, - alice, - alice, + { from: alice, value: collIncrease } ); assert.isTrue(tx.receipt.status); @@ -1988,8 +1935,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(1, 18), true, - bob, - bob, + { from: bob } ); assert.isFalse(txBob.receipt.status); @@ -2021,8 +1967,7 @@ contract("BorrowerOperations", async (accounts) => { 0, remainingDebt.add(toBN(1)), false, - bob, - bob, + { from: bob, value: dec(1, "ether") } ), "revert" @@ -2043,8 +1988,7 @@ contract("BorrowerOperations", async (accounts) => { carolColl.add(toBN(1)), 0, true, - carol, - carol, + { from: carol } ); assert.isFalse(txCarol.receipt.status); @@ -2081,8 +2025,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(100, 18), true, - bob, - bob, + { from: bob, value: dec(1, "ether") } ); assert.isFalse(txBob.receipt.status); @@ -2110,8 +2053,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(50, 18), true, - alice, - alice, + { from: alice, value: 0 } ); @@ -2141,8 +2083,7 @@ contract("BorrowerOperations", async (accounts) => { 0, 0, false, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -2177,8 +2118,7 @@ contract("BorrowerOperations", async (accounts) => { 0, await getNetBorrowingAmount(dec(50, 18)), true, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -2221,8 +2161,7 @@ contract("BorrowerOperations", async (accounts) => { dec(500, "finney"), dec(50, 18), false, - alice, - alice, + { from: alice } ); @@ -2257,8 +2196,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(50, 18), false, - alice, - alice, + { from: alice, value: dec(500, "finney") } ); @@ -2301,8 +2239,7 @@ contract("BorrowerOperations", async (accounts) => { dec(1, 17), await getNetBorrowingAmount(dec(1, 18)), true, - alice, - alice, + { from: alice } ); @@ -2345,8 +2282,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(50, 18), true, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -2383,8 +2319,7 @@ contract("BorrowerOperations", async (accounts) => { dec(500, "finney"), dec(50, 18), false, - alice, - alice, + { from: alice } ); @@ -2419,8 +2354,7 @@ contract("BorrowerOperations", async (accounts) => { dec(100, "finney"), dec(10, 18), false, - alice, - alice, + { from: alice } ); @@ -2455,8 +2389,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(100, 18), true, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -2495,8 +2428,7 @@ contract("BorrowerOperations", async (accounts) => { dec(100, "finney"), dec(10, 18), false, - alice, - alice, + { from: alice } ); @@ -2540,8 +2472,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(100, 18), true, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -2581,8 +2512,7 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(30, 18), false, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -2615,8 +2545,7 @@ contract("BorrowerOperations", async (accounts) => { 0, await getNetBorrowingAmount(dec(100, 18)), true, - alice, - alice, + { from: alice, value: dec(1, "ether") } ); @@ -2654,8 +2583,6 @@ contract("BorrowerOperations", async (accounts) => { aliceColl, aliceDebt, true, - alice, - alice, { from: alice } ), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" @@ -2675,7 +2602,7 @@ contract("BorrowerOperations", async (accounts) => { }); await assertRevert( - borrowerOperations.adjustTrove(th._100pct, 0, 0, true, alice, alice, { + borrowerOperations.adjustTrove(th._100pct, 0, 0, true, { from: alice, }), "BorrowerOps: Debt increase requires non-zero debtChange" @@ -2700,8 +2627,6 @@ contract("BorrowerOperations", async (accounts) => { dec(1, "ether"), dec(100, 18), true, - alice, - alice, { from: alice, value: dec(3, "ether") } ), "BorrowerOperations: Cannot withdraw and add coll" @@ -2716,7 +2641,7 @@ contract("BorrowerOperations", async (accounts) => { }); await assertRevert( - borrowerOperations.adjustTrove(th._100pct, 0, 0, false, alice, alice, { + borrowerOperations.adjustTrove(th._100pct, 0, 0, false, { from: alice, }), "BorrowerOps: There must be either a collateral change or a debt change" @@ -2744,8 +2669,6 @@ contract("BorrowerOperations", async (accounts) => { aliceColl.add(toBN(1)), 0, false, - alice, - alice, { from: alice } ) ); @@ -2754,9 +2677,7 @@ contract("BorrowerOperations", async (accounts) => { th._100pct, aliceColl.add(toBN(dec(37, "ether"))), 0, - false, - bob, - bob, + false, { from: bob } ) ); @@ -2787,8 +2708,6 @@ contract("BorrowerOperations", async (accounts) => { 0, bobDebt, false, - B, - B, { from: B } ); @@ -2816,8 +2735,7 @@ contract("BorrowerOperations", async (accounts) => { dec(1, 18), dec(1, 18), true, - alice, - alice, + { from: bob } ); await assertRevert( @@ -2829,8 +2747,7 @@ contract("BorrowerOperations", async (accounts) => { dec(1, 18), dec(1, 18), true, - alice, - alice, + { from: owner } ); await assertRevert( @@ -2842,8 +2759,7 @@ contract("BorrowerOperations", async (accounts) => { dec(1, 18), dec(1, 18), true, - alice, - alice, + { from: bob } ); await assertRevert( @@ -3489,8 +3405,6 @@ contract("BorrowerOperations", async (accounts) => { 0, dec(1, 18), true, - whale, - whale, { from: whale } ); @@ -3636,7 +3550,6 @@ contract("BorrowerOperations", async (accounts) => { const D_emittedColl = toBN( th.getEventArgByName(txD, "TroveUpdated", "_coll") ); - const E_emittedDebt = toBN( th.getEventArgByName(txE, "TroveUpdated", "_debt") ); @@ -3660,6 +3573,7 @@ contract("BorrowerOperations", async (accounts) => { await getNetBorrowingAmount(MIN_NET_DEBT.add(toBN(1))), A, A, + 0, { from: A, value: dec(100, 30) } ); assert.isTrue(txA.receipt.status); @@ -3670,6 +3584,7 @@ contract("BorrowerOperations", async (accounts) => { await getNetBorrowingAmount(MIN_NET_DEBT.add(toBN(dec(47789898, 22)))), A, A, + 0, { from: C, value: dec(100, 30) } ); assert.isTrue(txC.receipt.status); @@ -3677,7 +3592,7 @@ contract("BorrowerOperations", async (accounts) => { }); it("openTrove(): reverts if net debt < minimum net debt", async () => { - const txAPromise = borrowerOperations.openTrove(th._100pct, 0, A, A, { + const txAPromise = borrowerOperations.openTrove(th._100pct, 0, A, A, 0, { from: A, value: dec(100, 30), }); @@ -3688,6 +3603,7 @@ contract("BorrowerOperations", async (accounts) => { await getNetBorrowingAmount(MIN_NET_DEBT.sub(toBN(1))), B, B, + 0, { from: B, value: dec(100, 30) } ); await assertRevert(txBPromise, "revert"); @@ -3697,6 +3613,7 @@ contract("BorrowerOperations", async (accounts) => { MIN_NET_DEBT.sub(toBN(dec(173, 18))), C, C, + 0, { from: C, value: dec(100, 30) } ); await assertRevert(txCPromise, "revert"); @@ -3917,6 +3834,7 @@ contract("BorrowerOperations", async (accounts) => { await getNetBorrowingAmount(MIN_NET_DEBT), carol, carol, + 0, { from: carol, value: dec(1, "ether") } ) ); @@ -3935,7 +3853,7 @@ contract("BorrowerOperations", async (accounts) => { assert.equal(status_Before, 0); const BoldRequest = MIN_NET_DEBT; - await borrowerOperations.openTrove(th._100pct, MIN_NET_DEBT, carol, carol, { + await borrowerOperations.openTrove(th._100pct, MIN_NET_DEBT, carol, carol, 0, { from: alice, value: dec(100, "ether"), }); @@ -4157,6 +4075,7 @@ contract("BorrowerOperations", async (accounts) => { await getOpenTroveBoldAmount(dec(10000, 18)), alice, alice, + 0, { from: alice, value: dec(100, "ether") } ); @@ -4192,6 +4111,7 @@ contract("BorrowerOperations", async (accounts) => { dec(10000, 18), alice, alice, + 0, { from: alice, value: dec(100, "ether") } ); @@ -4437,6 +4357,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4444,6 +4365,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4488,6 +4410,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4495,6 +4418,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4539,6 +4463,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4546,6 +4471,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4589,6 +4515,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4596,6 +4523,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4640,6 +4568,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4647,6 +4576,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4692,6 +4622,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4699,6 +4630,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4744,6 +4676,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4751,6 +4684,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4796,6 +4730,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4803,6 +4738,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4848,6 +4784,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, alice, alice, + 0, { from: alice, value: troveColl } ); await borrowerOperations.openTrove( @@ -4855,6 +4792,7 @@ contract("BorrowerOperations", async (accounts) => { troveBoldAmount, bob, bob, + 0, { from: bob, value: troveColl } ); @@ -4899,6 +4837,7 @@ contract("BorrowerOperations", async (accounts) => { dec(100000, 18), alice, alice, + 0, { from: alice, value: dec(1000, 18) } ); @@ -4911,8 +4850,8 @@ contract("BorrowerOperations", async (accounts) => { const _100pctHex = "0xde0b6b3a7640000"; const _1e25Hex = "0xd3c21bcecceda1000000"; const openTroveData = th.getTransactionData( - "openTrove(uint256,uint256,address,address)", - [_100pctHex, _1e25Hex, "0x0", "0x0"] + "openTrove(uint256,uint256,address,address,uint256)", + [_100pctHex, _1e25Hex, "0x0", "0x0", "0x0"] ); await nonPayable.forward(borrowerOperations.address, openTroveData, { value: dec(10000, "ether"), diff --git a/contracts/test/CollSurplusPool.js b/contracts/test/CollSurplusPool.js index 85c31249..1278a776 100644 --- a/contracts/test/CollSurplusPool.js +++ b/contracts/test/CollSurplusPool.js @@ -103,8 +103,8 @@ contract("CollSurplusPool", async (accounts) => { B_boldAmount ); const openTroveData = th.getTransactionData( - "openTrove(uint256,uint256,address,address)", - ["0xde0b6b3a7640000", web3.utils.toHex(B_boldAmount), B, B] + "openTrove(uint256,uint256,address,address,uint256)", + ["0xde0b6b3a7640000", web3.utils.toHex(B_boldAmount), B, B, "0x0"] ); await nonPayable.forward(borrowerOperations.address, openTroveData, { value: B_coll, diff --git a/contracts/test/GasCompensationTest.js b/contracts/test/GasCompensationTest.js index 523f5bcf..da5dca5a 100644 --- a/contracts/test/GasCompensationTest.js +++ b/contracts/test/GasCompensationTest.js @@ -1283,7 +1283,7 @@ contract("Gas compensation tests", async (accounts) => { }); // liquidateTroves - full offset - it("liquidateTroves(): full offset. Compensates the correct amount, and liquidates the remainder", async () => { + it.skip("liquidateTroves(): full offset. Compensates the correct amount, and liquidates the remainder", async () => { await priceFeed.setPrice(dec(1000, 18)); await openTrove({ ICR: toBN(dec(2000, 18)), extraParams: { from: whale } }); @@ -1411,7 +1411,7 @@ contract("Gas compensation tests", async (accounts) => { }); // liquidateTroves - full redistribution - it("liquidateTroves(): full redistribution. Compensates the correct amount, and liquidates the remainder", async () => { + it.skip("liquidateTroves(): full redistribution. Compensates the correct amount, and liquidates the remainder", async () => { await priceFeed.setPrice(dec(1000, 18)); await openTrove({ ICR: toBN(dec(200, 18)), extraParams: { from: whale } }); @@ -1527,7 +1527,7 @@ contract("Gas compensation tests", async (accounts) => { }); // --- event emission in liquidation sequence --- - it("liquidateTroves(): full offset. Liquidation event emits the correct gas compensation and total liquidated coll and debt", async () => { + it.skip("liquidateTroves(): full offset. Liquidation event emits the correct gas compensation and total liquidated coll and debt", async () => { await priceFeed.setPrice(dec(1000, 18)); await openTrove({ ICR: toBN(dec(2000, 18)), extraParams: { from: whale } }); @@ -1643,7 +1643,7 @@ contract("Gas compensation tests", async (accounts) => { assert.isAtMost(th.getDifference(expectedGasComp, loggedGasComp), 1000); }); - it("liquidateTroves(): full redistribution. Liquidation event emits the correct gas compensation and total liquidated coll and debt", async () => { + it.skip("liquidateTroves(): full redistribution. Liquidation event emits the correct gas compensation and total liquidated coll and debt", async () => { await priceFeed.setPrice(dec(1000, 18)); await openTrove({ ICR: toBN(dec(2000, 18)), extraParams: { from: whale } }); diff --git a/contracts/test/SP_P_TruncationTest.js b/contracts/test/SP_P_TruncationTest.js index 1c5e56ed..e006f924 100644 --- a/contracts/test/SP_P_TruncationTest.js +++ b/contracts/test/SP_P_TruncationTest.js @@ -150,6 +150,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, + 0, { from: whale, value: dec(100000, "ether") } ); await boldToken.transfer(A, dec(50000, 18), { from: whale }); @@ -161,6 +162,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getBoldAmountForDesiredDebt(2000), account, account, + 0, { from: account, value: dec(15, "ether") } ); assert.isTrue( @@ -245,6 +247,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, + 0, { from: whale, value: dec(100000, "ether") } ); await boldToken.transfer(A, dec(50000, 18), { from: whale }); @@ -256,6 +259,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getBoldAmountForDesiredDebt(2000), account, account, + 0, { from: account, value: dec(15, "ether") } ); assert.isTrue( @@ -351,6 +355,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, + 0, { from: whale, value: dec(100000, "ether") } ); await boldToken.transfer(A, dec(50000, 18), { from: whale }); @@ -362,6 +367,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getBoldAmountForDesiredDebt(2000), account, account, + 0, { from: account, value: dec(15, "ether") } ); assert.isTrue( @@ -459,6 +465,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, + 0, { from: whale, value: dec(100000, "ether") } ); await boldToken.transfer(A, dec(50000, 18), { from: whale }); @@ -470,6 +477,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getBoldAmountForDesiredDebt(2000), account, account, + 0, { from: account, value: dec(15, "ether") } ); assert.isTrue( @@ -576,6 +584,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, + 0, { from: whale, value: dec(100000, "ether") } ); await boldToken.transfer(A, dec(50000, 18), { from: whale }); @@ -587,6 +596,7 @@ contract("StabilityPool Scale Factor issue tests", async (accounts) => { await getBoldAmountForDesiredDebt(2000), account, account, + 0, { from: account, value: dec(15, "ether") } ); assert.isTrue( diff --git a/contracts/test/SortedTrovesTest.js b/contracts/test/SortedTrovesTest.js index e776fad6..ec0e86b9 100644 --- a/contracts/test/SortedTrovesTest.js +++ b/contracts/test/SortedTrovesTest.js @@ -306,22 +306,22 @@ contract("SortedTroves", async (accounts) => { it("Finds the correct insert position given two addresses that loosely bound the correct position", async () => { await priceFeed.setPrice(dec(100, 18)); - // NICR sorted in descending order + // Inserted in descending order of interest rate await openTrove({ ICR: toBN(dec(500, 18)), extraParams: { from: whale }, }); - await openTrove({ ICR: toBN(dec(10, 18)), extraParams: { from: A } }); - await openTrove({ ICR: toBN(dec(5, 18)), extraParams: { from: B } }); - await openTrove({ ICR: toBN(dec(250, 16)), extraParams: { from: C } }); - await openTrove({ ICR: toBN(dec(166, 16)), extraParams: { from: D } }); - await openTrove({ ICR: toBN(dec(125, 16)), extraParams: { from: E } }); + await openTrove({ ICR: toBN(dec(10, 18)), extraParams: { from: A, annualInterestRate: toBN(dec(1,18))}}); // 100% interest rate + await openTrove({ ICR: toBN(dec(5, 18)), extraParams: { from: B , annualInterestRate: toBN(dec(75, 16))}}); // 75% interest rate + await openTrove({ ICR: toBN(dec(250, 16)), extraParams: { from: C, annualInterestRate: toBN(dec(5, 17))}}); // 50% interest rate + await openTrove({ ICR: toBN(dec(166, 16)), extraParams: { from: D, annualInterestRate: toBN(dec(25,16))}}); // 25% interest rate + await openTrove({ ICR: toBN(dec(125, 16)), extraParams: { from: E, annualInterestRate: toBN(dec(1, 16))}}); // 1% interest rate - // Expect a trove with NICR 300% to be inserted between B and C - const targetNICR = dec(3, 18); + // Expect a trove with 60% interest rate to be inserted between B and C + const targetAnnualIRate = toBN(dec(60, 16)); // Pass addresses that loosely bound the right postiion - const hints = await sortedTroves.findInsertPosition(targetNICR, A, E); + const hints = await sortedTroves.findInsertPosition(targetAnnualIRate, A, E); // Expect the exact correct insert hints have been returned assert.equal(hints[0], B); @@ -329,7 +329,7 @@ contract("SortedTroves", async (accounts) => { // The price doesn’t affect the hints await priceFeed.setPrice(dec(500, 18)); - const hints2 = await sortedTroves.findInsertPosition(targetNICR, A, E); + const hints2 = await sortedTroves.findInsertPosition(targetAnnualIRate, A, E); // Expect the exact correct insert hints have been returned assert.equal(hints2[0], B); @@ -338,7 +338,7 @@ contract("SortedTroves", async (accounts) => { }); describe("SortedTroves with mock dependencies", () => { - let sortedTrovesTester; + let sortedTrovesTester; beforeEach(async () => { sortedTroves = await SortedTroves.new(); @@ -352,6 +352,7 @@ contract("SortedTroves", async (accounts) => { await th.assertRevert( sortedTroves.setParams( 0, + // The SortedTrovesTester is being used here as both a wrapper for SortedTroves and a mock TroveManager. sortedTrovesTester.address, sortedTrovesTester.address ), @@ -393,13 +394,6 @@ contract("SortedTroves", async (accounts) => { ); }); - it("insert(): fails if NICR is zero", async () => { - await th.assertRevert( - sortedTrovesTester.insert(alice, 0, alice, alice), - "SortedTroves: NICR must be positive" - ); - }); - it("remove(): fails if id is not in the list", async () => { await th.assertRevert( sortedTrovesTester.remove(alice), @@ -414,22 +408,6 @@ contract("SortedTroves", async (accounts) => { ); }); - it("reInsert(): fails if new NICR is zero", async () => { - await sortedTrovesTester.insert(alice, 1, alice, alice); - assert.isTrue( - await sortedTroves.contains(alice), - "list should contain element" - ); - await th.assertRevert( - sortedTrovesTester.reInsert(alice, 0, alice, alice), - "SortedTroves: NICR must be positive" - ); - assert.isTrue( - await sortedTroves.contains(alice), - "list should contain element" - ); - }); - it("findInsertPosition(): No prevId for hint - ascend list starting from nextId, result is after the tail", async () => { await sortedTrovesTester.insert(alice, 1, alice, alice); const pos = await sortedTroves.findInsertPosition( diff --git a/contracts/test/StabilityPoolTest.js b/contracts/test/StabilityPoolTest.js index 9219a7e9..d12a94cd 100644 --- a/contracts/test/StabilityPoolTest.js +++ b/contracts/test/StabilityPoolTest.js @@ -1603,7 +1603,7 @@ contract("StabilityPool", async (accounts) => { assert.equal(await stabilityPool.getDepositorETHGain(alice), 0); // Alice attempts third withdrawal (this time, frm SP to Trove) - const txPromise_A = stabilityPool.withdrawETHGainToTrove(alice, alice, { + const txPromise_A = stabilityPool.withdrawETHGainToTrove({ from: alice, }); await th.assertRevert(txPromise_A); @@ -1803,6 +1803,7 @@ contract("StabilityPool", async (accounts) => { await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, + 0, { from: defaulter_1, value: dec(100, "ether") } ); @@ -1842,8 +1843,6 @@ contract("StabilityPool", async (accounts) => { await borrowerOperations.withdrawBold( th._100pct, dec(5000, 18), - bob, - bob, { from: bob } ); @@ -2613,6 +2612,7 @@ contract("StabilityPool", async (accounts) => { await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, + 0, { from: defaulter_1, value: dec(100, "ether") } ); @@ -3100,12 +3100,12 @@ contract("StabilityPool", async (accounts) => { await troveManager.liquidate(defaulter_1); assert.isFalse(await sortedTroves.contains(defaulter_1)); - const txAlice = await stabilityPool.withdrawETHGainToTrove(alice, alice, { + const txAlice = await stabilityPool.withdrawETHGainToTrove( { from: alice, }); assert.isTrue(txAlice.receipt.status); - const txPromise_B = stabilityPool.withdrawETHGainToTrove(bob, bob, { + const txPromise_B = stabilityPool.withdrawETHGainToTrove( { from: bob, }); await th.assertRevert(txPromise_B); @@ -3178,7 +3178,7 @@ contract("StabilityPool", async (accounts) => { ); // Alice sends her ETH Gains to her Trove - await stabilityPool.withdrawETHGainToTrove(alice, alice, { from: alice }); + await stabilityPool.withdrawETHGainToTrove( { from: alice }); // check Alice's BoldLoss has been applied to her deposit expectedCompoundedDeposit_A alice_deposit_afterDefault = (await stabilityPool.deposits(alice)); @@ -3244,7 +3244,7 @@ contract("StabilityPool", async (accounts) => { // Alice attempts to her ETH Gains to her Trove await assertRevert( - stabilityPool.withdrawETHGainToTrove(alice, alice, { from: alice }), + stabilityPool.withdrawETHGainToTrove( { from: alice }), "BorrowerOps: An operation that would result in ICR < MCR is not permitted" ); }); @@ -3294,14 +3294,14 @@ contract("StabilityPool", async (accounts) => { await priceFeed.setPrice(dec(200, 18)); // Alice sends her ETH Gains to her Trove - await stabilityPool.withdrawETHGainToTrove(alice, alice, { from: alice }); + await stabilityPool.withdrawETHGainToTrove( { from: alice }); assert.equal(await stabilityPool.getDepositorETHGain(alice), 0); const ETHinSP_Before = (await stabilityPool.getETH()).toString(); // Alice attempts second withdrawal from SP to Trove - reverts, due to 0 ETH Gain - const txPromise_A = stabilityPool.withdrawETHGainToTrove(alice, alice, { + const txPromise_A = stabilityPool.withdrawETHGainToTrove( { from: alice, }); await th.assertRevert(txPromise_A); @@ -3373,7 +3373,7 @@ contract("StabilityPool", async (accounts) => { const stability_ETH_Before = await stabilityPool.getETH(); // Alice retrieves redirects ETH gain to her Trove - await stabilityPool.withdrawETHGainToTrove(alice, alice, { from: alice }); + await stabilityPool.withdrawETHGainToTrove({ from: alice }); const active_ETH_After = await activePool.getETH(); const stability_ETH_After = await stabilityPool.getETH(); @@ -3427,27 +3427,27 @@ contract("StabilityPool", async (accounts) => { await priceFeed.setPrice(dec(200, 18)); // All depositors attempt to withdraw - const tx1 = await stabilityPool.withdrawETHGainToTrove(alice, alice, { + const tx1 = await stabilityPool.withdrawETHGainToTrove({ from: alice, }); assert.isTrue(tx1.receipt.status); - const tx2 = await stabilityPool.withdrawETHGainToTrove(bob, bob, { + const tx2 = await stabilityPool.withdrawETHGainToTrove({ from: bob, }); assert.isTrue(tx1.receipt.status); - const tx3 = await stabilityPool.withdrawETHGainToTrove(carol, carol, { + const tx3 = await stabilityPool.withdrawETHGainToTrove({ from: carol, }); assert.isTrue(tx1.receipt.status); - const tx4 = await stabilityPool.withdrawETHGainToTrove(dennis, dennis, { + const tx4 = await stabilityPool.withdrawETHGainToTrove({ from: dennis, }); assert.isTrue(tx1.receipt.status); - const tx5 = await stabilityPool.withdrawETHGainToTrove(erin, erin, { + const tx5 = await stabilityPool.withdrawETHGainToTrove({ from: erin, }); assert.isTrue(tx1.receipt.status); - const tx6 = await stabilityPool.withdrawETHGainToTrove(flyn, flyn, { + const tx6 = await stabilityPool.withdrawETHGainToTrove({ from: flyn, }); assert.isTrue(tx1.receipt.status); @@ -3497,28 +3497,28 @@ contract("StabilityPool", async (accounts) => { await priceFeed.setPrice(dec(200, 18)); - await stabilityPool.withdrawETHGainToTrove(alice, alice, { from: alice }); + await stabilityPool.withdrawETHGainToTrove({ from: alice }); const aliceCollAfter = (await troveManager.Troves(alice))[1]; assert.isAtMost( th.getDifference(aliceCollAfter.sub(collBefore), expectedCollGain), 10000 ); - await stabilityPool.withdrawETHGainToTrove(bob, bob, { from: bob }); + await stabilityPool.withdrawETHGainToTrove({ from: bob }); const bobCollAfter = (await troveManager.Troves(bob))[1]; assert.isAtMost( th.getDifference(bobCollAfter.sub(collBefore), expectedCollGain), 10000 ); - await stabilityPool.withdrawETHGainToTrove(carol, carol, { from: carol }); + await stabilityPool.withdrawETHGainToTrove({ from: carol }); const carolCollAfter = (await troveManager.Troves(carol))[1]; assert.isAtMost( th.getDifference(carolCollAfter.sub(collBefore), expectedCollGain), 10000 ); - await stabilityPool.withdrawETHGainToTrove(dennis, dennis, { + await stabilityPool.withdrawETHGainToTrove( { from: dennis, }); const dennisCollAfter = (await troveManager.Troves(dennis))[1]; @@ -3527,14 +3527,14 @@ contract("StabilityPool", async (accounts) => { 10000 ); - await stabilityPool.withdrawETHGainToTrove(erin, erin, { from: erin }); + await stabilityPool.withdrawETHGainToTrove({ from: erin }); const erinCollAfter = (await troveManager.Troves(erin))[1]; assert.isAtMost( th.getDifference(erinCollAfter.sub(collBefore), expectedCollGain), 10000 ); - await stabilityPool.withdrawETHGainToTrove(flyn, flyn, { from: flyn }); + await stabilityPool.withdrawETHGainToTrove({ from: flyn }); const flynCollAfter = (await troveManager.Troves(flyn))[1]; assert.isAtMost( th.getDifference(flynCollAfter.sub(collBefore), expectedCollGain), @@ -3608,9 +3608,9 @@ contract("StabilityPool", async (accounts) => { ); // A, B, C withdraw their full ETH gain from the Stability Pool to their trove - await stabilityPool.withdrawETHGainToTrove(alice, alice, { from: alice }); - await stabilityPool.withdrawETHGainToTrove(bob, bob, { from: bob }); - await stabilityPool.withdrawETHGainToTrove(carol, carol, { from: carol }); + await stabilityPool.withdrawETHGainToTrove( { from: alice }); + await stabilityPool.withdrawETHGainToTrove({ from: bob }); + await stabilityPool.withdrawETHGainToTrove({ from: carol }); // Check collateral of troves A, B, C has increased by the value of their ETH gain from liquidations, respectively const alice_expectedCollateral = alice_Collateral_Before @@ -3685,7 +3685,7 @@ contract("StabilityPool", async (accounts) => { // D attempts to withdraw his ETH gain to Trove await th.assertRevert( - stabilityPool.withdrawETHGainToTrove(dennis, dennis, { from: dennis }), + stabilityPool.withdrawETHGainToTrove( { from: dennis }), "caller must have an active trove to withdraw ETHGain to" ); }); @@ -3737,16 +3737,16 @@ contract("StabilityPool", async (accounts) => { assert.equal(await stabilityPool.getDepositorETHGain(C), "0"); // Check withdrawETHGainToTrove reverts for A, B, C - const txPromise_A = stabilityPool.withdrawETHGainToTrove(A, A, { + const txPromise_A = stabilityPool.withdrawETHGainToTrove({ from: A, }); - const txPromise_B = stabilityPool.withdrawETHGainToTrove(B, B, { + const txPromise_B = stabilityPool.withdrawETHGainToTrove({ from: B, }); - const txPromise_C = stabilityPool.withdrawETHGainToTrove(C, C, { + const txPromise_C = stabilityPool.withdrawETHGainToTrove({ from: C, }); - const txPromise_D = stabilityPool.withdrawETHGainToTrove(D, D, { + const txPromise_D = stabilityPool.withdrawETHGainToTrove({ from: D, }); diff --git a/contracts/test/StabilityPool_SPWithdrawalTest.js b/contracts/test/StabilityPool_SPWithdrawalTest.js index 696df6f5..8d5eeb9b 100644 --- a/contracts/test/StabilityPool_SPWithdrawalTest.js +++ b/contracts/test/StabilityPool_SPWithdrawalTest.js @@ -81,7 +81,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Identical deposits, identical liquidation amounts--- it("withdrawFromSP(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -91,7 +91,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulter opens trove with 200% ICR and 10k Bold net debt - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -120,7 +120,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after two identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -130,8 +130,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -160,7 +160,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after three identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -170,9 +170,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -204,7 +204,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Identical deposits, increasing liquidation amounts --- it("withdrawFromSP(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after two liquidations of increasing Bold", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -214,8 +214,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: '50000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: '70000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: '70000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -246,7 +246,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after three liquidations of increasing Bold", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -256,9 +256,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: '50000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(6000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: '60000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: '70000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(6000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: '60000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: '70000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -291,7 +291,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Increasing deposits, identical liquidation amounts --- it("withdrawFromSP(): Depositors with varying deposits withdraw correct compounded deposit and ETH Gain after two identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k, 20k, 30k Bold to A, B and C respectively who then deposit it to the SP await boldToken.transfer(alice, dec(10000, 18), { from: whale }) @@ -302,8 +302,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await stabilityPool.provideToSP(dec(30000, 18), { from: carol }) // 2 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -333,7 +333,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): Depositors with varying deposits withdraw correct compounded deposit and ETH Gain after three identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k, 20k, 30k Bold to A, B and C respectively who then deposit it to the SP await boldToken.transfer(alice, dec(10000, 18), { from: whale }) @@ -344,9 +344,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await stabilityPool.provideToSP(dec(30000, 18), { from: carol }) // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -378,7 +378,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Varied deposits and varied liquidation amount --- it("withdrawFromSP(): Depositors with varying deposits withdraw correct compounded deposit and ETH Gain after three varying liquidations", async () => { // Whale opens Trove with 1m ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, { from: whale, value: dec(1000000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, 0,{ from: whale, value: dec(1000000, 'ether') }) /* Depositors provide:- Alice: 2000 Bold @@ -398,9 +398,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' Defaulter 2: 5000 Bold & 50 ETH Defaulter 3: 46700 Bold & 500 ETH */ - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('207000000000000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(2160, 18) }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5, 21)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(50, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('46700000000000000000000'), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(500, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('207000000000000000000000'), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(2160, 18) }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5, 21)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(50, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('46700000000000000000000'), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(500, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -435,7 +435,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): A, B, C Deposit -> 2 liquidations -> D deposits -> 1 liquidation. All deposits and liquidations = 100 Bold. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -445,9 +445,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -490,7 +490,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): A, B, C Deposit -> 2 liquidations -> D deposits -> 2 liquidations. All deposits and liquidations = 100 Bold. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -500,10 +500,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -544,7 +544,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): A, B, C Deposit -> 2 liquidations -> D deposits -> 2 liquidations. Various deposit and liquidation vals. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 1m ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, { from: whale, value: dec(1000000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, 0,{ from: whale, value: dec(1000000, 'ether') }) /* Depositors open troves and make SP deposit: Alice: 60000 Bold @@ -565,10 +565,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' Defaulter 3: 5000 Bold, 50 ETH Defaulter 4: 40000 Bold, 400 ETH */ - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(25000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: '250000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: '50000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(40000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(400, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(25000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: '250000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(40000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: dec(400, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -613,7 +613,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): A, B, C, D deposit -> 2 liquidations -> D withdraws -> 2 liquidations. All deposits and liquidations = 100 Bold. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol, dennis] @@ -623,10 +623,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -669,7 +669,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): A, B, C, D deposit -> 2 liquidations -> D withdraws -> 2 liquidations. Various deposit and liquidation vals. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) /* Initial deposits: Alice: 20000 Bold @@ -693,10 +693,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' Defaulter 3: 30000 Bold Defaulter 4: 5000 Bold */ - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(30000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(300, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(30000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(300, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: '50000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -742,7 +742,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- One deposit enters at t > 0, and another leaves later --- it("withdrawFromSP(): A, B, D deposit -> 2 liquidations -> C makes deposit -> 1 liquidation -> D withdraws -> 1 liquidation. All deposits: 100 Bold. Liquidations: 100,100,100,50. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B and D who then deposit it to the SP const depositors = [alice, bob, dennis] @@ -752,10 +752,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: '50000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -811,7 +811,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // C, D withdraw 5000Bold & 500e it("withdrawFromSP(): Depositor withdraws correct compounded deposit after liquidation empties the pool", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B who then deposit it to the SP const depositors = [alice, bob] @@ -821,8 +821,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // 2 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -878,7 +878,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // L2 20000, 200 empties Pool it("withdrawFromSP(): Pool-emptying liquidation increases epoch by one, resets scaleFactor to 0, and resets P to 1e18", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B who then deposit it to the SP const depositors = [alice, bob] @@ -888,10 +888,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // 4 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -970,7 +970,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // C, D withdraw 5000 Bold & 50e it("withdrawFromSP(): Depositors withdraw correct compounded deposit after liquidation empties the pool", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Whale transfers 10k Bold to A, B who then deposit it to the SP const depositors = [alice, bob] @@ -980,8 +980,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // 2 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1037,15 +1037,15 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Expect A to withdraw 0 deposit and ether only from reward L1 it("withdrawFromSP(): single deposit fully offset. After subsequent liquidations, depositor withdraws 0 deposit and *only* the ETH Gain from one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1,2,3 withdraw 10000 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1079,13 +1079,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): Depositor withdraws correct compounded deposit after liquidation empties the pool", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // 4 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: dec(200, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -1188,18 +1188,18 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawFromSP(): deposit spans one scale factor change: Single depositor withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 withdraws 'almost' 10000 Bold: 9999.99991 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) assert.equal(await stabilityPool.currentScale(), '0') // Defaulter 2 withdraws 9900 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(9900, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(60, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(9900, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(60, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1245,16 +1245,16 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawFromSP(): Several deposits of varying amounts span one scale factor change. Depositors withdraw correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 withdraws 'almost' 10k Bold. - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) // Defaulter 2 withdraws 59400 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59400000000000000000000'), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(330, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59400000000000000000000'), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(330, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1327,14 +1327,14 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawFromSP(): deposit spans one scale factor change: Single depositor withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 and default 2 each withdraw 9999.999999999 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter 1 ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -1383,14 +1383,14 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawFromSP(): Several deposits of varying amounts span one scale factor change. Depositors withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 and default 2 withdraw up to debt of 9999.9 Bold and 59999.4 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59999400000000000000000'), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(600, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59999400000000000000000'), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(600, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1447,10 +1447,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Expect A to withdraw 0 deposit it("withdrawFromSP(): Deposit that decreases to less than 1e-9 of it's original value is reduced to 0", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Defaulters 1 withdraws 9999.9999999 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999999900000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999999900000000000'), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) // Price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1483,13 +1483,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawFromSP(): Several deposits of 10000 Bold span one scale factor change. Depositors withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Defaulters 1-4 each withdraw 9999.9 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1561,12 +1561,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): 2 depositors can withdraw after each receiving half of a pool-emptying liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Defaulters 1-3 each withdraw 24100, 24300, 24500 Bold (inc gas comp) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24100, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24300, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24500, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24100, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24300, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24500, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(200, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1689,14 +1689,14 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawFromSP(): Depositor's ETH gain stops increasing after two scale changes", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // Defaulters 1-5 each withdraw up to debt of 9999.9999999 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_5, defaulter_5, { from: defaulter_5, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_5, defaulter_5, 0, { from: defaulter_5, value: dec(100, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1765,19 +1765,19 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawFromSP(): Large liquidated coll/debt, deposits and ETH price", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // ETH:USD price is $2 billion per ETH await priceFeed.setPrice(dec(2, 27)); const depositors = [alice, bob] for (account of depositors) { - await borrowerOperations.openTrove(th._100pct, dec(1, 36), account, account, { from: account, value: dec(2, 27) }) + await borrowerOperations.openTrove(th._100pct, dec(1, 36), account, account, 0, { from: account, value: dec(2, 27) }) await stabilityPool.provideToSP(dec(1, 36), { from: account }) } // Defaulter opens trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1, 36)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(1, 27) }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1, 36)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: dec(1, 27) }) // ETH:USD price drops to $1 billion per ETH await priceFeed.setPrice(dec(1, 27)); @@ -1822,7 +1822,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawFromSP(): Small liquidated coll/debt, large deposits and ETH price", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0,{ from: whale, value: dec(100000, 'ether') }) // ETH:USD price is $2 billion per ETH await priceFeed.setPrice(dec(2, 27)); @@ -1835,7 +1835,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulter opens trove with 50e-7 ETH and 5000 Bold. 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: '5000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, 0,{ from: defaulter_1, value: '5000000000000' }) // ETH:USD price drops to $1 billion per ETH await priceFeed.setPrice(dec(1, 27)); diff --git a/contracts/test/StabilityPool_SPWithdrawalToCDPTest.js b/contracts/test/StabilityPool_SPWithdrawalToCDPTest.js index 119c7f42..a1081657 100644 --- a/contracts/test/StabilityPool_SPWithdrawalToCDPTest.js +++ b/contracts/test/StabilityPool_SPWithdrawalToCDPTest.js @@ -81,12 +81,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Identical deposits, identical liquidation amounts--- it("withdrawETHGainToTrove(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -96,7 +96,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulter opens trove with 200% ICR and 10k Bold net debt - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -105,9 +105,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_1, { from: owner }); // Check depositors' compounded deposit is 6666.66 Bold and ETH Gain is 33.16 ETH - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -125,12 +125,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after two identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -140,8 +140,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -151,9 +151,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_2, { from: owner }); // Check depositors' compounded deposit is 3333.33 Bold and ETH Gain is 66.33 ETH - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() const bob_ETHWithdrawn = th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() @@ -170,12 +170,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after three identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -185,9 +185,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -198,9 +198,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_3, { from: owner }); // Check depositors' compounded deposit is 0 Bold and ETH Gain is 99.5 ETH - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -219,12 +219,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Identical deposits, increasing liquidation amounts --- it("withdrawETHGainToTrove(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after two liquidations of increasing Bold", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -234,8 +234,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: '50000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: '70000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: '70000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -245,9 +245,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_2, { from: owner }); // Check depositors' compounded deposit - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -266,12 +266,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): Depositors with equal initial deposit withdraw correct compounded deposit and ETH Gain after three liquidations of increasing Bold", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -281,9 +281,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: '50000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(6000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: '60000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: '70000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(6000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: '60000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(7000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: '70000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -294,9 +294,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_3, { from: owner }); // Check depositors' compounded deposit - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -316,12 +316,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Increasing deposits, identical liquidation amounts --- it("withdrawETHGainToTrove(): Depositors with varying deposits withdraw correct compounded deposit and ETH Gain after two identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k, 20k, 30k Bold to A, B and C respectively who then deposit it to the SP await boldToken.transfer(alice, dec(10000, 18), { from: whale }) @@ -332,8 +332,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await stabilityPool.provideToSP(dec(30000, 18), { from: carol }) // 2 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -343,9 +343,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_2, { from: owner }); // Depositors attempt to withdraw everything - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -363,12 +363,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): Depositors with varying deposits withdraw correct compounded deposit and ETH Gain after three identical liquidations", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k, 20k, 30k Bold to A, B and C respectively who then deposit it to the SP await boldToken.transfer(alice, dec(10000, 18), { from: whale }) @@ -379,9 +379,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await stabilityPool.provideToSP(dec(30000, 18), { from: carol }) // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -392,9 +392,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_3, { from: owner }); // Depositors attempt to withdraw everything - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -413,12 +413,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- Varied deposits and varied liquidation amount --- it("withdrawETHGainToTrove(): Depositors with varying deposits withdraw correct compounded deposit and ETH Gain after three varying liquidations", async () => { // Whale opens Trove with 1m ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, { from: whale, value: dec(1000000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, 0, { from: whale, value: dec(1000000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) /* Depositors provide:- Alice: 2000 Bold @@ -438,9 +438,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' Defaulter 2: 5000 Bold & 50 ETH Defaulter 3: 46700 Bold & 500 ETH */ - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('207000000000000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(2160, 18) }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5, 21)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(50, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('46700000000000000000000'), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(500, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('207000000000000000000000'), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(2160, 18) }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5, 21)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(50, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('46700000000000000000000'), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(500, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -451,9 +451,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_3, { from: owner }); // Depositors attempt to withdraw everything - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -475,13 +475,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): A, B, C Deposit -> 2 liquidations -> D deposits -> 1 liquidation. All deposits and liquidations = 100 Bold. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -491,9 +491,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -509,10 +509,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Third defaulter liquidated await troveManager.liquidate(defaulter_3, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -536,13 +536,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): A, B, C Deposit -> 2 liquidations -> D deposits -> 2 liquidations. All deposits and liquidations = 100 Bold. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol] @@ -552,10 +552,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, 0,{ from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -572,10 +572,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_3, { from: owner }); await troveManager.liquidate(defaulter_4, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -596,13 +596,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): A, B, C Deposit -> 2 liquidations -> D deposits -> 2 liquidations. Various deposit and liquidation vals. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 1m ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, { from: whale, value: dec(1000000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1000000, 18)), whale, whale, 0, { from: whale, value: dec(1000000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) /* Depositors open troves and make SP deposit: Alice: 60000 Bold @@ -623,10 +623,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' Defaulter 3: 5000 Bold, 50 ETH Defaulter 4: 40000 Bold, 400 ETH */ - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(25000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: '250000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: '50000000000000000000' }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(40000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(400, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(25000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: '250000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(40000, 18)), defaulter_4, defaulter_4, 0,{ from: defaulter_4, value: dec(400, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -644,10 +644,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_4, { from: owner }); // Each depositor withdraws as much as possible - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -671,13 +671,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): A, B, C, D deposit -> 2 liquidations -> D withdraws -> 2 liquidations. All deposits and liquidations = 100 Bold. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and C who then deposit it to the SP const depositors = [alice, bob, carol, dennis] @@ -687,10 +687,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, 0,{ from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -702,7 +702,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Dennis withdraws his deposit and ETH gain // Increasing the price for a moment to avoid pending liquidations to block withdrawal await priceFeed.setPrice(dec(200, 18)) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) await priceFeed.setPrice(dec(100, 18)) const dennis_ETHWithdrawn = th.getEventArgByName(txD, 'ETHGainWithdrawn', '_ETH').toString() @@ -713,9 +713,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_3, { from: owner }); await troveManager.liquidate(defaulter_4, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -733,12 +733,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): A, B, C, D deposit -> 2 liquidations -> D withdraws -> 2 liquidations. Various deposit and liquidation vals. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) /* Initial deposits: Alice: 20000 Bold @@ -762,10 +762,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' Defaulter 3: 30000 Bold Defaulter 4: 5000 Bold */ - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(30000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(300, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(30000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(300, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, 0,{ from: defaulter_4, value: '50000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -789,9 +789,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_3, { from: owner }); await troveManager.liquidate(defaulter_4, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -811,12 +811,12 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // --- One deposit enters at t > 0, and another leaves later --- it("withdrawETHGainToTrove(): A, B, D deposit -> 2 liquidations -> C makes deposit -> 1 liquidation -> D withdraws -> 1 liquidation. All deposits: 100 Bold. Liquidations: 100,100,100,50. A, B, C, D withdraw correct Bold deposit and ETH Gain", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B and D who then deposit it to the SP const depositors = [alice, bob, dennis] @@ -826,10 +826,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulters open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: '50000000000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_4, defaulter_4, 0, { from: defaulter_4, value: '50000000000000000000' }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -856,9 +856,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_4, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -885,13 +885,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // C, D withdraw 5000Bold & 500e it("withdrawETHGainToTrove(): Depositor withdraws correct compounded deposit after liquidation empties the pool", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B who then deposit it to the SP const depositors = [alice, bob] @@ -901,8 +901,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // 2 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -923,10 +923,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // await borrowerOperations.openTrove(th._100pct, dec(1, 18), account, account, { from: erin, value: dec(2, 'ether') }) // await stabilityPool.provideToSP(dec(1, 18), { from: erin }) - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() const bob_ETHWithdrawn = th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() @@ -958,13 +958,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // L2 20000, 200 empties Pool it("withdrawETHGainToTrove(): Pool-emptying liquidation increases epoch by one, resets scaleFactor to 0, and resets P to 1e18", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B who then deposit it to the SP const depositors = [alice, bob] @@ -974,10 +974,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // 4 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_4, defaulter_4, 0,{ from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -1056,14 +1056,14 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // C, D withdraw 5000 Bold & 50e it("withdrawETHGainToTrove(): Depositors withdraw correct compounded deposit after liquidation empties the pool", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: erin, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: erin, value: dec(10000, 'ether') }) // Whale transfers 10k Bold to A, B who then deposit it to the SP const depositors = [alice, bob] @@ -1073,8 +1073,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // 2 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1095,11 +1095,11 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Defaulter 2 liquidated. 10000 Bold offset await troveManager.liquidate(defaulter_2, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) - const txE = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: erin }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) + const txE = await stabilityPool.withdrawETHGainToTrove({ from: erin }) const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() const bob_ETHWithdrawn = th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() @@ -1130,21 +1130,21 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Expect A to withdraw 0 deposit and ether only from reward L1 it("withdrawETHGainToTrove(): single deposit fully offset. After subsequent liquidations, depositor withdraws 0 deposit and *only* the ETH Gain from one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1,2,3 withdraw 10000 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(100, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1154,7 +1154,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' await troveManager.liquidate(defaulter_2, { from: owner }); await troveManager.liquidate(defaulter_3, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() @@ -1178,23 +1178,23 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): Depositor withdraws correct compounded deposit after liquidation empties the pool", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // A, B, C, D, E, F, G, H open troves - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: erin, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: flyn, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: harriet, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: graham, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: erin, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: flyn, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: harriet, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: graham, value: dec(10000, 'ether') }) // 4 Defaulters open trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_3, defaulter_3, 0,{ from: defaulter_3, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(20000, 18)), defaulter_4, defaulter_4, 0,{ from: defaulter_4, value: dec(200, 'ether') }) // price drops by 50%: defaulter ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -1239,14 +1239,14 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Defaulter 4 liquidated. 10k Bold offset await troveManager.liquidate(defaulter_4, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) - const txE = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: erin }) - const txF = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: flyn }) - const txG = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: graham }) - const txH = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: harriet }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) + const txE = await stabilityPool.withdrawETHGainToTrove({ from: erin }) + const txF = await stabilityPool.withdrawETHGainToTrove({ from: flyn }) + const txG = await stabilityPool.withdrawETHGainToTrove({ from: graham }) + const txH = await stabilityPool.withdrawETHGainToTrove({ from: harriet }) const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() const bob_ETHWithdrawn = th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() @@ -1297,21 +1297,21 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawETHGainToTrove(): deposit spans one scale factor change: Single depositor withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 withdraws 'almost' 10000 Bold: 9999.99991 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) assert.equal(await stabilityPool.currentScale(), '0') // Defaulter 2 withdraws 9900 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(9900, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(60, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(9900, 18)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(60, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1337,7 +1337,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' assert.equal(await stabilityPool.currentScale(), '1') - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) const bob_ETHWithdrawn = await th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() // Expect Bob to retain 1% of initial deposit (100 Bold) and all the liquidated ETH (60 ether) @@ -1359,21 +1359,21 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawETHGainToTrove(): Several deposits of varying amounts span one scale factor change. Depositors withdraw correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 withdraws 'almost' 10k Bold. - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999910000000000000'), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) // Defaulter 2 withdraws 59400 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59400000000000000000000'), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(330, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59400000000000000000000'), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(330, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1406,9 +1406,9 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' assert.equal(await stabilityPool.currentScale(), '1') - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) /* Expect depositors to retain 1% of their initial deposit, and an ETH gain in proportion to their initial deposit: @@ -1447,18 +1447,18 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawETHGainToTrove(): deposit spans one scale factor change: Single depositor withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 and default 2 each withdraw 9999.999999999 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(99999, 17)), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) // price drops by 50%: defaulter 1 ICR falls to 100% await priceFeed.setPrice(dec(100, 18)); @@ -1486,7 +1486,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' assert.equal(await stabilityPool.P(), dec(1, 17)) // Scale changes and P changes. P = 1e(13-5+9) = 1e17 assert.equal(await stabilityPool.currentScale(), '1') - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) const bob_ETHWithdrawn = await th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() // Bob should withdraw 1e-5 of initial deposit: 0.1 Bold and the full ETH gain of 100 ether @@ -1507,19 +1507,19 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawETHGainToTrove(): Several deposits of varying amounts span one scale factor change. Depositors withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) await boldToken.transfer(alice, dec(10000, 18), { from: whale }) await stabilityPool.provideToSP(dec(10000, 18), { from: alice }) // Defaulter 1 and default 2 withdraw up to debt of 9999.9 Bold and 59999.4 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59999400000000000000000'), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(600, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('59999400000000000000000'), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(600, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1552,13 +1552,13 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' assert.equal(await stabilityPool.P(), dec(1, 17)) // P decreases. P = 1e(13-5+9) = 1e17 assert.equal(await stabilityPool.currentScale(), '1') - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) const bob_ETHWithdrawn = await th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) const carol_ETHWithdrawn = await th.getEventArgByName(txC, 'ETHGainWithdrawn', '_ETH').toString() - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) const dennis_ETHWithdrawn = await th.getEventArgByName(txD, 'ETHGainWithdrawn', '_ETH').toString() // {B, C, D} should have a compounded deposit of {0.1, 0.2, 0.3} Bold @@ -1576,15 +1576,15 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Expect A to withdraw 0 deposit it("withdrawETHGainToTrove(): Deposit that decreases to less than 1e-9 of it's original value is reduced to 0", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) // Defaulters 1 withdraws 9999.9999999 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999999900000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999999999900000000000'), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) // Price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1618,18 +1618,18 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // in helper functon getOpenTroveBoldAmount due to now-zero borrow fees. Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawETHGainToTrove(): Several deposits of 10000 Bold span one scale factor change. Depositors withdraws correct compounded deposit and ETH Gain after one liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: alice, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: bob, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: carol, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: alice, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: bob, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: carol, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: dennis, value: dec(10000, 'ether') }) // Defaulters 1-4 each withdraw 9999.9 Bold - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(100, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_4, defaulter_4, { from: defaulter_4, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_2, defaulter_2, 0,{ from: defaulter_2, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_3, defaulter_3, 0,0,{ from: defaulter_3, value: dec(100, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount('9999900000000000000000'), defaulter_4, defaulter_4, 0,{ from: defaulter_4, value: dec(100, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1674,10 +1674,10 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' assert.equal(await stabilityPool.P(), dec(1, 16)) // Scale changes and P changes to 1e(12-5+9) = 1e16 assert.equal(await stabilityPool.currentScale(), '2') - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: carol }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: dennis }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: carol }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: dennis }) const alice_ETHWithdrawn = await th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH').toString() const bob_ETHWithdrawn = await th.getEventArgByName(txB, 'ETHGainWithdrawn', '_ETH').toString() @@ -1701,19 +1701,19 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): 2 depositors can withdraw after each receiving half of a pool-emptying liquidation", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) - - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: A, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: B, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: C, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: D, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: E, value: dec(10000, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, { from: F, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) + + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: A, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: B, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: C, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: D, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: E, value: dec(10000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), ZERO_ADDRESS, ZERO_ADDRESS, 0, { from: F, value: dec(10000, 'ether') }) // Defaulters 1-3 each withdraw 24100, 24300, 24500 Bold (inc gas comp) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24100, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24300, 18)), defaulter_2, defaulter_2, { from: defaulter_2, value: dec(200, 'ether') }) - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24500, 18)), defaulter_3, defaulter_3, { from: defaulter_3, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24100, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24300, 18)), defaulter_2, defaulter_2, 0, { from: defaulter_2, value: dec(200, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(24500, 18)), defaulter_3, defaulter_3, 0, { from: defaulter_3, value: dec(200, 'ether') }) // price drops by 50% await priceFeed.setPrice(dec(100, 18)); @@ -1749,8 +1749,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Attempt withdrawals // Increasing the price for a moment to avoid pending liquidations to block withdrawal await priceFeed.setPrice(dec(200, 18)) - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: A }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: B }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: A }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: B }) await priceFeed.setPrice(dec(100, 18)) assert.isTrue(txA.receipt.status) @@ -1789,8 +1789,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Attempt withdrawals // Increasing the price for a moment to avoid pending liquidations to block withdrawal await priceFeed.setPrice(dec(200, 18)) - const txC = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: C }) - const txD = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: D }) + const txC = await stabilityPool.withdrawETHGainToTrove({ from: C }) + const txD = await stabilityPool.withdrawETHGainToTrove({ from: D }) await priceFeed.setPrice(dec(100, 18)) assert.isTrue(txC.receipt.status) @@ -1826,8 +1826,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' assert.equal(SPBoldBalance_3, '0') // Attempt withdrawals - const txE = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: E }) - const txF = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: F }) + const txE = await stabilityPool.withdrawETHGainToTrove({ from: E }) + const txF = await stabilityPool.withdrawETHGainToTrove({ from: F }) assert.isTrue(txE.receipt.status) assert.isTrue(txF.receipt.status) }) @@ -1836,19 +1836,19 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' it("withdrawETHGainToTrove(): Large liquidated coll/debt, deposits and ETH price", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // ETH:USD price is $2 billion per ETH await priceFeed.setPrice(dec(2, 27)); const depositors = [alice, bob] for (account of depositors) { - await borrowerOperations.openTrove(th._100pct, dec(1, 36), account, account, { from: account, value: dec(2, 27) }) + await borrowerOperations.openTrove(th._100pct, dec(1, 36), account, account, 0, { from: account, value: dec(2, 27) }) await stabilityPool.provideToSP(dec(1, 36), { from: account }) } // Defaulter opens trove with 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1, 36)), defaulter_1, defaulter_1, { from: defaulter_1, value: dec(1, 27) }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(1, 36)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: dec(1, 27) }) // ETH:USD price drops to $1 billion per ETH await priceFeed.setPrice(dec(1, 27)); @@ -1856,8 +1856,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Defaulter liquidated await troveManager.liquidate(defaulter_1, { from: owner }); - const txA = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txB = await stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) + const txA = await stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txB = await stabilityPool.withdrawETHGainToTrove({ from: bob }) // Grab the ETH gain from the emitted event in the tx log const alice_ETHWithdrawn = th.getEventArgByName(txA, 'ETHGainWithdrawn', '_ETH') @@ -1893,7 +1893,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Double-check this when we write new SP arithmetic tests and fix the "P" issue. it.skip("withdrawETHGainToTrove(): Small liquidated coll/debt, large deposits and ETH price", async () => { // Whale opens Trove with 100k ETH - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, { from: whale, value: dec(100000, 'ether') }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(100000, 18)), whale, whale, 0, { from: whale, value: dec(100000, 'ether') }) // ETH:USD price is $2 billion per ETH await priceFeed.setPrice(dec(2, 27)); @@ -1906,7 +1906,7 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' } // Defaulter opens trove with 50e-7 ETH and 5000 Bold. 200% ICR - await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, { from: defaulter_1, value: '5000000000000' }) + await borrowerOperations.openTrove(th._100pct, await getOpenTroveBoldAmount(dec(5000, 18)), defaulter_1, defaulter_1, 0, { from: defaulter_1, value: '5000000000000' }) // ETH:USD price drops to $1 billion per ETH await priceFeed.setPrice(dec(1, 27)); @@ -1914,8 +1914,8 @@ contract('StabilityPool - Withdrawal of stability deposit - Reward calculations' // Defaulter liquidated await troveManager.liquidate(defaulter_1, { from: owner }); - const txAPromise = stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: alice }) - const txBPromise = stabilityPool.withdrawETHGainToTrove(ZERO_ADDRESS, ZERO_ADDRESS, { from: bob }) + const txAPromise = stabilityPool.withdrawETHGainToTrove({ from: alice }) + const txBPromise = stabilityPool.withdrawETHGainToTrove({ from: bob }) // Expect ETH gain per depositor of ~1e11 wei to be rounded to 0 by the ETHGainedPerUnitStaked calculation (e / D), where D is ~1e36. await th.assertRevert(txAPromise, 'StabilityPool: caller must have non-zero ETH Gain') diff --git a/contracts/test/TroveManagerTest.js b/contracts/test/TroveManagerTest.js index f675d90f..9e25888b 100644 --- a/contracts/test/TroveManagerTest.js +++ b/contracts/test/TroveManagerTest.js @@ -1238,8 +1238,9 @@ contract("TroveManager", async (accounts) => { }); // --- liquidateTroves() --- - - it("liquidateTroves(): liquidates a Trove that a) was skipped in a previous liquidation and b) has pending rewards", async () => { + // TODO: likely remove liquidateTroves() function and all tests for it, since it no longer works due to the + // new list ordering by interest rates + it.skip("liquidateTroves(): liquidates a Trove that a) was skipped in a previous liquidation and b) has pending rewards", async () => { // A, B, C, D, E open troves await openTrove({ ICR: toBN(dec(333, 16)), extraParams: { from: D } }); await openTrove({ ICR: toBN(dec(333, 16)), extraParams: { from: E } }); @@ -1324,7 +1325,7 @@ contract("TroveManager", async (accounts) => { assert.isTrue((await sortedTroves.getSize()).eq(toBN("1"))); }); - it("liquidateTroves(): closes every Trove with ICR < MCR, when n > number of undercollateralized troves", async () => { + it.skip("liquidateTroves(): closes every Trove with ICR < MCR, when n > number of undercollateralized troves", async () => { // --- SETUP --- await openTrove({ ICR: toBN(dec(10, 18)), extraParams: { from: whale } }); @@ -1400,7 +1401,7 @@ contract("TroveManager", async (accounts) => { assert.equal((await sortedTroves.getSize()).toString(), "4"); }); - it("liquidateTroves(): liquidates up to the requested number of undercollateralized troves", async () => { + it.skip("liquidateTroves(): liquidates up to the requested number of undercollateralized troves", async () => { // --- SETUP --- await openTrove({ ICR: toBN(dec(10, 18)), extraParams: { from: whale } }); @@ -1465,7 +1466,7 @@ contract("TroveManager", async (accounts) => { assert.isTrue(erin_isInSortedList); }); - it("liquidateTroves(): does nothing if all troves have ICR > 110%", async () => { + it.skip("liquidateTroves(): does nothing if all troves have ICR > 110%", async () => { await openTrove({ ICR: toBN(dec(10, 18)), extraParams: { from: whale } }); await openTrove({ ICR: toBN(dec(222, 16)), extraParams: { from: alice } }); await openTrove({ ICR: toBN(dec(222, 16)), extraParams: { from: bob } }); @@ -1516,7 +1517,7 @@ contract("TroveManager", async (accounts) => { assert.equal(listSize_Before, listSize_After); }); - it("liquidateTroves(): liquidates based on entire/collateral debt (including pending rewards), not raw collateral/debt", async () => { + it.skip("liquidateTroves(): liquidates based on entire/collateral debt (including pending rewards), not raw collateral/debt", async () => { await openTrove({ ICR: toBN(dec(400, 16)), extraParams: { from: alice } }); await openTrove({ ICR: toBN(dec(221, 16)), extraParams: { from: bob } }); await openTrove({ ICR: toBN(dec(200, 16)), extraParams: { from: carol } }); @@ -1592,7 +1593,7 @@ contract("TroveManager", async (accounts) => { assert.equal((await troveManager.Troves(carol))[3].toString(), "3"); }); - it("liquidateTroves(): reverts if n = 0", async () => { + it.skip("liquidateTroves(): reverts if n = 0", async () => { await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale } }); await openTrove({ ICR: toBN(dec(210, 16)), extraParams: { from: alice } }); await openTrove({ ICR: toBN(dec(218, 16)), extraParams: { from: bob } }); @@ -1632,7 +1633,7 @@ contract("TroveManager", async (accounts) => { assert.equal(TCR_Before, TCR_After); }); - it("liquidateTroves(): liquidates troves with ICR < MCR", async () => { + it.skip("liquidateTroves(): liquidates troves with ICR < MCR", async () => { await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale } }); // A, B, C open troves that will remain active when price drops to 100 @@ -1690,7 +1691,7 @@ contract("TroveManager", async (accounts) => { assert.isFalse(await sortedTroves.contains(flyn)); }); - it("liquidateTroves(): does not affect the liquidated user's token balances", async () => { + it.skip("liquidateTroves(): does not affect the liquidated user's token balances", async () => { await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale } }); // D, E, F open troves that will fall below MCR when price drops to 100 @@ -1735,7 +1736,7 @@ contract("TroveManager", async (accounts) => { assert.equal((await boldToken.balanceOf(flyn)).toString(), F_balanceBefore); }); - it("liquidateTroves(): A liquidation sequence containing Pool offsets increases the TCR", async () => { + it.skip("liquidateTroves(): A liquidation sequence containing Pool offsets increases the TCR", async () => { // Whale provides 500 Bold to SP await openTrove({ ICR: toBN(dec(100, 18)), @@ -1809,7 +1810,7 @@ contract("TroveManager", async (accounts) => { assert.isTrue(TCR_After.gte(TCR_Before)); }); - it("liquidateTroves(): A liquidation sequence of pure redistributions decreases the TCR, due to gas compensation, but up to 0.5%", async () => { + it.skip("liquidateTroves(): A liquidation sequence of pure redistributions decreases the TCR, due to gas compensation, but up to 0.5%", async () => { const { collateral: W_coll, totalDebt: W_debt } = await openTrove({ ICR: toBN(dec(100, 18)), extraParams: { from: whale }, @@ -1915,7 +1916,7 @@ contract("TroveManager", async (accounts) => { assert.isTrue(TCR_After.gte(TCR_Before.mul(toBN(995)).div(toBN(1000)))); }); - it("liquidateTroves(): Liquidating troves with SP deposits correctly impacts their SP deposit and ETH gain", async () => { + it.skip("liquidateTroves(): Liquidating troves with SP deposits correctly impacts their SP deposit and ETH gain", async () => { // Whale provides 400 Bold to the SP const whaleDeposit = toBN(dec(40000, 18)); await openTrove({ @@ -2082,8 +2083,10 @@ contract("TroveManager", async (accounts) => { }); // --- batchLiquidateTroves() --- + // TODO: revisit the relevance of this test since it relies on liquidateTroves(), which now no longer works due to ordering by interest rate. + // Can we achieve / test the same thing using another liquidation function? - it("batchLiquidateTroves(): liquidates a Trove that a) was skipped in a previous liquidation and b) has pending rewards", async () => { + it.skip("batchLiquidateTroves(): liquidates a Trove that a) was skipped in a previous liquidation and b) has pending rewards", async () => { // A, B, C, D, E open troves await openTrove({ ICR: toBN(dec(300, 16)), extraParams: { from: C } }); await openTrove({ ICR: toBN(dec(364, 16)), extraParams: { from: D } }); @@ -2585,7 +2588,10 @@ contract("TroveManager", async (accounts) => { // --- redemptions --- - it("getRedemptionHints(): gets the address of the first Trove and the final ICR of the last Trove involved in a redemption", async () => { + // TODO: Revisit all redemption tests when implementing redeeming by interest rate ordering, and leaving fully redeemed Troves open. + // Many of these tests rely on specific ICR ordering in the setup, and close fully redeemed. + // It may be more efficient to write wholly new redemption tests in Solidity for Foundry. + it.skip("getRedemptionHints(): gets the address of the first Trove and the final ICR of the last Trove involved in a redemption", async () => { // --- SETUP --- const partialRedemptionAmount = toBN(dec(100, 18)); const { collateral: A_coll, totalDebt: A_totalDebt } = await openTrove({ @@ -2620,7 +2626,7 @@ contract("TroveManager", async (accounts) => { th.assertIsApproximatelyEqual(partialRedemptionHintNICR, expectedICR); }); - it("getRedemptionHints(): returns 0 as partialRedemptionHintNICR when reaching _maxIterations", async () => { + it.skip("getRedemptionHints(): returns 0 as partialRedemptionHintNICR when reaching _maxIterations", async () => { // --- SETUP --- await openTrove({ ICR: toBN(dec(310, 16)), extraParams: { from: alice } }); await openTrove({ ICR: toBN(dec(290, 16)), extraParams: { from: bob } }); @@ -2642,7 +2648,7 @@ contract("TroveManager", async (accounts) => { assert.equal(partialRedemptionHintNICR, "0"); }); - it("redeemCollateral(): cancels the provided Bold with debt from Troves with the lowest ICRs and sends an equivalent amount of Ether", async () => { + it.skip("redeemCollateral(): cancels the provided Bold with debt from Troves with the lowest ICRs and sends an equivalent amount of Ether", async () => { // --- SETUP --- const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(310, 16)), @@ -2763,7 +2769,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): with invalid first hint, zero address", async () => { + it.skip("redeemCollateral(): with invalid first hint, zero address", async () => { // --- SETUP --- const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(310, 16)), @@ -2874,7 +2880,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): with invalid first hint, non-existent trove", async () => { + it.skip("redeemCollateral(): with invalid first hint, non-existent trove", async () => { // --- SETUP --- const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(310, 16)), @@ -2985,7 +2991,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): with invalid first hint, trove below MCR", async () => { + it.skip("redeemCollateral(): with invalid first hint, trove below MCR", async () => { // --- SETUP --- const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(310, 16)), @@ -3101,7 +3107,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): ends the redemption sequence when the token redemption request has been filled", async () => { + it.skip("redeemCollateral(): ends the redemption sequence when the token redemption request has been filled", async () => { // --- SETUP --- await openTrove({ ICR: toBN(dec(100, 18)), extraParams: { from: whale } }); @@ -3198,7 +3204,7 @@ contract("TroveManager", async (accounts) => { assert.equal(erin_Coll.toString(), E_coll.toString()); }); - it("redeemCollateral(): ends the redemption sequence when max iterations have been reached", async () => { + it.skip("redeemCollateral(): ends the redemption sequence when max iterations have been reached", async () => { // --- SETUP --- await openTrove({ ICR: toBN(dec(100, 18)), extraParams: { from: whale } }); @@ -3273,7 +3279,7 @@ contract("TroveManager", async (accounts) => { assert.equal(carol_Status, 1); }); - it("redeemCollateral(): performs partial redemption if resultant debt is > minimum net debt", async () => { + it.skip("redeemCollateral(): performs partial redemption if resultant debt is > minimum net debt", async () => { await borrowerOperations.openTrove( th._100pct, await getOpenTroveBoldAmount(dec(10000, 18)), @@ -3327,7 +3333,7 @@ contract("TroveManager", async (accounts) => { await th.assertIsApproximatelyEqual(A_debt, dec(4600, 18), 1000); }); - it("redeemCollateral(): doesn't perform partial redemption if resultant debt would be < minimum net debt", async () => { + it.skip("redeemCollateral(): doesn't perform partial redemption if resultant debt would be < minimum net debt", async () => { await borrowerOperations.openTrove( th._100pct, await getOpenTroveBoldAmount(dec(6000, 18)), @@ -3382,7 +3388,7 @@ contract("TroveManager", async (accounts) => { await th.assertIsApproximatelyEqual(A_debt, dec(6000, 18)); }); - it("redeemCollateral(): doesnt perform the final partial redemption in the sequence if the hint is out-of-date", async () => { + it.skip("redeemCollateral(): doesnt perform the final partial redemption in the sequence if the hint is out-of-date", async () => { // --- SETUP --- const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(363, 16)), @@ -3573,7 +3579,7 @@ contract("TroveManager", async (accounts) => { assert.equal(carol_BoldBalance_After, "0"); }); - it("redeemCollateral(): doesn't touch Troves with ICR < 110%", async () => { + it.skip("redeemCollateral(): doesn't touch Troves with ICR < 110%", async () => { // --- SETUP --- const { netDebt: A_debt } = await openTrove({ @@ -3621,7 +3627,7 @@ contract("TroveManager", async (accounts) => { th.assertIsApproximatelyEqual(bob_Debt_After, B_totalDebt); }); - it("redeemCollateral(): finds the last Trove with ICR == 110% even if there is more than one", async () => { + it.skip("redeemCollateral(): finds the last Trove with ICR == 110% even if there is more than one", async () => { // --- SETUP --- const amount1 = toBN(dec(100, 18)); const { totalDebt: A_totalDebt } = await openTrove({ @@ -3697,7 +3703,7 @@ contract("TroveManager", async (accounts) => { th.assertIsApproximatelyEqual(dennis_Debt_After, D_totalDebt); }); - it("redeemCollateral(): reverts when TCR < MCR", async () => { + it.skip("redeemCollateral(): reverts when TCR < MCR", async () => { await openTrove({ ICR: toBN(dec(200, 16)), extraParams: { from: alice } }); await openTrove({ ICR: toBN(dec(200, 16)), extraParams: { from: bob } }); await openTrove({ ICR: toBN(dec(200, 16)), extraParams: { from: carol } }); @@ -3723,7 +3729,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): reverts when argument _amount is 0", async () => { + it.skip("redeemCollateral(): reverts when argument _amount is 0", async () => { await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale } }); // Alice opens trove and transfers 500Bold to Erin, the would-be redeemer @@ -3762,7 +3768,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): reverts if max fee > 100%", async () => { + it.skip("redeemCollateral(): reverts if max fee > 100%", async () => { await openTrove({ ICR: toBN(dec(400, 16)), extraBoldAmount: dec(10, 18), @@ -3812,7 +3818,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): reverts if max fee < 0.5%", async () => { + it.skip("redeemCollateral(): reverts if max fee < 0.5%", async () => { await openTrove({ ICR: toBN(dec(400, 16)), extraBoldAmount: dec(10, 18), @@ -3872,7 +3878,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): reverts if fee exceeds max fee percentage", async () => { + it.skip("redeemCollateral(): reverts if fee exceeds max fee percentage", async () => { const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(400, 16)), extraBoldAmount: dec(80, 18), @@ -3957,7 +3963,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): doesn't affect the Stability Pool deposits or ETH gain of redeemed-from troves", async () => { + it.skip("redeemCollateral(): doesn't affect the Stability Pool deposits or ETH gain of redeemed-from troves", async () => { await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale } }); // B, C, D, F open trove @@ -4094,7 +4100,7 @@ contract("TroveManager", async (accounts) => { assert.equal(dennis_ETHGain_before, dennis_ETHGain_after); }); - it("redeemCollateral(): caller can redeem their entire BoldToken balance", async () => { + it.skip("redeemCollateral(): caller can redeem their entire BoldToken balance", async () => { const { collateral: W_coll, totalDebt: W_totalDebt } = await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale }, @@ -4194,7 +4200,7 @@ contract("TroveManager", async (accounts) => { assert.equal(erin_balance_after, "0"); }); - it("redeemCollateral(): reverts when requested redemption amount exceeds caller's Bold token balance", async () => { + it.skip("redeemCollateral(): reverts when requested redemption amount exceeds caller's Bold token balance", async () => { const { collateral: W_coll, totalDebt: W_totalDebt } = await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale }, @@ -4403,7 +4409,7 @@ contract("TroveManager", async (accounts) => { } }); - it("redeemCollateral(): value of issued ETH == face value of redeemed Bold (assuming 1 Bold has value of $1)", async () => { + it.skip("redeemCollateral(): value of issued ETH == face value of redeemed Bold (assuming 1 Bold has value of $1)", async () => { const { collateral: W_coll } = await openTrove({ ICR: toBN(dec(20, 18)), extraParams: { from: whale }, @@ -4560,7 +4566,7 @@ contract("TroveManager", async (accounts) => { // it doesn’t make much sense as there’s now min debt enforced and at least one trove must remain active // the only way to test it is before any trove is opened - it("redeemCollateral(): reverts if there is zero outstanding system debt", async () => { + it.skip("redeemCollateral(): reverts if there is zero outstanding system debt", async () => { // --- SETUP --- illegally mint Bold to Bob await boldToken.unprotectedMint(bob, dec(100, 18)); @@ -4600,7 +4606,7 @@ contract("TroveManager", async (accounts) => { // assert.isFalse(redemptionTx.receipt.status); }); - it("redeemCollateral(): reverts if caller's tries to redeem more than the outstanding system debt", async () => { + it.skip("redeemCollateral(): reverts if caller's tries to redeem more than the outstanding system debt", async () => { // --- SETUP --- illegally mint Bold to Bob await boldToken.unprotectedMint(bob, "101000000000000000000"); @@ -4660,7 +4666,7 @@ contract("TroveManager", async (accounts) => { } }); - it("redeemCollateral(): a redemption sends the ETH remainder (ETHDrawn - gas) to the redeemer", async () => { + it.skip("redeemCollateral(): a redemption sends the ETH remainder (ETHDrawn - gas) to the redeemer", async () => { // time fast-forwards 1 year, and multisig stakes 1 LQTY await th.fastForwardTime( timeValues.SECONDS_IN_ONE_YEAR, @@ -4726,7 +4732,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): a full redemption (leaving trove with 0 debt), closes the trove", async () => { + it.skip("redeemCollateral(): a full redemption (leaving trove with 0 debt), closes the trove", async () => { // time fast-forwards 1 year, and multisig stakes 1 LQTY await th.fastForwardTime( timeValues.SECONDS_IN_ONE_YEAR, @@ -4891,7 +4897,7 @@ contract("TroveManager", async (accounts) => { }; }; - it("redeemCollateral(): emits correct debt and coll values in each redeemed trove's TroveUpdated event", async () => { + it.skip("redeemCollateral(): emits correct debt and coll values in each redeemed trove's TroveUpdated event", async () => { const { netDebt: W_netDebt } = await openTrove({ ICR: toBN(dec(20, 18)), extraBoldAmount: dec(10000, 18), @@ -4982,7 +4988,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): a redemption that closes a trove leaves the trove's ETH surplus (collateral - ETH drawn) available for the trove owner to claim", async () => { + it.skip("redeemCollateral(): a redemption that closes a trove leaves the trove's ETH surplus (collateral - ETH drawn) available for the trove owner to claim", async () => { const { A_netDebt, A_coll, B_netDebt, B_coll, C_netDebt, C_coll } = await redeemCollateral3Full1Partial(); @@ -5030,7 +5036,7 @@ contract("TroveManager", async (accounts) => { ); }); - it("redeemCollateral(): a redemption that closes a trove leaves the trove's ETH surplus (collateral - ETH drawn) available for the trove owner after re-opening trove", async () => { + it.skip("redeemCollateral(): a redemption that closes a trove leaves the trove's ETH surplus (collateral - ETH drawn) available for the trove owner after re-opening trove", async () => { const { A_netDebt, A_coll: A_collBefore, diff --git a/contracts/test/TroveManager_LiquidationRewardsTest.js b/contracts/test/TroveManager_LiquidationRewardsTest.js index 85cd2557..a0e96068 100644 --- a/contracts/test/TroveManager_LiquidationRewardsTest.js +++ b/contracts/test/TroveManager_LiquidationRewardsTest.js @@ -523,7 +523,7 @@ contract( // Bob adds 1 ETH to his trove const addedColl1 = toBN(dec(1, "ether")); - await borrowerOperations.addColl(B, B, { from: B, value: addedColl1 }); + await borrowerOperations.addColl({ from: B, value: addedColl1 }); // Liquidate C const txC = await troveManager.liquidate(C); @@ -566,7 +566,7 @@ contract( // Bob adds 1 ETH to his trove const addedColl2 = toBN(dec(1, "ether")); - await borrowerOperations.addColl(B, B, { from: B, value: addedColl2 }); + await borrowerOperations.addColl({ from: B, value: addedColl2 }); // Liquidate E const txE = await troveManager.liquidate(E); @@ -681,7 +681,7 @@ contract( assert.isAtMost(getDifference(E_expectedPendingETH_1, E_ETHGain_1), 1e8); // // Bob adds 1 ETH to his trove - await borrowerOperations.addColl(B, B, { + await borrowerOperations.addColl( { from: B, value: dec(1, "ether"), }); @@ -733,7 +733,7 @@ contract( assert.isAtMost(getDifference(E_expectedPendingETH_2, E_ETHGain_2), 1e8); // // Bob adds 1 ETH to his trove - await borrowerOperations.addColl(B, B, { + await borrowerOperations.addColl( { from: B, value: dec(1, "ether"), }); @@ -807,7 +807,7 @@ contract( //Bob adds ETH to his trove const addedColl = toBN(dec(1, "ether")); - await borrowerOperations.addColl(bob, bob, { + await borrowerOperations.addColl({ from: bob, value: addedColl, }); @@ -816,8 +816,6 @@ contract( await borrowerOperations.withdrawBold( th._100pct, await getNetBorrowingAmount(A_totalDebt), - alice, - alice, { from: alice } ); @@ -886,7 +884,7 @@ contract( //Bob adds ETH to his trove const addedColl = toBN(dec(1, "ether")); - await borrowerOperations.addColl(bob, bob, { + await borrowerOperations.addColl({ from: bob, value: addedColl, }); @@ -1033,7 +1031,7 @@ contract( //Carol adds 1 ETH to her trove, brings it to 1992.01 total coll const C_addedColl = toBN(dec(1, "ether")); - await borrowerOperations.addColl(carol, carol, { + await borrowerOperations.addColl({ from: carol, value: dec(1, "ether"), }); @@ -1201,15 +1199,15 @@ contract( bringing them to 2.995, 2.995, 1992.01 total coll each. */ const addedColl = toBN(dec(1, "ether")); - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl( { from: alice, value: addedColl, }); - await borrowerOperations.addColl(bob, bob, { + await borrowerOperations.addColl( { from: bob, value: addedColl, }); - await borrowerOperations.addColl(carol, carol, { + await borrowerOperations.addColl({ from: carol, value: addedColl, }); @@ -1346,7 +1344,7 @@ contract( //Bob withdraws 0.5 ETH from his trove const withdrawnColl = toBN(dec(500, "finney")); - await borrowerOperations.withdrawColl(withdrawnColl, bob, bob, { + await borrowerOperations.withdrawColl(withdrawnColl, { from: bob, }); @@ -1354,8 +1352,6 @@ contract( await borrowerOperations.withdrawBold( th._100pct, await getNetBorrowingAmount(A_totalDebt), - alice, - alice, { from: alice } ); @@ -1428,7 +1424,7 @@ contract( //Bob withdraws 0.5 ETH from his trove const withdrawnColl = toBN(dec(500, "finney")); - await borrowerOperations.withdrawColl(withdrawnColl, bob, bob, { + await borrowerOperations.withdrawColl(withdrawnColl, { from: bob, }); @@ -1595,7 +1591,7 @@ contract( //Carol wthdraws 1 ETH from her trove, brings it to 1990.01 total coll const C_withdrawnColl = toBN(dec(1, "ether")); - await borrowerOperations.withdrawColl(C_withdrawnColl, carol, carol, { + await borrowerOperations.withdrawColl(C_withdrawnColl, { from: carol, }); @@ -1758,13 +1754,13 @@ contract( /* Alice, Bob, Carol each withdraw 0.5 ETH to their troves, bringing them to 1.495, 1.495, 1990.51 total coll each. */ const withdrawnColl = toBN(dec(500, "finney")); - await borrowerOperations.withdrawColl(withdrawnColl, alice, alice, { + await borrowerOperations.withdrawColl(withdrawnColl, { from: alice, }); - await borrowerOperations.withdrawColl(withdrawnColl, bob, bob, { + await borrowerOperations.withdrawColl(withdrawnColl, { from: bob, }); - await borrowerOperations.withdrawColl(withdrawnColl, carol, carol, { + await borrowerOperations.withdrawColl(withdrawnColl, { from: carol, }); @@ -1983,14 +1979,14 @@ contract( //Bob adds 1 ETH to his trove const B_addedColl = toBN(dec(1, "ether")); - await borrowerOperations.addColl(bob, bob, { + await borrowerOperations.addColl( { from: bob, value: B_addedColl, }); //Carol withdraws 1 ETH from her trove const C_withdrawnColl = toBN(dec(1, "ether")); - await borrowerOperations.withdrawColl(C_withdrawnColl, carol, carol, { + await borrowerOperations.withdrawColl(C_withdrawnColl, { from: carol, }); @@ -2077,7 +2073,7 @@ contract( // D tops up const D_addedColl = toBN(dec(1, "ether")); - await borrowerOperations.addColl(dennis, dennis, { + await borrowerOperations.addColl({ from: dennis, value: D_addedColl, }); @@ -2274,14 +2270,14 @@ contract( // Bob adds 11.33909 ETH to his trove const B_addedColl = toBN("11339090000000000000"); - await borrowerOperations.addColl(bob, bob, { + await borrowerOperations.addColl( { from: bob, value: B_addedColl, }); // Carol withdraws 15 ETH from her trove const C_withdrawnColl = toBN(dec(15, "ether")); - await borrowerOperations.withdrawColl(C_withdrawnColl, carol, carol, { + await borrowerOperations.withdrawColl(C_withdrawnColl, { from: carol, }); @@ -2370,7 +2366,7 @@ contract( // D tops up const D_addedColl = toBN(dec(1, "ether")); - await borrowerOperations.addColl(dennis, dennis, { + await borrowerOperations.addColl({ from: dennis, value: D_addedColl, }); diff --git a/contracts/test/TroveManager_RecoveryModeTest.js b/contracts/test/TroveManager_RecoveryModeTest.js index 93dc9adf..a174d4b1 100644 --- a/contracts/test/TroveManager_RecoveryModeTest.js +++ b/contracts/test/TroveManager_RecoveryModeTest.js @@ -139,7 +139,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { const recoveryMode_Before = await th.checkRecoveryMode(contracts); assert.isTrue(recoveryMode_Before); - await borrowerOperations.addColl(alice, alice, { from: alice, value: "1" }); + await borrowerOperations.addColl({ from: alice, value: "1" }); const recoveryMode_After = await th.checkRecoveryMode(contracts); assert.isTrue(recoveryMode_After); @@ -154,9 +154,9 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { const recoveryMode_Before = await th.checkRecoveryMode(contracts); assert.isFalse(recoveryMode_Before); - await borrowerOperations.withdrawColl(_1_Ether, alice, alice, { + await borrowerOperations.withdrawColl(_1_Ether, { from: alice, - }); + }); const recoveryMode_After = await th.checkRecoveryMode(contracts); assert.isFalse(recoveryMode_After); @@ -180,7 +180,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { const recoveryMode_Before = await th.checkRecoveryMode(contracts); assert.isTrue(recoveryMode_Before); - await borrowerOperations.addColl(alice, alice, { + await borrowerOperations.addColl({ from: alice, value: A_coll, }); @@ -1663,8 +1663,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { const bob_Coll_Before = (await troveManager.Troves(bob))[1]; const bob_Debt_Before = (await troveManager.Troves(bob))[0]; - // confirm Bob is last trove in list, and has >110% ICR - assert.equal((await sortedTroves.getLast()).toString(), bob); + // confirm Bob has >110% ICR assert.isTrue((await troveManager.getCurrentICR(bob, price)).gt(mv._MCR)); // L1: Try to liquidate Bob. Nothing happens @@ -1712,8 +1711,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { const carol_Coll_Before = (await troveManager.Troves(carol))[1]; const carol_Debt_Before = (await troveManager.Troves(carol))[0]; - // Confirm Carol is last trove in list, and has >110% ICR - assert.equal(await sortedTroves.getLast(), carol); + // Confirm Carol has >110% ICR assert.isTrue((await troveManager.getCurrentICR(carol, price)).gt(mv._MCR)); // L2: Try to liquidate Carol. Nothing happens @@ -2216,19 +2214,20 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal((await boldToken.balanceOf(carol)).toString(), C_boldAmount); }); - it("liquidate(), with 110% < ICR < TCR, can claim collateral, re-open, be reedemed and claim again", async () => { + // TODO: test relies on specific redemption behavior, so rewrite in Solidity after we've finalized new redemption logic + it.skip("liquidate(), with 110% < ICR < TCR, can claim collateral, re-open, be reedemed and claim again", async () => { // --- SETUP --- // Alice withdraws up to 1500 Bold of debt, resulting in ICRs of 266%. - // Bob withdraws up to 480 Bold of debt, resulting in ICR of 240%. Bob has lowest ICR. + // Bob withdraws up to 480 Bold of debt, resulting in ICR of 240%. Bob has lowest interest rate. const { collateral: B_coll, totalDebt: B_totalDebt } = await openTrove({ ICR: toBN(dec(240, 16)), extraBoldAmount: dec(480, 18), - extraParams: { from: bob }, + extraParams: { from: bob, annualInterestRate: 0 }, }); const { collateral: A_coll } = await openTrove({ ICR: toBN(dec(266, 16)), extraBoldAmount: B_totalDebt, - extraParams: { from: alice }, + extraParams: { from: alice }, annualInterestRate: th.toBN(dec(5,17)) // 50% interest rate }); // Alice deposits Bold in the Stability Pool @@ -2281,18 +2280,18 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { web3.currentProvider ); - // Bob re-opens the trove, price 200, total debt 80 Bold, ICR = 120% (lowest one) + // Bob re-opens the trove, price 200, total debt 80 Bold, ICR = 120%, 0 interest rate (lowest one) // Dennis redeems 30, so Bob has a surplus of (200 * 0.48 - 30) / 200 = 0.33 ETH await priceFeed.setPrice("200000000000000000000"); const { collateral: B_coll_2, netDebt: B_netDebt_2 } = await openTrove({ ICR: toBN(dec(150, 16)), extraBoldAmount: dec(480, 18), - extraParams: { from: bob, value: bob_remainingCollateral }, + extraParams: { from: bob, value: bob_remainingCollateral, annualInterestRate: 0} }); const { collateral: D_coll } = await openTrove({ ICR: toBN(dec(266, 16)), extraBoldAmount: B_netDebt_2, - extraParams: { from: dennis }, + extraParams: { from: dennis }, annualInterestRate: th.toBN(dec(5,17)) }); await th.redeemCollateral(dennis, contracts, B_netDebt_2, GAS_PRICE); price = await priceFeed.getPrice(); @@ -2428,7 +2427,9 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { // --- liquidateTroves --- - it("liquidateTroves(): With all ICRs > 110%, Liquidates Troves until system leaves recovery mode", async () => { + // TODO: delete these tests when we delete liquidateTroves(), since we no will no longer liquidate sequentially + + it.skip("liquidateTroves(): With all ICRs > 110%, Liquidates Troves until system leaves recovery mode", async () => { // make 8 Troves accordingly // --- SETUP --- @@ -2577,7 +2578,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.isFalse(await sortedTroves.contains(harry)); }); - it("liquidateTroves(): Liquidates Troves until 1) system has left recovery mode AND 2) it reaches a Trove with ICR >= 110%", async () => { + it.skip("liquidateTroves(): Liquidates Troves until 1) system has left recovery mode AND 2) it reaches a Trove with ICR >= 110%", async () => { // make 6 Troves accordingly // --- SETUP --- const { totalDebt: B_totalDebt } = await openTrove({ @@ -2702,7 +2703,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.isFalse(await sortedTroves.contains(freddy)); }); - it("liquidateTroves(): liquidates only up to the requested number of undercollateralized troves", async () => { + it.skip("liquidateTroves(): liquidates only up to the requested number of undercollateralized troves", async () => { await openTrove({ ICR: toBN(dec(300, 16)), extraParams: { from: whale, value: dec(300, "ether") }, @@ -2777,7 +2778,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.isTrue(erin_isInSortedList); }); - it("liquidateTroves(): does nothing if n = 0", async () => { + it.skip("liquidateTroves(): does nothing if n = 0", async () => { await openTrove({ ICR: toBN(dec(200, 16)), extraBoldAmount: dec(100, 18), @@ -2827,7 +2828,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal(TCR_Before, TCR_After); }); - it("liquidateTroves(): closes every Trove with ICR < MCR, when n > number of undercollateralized troves", async () => { + it.skip("liquidateTroves(): closes every Trove with ICR < MCR, when n > number of undercollateralized troves", async () => { // --- SETUP --- await openTrove({ ICR: toBN(dec(300, 16)), @@ -2895,7 +2896,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal((await troveManager.Troves(freddy))[3].toString(), "3"); }); - it("liquidateTroves(): a liquidation sequence containing Pool offsets increases the TCR", async () => { + it.skip("liquidateTroves(): a liquidation sequence containing Pool offsets increases the TCR", async () => { // Whale provides 500 Bold to SP await openTrove({ ICR: toBN(dec(200, 16)), @@ -2979,7 +2980,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.isTrue(TCR_After.gte(TCR_Before)); }); - it("liquidateTroves(): A liquidation sequence of pure redistributions decreases the TCR, due to gas compensation, but up to 0.5%", async () => { + it.skip("liquidateTroves(): A liquidation sequence of pure redistributions decreases the TCR, due to gas compensation, but up to 0.5%", async () => { const { collateral: W_coll, totalDebt: W_totalDebt } = await openTrove({ ICR: toBN(dec(250, 16)), extraBoldAmount: dec(500, 18), @@ -3097,7 +3098,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { ); }); - it("liquidateTroves(): liquidates based on entire/collateral debt (including pending rewards), not raw collateral/debt", async () => { + it.skip("liquidateTroves(): liquidates based on entire/collateral debt (including pending rewards), not raw collateral/debt", async () => { await openTrove({ ICR: toBN(dec(400, 16)), extraParams: { from: alice } }); await openTrove({ ICR: toBN(dec(220, 16)), extraParams: { from: bob } }); await openTrove({ ICR: toBN(dec(200, 16)), extraParams: { from: carol } }); @@ -3171,7 +3172,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal((await troveManager.Troves(carol))[3].toString(), "3"); }); - it("liquidateTroves(): does nothing if all troves have ICR > 110% and Stability Pool is empty", async () => { + it.skip("liquidateTroves(): does nothing if all troves have ICR > 110% and Stability Pool is empty", async () => { await openTrove({ ICR: toBN(dec(222, 16)), extraParams: { from: alice } }); await openTrove({ ICR: toBN(dec(250, 16)), extraParams: { from: bob } }); await openTrove({ ICR: toBN(dec(285, 16)), extraParams: { from: carol } }); @@ -3219,7 +3220,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal(listSize_Before, listSize_After); }); - it("liquidateTroves(): emits liquidation event with correct values when all troves have ICR > 110% and Stability Pool covers a subset of troves", async () => { + it.skip("liquidateTroves(): emits liquidation event with correct values when all troves have ICR > 110% and Stability Pool covers a subset of troves", async () => { // Troves to be absorbed by SP const { collateral: F_coll, totalDebt: F_totalDebt } = await openTrove({ ICR: toBN(dec(222, 16)), @@ -3350,7 +3351,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { ); }); - it("liquidateTroves(): emits liquidation event with correct values when all troves have ICR > 110% and Stability Pool covers a subset of troves, including a partial", async () => { + it.skip("liquidateTroves(): emits liquidation event with correct values when all troves have ICR > 110% and Stability Pool covers a subset of troves, including a partial", async () => { // Troves to be absorbed by SP const { collateral: F_coll, totalDebt: F_totalDebt } = await openTrove({ ICR: toBN(dec(222, 16)), @@ -3508,7 +3509,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { ); }); - it("liquidateTroves(): does not affect the liquidated user's token balances", async () => { + it.skip("liquidateTroves(): does not affect the liquidated user's token balances", async () => { await openTrove({ ICR: toBN(dec(300, 16)), extraParams: { from: whale } }); // D, E, F open troves that will fall below MCR when price drops to 100 @@ -3556,7 +3557,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal((await boldToken.balanceOf(freddy)).toString(), boldAmountF); }); - it("liquidateTroves(): Liquidating troves at 100 < ICR < 110 with SP deposits correctly impacts their SP deposit and ETH gain", async () => { + it.skip("liquidateTroves(): Liquidating troves at 100 < ICR < 110 with SP deposits correctly impacts their SP deposit and ETH gain", async () => { // Whale provides Bold to the SP const { boldAmount: W_boldAmount } = await openTrove({ ICR: toBN(dec(300, 16)), @@ -3756,7 +3757,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { ); }); - it("liquidateTroves(): Liquidating troves at ICR <=100% with SP deposits does not alter their deposit or ETH gain", async () => { + it.skip("liquidateTroves(): Liquidating troves at ICR <=100% with SP deposits does not alter their deposit or ETH gain", async () => { // Whale provides 400 Bold to the SP await openTrove({ ICR: toBN(dec(300, 16)), @@ -3862,7 +3863,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal(bob_ETHGain_After, "0"); }); - it("liquidateTroves() with a non fullfilled liquidation: non liquidated trove remains active", async () => { + it.skip("liquidateTroves() with a non fullfilled liquidation: non liquidated trove remains active", async () => { const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(196, 16)), extraParams: { from: alice }, @@ -3920,7 +3921,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal((await troveManager.Troves(carol))[3].toString(), "1"); // check Status is active }); - it("liquidateTroves() with a non fullfilled liquidation: non liquidated trove remains in TroveOwners Array", async () => { + it.skip("liquidateTroves() with a non fullfilled liquidation: non liquidated trove remains in TroveOwners Array", async () => { const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(210, 16)), extraParams: { from: alice }, @@ -3989,7 +3990,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.equal(addressIdx.toString(), idxOnStruct); }); - it("liquidateTroves() with a non fullfilled liquidation: still can liquidate further troves after the non-liquidated, emptied pool", async () => { + it.skip("liquidateTroves() with a non fullfilled liquidation: still can liquidate further troves after the non-liquidated, emptied pool", async () => { const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(196, 16)), extraParams: { from: alice }, @@ -4059,7 +4060,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.isTrue(await sortedTroves.contains(erin)); }); - it("liquidateTroves() with a non fullfilled liquidation: still can liquidate further troves after the non-liquidated, non emptied pool", async () => { + it.skip("liquidateTroves() with a non fullfilled liquidation: still can liquidate further troves after the non-liquidated, non emptied pool", async () => { const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(196, 16)), extraParams: { from: alice }, @@ -4130,7 +4131,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { assert.isTrue(await sortedTroves.contains(erin)); }); - it("liquidateTroves() with a non fullfilled liquidation: total liquidated coll and debt is correct", async () => { + it.skip("liquidateTroves() with a non fullfilled liquidation: total liquidated coll and debt is correct", async () => { const { collateral: A_coll, totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(196, 16)), extraParams: { from: alice }, @@ -4200,7 +4201,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { ); }); - it("liquidateTroves() with a non fullfilled liquidation: emits correct liquidation event values", async () => { + it.skip("liquidateTroves() with a non fullfilled liquidation: emits correct liquidation event values", async () => { const { collateral: A_coll, totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(210, 16)), extraParams: { from: alice }, @@ -4314,7 +4315,7 @@ contract("TroveManager - in Recovery Mode", async (accounts) => { ); }); - it("liquidateTroves() with a non fullfilled liquidation: ICR of non liquidated trove does not change", async () => { + it.skip("liquidateTroves() with a non fullfilled liquidation: ICR of non liquidated trove does not change", async () => { const { totalDebt: A_totalDebt } = await openTrove({ ICR: toBN(dec(196, 16)), extraParams: { from: alice }, diff --git a/contracts/test/stakeDeclineTest.js b/contracts/test/stakeDeclineTest.js index fa1ab383..41c70221 100644 --- a/contracts/test/stakeDeclineTest.js +++ b/contracts/test/stakeDeclineTest.js @@ -79,6 +79,7 @@ contract("TroveManager", async (accounts) => { await getOpenTroveBoldAmount(dec(1, 31)), ZERO_ADDRESS, ZERO_ADDRESS, + 0, { from: A, value: dec(2, 29) } ); @@ -88,6 +89,7 @@ contract("TroveManager", async (accounts) => { await getOpenTroveBoldAmount(dec(2, 30)), ZERO_ADDRESS, ZERO_ADDRESS, + 0, { from: B, value: dec(4, 28) } ); await borrowerOperations.openTrove( @@ -95,6 +97,7 @@ contract("TroveManager", async (accounts) => { await getOpenTroveBoldAmount(dec(2, 30)), ZERO_ADDRESS, ZERO_ADDRESS, + 0, { from: C, value: dec(4, 28) } ); await borrowerOperations.openTrove( @@ -102,6 +105,7 @@ contract("TroveManager", async (accounts) => { await getOpenTroveBoldAmount(dec(2, 30)), ZERO_ADDRESS, ZERO_ADDRESS, + 0, { from: D, value: dec(4, 28) } ); await borrowerOperations.openTrove( @@ -109,6 +113,7 @@ contract("TroveManager", async (accounts) => { await getOpenTroveBoldAmount(dec(2, 30)), ZERO_ADDRESS, ZERO_ADDRESS, + 0, { from: E, value: dec(4, 28) } ); await borrowerOperations.openTrove( @@ -116,6 +121,7 @@ contract("TroveManager", async (accounts) => { await getOpenTroveBoldAmount(dec(2, 30)), ZERO_ADDRESS, ZERO_ADDRESS, + 0, { from: F, value: dec(4, 28) } ); @@ -127,6 +133,7 @@ contract("TroveManager", async (accounts) => { await getOpenTroveBoldAmount(dec(1, 22)), ZERO_ADDRESS, ZERO_ADDRESS, + 0, { from: account, value: dec(2, 20) } ); } @@ -158,8 +165,6 @@ contract("TroveManager", async (accounts) => { 0, 1, false, - ZERO_ADDRESS, - ZERO_ADDRESS, { from: B } ); // B repays 1 wei console.log(`B stake after A1: ${(await troveManager.Troves(B))[2]}`); @@ -181,8 +186,6 @@ contract("TroveManager", async (accounts) => { 0, 1, false, - ZERO_ADDRESS, - ZERO_ADDRESS, { from: B } ); // A repays 1 wei console.log( diff --git a/contracts/utils/testHelpers.js b/contracts/utils/testHelpers.js index 42e36db3..05f5ee20 100644 --- a/contracts/utils/testHelpers.js +++ b/contracts/utils/testHelpers.js @@ -851,7 +851,7 @@ class TestHelper { extraBoldAmount = this.toBN(extraBoldAmount); if (!upperHint) upperHint = this.ZERO_ADDRESS; if (!lowerHint) lowerHint = this.ZERO_ADDRESS; - + if (!extraParams.annualInterestRate) extraParams.annualInterestRate = 0; const MIN_DEBT = ( await this.getNetBorrowingAmount( @@ -885,6 +885,7 @@ class TestHelper { //extraParams.value, // TODO: this is the stETH value - ensure its still working upperHint, lowerHint, + extraParams.annualInterestRate, { from: extraParams.from, value: extraParams.value, @@ -903,11 +904,9 @@ class TestHelper { static async withdrawBold( contracts, - { maxFeePercentage, boldAmount, ICR, upperHint, lowerHint, extraParams } + { maxFeePercentage, boldAmount, ICR, extraParams } ) { if (!maxFeePercentage) maxFeePercentage = this._100pct; - if (!upperHint) upperHint = this.ZERO_ADDRESS; - if (!lowerHint) lowerHint = this.ZERO_ADDRESS; assert( !(boldAmount && ICR) && (boldAmount || ICR), @@ -941,8 +940,6 @@ class TestHelper { await contracts.borrowerOperations.withdrawBold( maxFeePercentage, boldAmount, - upperHint, - lowerHint, extraParams );