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

Vault.balanceOf() -> Vault.slashableBalanceOf() #40

Merged
merged 1 commit into from
Sep 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/contracts/vault/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, IVau
/**
* @inheritdoc IVault
*/
function balanceOf(
function slashableBalanceOf(
address account
) external view returns (uint256) {
uint256 epoch = currentEpoch();
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/vault/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ interface IVault is IMigratableEntity, IVaultStorage {
* @notice Get a total amount of the collateral that can be slashed for a given account.
* @return total amount of the slashable collateral
*/
function balanceOf(
function slashableBalanceOf(
address account
) external view returns (uint256);

Expand Down
22 changes: 11 additions & 11 deletions test/vault/Vault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ contract VaultTest is Test {
assertEq(vault.isWithdrawalsClaimed(0, alice), false);
assertEq(vault.depositWhitelist(), depositWhitelist);
assertEq(vault.isDepositorWhitelisted(alice), false);
assertEq(vault.balanceOf(alice), 0);
assertEq(vault.slashableBalanceOf(alice), 0);

blockTimestamp = blockTimestamp + vault.epochDuration() - 1;
vm.warp(blockTimestamp);
Expand Down Expand Up @@ -754,7 +754,7 @@ contract VaultTest is Test {
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp - 1), ""), 0);
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp), ""), amount1);
assertEq(vault.activeBalanceOf(alice), amount1);
assertEq(vault.balanceOf(alice), amount1);
assertEq(vault.slashableBalanceOf(alice), amount1);

blockTimestamp = blockTimestamp + 1;
vm.warp(blockTimestamp);
Expand Down Expand Up @@ -815,7 +815,7 @@ contract VaultTest is Test {
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp - 1), ""), amount1);
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp), ""), amount1 + amount2);
assertEq(vault.activeBalanceOf(alice), amount1 + amount2);
assertEq(vault.balanceOf(alice), amount1 + amount2);
assertEq(vault.slashableBalanceOf(alice), amount1 + amount2);
gasLeft = gasleft();
assertEq(
vault.activeBalanceOfAt(
Expand Down Expand Up @@ -962,7 +962,7 @@ contract VaultTest is Test {
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp - 1), ""), 0);
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp), ""), amount1 - 1);
assertEq(vault.activeBalanceOf(alice), amount1 - 1);
assertEq(vault.balanceOf(alice), amount1 - 1);
assertEq(vault.slashableBalanceOf(alice), amount1 - 1);

blockTimestamp = blockTimestamp + 1;
vm.warp(blockTimestamp);
Expand Down Expand Up @@ -1027,7 +1027,7 @@ contract VaultTest is Test {
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp - 1), ""), amount1 - 1);
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp), ""), amount1 - 1 + amount2 - 1);
assertEq(vault.activeBalanceOf(alice), amount1 - 1 + amount2 - 1);
assertEq(vault.balanceOf(alice), amount1 - 1 + amount2 - 1);
assertEq(vault.slashableBalanceOf(alice), amount1 - 1 + amount2 - 1);
gasLeft = gasleft();
assertEq(
vault.activeBalanceOfAt(
Expand Down Expand Up @@ -1135,14 +1135,14 @@ contract VaultTest is Test {
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp - 1), ""), amount1);
assertEq(vault.activeBalanceOfAt(alice, uint48(blockTimestamp), ""), amount1);
assertEq(vault.activeBalanceOf(alice), amount1);
assertEq(vault.balanceOf(alice), amount1);
assertEq(vault.slashableBalanceOf(alice), amount1);
assertEq(vault.activeSharesOfAt(bob, uint48(blockTimestamp - 1), ""), 0);
assertEq(vault.activeSharesOfAt(bob, uint48(blockTimestamp), ""), shares2);
assertEq(vault.activeSharesOf(bob), shares2);
assertEq(vault.activeBalanceOfAt(bob, uint48(blockTimestamp - 1), ""), 0);
assertEq(vault.activeBalanceOfAt(bob, uint48(blockTimestamp), ""), amount2);
assertEq(vault.activeBalanceOf(bob), amount2);
assertEq(vault.balanceOf(bob), amount2);
assertEq(vault.slashableBalanceOf(bob), amount2);
}

function test_DepositRevertInvalidOnBehalfOf(
Expand Down Expand Up @@ -1215,7 +1215,7 @@ contract VaultTest is Test {
assertEq(vault.withdrawalSharesOf(vault.currentEpoch(), alice), 0);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 1, alice), mintedShares);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 2, alice), 0);
assertEq(vault.balanceOf(alice), amount1);
assertEq(vault.slashableBalanceOf(alice), amount1);

shares -= burnedShares;

Expand Down Expand Up @@ -1253,7 +1253,7 @@ contract VaultTest is Test {
assertEq(vault.withdrawalSharesOf(vault.currentEpoch(), alice), amount2 * 10 ** 0);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 1, alice), amount3 * 10 ** 0);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 2, alice), 0);
assertEq(vault.balanceOf(alice), amount1);
assertEq(vault.slashableBalanceOf(alice), amount1);

shares -= burnedShares;

Expand Down Expand Up @@ -1358,7 +1358,7 @@ contract VaultTest is Test {
assertEq(vault.withdrawalSharesOf(vault.currentEpoch(), alice), 0);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 1, alice), mintedShares);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 2, alice), 0);
assertEq(vault.balanceOf(alice), amount1);
assertEq(vault.slashableBalanceOf(alice), amount1);

shares -= amount2;

Expand Down Expand Up @@ -1398,7 +1398,7 @@ contract VaultTest is Test {
assertEq(vault.withdrawalSharesOf(vault.currentEpoch(), alice), withdrawnAssets2 * 10 ** 0);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 1, alice), withdrawnAssets3 * 10 ** 0);
assertEq(vault.withdrawalSharesOf(vault.currentEpoch() + 2, alice), 0);
assertEq(vault.balanceOf(alice), amount1);
assertEq(vault.slashableBalanceOf(alice), amount1);

shares -= amount3;

Expand Down
Loading