From 277dc1ed2d857c8bf88fc944494d02022464be9d Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 15:33:45 +0100 Subject: [PATCH 01/24] Rename `Staked` event We decided to rename this event to `StakeReferral` and remove the `shares` param. --- core/contracts/Acre.sol | 4 ++-- core/test/Acre.test.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/contracts/Acre.sol b/core/contracts/Acre.sol index bb8f357e9..59bf4b69d 100644 --- a/core/contracts/Acre.sol +++ b/core/contracts/Acre.sol @@ -11,7 +11,7 @@ import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; /// tokens. /// @dev ERC-4626 standard extends the ERC-20 token. contract Acre is ERC4626 { - event Staked(bytes32 indexed referral, uint256 assets, uint256 shares); + event StakeReferral(bytes32 indexed referral, uint256 assets); constructor( IERC20 tbtc @@ -32,7 +32,7 @@ contract Acre is ERC4626 { // TODO: revisit the type of referral. uint256 shares = deposit(assets, receiver); - emit Staked(referral, assets, shares); + emit StakeReferral(referral, assets); return shares; } diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 369f80704..3c0934ca4 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -82,10 +82,10 @@ describe("Acre", () => { ) }) - it("should emit Staked event", () => { + it("should emit StakeReferral event", () => { expect(tx) - .to.emit(acre, "Staked") - .withArgs(referral, amountToStake, expectedReceivedShares) + .to.emit(acre, "StakeReferral") + .withArgs(referral, amountToStake) }) it("should mint stBTC tokens", async () => { From eb91b4d6a126d5c358e415e1bdf4bcc438afa31c Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 15:36:00 +0100 Subject: [PATCH 02/24] Update the `stake` fn Emit the `StakeReferral` event only if the referral is not empty value. Actually, we need this data when the referral is present so it doesn't make sense to emit this event with empty referral value. --- core/contracts/Acre.sol | 4 +++- core/test/Acre.test.ts | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/contracts/Acre.sol b/core/contracts/Acre.sol index 59bf4b69d..7f2bdb019 100644 --- a/core/contracts/Acre.sol +++ b/core/contracts/Acre.sol @@ -32,7 +32,9 @@ contract Acre is ERC4626 { // TODO: revisit the type of referral. uint256 shares = deposit(assets, receiver); - emit StakeReferral(referral, assets); + if (referral != bytes32(0)) { + emit StakeReferral(referral, assets); + } return shares; } diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 3c0934ca4..c3902c301 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -120,6 +120,10 @@ describe("Acre", () => { it("should not revert", async () => { await expect(tx).to.be.not.reverted }) + + it("should not emit the StakeReferral event", async () => { + await expect(tx).to.not.emit(acre, "StakeReferral") + }) }) context( From fbb2085d5465051361eb42715421cce23292d312 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 15:40:08 +0100 Subject: [PATCH 03/24] Update `stake` fn docs Clarify under the `dev` tag that the amount of the assets has to be pre-approved in the tBTC contract. --- core/contracts/Acre.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/contracts/Acre.sol b/core/contracts/Acre.sol index 7f2bdb019..84f33722c 100644 --- a/core/contracts/Acre.sol +++ b/core/contracts/Acre.sol @@ -19,7 +19,8 @@ contract Acre is ERC4626 { /// @notice Stakes a given amount of tBTC token and mints shares to a /// receiver. - /// @dev This function calls `deposit` function from `ERC4626` contract. + /// @dev This function calls `deposit` function from `ERC4626` contract. The + /// amount of the assets has to be pre-approved in the tBTC contract. /// @param assets Approved amount for the transfer and stake. /// @param receiver The address to which the shares will be minted. /// @param referral Data used for referral program. From 48eeed3c2b655bc57cb15786691237c07126ae27 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 15:44:26 +0100 Subject: [PATCH 04/24] Rename variable in Acre unit tests Since we have `staker2` let's rename `staker` to `staker1`. --- core/test/Acre.test.ts | 68 ++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index c3902c301..a16e00930 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -11,29 +11,29 @@ import type { TestERC20, Acre } from "../typechain" import { to1e18 } from "./utils" async function acreFixture() { - const [staker, staker2] = await ethers.getSigners() + const [staker1, staker2] = await ethers.getSigners() const Token = await ethers.getContractFactory("TestERC20") const tbtc = await Token.deploy() const amountToMint = to1e18(100000) - tbtc.mint(staker, amountToMint) + tbtc.mint(staker1, amountToMint) tbtc.mint(staker2, amountToMint) const Acre = await ethers.getContractFactory("Acre") const acre = await Acre.deploy(await tbtc.getAddress()) - return { acre, tbtc, staker, staker2 } + return { acre, tbtc, staker1, staker2 } } describe("Acre", () => { let acre: Acre let tbtc: TestERC20 - let staker: HardhatEthersSigner + let staker1: HardhatEthersSigner let staker2: HardhatEthersSigner before(async () => { - ;({ acre, tbtc, staker, staker2 } = await loadFixture(acreFixture)) + ;({ acre, tbtc, staker1, staker2 } = await loadFixture(acreFixture)) }) describe("Staking", () => { @@ -61,20 +61,20 @@ describe("Acre", () => { beforeEach(async () => { await tbtc - .connect(staker) + .connect(staker1) .approve(await acre.getAddress(), amountToStake) tx = await acre - .connect(staker) - .stake(amountToStake, staker.address, referral) + .connect(staker1) + .stake(amountToStake, staker1.address, referral) }) it("should emit Deposit event", () => { expect(tx).to.emit(acre, "Deposit").withArgs( // Caller. - staker.address, + staker1.address, // Receiver. - staker.address, + staker1.address, // Staked tokens. amountToStake, // Received shares. @@ -91,7 +91,7 @@ describe("Acre", () => { it("should mint stBTC tokens", async () => { await expect(tx).to.changeTokenBalances( acre, - [staker.address], + [staker1.address], [amountToStake], ) }) @@ -99,7 +99,7 @@ describe("Acre", () => { it("should transfer tBTC tokens", async () => { await expect(tx).to.changeTokenBalances( tbtc, - [staker.address, acre], + [staker1.address, acre], [-amountToStake, amountToStake], ) }) @@ -110,11 +110,11 @@ describe("Acre", () => { let tx: ContractTransactionResponse beforeEach(async () => { - await tbtc.connect(staker).approve(await acre.getAddress(), 1) + await tbtc.connect(staker1).approve(await acre.getAddress(), 1) tx = await acre - .connect(staker) - .stake(1, staker.address, emptyReferral) + .connect(staker1) + .stake(1, staker1.address, emptyReferral) }) it("should not revert", async () => { @@ -132,15 +132,15 @@ describe("Acre", () => { const amountToStake = to1e18(10) beforeEach(async () => { await tbtc - .connect(staker) + .connect(staker1) .approve(await acre.getAddress(), amountToStake) }) it("should revert", async () => { await expect( acre - .connect(staker) - .stake(amountToStake + 1n, staker.address, referral), + .connect(staker1) + .stake(amountToStake + 1n, staker1.address, referral), ).to.be.reverted }) }, @@ -151,13 +151,15 @@ describe("Acre", () => { beforeEach(async () => { await tbtc - .connect(staker) + .connect(staker1) .approve(await acre.getAddress(), amountToStake) }) it("should not revert", async () => { await expect( - acre.connect(staker).stake(amountToStake, staker.address, referral), + acre + .connect(staker1) + .stake(amountToStake, staker1.address, referral), ).to.not.be.reverted }) }) @@ -167,13 +169,13 @@ describe("Acre", () => { beforeEach(async () => { await tbtc - .connect(staker) + .connect(staker1) .approve(await acre.getAddress(), amountToStake) }) it("should revert", async () => { await expect( - acre.connect(staker).stake(amountToStake, ZeroAddress, referral), + acre.connect(staker1).stake(amountToStake, ZeroAddress, referral), ).to.be.revertedWithCustomError(acre, "ERC20InvalidReceiver") }) }) @@ -185,19 +187,19 @@ describe("Acre", () => { beforeEach(async () => { await tbtc - .connect(staker) + .connect(staker1) .approve(await acre.getAddress(), amountToStake) await acre - .connect(staker) - .stake(amountToStake, staker.address, referral) + .connect(staker1) + .stake(amountToStake, staker1.address, referral) }) it("should revert", async () => { await expect( acre - .connect(staker) - .stake(amountToStake, staker.address, referral), + .connect(staker1) + .stake(amountToStake, staker1.address, referral), ).to.be.revertedWithCustomError(acre, "ERC20InsufficientAllowance") }) }, @@ -216,24 +218,24 @@ describe("Acre", () => { let afterSimulatingYieldSnapshot: SnapshotRestorer before(async () => { - const stakerAmountToStake = to1e18(75) + const staker1AmountToStake = to1e18(75) const staker2AmountToStake = to1e18(25) // Infinite approval for staking contract. await tbtc - .connect(staker) + .connect(staker1) .approve(await acre.getAddress(), ethers.MaxUint256) await tbtc .connect(staker2) .approve(await acre.getAddress(), ethers.MaxUint256) // Mint tokens. - await tbtc.connect(staker).mint(staker.address, stakerAmountToStake) + await tbtc.connect(staker1).mint(staker1.address, staker1AmountToStake) await tbtc.connect(staker2).mint(staker2.address, staker2AmountToStake) stakerA = { - signer: staker, - address: staker.address, - amountToStake: stakerAmountToStake, + signer: staker1, + address: staker1.address, + amountToStake: staker1AmountToStake, } stakerB = { signer: staker2, From f7003b81bf8637e84ffe43f4aa3fc8b3c68c6af7 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 15:50:30 +0100 Subject: [PATCH 05/24] Rename variable in `acreFixture` `Token` -> `TestERC20` to be consistent. --- core/test/Acre.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index a16e00930..dff30aab1 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -12,8 +12,8 @@ import { to1e18 } from "./utils" async function acreFixture() { const [staker1, staker2] = await ethers.getSigners() - const Token = await ethers.getContractFactory("TestERC20") - const tbtc = await Token.deploy() + const TestERC20 = await ethers.getContractFactory("TestERC20") + const tbtc = await TestERC20.deploy() const amountToMint = to1e18(100000) From 076a29cd15221243abeca5175dc4635872229226 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 15:56:05 +0100 Subject: [PATCH 06/24] Update the `acreFixture` fn Let's deploy the contracts first and then perform the minting. --- core/test/Acre.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index dff30aab1..9e167f32e 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -12,17 +12,17 @@ import { to1e18 } from "./utils" async function acreFixture() { const [staker1, staker2] = await ethers.getSigners() + const TestERC20 = await ethers.getContractFactory("TestERC20") const tbtc = await TestERC20.deploy() - const amountToMint = to1e18(100000) + const Acre = await ethers.getContractFactory("Acre") + const acre = await Acre.deploy(await tbtc.getAddress()) + const amountToMint = to1e18(100000) tbtc.mint(staker1, amountToMint) tbtc.mint(staker2, amountToMint) - const Acre = await ethers.getContractFactory("Acre") - const acre = await Acre.deploy(await tbtc.getAddress()) - return { acre, tbtc, staker1, staker2 } } From 961580b996da7f7cc4fbf9861984d9eb226cb0c7 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 15:57:02 +0100 Subject: [PATCH 07/24] Update the test name It's worth to match the test name with the function name. --- core/test/Acre.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 9e167f32e..01b4be062 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -36,7 +36,7 @@ describe("Acre", () => { ;({ acre, tbtc, staker1, staker2 } = await loadFixture(acreFixture)) }) - describe("Staking", () => { + describe("stake", () => { const referral = ethers.encodeBytes32String("referral") let snapshot: SnapshotRestorer From 9674f5e5a72c9fbf36831f0ff141bbdcd40cf4e6 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 16:12:16 +0100 Subject: [PATCH 08/24] Rename file `TestToken` -> `TestERC20`. The file name should match the contract name. --- core/contracts/test/{TestToken.sol => TestERC20.sol} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename core/contracts/test/{TestToken.sol => TestERC20.sol} (100%) diff --git a/core/contracts/test/TestToken.sol b/core/contracts/test/TestERC20.sol similarity index 100% rename from core/contracts/test/TestToken.sol rename to core/contracts/test/TestERC20.sol From 9737ed8f443c22685c04c80a118684360587e1fc Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 16:26:17 +0100 Subject: [PATCH 09/24] Avoid infinite approvals in unit tests --- core/test/Acre.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 01b4be062..5964b3b8d 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -220,13 +220,13 @@ describe("Acre", () => { before(async () => { const staker1AmountToStake = to1e18(75) const staker2AmountToStake = to1e18(25) - // Infinite approval for staking contract. + await tbtc .connect(staker1) - .approve(await acre.getAddress(), ethers.MaxUint256) + .approve(await acre.getAddress(), staker1AmountToStake) await tbtc .connect(staker2) - .approve(await acre.getAddress(), ethers.MaxUint256) + .approve(await acre.getAddress(), staker2AmountToStake) // Mint tokens. await tbtc.connect(staker1).mint(staker1.address, staker1AmountToStake) @@ -401,6 +401,10 @@ describe("Acre", () => { tbtc.mint(stakerA.address, newAmountToStake) + await tbtc + .connect(stakerA.signer) + .approve(await acre.getAddress(), newAmountToStake) + expectedSharesToMint = (newAmountToStake * (totalSupplyBefore + 1n)) / (totalAssetsBefore + 1n) From d33c5527735da7d58690a67b791546a39557983b Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 16:40:33 +0100 Subject: [PATCH 10/24] Get rid of unnecessary `Staker` type in unit tests --- core/test/Acre.test.ts | 85 ++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 53 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 5964b3b8d..c574240da 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -207,20 +207,12 @@ describe("Acre", () => { }) context("when there are two stakers, A and B ", () => { - type Staker = { - signer: HardhatEthersSigner - address: string - amountToStake: bigint - } - let stakerA: Staker - let stakerB: Staker + const staker1AmountToStake = to1e18(75) + const staker2AmountToStake = to1e18(25) let afterStakesSnapshot: SnapshotRestorer let afterSimulatingYieldSnapshot: SnapshotRestorer before(async () => { - const staker1AmountToStake = to1e18(75) - const staker2AmountToStake = to1e18(25) - await tbtc .connect(staker1) .approve(await acre.getAddress(), staker1AmountToStake) @@ -231,17 +223,6 @@ describe("Acre", () => { // Mint tokens. await tbtc.connect(staker1).mint(staker1.address, staker1AmountToStake) await tbtc.connect(staker2).mint(staker2.address, staker2AmountToStake) - - stakerA = { - signer: staker1, - address: staker1.address, - amountToStake: staker1AmountToStake, - } - stakerB = { - signer: staker2, - address: staker2.address, - amountToStake: staker2AmountToStake, - } }) context( @@ -255,15 +236,15 @@ describe("Acre", () => { it("should stake tokens correctly", async () => { await expect( acre - .connect(stakerA.signer) - .stake(stakerA.amountToStake, stakerA.address, referral), + .connect(staker1) + .stake(staker1AmountToStake, staker1.address, referral), ).to.be.not.reverted }) it("should receive shares equal to a staked amount", async () => { - const shares = await acre.balanceOf(stakerA.address) + const shares = await acre.balanceOf(staker1.address) - expect(shares).to.eq(stakerA.amountToStake) + expect(shares).to.eq(staker1AmountToStake) }) }) @@ -271,15 +252,15 @@ describe("Acre", () => { it("should stake tokens correctly", async () => { await expect( acre - .connect(stakerB.signer) - .stake(stakerB.amountToStake, stakerB.address, referral), + .connect(staker2) + .stake(staker2AmountToStake, staker2.address, referral), ).to.be.not.reverted }) it("should receive shares equal to a staked amount", async () => { - const shares = await acre.balanceOf(stakerB.address) + const shares = await acre.balanceOf(staker2.address) - expect(shares).to.eq(stakerB.amountToStake) + expect(shares).to.eq(staker2AmountToStake) }) }) }, @@ -293,15 +274,13 @@ describe("Acre", () => { it("the total assets amount should be equal to all staked tokens", async () => { const totalAssets = await acre.totalAssets() - expect(totalAssets).to.eq( - stakerA.amountToStake + stakerB.amountToStake, - ) + expect(totalAssets).to.eq(staker1AmountToStake + staker2AmountToStake) }) }) context("when vault earns yield", () => { - let stakerASharesBefore: bigint - let stakerBSharesBefore: bigint + let staker1SharesBefore: bigint + let staker2SharesBefore: bigint let vaultYield: bigint let expectedTotalAssets: bigint let expectedTotalSupply: bigint @@ -309,16 +288,16 @@ describe("Acre", () => { before(async () => { await afterStakesSnapshot.restore() - stakerASharesBefore = await acre.balanceOf(stakerA.address) - stakerBSharesBefore = await acre.balanceOf(stakerB.address) + staker1SharesBefore = await acre.balanceOf(staker1.address) + staker2SharesBefore = await acre.balanceOf(staker2.address) vaultYield = to1e18(100) // Staker A shares = 75 // Staker B shares = 25 // Total assets = 75(staker A) + 25(staker B) + 100(yield) expectedTotalAssets = - stakerA.amountToStake + stakerB.amountToStake + vaultYield + staker1AmountToStake + staker2AmountToStake + vaultYield // Total shares = 75 + 25 = 100 - expectedTotalSupply = stakerA.amountToStake + stakerB.amountToStake + expectedTotalSupply = staker1AmountToStake + staker2AmountToStake // Simulating yield returned from strategies. The vault now contains // more tokens than deposited which causes the exchange rate to @@ -332,21 +311,21 @@ describe("Acre", () => { it("the vault should hold more assets", async () => { expect(await acre.totalAssets()).to.be.eq( - stakerA.amountToStake + stakerB.amountToStake + vaultYield, + staker1AmountToStake + staker2AmountToStake + vaultYield, ) }) it("the staker's shares should be the same", async () => { - expect(await acre.balanceOf(stakerA.address)).to.be.eq( - stakerASharesBefore, + expect(await acre.balanceOf(staker1.address)).to.be.eq( + staker1SharesBefore, ) - expect(await acre.balanceOf(stakerB.address)).to.be.eq( - stakerBSharesBefore, + expect(await acre.balanceOf(staker2.address)).to.be.eq( + staker2SharesBefore, ) }) it("the staker A should be able to redeem more tokens than before", async () => { - const shares = await acre.balanceOf(stakerA.address) + const shares = await acre.balanceOf(staker1.address) const availableAssetsToRedeem = await acre.previewRedeem(shares) // Expected amount w/o rounding: 75 * 200 / 100 = 150 @@ -356,13 +335,13 @@ describe("Acre", () => { (shares * (expectedTotalAssets + 1n)) / (expectedTotalSupply + 1n) expect(availableAssetsToRedeem).to.be.greaterThan( - stakerA.amountToStake, + staker1AmountToStake, ) expect(availableAssetsToRedeem).to.be.eq(expectedAssetsToRedeem) }) it("the staker B should be able to redeem more tokens than before", async () => { - const shares = await acre.balanceOf(stakerB.address) + const shares = await acre.balanceOf(staker2.address) const availableAssetsToRedeem = await acre.previewRedeem(shares) // Expected amount w/o rounding: 25 * 200 / 100 = 50 @@ -372,7 +351,7 @@ describe("Acre", () => { (shares * (expectedTotalAssets + 1n)) / (expectedTotalSupply + 1n) expect(availableAssetsToRedeem).to.be.greaterThan( - stakerB.amountToStake, + staker2AmountToStake, ) expect(availableAssetsToRedeem).to.be.eq(expectedAssetsToRedeem) }) @@ -394,22 +373,22 @@ describe("Acre", () => { // Total shares = 75 + 25 = 100 await afterSimulatingYieldSnapshot.restore() - sharesBefore = await acre.balanceOf(stakerA.address) + sharesBefore = await acre.balanceOf(staker1.address) availableToRedeemBefore = await acre.previewRedeem(sharesBefore) totalAssetsBefore = await acre.totalAssets() totalSupplyBefore = await acre.totalSupply() - tbtc.mint(stakerA.address, newAmountToStake) + tbtc.mint(staker1.address, newAmountToStake) await tbtc - .connect(stakerA.signer) + .connect(staker1) .approve(await acre.getAddress(), newAmountToStake) expectedSharesToMint = (newAmountToStake * (totalSupplyBefore + 1n)) / (totalAssetsBefore + 1n) - await acre.stake(newAmountToStake, stakerA.address, referral) + await acre.stake(newAmountToStake, staker1.address, referral) // State after stake: // Total assets = 75(staker A) + 25(staker B) + 100(yield) + 20(staker @@ -420,14 +399,14 @@ describe("Acre", () => { }) it("should receive more shares", async () => { - const shares = await acre.balanceOf(stakerA.address) + const shares = await acre.balanceOf(staker1.address) expect(shares).to.be.greaterThan(sharesBefore) expect(shares).to.be.eq(sharesBefore + expectedSharesToMint) }) it("should be able to redeem more tokens than before", async () => { - const shares = await acre.balanceOf(stakerA.address) + const shares = await acre.balanceOf(staker1.address) const availableToRedeem = await acre.previewRedeem(shares) // Expected amount w/o rounding: 85 * 220 / 110 = 170 From eef74bc541400fca0dc2d08d04d626f4037e62bf Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 16:50:58 +0100 Subject: [PATCH 11/24] Hardcode expected values in unit tests To avoid a false-positive result where both contracts and tests calculations are wrong. --- core/test/Acre.test.ts | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index c574240da..c46b6ef4d 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -282,22 +282,17 @@ describe("Acre", () => { let staker1SharesBefore: bigint let staker2SharesBefore: bigint let vaultYield: bigint - let expectedTotalAssets: bigint - let expectedTotalSupply: bigint before(async () => { + // Current state: + // Staker A shares = 75 + // Staker B shares = 25 + // Total assets = 75(staker A) + 25(staker B) + 100(yield) await afterStakesSnapshot.restore() staker1SharesBefore = await acre.balanceOf(staker1.address) staker2SharesBefore = await acre.balanceOf(staker2.address) vaultYield = to1e18(100) - // Staker A shares = 75 - // Staker B shares = 25 - // Total assets = 75(staker A) + 25(staker B) + 100(yield) - expectedTotalAssets = - staker1AmountToStake + staker2AmountToStake + vaultYield - // Total shares = 75 + 25 = 100 - expectedTotalSupply = staker1AmountToStake + staker2AmountToStake // Simulating yield returned from strategies. The vault now contains // more tokens than deposited which causes the exchange rate to @@ -331,8 +326,7 @@ describe("Acre", () => { // Expected amount w/o rounding: 75 * 200 / 100 = 150 // Expected amount w/ support for rounding: 149999999999999999999 in // tBTC token precision. - const expectedAssetsToRedeem = - (shares * (expectedTotalAssets + 1n)) / (expectedTotalSupply + 1n) + const expectedAssetsToRedeem = 149999999999999999999n expect(availableAssetsToRedeem).to.be.greaterThan( staker1AmountToStake, @@ -347,8 +341,7 @@ describe("Acre", () => { // Expected amount w/o rounding: 25 * 200 / 100 = 50 // Expected amount w/ support for rounding: 49999999999999999999 in // tBTC token precision. - const expectedAssetsToRedeem = - (shares * (expectedTotalAssets + 1n)) / (expectedTotalSupply + 1n) + const expectedAssetsToRedeem = 49999999999999999999n expect(availableAssetsToRedeem).to.be.greaterThan( staker2AmountToStake, @@ -359,13 +352,9 @@ describe("Acre", () => { context("when staker A stakes more tokens", () => { const newAmountToStake = to1e18(20) + const expectedSharesToMint = to1e18(10) let sharesBefore: bigint let availableToRedeemBefore: bigint - let totalAssetsBefore: bigint - let totalSupplyBefore: bigint - let expectedSharesToMint: bigint - let expectedTotalSupply: bigint - let expectedTotalAssets: bigint before(async () => { // Current state: @@ -375,8 +364,6 @@ describe("Acre", () => { sharesBefore = await acre.balanceOf(staker1.address) availableToRedeemBefore = await acre.previewRedeem(sharesBefore) - totalAssetsBefore = await acre.totalAssets() - totalSupplyBefore = await acre.totalSupply() tbtc.mint(staker1.address, newAmountToStake) @@ -384,18 +371,11 @@ describe("Acre", () => { .connect(staker1) .approve(await acre.getAddress(), newAmountToStake) - expectedSharesToMint = - (newAmountToStake * (totalSupplyBefore + 1n)) / - (totalAssetsBefore + 1n) - - await acre.stake(newAmountToStake, staker1.address, referral) - // State after stake: // Total assets = 75(staker A) + 25(staker B) + 100(yield) + 20(staker // A) = 220 // Total shares = 75 + 25 + 10 = 110 - expectedTotalAssets = totalAssetsBefore + newAmountToStake - expectedTotalSupply = totalSupplyBefore + expectedSharesToMint + await acre.stake(newAmountToStake, staker1.address, referral) }) it("should receive more shares", async () => { @@ -412,8 +392,7 @@ describe("Acre", () => { // Expected amount w/o rounding: 85 * 220 / 110 = 170 // Expected amount w/ support for rounding: 169999999999999999999 in // tBTC token precision. - const expectedTotalAssetsAvailableToRedeem = - (shares * (expectedTotalAssets + 1n)) / (expectedTotalSupply + 1n) + const expectedTotalAssetsAvailableToRedeem = 169999999999999999999n expect(availableToRedeem).to.be.greaterThan(availableToRedeemBefore) expect(availableToRedeem).to.be.eq( From 8a243cf30d65b13c2f964c99b6db5fee036c4def Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 16:58:37 +0100 Subject: [PATCH 12/24] Remove unnecessary check in unit test We validate the exact value in the next line so this check seems redundant. --- core/test/Acre.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index c46b6ef4d..863d1800e 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -381,7 +381,6 @@ describe("Acre", () => { it("should receive more shares", async () => { const shares = await acre.balanceOf(staker1.address) - expect(shares).to.be.greaterThan(sharesBefore) expect(shares).to.be.eq(sharesBefore + expectedSharesToMint) }) From b812107a2e8c22649758f7fcec68b075fef3e333 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 17:01:48 +0100 Subject: [PATCH 13/24] Rename test context name `when staking` -> `when staking as a first staker`. --- core/test/Acre.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 863d1800e..445cf0618 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -40,7 +40,7 @@ describe("Acre", () => { const referral = ethers.encodeBytes32String("referral") let snapshot: SnapshotRestorer - context("when staking", () => { + context("when staking as first staker", () => { beforeEach(async () => { snapshot = await takeSnapshot() }) From 910a3992e6cf68d056abcfca6fe1f1599896f273 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 17:03:43 +0100 Subject: [PATCH 14/24] Update `without referral` test case Define a variable `amountToStake` instead of passing number directly to functions - to improve readability. --- core/test/Acre.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 445cf0618..d043adf8d 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -106,15 +106,18 @@ describe("Acre", () => { }) context("without referral", () => { + const amountToStake = to1e18(10) const emptyReferral = ethers.encodeBytes32String("") let tx: ContractTransactionResponse beforeEach(async () => { - await tbtc.connect(staker1).approve(await acre.getAddress(), 1) + await tbtc + .connect(staker1) + .approve(await acre.getAddress(), amountToStake) tx = await acre .connect(staker1) - .stake(1, staker1.address, emptyReferral) + .stake(amountToStake, staker1.address, emptyReferral) }) it("should not revert", async () => { From a868dcec1dc4e2483357397e6a9fc78fbaeb933b Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 17:16:56 +0100 Subject: [PATCH 15/24] Improve test case Since the variable is named `amountToStake`, the amount we pass to `stake` function should be exactly `amountToStake`. Here we add a new variable `approvedAmount` which will be approved in the `before` hook and we use this value when defining the `amountToStake` which is equal `amountToStake + 1`. This will imporve readability. --- core/test/Acre.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index d043adf8d..14d6db66b 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -132,18 +132,20 @@ describe("Acre", () => { context( "when amount to stake is greater than the approved amount", () => { - const amountToStake = to1e18(10) + const approvedAmount = to1e18(10) + const amountToStake = approvedAmount + 1n + beforeEach(async () => { await tbtc .connect(staker1) - .approve(await acre.getAddress(), amountToStake) + .approve(await acre.getAddress(), approvedAmount) }) it("should revert", async () => { await expect( acre .connect(staker1) - .stake(amountToStake + 1n, staker1.address, referral), + .stake(amountToStake, staker1.address, referral), ).to.be.reverted }) }, From 567b52ca96eb50eae82a35f339b685d81200f197 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 17:17:34 +0100 Subject: [PATCH 16/24] Make sure the tx is reverted with expected reason --- core/test/Acre.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 14d6db66b..5d9c70f99 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -146,7 +146,7 @@ describe("Acre", () => { acre .connect(staker1) .stake(amountToStake, staker1.address, referral), - ).to.be.reverted + ).to.be.revertedWithCustomError(tbtc, "ERC20InsufficientAllowance") }) }, ) From 4889a0355677f39359fbc434899b084a021191a3 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 17:18:58 +0100 Subject: [PATCH 17/24] Use dedicated variable in unit test We should use `expectedReceivedShares` while checking `stBTC` balance after staking. --- core/test/Acre.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 5d9c70f99..0d13690fd 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -92,7 +92,7 @@ describe("Acre", () => { await expect(tx).to.changeTokenBalances( acre, [staker1.address], - [amountToStake], + [expectedReceivedShares], ) }) From 9cac49c8d9be916656bc0bf546fbdfeb1af4f467 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 18:00:56 +0100 Subject: [PATCH 18/24] Update staking unit tests Since the ERC4626 deposit function has different caller and receiver roles, let's test them here. This will reflect the flow for tBTC minting and staking in one transaction, where an external contract will call the stake function in the name of the staker. --- core/test/Acre.test.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 0d13690fd..051732352 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -58,23 +58,28 @@ describe("Acre", () => { const expectedReceivedShares = amountToStake let tx: ContractTransactionResponse + let tbtcHolder: HardhatEthersSigner + let receiver: HardhatEthersSigner beforeEach(async () => { + tbtcHolder = staker1 + receiver = staker2 + await tbtc - .connect(staker1) + .connect(tbtcHolder) .approve(await acre.getAddress(), amountToStake) tx = await acre - .connect(staker1) - .stake(amountToStake, staker1.address, referral) + .connect(tbtcHolder) + .stake(amountToStake, receiver.address, referral) }) it("should emit Deposit event", () => { expect(tx).to.emit(acre, "Deposit").withArgs( // Caller. - staker1.address, + tbtcHolder.address, // Receiver. - staker1.address, + receiver.address, // Staked tokens. amountToStake, // Received shares. @@ -91,7 +96,7 @@ describe("Acre", () => { it("should mint stBTC tokens", async () => { await expect(tx).to.changeTokenBalances( acre, - [staker1.address], + [receiver.address], [expectedReceivedShares], ) }) @@ -99,7 +104,7 @@ describe("Acre", () => { it("should transfer tBTC tokens", async () => { await expect(tx).to.changeTokenBalances( tbtc, - [staker1.address, acre], + [tbtcHolder.address, acre], [-amountToStake, amountToStake], ) }) From 88ee4d6f9ad8462ea90ffb3fed9ce0ad34246b14 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Tue, 5 Dec 2023 18:27:44 +0100 Subject: [PATCH 19/24] Complicate the math in test scenario Complicate the math by using `50` instead of `100` to use a different value than `100` which we already have in `totalShares` (25+75=100). --- core/test/Acre.test.ts | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index 051732352..c858bc43e 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -297,12 +297,12 @@ describe("Acre", () => { // Current state: // Staker A shares = 75 // Staker B shares = 25 - // Total assets = 75(staker A) + 25(staker B) + 100(yield) + // Total assets = 75(staker A) + 25(staker B) + 50(yield) await afterStakesSnapshot.restore() staker1SharesBefore = await acre.balanceOf(staker1.address) staker2SharesBefore = await acre.balanceOf(staker2.address) - vaultYield = to1e18(100) + vaultYield = to1e18(50) // Simulating yield returned from strategies. The vault now contains // more tokens than deposited which causes the exchange rate to @@ -333,10 +333,10 @@ describe("Acre", () => { const shares = await acre.balanceOf(staker1.address) const availableAssetsToRedeem = await acre.previewRedeem(shares) - // Expected amount w/o rounding: 75 * 200 / 100 = 150 - // Expected amount w/ support for rounding: 149999999999999999999 in + // Expected amount w/o rounding: 75 * 150 / 100 = 112.5 + // Expected amount w/ support for rounding: 112499999999999999999 in // tBTC token precision. - const expectedAssetsToRedeem = 149999999999999999999n + const expectedAssetsToRedeem = 112499999999999999999n expect(availableAssetsToRedeem).to.be.greaterThan( staker1AmountToStake, @@ -348,10 +348,10 @@ describe("Acre", () => { const shares = await acre.balanceOf(staker2.address) const availableAssetsToRedeem = await acre.previewRedeem(shares) - // Expected amount w/o rounding: 25 * 200 / 100 = 50 - // Expected amount w/ support for rounding: 49999999999999999999 in + // Expected amount w/o rounding: 25 * 150 / 100 = 37.5 + // Expected amount w/ support for rounding: 37499999999999999999 in // tBTC token precision. - const expectedAssetsToRedeem = 49999999999999999999n + const expectedAssetsToRedeem = 37499999999999999999n expect(availableAssetsToRedeem).to.be.greaterThan( staker2AmountToStake, @@ -362,14 +362,16 @@ describe("Acre", () => { context("when staker A stakes more tokens", () => { const newAmountToStake = to1e18(20) - const expectedSharesToMint = to1e18(10) + // Current state: + // Total assets = 75(staker A) + 25(staker B) + 50(yield) + // Total shares = 75 + 25 = 100 + // 20 * 100 / 150 = 13.(3) -> 13333333333333333333 in stBTC token + /// precision + const expectedSharesToMint = 13333333333333333333n let sharesBefore: bigint let availableToRedeemBefore: bigint before(async () => { - // Current state: - // Total assets = 75(staker A) + 25(staker B) + 100(yield) - // Total shares = 75 + 25 = 100 await afterSimulatingYieldSnapshot.restore() sharesBefore = await acre.balanceOf(staker1.address) @@ -382,9 +384,9 @@ describe("Acre", () => { .approve(await acre.getAddress(), newAmountToStake) // State after stake: - // Total assets = 75(staker A) + 25(staker B) + 100(yield) + 20(staker - // A) = 220 - // Total shares = 75 + 25 + 10 = 110 + // Total assets = 75(staker A) + 25(staker B) + 50(yield) + 20(staker + // A) = 170 + // Total shares = 75 + 25 + 13.(3) = 113.(3) await acre.stake(newAmountToStake, staker1.address, referral) }) @@ -398,10 +400,10 @@ describe("Acre", () => { const shares = await acre.balanceOf(staker1.address) const availableToRedeem = await acre.previewRedeem(shares) - // Expected amount w/o rounding: 85 * 220 / 110 = 170 - // Expected amount w/ support for rounding: 169999999999999999999 in + // Expected amount w/o rounding: 88.(3) * 170 / 113.(3) = 132.5 + // Expected amount w/ support for rounding: 132499999999999999999 in // tBTC token precision. - const expectedTotalAssetsAvailableToRedeem = 169999999999999999999n + const expectedTotalAssetsAvailableToRedeem = 132499999999999999999n expect(availableToRedeem).to.be.greaterThan(availableToRedeemBefore) expect(availableToRedeem).to.be.eq( From 5e4849885d07165bee4937eab2d3b1dcef8b3e2d Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Wed, 6 Dec 2023 10:17:28 +0100 Subject: [PATCH 20/24] Add a basic typography --- dapp/src/components/Typography/index.tsx | 33 ++++++++++++++++++++++++ dapp/src/theme/index.ts | 4 +++ dapp/src/theme/utils/fonts.ts | 22 ++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 dapp/src/components/Typography/index.tsx create mode 100644 dapp/src/theme/utils/fonts.ts diff --git a/dapp/src/components/Typography/index.tsx b/dapp/src/components/Typography/index.tsx new file mode 100644 index 000000000..6e1231239 --- /dev/null +++ b/dapp/src/components/Typography/index.tsx @@ -0,0 +1,33 @@ +/* eslint-disable react/jsx-props-no-spreading */ +import React from "react" +import { Text, TextProps } from "@chakra-ui/react" + +export function TextXl(props: TextProps) { + return ( + + ) +} + +export function TextLg(props: TextProps) { + return ( + + ) +} + +export function TextMd(props: TextProps) { + return ( + + ) +} + +export function TextSm(props: TextProps) { + return ( + + ) +} + +export function TextXs(props: TextProps) { + return ( + + ) +} diff --git a/dapp/src/theme/index.ts b/dapp/src/theme/index.ts index 980c42838..366e952a6 100644 --- a/dapp/src/theme/index.ts +++ b/dapp/src/theme/index.ts @@ -2,9 +2,13 @@ import { StyleFunctionProps, extendTheme } from "@chakra-ui/react" import { mode } from "@chakra-ui/theme-tools" import Button from "./Button" import { colors } from "./utils" +import { fontSizes, fontWeights, lineHeights } from "./utils/fonts" const defaultTheme = { colors, + fontSizes, + fontWeights, + lineHeights, styles: { global: (props: StyleFunctionProps) => ({ body: { diff --git a/dapp/src/theme/utils/fonts.ts b/dapp/src/theme/utils/fonts.ts new file mode 100644 index 000000000..18a482760 --- /dev/null +++ b/dapp/src/theme/utils/fonts.ts @@ -0,0 +1,22 @@ +export const fontSizes = { + xs: "0.75rem", + sm: "0.875rem", + md: "1rem", + lg: "1.125rem", + xl: "1.25rem", +} + +export const fontWeights = { + medium: 500, + semibold: 600, + bold: 700, + black: 900, +} + +export const lineHeights = { + xs: "1.125rem", + sm: "1.25rem", + md: "1.5rem", + lg: "1.75rem", + xl: "1.875rem", +} From b037200f87be5a2715d2a61c50cc54ea6e68d643 Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Wed, 6 Dec 2023 12:20:26 +0100 Subject: [PATCH 21/24] Fix for incorrect import --- dapp/src/theme/index.ts | 3 +-- dapp/src/theme/utils/index.ts | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dapp/src/theme/index.ts b/dapp/src/theme/index.ts index 366e952a6..39ec6d51b 100644 --- a/dapp/src/theme/index.ts +++ b/dapp/src/theme/index.ts @@ -1,8 +1,7 @@ import { StyleFunctionProps, extendTheme } from "@chakra-ui/react" import { mode } from "@chakra-ui/theme-tools" import Button from "./Button" -import { colors } from "./utils" -import { fontSizes, fontWeights, lineHeights } from "./utils/fonts" +import { colors, fontSizes, fontWeights, lineHeights } from "./utils" const defaultTheme = { colors, diff --git a/dapp/src/theme/utils/index.ts b/dapp/src/theme/utils/index.ts index c0b5e2654..9f377b3e3 100644 --- a/dapp/src/theme/utils/index.ts +++ b/dapp/src/theme/utils/index.ts @@ -1 +1,2 @@ export * from "./colors" +export * from "./fonts" From 275028608474e5e288c4be7c39b0e849a6f97697 Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 6 Dec 2023 13:33:07 +0100 Subject: [PATCH 22/24] Improve Acre contract docs comment Add short description what is the purpose of Acre system. --- core/contracts/Acre.sol | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/contracts/Acre.sol b/core/contracts/Acre.sol index 84f33722c..0e1cf640f 100644 --- a/core/contracts/Acre.sol +++ b/core/contracts/Acre.sol @@ -4,12 +4,16 @@ pragma solidity ^0.8.21; import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; /// @title Acre -/// @notice Implementation of the ERR-4626 tokenized vault standard. ERC-4626 is -/// a standard to optimize and unify the technical parameters of -/// yield-bearing vaults. This contract allows the minting and burning -/// of shares, represented as standard ERC20 token, in exchange for tBTC -/// tokens. -/// @dev ERC-4626 standard extends the ERC-20 token. +/// @notice This contract implements the ERC-4626 tokenized vault standard. By +/// staking tBTC, users acquire a liquid staking token called stBTC, +/// commonly referred to as "shares". The staked tBTC is securely +/// deposited into Acre's vaults, where it generates yield over time. +/// Users have the flexibility to redeem stBTC, enabling them to +/// withdraw their staked tBTC along with the accrued yield. +/// @dev ERC-4626 is a standard to optimize and unify the technical parameters +/// of yield-bearing vaults. This contract facilitates the minting and +/// burning of shares (stBTC), which are represented as standard ERC20 +/// tokens, providing a seamless exchange with tBTC tokens. contract Acre is ERC4626 { event StakeReferral(bytes32 indexed referral, uint256 assets); From ed73109db8c39dd10cdcc5ddedbcb5e5b086ee5c Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 6 Dec 2023 13:38:24 +0100 Subject: [PATCH 23/24] Remove unnecessary check expectation in test The equality check is enough given we hardcode the expected values. --- core/test/Acre.test.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index c858bc43e..ab9fcb0a2 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -338,9 +338,6 @@ describe("Acre", () => { // tBTC token precision. const expectedAssetsToRedeem = 112499999999999999999n - expect(availableAssetsToRedeem).to.be.greaterThan( - staker1AmountToStake, - ) expect(availableAssetsToRedeem).to.be.eq(expectedAssetsToRedeem) }) @@ -353,9 +350,6 @@ describe("Acre", () => { // tBTC token precision. const expectedAssetsToRedeem = 37499999999999999999n - expect(availableAssetsToRedeem).to.be.greaterThan( - staker2AmountToStake, - ) expect(availableAssetsToRedeem).to.be.eq(expectedAssetsToRedeem) }) }) From 68b81d0c540b54b1d69bce767a6bbe0d9641abdc Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 6 Dec 2023 13:49:52 +0100 Subject: [PATCH 24/24] Remove unnecessary check If the call reverts it will throw an exception in `beforeEach` hook for `await acre.connect(staker1).stake(...)`. --- core/test/Acre.test.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/test/Acre.test.ts b/core/test/Acre.test.ts index ab9fcb0a2..74e764ca0 100644 --- a/core/test/Acre.test.ts +++ b/core/test/Acre.test.ts @@ -125,10 +125,6 @@ describe("Acre", () => { .stake(amountToStake, staker1.address, emptyReferral) }) - it("should not revert", async () => { - await expect(tx).to.be.not.reverted - }) - it("should not emit the StakeReferral event", async () => { await expect(tx).to.not.emit(acre, "StakeReferral") })