Skip to content

Commit

Permalink
Add UserEjected event to FoxVault
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi committed Mar 5, 2024
1 parent 397a60e commit cc392d2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
19 changes: 19 additions & 0 deletions abi/IEthFoxVault.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,25 @@
"name": "Redeemed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "user",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "shares",
"type": "uint256"
}
],
"name": "UserEjected",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down
7 changes: 7 additions & 0 deletions contracts/interfaces/IEthFoxVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ interface IEthFoxVault is
IVaultBlocklist,
IMulticall
{
/**
* @notice Event emitted when a user is ejected from the Vault
* @param user The address of the user
* @param shares The amount of shares ejected
*/
event UserEjected(address user, uint256 shares);

/**
* @dev Struct for initializing the EthFoxVault contract
* @param admin The address of the Vault admin
Expand Down
1 change: 1 addition & 0 deletions contracts/vaults/ethereum/custom/EthFoxVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract EthFoxVault is
// redeem user shares
_redeem(user, userShares, user);
}
emit UserEjected(user, userShares);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions test/EthFoxVault.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ describe('EthFoxVault', () => {
await expect(tx)
.to.emit(vault, 'Redeemed')
.withArgs(sender.address, sender.address, senderAssets, senderShares)
await expect(tx).to.emit(vault, 'UserEjected').withArgs(sender.address, senderShares)
expect(await vault.getShares(sender.address)).to.eq(0)
await snapshotGasCost(tx)
})
Expand All @@ -245,6 +246,7 @@ describe('EthFoxVault', () => {
await expect(tx)
.to.emit(vault, 'ExitQueueEntered')
.withArgs(sender.address, sender.address, positionTicket, senderShares)
await expect(tx).to.emit(vault, 'UserEjected').withArgs(sender.address, senderShares)
expect(await vault.getShares(sender.address)).to.eq(0)
await snapshotGasCost(tx)
})
Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/EthFoxVault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ Object {
exports[`EthFoxVault ejecting user blocklist manager can eject all of the user assets for collateralized vault 1`] = `
Object {
"calldataByteLength": 36,
"gasUsed": 112108,
"gasUsed": 113416,
}
`;

exports[`EthFoxVault ejecting user blocklist manager can eject all of the user assets for not collateralized vault 1`] = `
Object {
"calldataByteLength": 36,
"gasUsed": 83278,
"gasUsed": 84597,
}
`;

exports[`EthFoxVault ejecting user does not fail for user with no vault shares 1`] = `
Object {
"calldataByteLength": 36,
"gasUsed": 55808,
"gasUsed": 55813,
}
`;

Expand Down

0 comments on commit cc392d2

Please sign in to comment.