diff --git a/src/contracts/facilitators/aave/misc/UiGhoDataProvider.sol b/src/contracts/facilitators/aave/misc/UiGhoDataProvider.sol index 8d337a12..57957778 100644 --- a/src/contracts/facilitators/aave/misc/UiGhoDataProvider.sol +++ b/src/contracts/facilitators/aave/misc/UiGhoDataProvider.sol @@ -45,7 +45,6 @@ contract UiGhoDataProvider is IUiGhoDataProvider { ghoBaseVariableBorrowRate: baseData.currentVariableBorrowRate, ghoDiscountedPerToken: discountRateStrategy.GHO_DISCOUNTED_PER_DISCOUNT_TOKEN(), ghoDiscountRate: discountRateStrategy.DISCOUNT_RATE(), - ghoDiscountLockPeriod: debtToken.getDiscountLockPeriod(), ghoMinDebtTokenBalanceForDiscount: discountRateStrategy.MIN_DISCOUNT_TOKEN_BALANCE(), ghoMinDiscountTokenBalanceForDiscount: discountRateStrategy.MIN_DEBT_TOKEN_BALANCE(), ghoReserveLastUpdateTimestamp: baseData.lastUpdateTimestamp, @@ -66,8 +65,7 @@ contract UiGhoDataProvider is IUiGhoDataProvider { userGhoDiscountPercent: debtToken.getDiscountPercent(user), userDiscountTokenBalance: IERC20(discountToken).balanceOf(user), userPreviousGhoBorrowIndex: debtToken.getPreviousIndex(user), - userGhoScaledBorrowBalance: debtToken.scaledBalanceOf(user), - userDiscountLockPeriodEndTimestamp: debtToken.getUserRebalanceTimestamp(user) + userGhoScaledBorrowBalance: debtToken.scaledBalanceOf(user) }); } } diff --git a/src/contracts/facilitators/aave/misc/interfaces/IUiGhoDataProvider.sol b/src/contracts/facilitators/aave/misc/interfaces/IUiGhoDataProvider.sol index 027441bd..6a42cbac 100644 --- a/src/contracts/facilitators/aave/misc/interfaces/IUiGhoDataProvider.sol +++ b/src/contracts/facilitators/aave/misc/interfaces/IUiGhoDataProvider.sol @@ -11,7 +11,6 @@ interface IUiGhoDataProvider { uint256 ghoBaseVariableBorrowRate; uint256 ghoDiscountedPerToken; uint256 ghoDiscountRate; - uint256 ghoDiscountLockPeriod; uint256 ghoMinDebtTokenBalanceForDiscount; uint256 ghoMinDiscountTokenBalanceForDiscount; uint40 ghoReserveLastUpdateTimestamp; @@ -25,7 +24,6 @@ interface IUiGhoDataProvider { uint256 userDiscountTokenBalance; uint256 userPreviousGhoBorrowIndex; uint256 userGhoScaledBorrowBalance; - uint256 userDiscountLockPeriodEndTimestamp; } /** diff --git a/src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol b/src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol index f0370792..592c8b4d 100644 --- a/src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol +++ b/src/contracts/facilitators/aave/tokens/GhoVariableDebtToken.sol @@ -47,16 +47,11 @@ contract GhoVariableDebtToken is DebtTokenBase, ScaledBalanceTokenBase, IGhoVari uint128 accumulatedDebtInterest; // Discount percent of the user (expressed in bps) uint16 discountPercent; - // Timestamp when user's discount can be rebalanced - uint40 rebalanceTimestamp; } // Map of users' address and their gho state data (userAddress => ghoUserState) mapping(address => GhoUserState) internal _ghoUserState; - // The amount of time a user's discount is guarded from being rebalanced (expressed in seconds) - uint256 internal _discountLockPeriod; - /** * @dev Only discount token can call functions marked by this modifier. */ @@ -337,12 +332,6 @@ contract GhoVariableDebtToken is DebtTokenBase, ScaledBalanceTokenBase, IGhoVari /// @inheritdoc IGhoVariableDebtToken function rebalanceUserDiscountPercent(address user) external override { - require( - _ghoUserState[user].rebalanceTimestamp < block.timestamp, - 'DISCOUNT_LOCK_PERIOD_NOT_OVER' - ); - require(_ghoUserState[user].rebalanceTimestamp != 0, 'NO_USER_DISCOUNT_TO_REBALANCE'); - uint256 index = POOL.getReserveNormalizedVariableDebt(_underlyingAsset); uint256 previousScaledBalance = super.balanceOf(user); uint256 discountPercent = _ghoUserState[user].discountPercent; @@ -367,23 +356,6 @@ contract GhoVariableDebtToken is DebtTokenBase, ScaledBalanceTokenBase, IGhoVari emit Mint(address(0), user, balanceIncrease, balanceIncrease, index); } - /// @inheritdoc IGhoVariableDebtToken - function updateDiscountLockPeriod(uint256 newLockPeriod) external override onlyPoolAdmin { - uint256 oldLockPeriod = _discountLockPeriod; - _discountLockPeriod = uint40(newLockPeriod); - emit DiscountLockPeriodUpdated(oldLockPeriod, newLockPeriod); - } - - /// @inheritdoc IGhoVariableDebtToken - function getDiscountLockPeriod() external view override returns (uint256) { - return _discountLockPeriod; - } - - /// @inheritdoc IGhoVariableDebtToken - function getUserRebalanceTimestamp(address user) external view override returns (uint256) { - return _ghoUserState[user].rebalanceTimestamp; - } - /** * @notice Implements the basic logic to mint a scaled balance token. * @param caller The address performing the mint @@ -532,22 +504,7 @@ contract GhoVariableDebtToken is DebtTokenBase, ScaledBalanceTokenBase, IGhoVari if (previousDiscountPercent != newDiscountPercent) { _ghoUserState[user].discountPercent = newDiscountPercent.toUint16(); - } - - if (newDiscountPercent != 0) { - uint40 newRebalanceTimestamp = uint40(block.timestamp + _discountLockPeriod); - _ghoUserState[user].rebalanceTimestamp = newRebalanceTimestamp; - emit DiscountPercentLocked( - user, - previousDiscountPercent, - newDiscountPercent, - newRebalanceTimestamp - ); - } else { - if (previousDiscountPercent != newDiscountPercent) { - _ghoUserState[user].rebalanceTimestamp = 0; - emit DiscountPercentLocked(user, previousDiscountPercent, 0, 0); - } + emit DiscountPercentUpdated(user, previousDiscountPercent, newDiscountPercent); } } } diff --git a/src/contracts/facilitators/aave/tokens/interfaces/IGhoVariableDebtToken.sol b/src/contracts/facilitators/aave/tokens/interfaces/IGhoVariableDebtToken.sol index 7bcf7e0d..847b2849 100644 --- a/src/contracts/facilitators/aave/tokens/interfaces/IGhoVariableDebtToken.sol +++ b/src/contracts/facilitators/aave/tokens/interfaces/IGhoVariableDebtToken.sol @@ -33,27 +33,15 @@ interface IGhoVariableDebtToken is IVariableDebtToken { event DiscountTokenUpdated(address indexed oldDiscountToken, address indexed newDiscountToken); /** - * @dev Emitted when the discount lock period is updated - * @param oldDiscountLockPeriod The value of the old DiscountLockPeriod - * @param newDiscountLockPeriod The value of the new DiscountLockPeriod - */ - event DiscountLockPeriodUpdated( - uint256 indexed oldDiscountLockPeriod, - uint256 indexed newDiscountLockPeriod - ); - - /** - * @dev Emitted when a user's discount or rebalanceTimestamp is updated + * @dev Emitted when a user's discount is updated * @param user The address of the user * @param oldDiscountPercent The old discount percent of the user * @param newDiscountPercent The new discount percent of the user - * @param rebalanceTimestamp Timestamp when a users locked discount can be rebalanced */ - event DiscountPercentLocked( + event DiscountPercentUpdated( address indexed user, uint256 oldDiscountPercent, - uint256 indexed newDiscountPercent, - uint256 indexed rebalanceTimestamp + uint256 indexed newDiscountPercent ); /** @@ -130,27 +118,8 @@ interface IGhoVariableDebtToken is IVariableDebtToken { function decreaseBalanceFromInterest(address user, uint256 amount) external; /** - * @notice Rebalances the discount percent of a user if they are past their rebalance timestamp + * @notice Rebalances the discount percent of a user * @param user The address of the user */ function rebalanceUserDiscountPercent(address user) external; - - /** - * @notice Updates the discount percent lock period - * @param newLockPeriod The new discount lock period (in seconds) - */ - function updateDiscountLockPeriod(uint256 newLockPeriod) external; - - /** - * @notice Returns the discount percent lock period - * @return The discount percent lock period (in seconds) - */ - function getDiscountLockPeriod() external view returns (uint256); - - /** - * @notice Returns the timestamp at which a user's discount percent can be rebalanced - * @param user The address of the user's rebalance timestamp being requested - * @return The time when a users discount percent can be rebalanced - */ - function getUserRebalanceTimestamp(address user) external view returns (uint256); } diff --git a/src/helpers/config.ts b/src/helpers/config.ts index 33a7f81a..283e9d03 100644 --- a/src/helpers/config.ts +++ b/src/helpers/config.ts @@ -17,7 +17,6 @@ export const ghoTokenConfig = { export const ghoReserveConfig = { INTEREST_RATE: ethers.utils.parseUnits('2.0', 25), - DISCOUNT_LOCK_PERIOD: 31556952, }; export const ghoEntityConfig = { diff --git a/src/tasks/testnet-setup/05_set-gho-addresses.ts b/src/tasks/testnet-setup/05_set-gho-addresses.ts index 9f645350..47762bbd 100644 --- a/src/tasks/testnet-setup/05_set-gho-addresses.ts +++ b/src/tasks/testnet-setup/05_set-gho-addresses.ts @@ -68,14 +68,4 @@ task( console.log( `VariableDebtToken discount token set to: ${stkAave} in tx: ${updateDiscountTokenTxReceipt.transactionHash}` ); - - // Set initial discount lock period - const updateDiscountLockPeriodReceipt = await waitForTx( - await ghoVariableDebtToken.updateDiscountLockPeriod(ghoReserveConfig.DISCOUNT_LOCK_PERIOD) - ); - console.log( - `VariableDebtToken discount lock period set to: ${await ghoVariableDebtToken.getDiscountLockPeriod()} in tx: ${ - updateDiscountLockPeriodReceipt.transactionHash - }` - ); }); diff --git a/src/test/basic-borrow.test.ts b/src/test/basic-borrow.test.ts index fb61dbb9..bedfdcbc 100644 --- a/src/test/basic-borrow.test.ts +++ b/src/test/basic-borrow.test.ts @@ -43,7 +43,7 @@ makeSuite('Gho Basic Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[0].address, borrowAmount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[0].address, users[0].address, borrowAmount, 0, oneRay) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await gho.balanceOf(users[0].address)).to.be.equal(borrowAmount); expect(await variableDebtToken.totalSupply()).to.be.equal(borrowAmount); @@ -108,7 +108,7 @@ makeSuite('Gho Basic Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[1].address, borrowAmount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[1].address, users[1].address, borrowAmount, 0, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await gho.balanceOf(users[1].address)).to.be.equal(borrowAmount); @@ -152,7 +152,7 @@ makeSuite('Gho Basic Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[0].address, amount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[0].address, users[0].address, amount, user1ExpectedBalanceIncrease, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); const user1Debt = await variableDebtToken.balanceOf(users[0].address); const user2Debt = await variableDebtToken.balanceOf(users[1].address); @@ -200,7 +200,7 @@ makeSuite('Gho Basic Borrow Flow', (testEnv: TestEnv) => { .withArgs(users[1].address, ZERO_ADDRESS, borrowAmount) .to.emit(variableDebtToken, 'Burn') .withArgs(users[1].address, ZERO_ADDRESS, borrowAmount, user2ExpectedInterest, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); const user1Debt = await variableDebtToken.balanceOf(users[0].address); const user2Debt = await variableDebtToken.balanceOf(users[1].address); @@ -245,7 +245,7 @@ makeSuite('Gho Basic Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[2].address, borrowAmount.mul(3)) .to.emit(variableDebtToken, 'Mint') .withArgs(users[2].address, users[2].address, borrowAmount.mul(3), 0, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await gho.balanceOf(users[2].address)).to.be.equal(borrowAmount.mul(3)); expect(await variableDebtToken.getBalanceFromInterest(users[2].address)).to.be.equal(0); @@ -289,7 +289,7 @@ makeSuite('Gho Basic Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[0].address, amount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[0].address, users[0].address, amount, user1ExpectedBalanceIncrease, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await variableDebtToken.balanceOf(users[0].address)).to.be.eq( user1ExpectedBalance.sub(repayAmount) @@ -338,7 +338,7 @@ makeSuite('Gho Basic Borrow Flow', (testEnv: TestEnv) => { .withArgs(users[0].address, ZERO_ADDRESS, amount) .to.emit(variableDebtToken, 'Burn') .withArgs(users[0].address, ZERO_ADDRESS, amount, user1ExpectedBalanceIncrease, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await variableDebtToken.balanceOf(users[0].address)).to.be.eq(0); expect(await variableDebtToken.getBalanceFromInterest(users[0].address)).to.be.equal(0); diff --git a/src/test/borrow-onBehalf.test.ts b/src/test/borrow-onBehalf.test.ts index 5dc09135..eb06b0b5 100644 --- a/src/test/borrow-onBehalf.test.ts +++ b/src/test/borrow-onBehalf.test.ts @@ -56,7 +56,7 @@ makeSuite('Gho OnBehalf Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[0].address, borrowAmount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[1].address, users[0].address, borrowAmount, 0, oneRay) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await gho.balanceOf(users[1].address)).to.be.equal(borrowAmount); expect(await variableDebtToken.getBalanceFromInterest(users[0].address)).to.be.equal(0); @@ -119,7 +119,7 @@ makeSuite('Gho OnBehalf Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[2].address, borrowAmount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[2].address, users[2].address, borrowAmount, 0, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await gho.balanceOf(users[2].address)).to.be.equal(borrowAmount); @@ -164,7 +164,7 @@ makeSuite('Gho OnBehalf Borrow Flow', (testEnv: TestEnv) => { .withArgs(users[0].address, ZERO_ADDRESS, borrowAmount) .to.emit(variableDebtToken, 'Burn') .withArgs(users[0].address, ZERO_ADDRESS, borrowAmount, user1ExpectedInterest, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); const user1Debt = await variableDebtToken.balanceOf(users[0].address); const user2Debt = await variableDebtToken.balanceOf(users[1].address); diff --git a/src/test/discount-borrow.test.ts b/src/test/discount-borrow.test.ts index 3d39cc23..0c0a608d 100644 --- a/src/test/discount-borrow.test.ts +++ b/src/test/discount-borrow.test.ts @@ -137,13 +137,8 @@ makeSuite('Gho Discount Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[1].address, borrowAmount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[1].address, users[1].address, borrowAmount, 0, expIndex) - .to.emit(variableDebtToken, 'DiscountPercentLocked') - .withArgs( - users[1].address, - discountPercentBefore, - discountPercent, - txTimestamp.add(ghoReserveConfig.DISCOUNT_LOCK_PERIOD) - ); + .to.emit(variableDebtToken, 'DiscountPercentUpdated') + .withArgs(users[1].address, discountPercentBefore, discountPercent); expect(await variableDebtToken.getDiscountPercent(users[1].address)).to.be.eq(discountPercent); @@ -236,7 +231,7 @@ makeSuite('Gho Discount Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[0].address, amount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[0].address, users[0].address, amount, user1BalanceIncrease, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); const user1Debt = await variableDebtToken.balanceOf(users[0].address); const user2Debt = await variableDebtToken.balanceOf(users[1].address); @@ -306,8 +301,8 @@ makeSuite('Gho Discount Borrow Flow', (testEnv: TestEnv) => { .withArgs(users[1].address, ZERO_ADDRESS, borrowAmount) .to.emit(variableDebtToken, 'Burn') .withArgs(users[1].address, ZERO_ADDRESS, borrowAmount, user2ExpectedInterest, expIndex) - .to.emit(variableDebtToken, 'DiscountPercentLocked') - .withArgs(users[1].address, user2DiscountPercentBefore, user2DiscountPercent, 0); + .to.emit(variableDebtToken, 'DiscountPercentUpdated') + .withArgs(users[1].address, user2DiscountPercentBefore, user2DiscountPercent); const user1Debt = await variableDebtToken.balanceOf(users[0].address); const user2Debt = await variableDebtToken.balanceOf(users[1].address); @@ -358,7 +353,7 @@ makeSuite('Gho Discount Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[2].address, borrowAmount.mul(3)) .to.emit(variableDebtToken, 'Mint') .withArgs(users[2].address, users[2].address, borrowAmount.mul(3), 0, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await variableDebtToken.getDiscountPercent(users[2].address)).to.be.eq(0); @@ -404,7 +399,7 @@ makeSuite('Gho Discount Borrow Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[0].address, amount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[0].address, users[0].address, amount, user1ExpectedBalanceIncrease, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await variableDebtToken.getDiscountPercent(users[0].address)).to.be.eq(0); @@ -455,7 +450,7 @@ makeSuite('Gho Discount Borrow Flow', (testEnv: TestEnv) => { .withArgs(users[0].address, ZERO_ADDRESS, amount) .to.emit(variableDebtToken, 'Burn') .withArgs(users[0].address, ZERO_ADDRESS, amount, user1ExpectedBalanceIncrease, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await variableDebtToken.getDiscountPercent(users[0].address)).to.be.eq(0); diff --git a/src/test/discount-rebalance.test.ts b/src/test/discount-rebalance.test.ts index 9309a095..02de668f 100644 --- a/src/test/discount-rebalance.test.ts +++ b/src/test/discount-rebalance.test.ts @@ -56,9 +56,6 @@ makeSuite('Gho Discount Rebalance Flow', (testEnv: TestEnv) => { .borrow(gho.address, borrowAmount, 2, 0, users[0].address); rcpt = await tx.wait(); - const { txTimestamp } = await getTxCostAndTimestamp(rcpt); - const expectedRebalanceTimestamp = txTimestamp.add(ghoReserveConfig.DISCOUNT_LOCK_PERIOD); - const discountTokenBalance = await stakedAave.balanceOf(users[0].address); const discountPercent = calcDiscountRate( discountRate, @@ -73,41 +70,21 @@ makeSuite('Gho Discount Rebalance Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[0].address, borrowAmount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[0].address, users[0].address, borrowAmount, 0, oneRay) - .to.emit(variableDebtToken, 'DiscountPercentLocked') - .withArgs( - users[0].address, - discountPercentBefore, - discountPercent, - expectedRebalanceTimestamp - ); + .to.emit(variableDebtToken, 'DiscountPercentUpdated') + .withArgs(users[0].address, discountPercentBefore, discountPercent); expect(await variableDebtToken.getDiscountPercent(users[0].address)).to.be.eq(discountPercent); - expect(await variableDebtToken.getUserRebalanceTimestamp(users[0].address)).to.be.eq( - expectedRebalanceTimestamp - ); expect(await gho.balanceOf(users[0].address)).to.be.equal(borrowAmount); expect(await variableDebtToken.getBalanceFromInterest(users[0].address)).to.be.equal(0); expect(await variableDebtToken.balanceOf(users[0].address)).to.be.equal(borrowAmount); }); - it('User 3 tries to rebalance User 1 discount percent (revert expected)', async function () { - const { users, variableDebtToken } = testEnv; - - await expect( - variableDebtToken.connect(users[2].signer).rebalanceUserDiscountPercent(users[0].address) - ).to.be.revertedWith('DISCOUNT_LOCK_PERIOD_NOT_OVER'); - }); - it('User 2: Deposit WETH and Borrow GHO', async function () { const { users, pool, weth, gho, variableDebtToken, stakedAave } = testEnv; const { lastUpdateTimestamp: ghoLastUpdateTimestamp, variableBorrowIndex } = await pool.getReserveData(gho.address); - const rebalanceTimestampBefore = await variableDebtToken.getUserRebalanceTimestamp( - users[1].address - ); - await weth.connect(users[1].signer).approve(pool.address, collateralAmount); await pool .connect(users[1].signer) @@ -139,12 +116,9 @@ makeSuite('Gho Discount Rebalance Flow', (testEnv: TestEnv) => { .withArgs(ZERO_ADDRESS, users[1].address, borrowAmount) .to.emit(variableDebtToken, 'Mint') .withArgs(users[1].address, users[1].address, borrowAmount, 0, expIndex) - .to.not.emit(variableDebtToken, 'DiscountPercentLocked'); + .to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await variableDebtToken.getDiscountPercent(users[1].address)).to.be.eq(discountPercent); - expect(await variableDebtToken.getUserRebalanceTimestamp(users[1].address)).to.be.eq( - rebalanceTimestampBefore - ); expect(await gho.balanceOf(users[1].address)).to.be.equal(borrowAmount); expect(await variableDebtToken.getBalanceFromInterest(users[1].address)).to.be.equal(0); expect(await variableDebtToken.balanceOf(users[1].address)).to.be.equal(borrowAmount); @@ -196,13 +170,8 @@ makeSuite('Gho Discount Rebalance Flow', (testEnv: TestEnv) => { ); await expect(tx) - .to.emit(variableDebtToken, 'DiscountPercentLocked') - .withArgs( - users[0].address, - discountPercentBefore, - expectedUser1DiscountPercent, - txTimestamp.add(ghoReserveConfig.DISCOUNT_LOCK_PERIOD) - ) + .to.emit(variableDebtToken, 'DiscountPercentUpdated') + .withArgs(users[0].address, discountPercentBefore, expectedUser1DiscountPercent) .to.emit(variableDebtToken, 'Transfer') .withArgs(ZERO_ADDRESS, users[0].address, user1BalanceIncreaseWithDiscount) .to.emit(variableDebtToken, 'Mint') @@ -217,9 +186,6 @@ makeSuite('Gho Discount Rebalance Flow', (testEnv: TestEnv) => { expect(await variableDebtToken.getDiscountPercent(users[0].address)).to.be.eq( expectedUser1DiscountPercent ); - expect(await variableDebtToken.getUserRebalanceTimestamp(users[0].address)).to.be.eq( - txTimestamp.add(ghoReserveConfig.DISCOUNT_LOCK_PERIOD) - ); }); it('Time flies - variable debt index increases', async function () { @@ -247,14 +213,13 @@ makeSuite('Gho Discount Rebalance Flow', (testEnv: TestEnv) => { await expect( variableDebtToken.connect(users[2].signer).rebalanceUserDiscountPercent(users[0].address) ) - .to.emit(variableDebtToken, 'DiscountPercentLocked') - .withArgs(users[0].address, discountPercentBefore, 0, 0); + .to.emit(variableDebtToken, 'DiscountPercentUpdated') + .withArgs(users[0].address, discountPercentBefore, 0); expect(await variableDebtToken.getDiscountPercent(users[0].address)).to.be.not.eq( discountPercentBefore ); expect(await variableDebtToken.getDiscountPercent(users[0].address)).to.be.eq(0); - expect(await variableDebtToken.getUserRebalanceTimestamp(users[0].address)).to.be.eq(0); }); it('Time flies - variable debt index increases', async function () { @@ -268,7 +233,7 @@ makeSuite('Gho Discount Rebalance Flow', (testEnv: TestEnv) => { await expect( variableDebtToken.connect(users[2].signer).rebalanceUserDiscountPercent(users[0].address) - ).to.be.revertedWith('NO_USER_DISCOUNT_TO_REBALANCE'); + ).to.not.emit(variableDebtToken, 'DiscountPercentUpdated'); expect(await variableDebtToken.getDiscountPercent(users[0].address)).to.be.eq( discountPercentBefore diff --git a/src/test/gho-variable-debt.test.ts b/src/test/gho-variable-debt.test.ts index c48ec157..228d6230 100644 --- a/src/test/gho-variable-debt.test.ts +++ b/src/test/gho-variable-debt.test.ts @@ -2,7 +2,6 @@ import hre from 'hardhat'; import { expect } from 'chai'; import { makeSuite, TestEnv } from './helpers/make-suite'; import { impersonateAccountHardhat } from '../helpers/misc-utils'; -import { ghoReserveConfig } from '../helpers/config'; import { ONE_ADDRESS, ZERO_ADDRESS } from '../helpers/constants'; import { GhoVariableDebtToken__factory } from '../../types'; import { ProtocolErrors } from '@aave/core-v3'; @@ -125,7 +124,6 @@ makeSuite('Gho VariableDebtToken End-To-End', (testEnv: TestEnv) => { { fn: 'setAToken', args: [randomAddress] }, { fn: 'updateDiscountRateStrategy', args: [randomAddress] }, { fn: 'updateDiscountToken', args: [randomAddress] }, - { fn: 'updateDiscountLockPeriod', args: [randomNumber] }, ]; for (const call of calls) { await expect( @@ -227,18 +225,4 @@ makeSuite('Gho VariableDebtToken End-To-End', (testEnv: TestEnv) => { variableDebtToken.connect(randomSigner).updateDiscountToken(ONE_ADDRESS) ).to.be.revertedWith(ProtocolErrors.CALLER_NOT_POOL_ADMIN); }); - - it('Set Rebalance Lock Period', async function () { - const { variableDebtToken, deployer } = testEnv; - - await expect(variableDebtToken.connect(deployer.signer).updateDiscountLockPeriod(2)) - .to.emit(variableDebtToken, 'DiscountLockPeriodUpdated') - .withArgs(ghoReserveConfig.DISCOUNT_LOCK_PERIOD, 2); - }); - - it('Get Rebalance Lock Period', async function () { - const { variableDebtToken } = testEnv; - - expect(await variableDebtToken.getDiscountLockPeriod()).to.be.equal(2); - }); }); diff --git a/src/test/helpers/tokenization-events.ts b/src/test/helpers/tokenization-events.ts index db6d6ab8..6488e781 100644 --- a/src/test/helpers/tokenization-events.ts +++ b/src/test/helpers/tokenization-events.ts @@ -1,7 +1,7 @@ import { ethers } from 'hardhat'; -import { utils, BigNumber } from 'ethers'; +import { utils } from 'ethers'; import { TransactionReceipt } from '@ethersproject/providers'; -import { GhoVariableDebtToken, VariableDebtToken } from '../../../types'; +import { GhoVariableDebtToken } from '../../../types'; const GHO_VARIABLE_DEBT_TOKEN_EVENTS = [ { sig: 'Transfer(address,address,uint256)', args: ['from', 'to', 'value'] }, @@ -14,8 +14,8 @@ const GHO_VARIABLE_DEBT_TOKEN_EVENTS = [ args: ['from', 'target', 'value', 'balanceIncrease', 'index'], }, { - sig: 'DiscountPercentLocked(address,uint256,uint256)', - args: ['user', 'nextDiscountPercent', 'rebalanceTimestamp'], + sig: 'DiscountPercentUpdated(address,uint256,uint256)', + args: ['user', 'oldDiscountPercent', 'newDiscountPercent'], }, ];