Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decimals #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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. **
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify that this is only required for large assets where manipulation is profitable with a 0 decimal offset. The vault internally already uses virtual assets and shares making it not profitable for most assets even with a 0 decimal offset.

(Also, nit, remove the excess bolding and capitalization and use code markers for contract names and symbols)

2 changes: 1 addition & 1 deletion contracts/staking/GenericStakedAppreciatingVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ contract GenericStakedAppreciatingVault is ERC4626 {
}

function _decimalsOffset() internal pure override returns (uint8) {
return 3;
return 0;
}
}
2 changes: 1 addition & 1 deletion test/ERC4626Router.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion test/GenericStakedAppreciatingVault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down