From ecf18e539266028a62ee29eac88e04526f8c81b7 Mon Sep 17 00:00:00 2001 From: Patrick McKelvy Date: Fri, 18 Oct 2024 15:22:25 -0400 Subject: [PATCH 1/2] just set decimals to 0. --- README.md | 4 ++++ contracts/staking/GenericStakedAppreciatingVault.sol | 2 +- test/ERC4626Router.t.sol | 2 +- test/GenericStakedAppreciatingVault.t.sol | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4f700d0..faaed28 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,7 @@ The vault takes heavy inspiration from the following sources: - [Popcorn DAO - MultiRewardStaking](https://github.com/Popcorn-Limited/contracts/blob/d029c413239735f58b0adcead11fdbe8f69a0e34/src/utils/MultiRewardStaking.sol) This is a simplified implementation that keeps only the core functionality of the vaults and removes any additional features. + +## WARNING + +** When deploying GenericStakedAppreciatingVault, make sure to mint some initial dust (at least 1e4), to avoid an inflation attack. ** diff --git a/contracts/staking/GenericStakedAppreciatingVault.sol b/contracts/staking/GenericStakedAppreciatingVault.sol index 48da46d..4d9ef0a 100644 --- a/contracts/staking/GenericStakedAppreciatingVault.sol +++ b/contracts/staking/GenericStakedAppreciatingVault.sol @@ -133,6 +133,6 @@ contract GenericStakedAppreciatingVault is ERC4626 { } function _decimalsOffset() internal pure override returns (uint8) { - return 3; + return 0; } } diff --git a/test/ERC4626Router.t.sol b/test/ERC4626Router.t.sol index 4099f00..8ab4761 100644 --- a/test/ERC4626Router.t.sol +++ b/test/ERC4626Router.t.sol @@ -45,6 +45,6 @@ contract ERC4626RouterTest is Test { router.depositChained(vaults, depositAmount); vm.stopPrank(); - assertEq(rewardsVault.balanceOf(USER1), depositAmount * 1e3); + assertEq(rewardsVault.balanceOf(USER1), depositAmount); } } diff --git a/test/GenericStakedAppreciatingVault.t.sol b/test/GenericStakedAppreciatingVault.t.sol index 8bd2dec..7c449ce 100644 --- a/test/GenericStakedAppreciatingVault.t.sol +++ b/test/GenericStakedAppreciatingVault.t.sol @@ -26,7 +26,7 @@ contract GenericStakedAppreciatingVaultTest is Test { vaultDecimals = vault.decimals(); tokenDecimals = token.decimals(); - assertTrue(vaultDecimals > tokenDecimals); + assertTrue(vaultDecimals == tokenDecimals); maxError = 10 ** (vaultDecimals - tokenDecimals + 1); token.mint(DEPLOYER, 1000 * 10 ** tokenDecimals); From 77fe12f8d3b0ef3711b47c2bb72e4cbb8985ac6f Mon Sep 17 00:00:00 2001 From: Patrick McKelvy Date: Fri, 18 Oct 2024 15:23:39 -0400 Subject: [PATCH 2/2] fix readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index faaed28..c7a7103 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The epochs run automatically and yield is auto-compounded with hooks on the `dep ### Dev -The implementation of the vault relies on an always increasing `totalAssets` value, the rate is calculated internally based on `totalAssets` per `totalSupply` which gives the exchange rate per unit of vault token. Additionally, the vault tackles inflation attacks with a decimal offset of `3` (equivalent to virtual shares offset of `1e3`). +The implementation of the vault relies on an always increasing `totalAssets` value, the rate is calculated internally based on `totalAssets` per `totalSupply` which gives the exchange rate per unit of vault token. # Generic Multi Rewards Vault