From 95f14c2845858f86bd49089ef1265c8eb029c839 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Mon, 17 Jun 2024 14:15:38 +0200 Subject: [PATCH] natspec, cosmetic changes --- mainnet-contracts/src/Errors.sol | 6 + mainnet-contracts/src/PufLocker.sol | 71 +++++++---- mainnet-contracts/src/PufLockerStorage.sol | 2 +- mainnet-contracts/src/PufToken.sol | 18 +-- .../src/interface/IPufLocker.sol | 120 ++++++++++++++++-- .../src/interface/IPufStakingPool.sol | 78 +++++++++++- mainnet-contracts/test/unit/PufLocker.t.sol | 9 +- .../test/unit/PufferL2Staking.t.sol | 78 ++++++++++-- 8 files changed, 313 insertions(+), 69 deletions(-) diff --git a/mainnet-contracts/src/Errors.sol b/mainnet-contracts/src/Errors.sol index 1977ddf..0399d6f 100644 --- a/mainnet-contracts/src/Errors.sol +++ b/mainnet-contracts/src/Errors.sol @@ -12,3 +12,9 @@ error Unauthorized(); * @dev Signature "0xe6c4247b" */ error InvalidAddress(); + +/** + * @notice Thrown when amount is not valid + * @dev Signature "0x2c5211c6" + */ +error InvalidAmount(); diff --git a/mainnet-contracts/src/PufLocker.sol b/mainnet-contracts/src/PufLocker.sol index de0ed0a..c8f2ff7 100644 --- a/mainnet-contracts/src/PufLocker.sol +++ b/mainnet-contracts/src/PufLocker.sol @@ -10,6 +10,7 @@ import { IPufLocker } from "./interface/IPufLocker.sol"; import { ERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { Permit } from "./structs/Permit.sol"; +import { InvalidAmount } from "./Errors.sol"; /** * @title PufLocker @@ -37,29 +38,8 @@ contract PufLocker is AccessManagedUpgradeable, IPufLocker, PufLockerStorage { } /** - * @notice Creates a new staking token contract - * @dev Restricted to Puffer DAO - */ - function setIsAllowedToken(address token, bool allowed) external restricted { - PufLockerData storage $ = _getPufLockerStorage(); - $.allowedTokens[token] = allowed; - emit SetTokenIsAllowed(token, allowed); - } - - /** - * @notice Creates a new staking token contract - * @dev Restricted to Puffer DAO + * @inheritdoc IPufLocker */ - function setLockPeriods(uint128 minLock, uint128 maxLock) external restricted { - if (minLock > maxLock) { - revert InvalidLockPeriod(); - } - PufLockerData storage $ = _getPufLockerStorage(); - emit LockPeriodsChanged($.minLockPeriod, minLock, $.maxLockPeriod, maxLock); - $.minLockPeriod = minLock; - $.maxLockPeriod = maxLock; - } - function deposit(address token, uint128 lockPeriod, Permit calldata permitData) external isAllowedToken(token) { if (permitData.amount == 0) { revert InvalidAmount(); @@ -90,16 +70,20 @@ contract PufLocker is AccessManagedUpgradeable, IPufLocker, PufLockerStorage { emit Deposited(msg.sender, token, uint128(permitData.amount), releaseTime); } + /** + * @inheritdoc IPufLocker + */ function withdraw(address token, uint256[] calldata depositIndexes, address recipient) external { if (recipient == address(0)) { revert InvalidRecipientAddress(); } PufLockerData storage $ = _getPufLockerStorage(); + uint128 totalAmount = 0; Deposit[] storage userDeposits = $.deposits[msg.sender][token]; - for (uint256 i = 0; i < depositIndexes.length; i++) { + for (uint256 i = 0; i < depositIndexes.length; ++i) { uint256 index = depositIndexes[i]; if (index >= userDeposits.length) { revert InvalidDepositIndex(); @@ -107,7 +91,7 @@ contract PufLocker is AccessManagedUpgradeable, IPufLocker, PufLockerStorage { Deposit storage userDeposit = userDeposits[index]; if (userDeposit.releaseTime > uint128(block.timestamp)) { - revert DepositStillLocked(); + revert DepositLocked(); } totalAmount += userDeposit.amount; @@ -120,9 +104,36 @@ contract PufLocker is AccessManagedUpgradeable, IPufLocker, PufLockerStorage { IERC20(token).safeTransfer(recipient, totalAmount); - emit Withdrawn(msg.sender, token, totalAmount, recipient); + emit Withdrawn({ user: msg.sender, token: token, amount: totalAmount, recipient: recipient }); + } + + /** + * @notice Creates a new staking token contract + * @dev Restricted to Puffer DAO + */ + function setIsAllowedToken(address token, bool allowed) external restricted { + PufLockerData storage $ = _getPufLockerStorage(); + $.allowedTokens[token] = allowed; + emit SetTokenIsAllowed(token, allowed); + } + + /** + * @notice Creates a new staking token contract + * @dev Restricted to Puffer DAO + */ + function setLockPeriods(uint128 minLock, uint128 maxLock) external restricted { + if (minLock > maxLock) { + revert InvalidLockPeriod(); + } + PufLockerData storage $ = _getPufLockerStorage(); + emit LockPeriodsChanged($.minLockPeriod, minLock, $.maxLockPeriod, maxLock); + $.minLockPeriod = minLock; + $.maxLockPeriod = maxLock; } + /** + * @inheritdoc IPufLocker + */ function getDeposits(address user, address token, uint256 start, uint256 limit) external view @@ -141,13 +152,21 @@ contract PufLocker is AccessManagedUpgradeable, IPufLocker, PufLockerStorage { uint256 count = end - start; depositPage = new Deposit[](count); - for (uint256 i = 0; i < count; i++) { + for (uint256 i = 0; i < count; ++i) { depositPage[i] = userDeposits[start + i]; } return depositPage; } + /** + * @inheritdoc IPufLocker + */ + function getAllDeposits(address token, address depositor) external view returns (Deposit[] memory) { + PufLockerData storage $ = _getPufLockerStorage(); + return $.deposits[token][depositor]; + } + /** * @inheritdoc IPufLocker */ diff --git a/mainnet-contracts/src/PufLockerStorage.sol b/mainnet-contracts/src/PufLockerStorage.sol index 8c5048b..f6c648a 100644 --- a/mainnet-contracts/src/PufLockerStorage.sol +++ b/mainnet-contracts/src/PufLockerStorage.sol @@ -19,7 +19,7 @@ abstract contract PufLockerStorage { /// @custom:storage-location erc7201:PufLocker.storage struct PufLockerData { mapping(address token => bool isAllowed) allowedTokens; - mapping(address token => mapping(address depositor => IPufLocker.Deposit[])) deposits; + mapping(address depositor => mapping(address token => IPufLocker.Deposit[])) deposits; uint128 minLockPeriod; uint128 maxLockPeriod; } diff --git a/mainnet-contracts/src/PufToken.sol b/mainnet-contracts/src/PufToken.sol index 3ecf2ee..63705d6 100644 --- a/mainnet-contracts/src/PufToken.sol +++ b/mainnet-contracts/src/PufToken.sol @@ -8,6 +8,7 @@ import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/Sig import { PufferL2Depositor } from "./PufferL2Depositor.sol"; import { IMigrator } from "./interface/IMigrator.sol"; import { IPufStakingPool } from "./interface/IPufStakingPool.sol"; +import { Unauthorized, InvalidAmount } from "./Errors.sol"; /** * @title Puf token @@ -101,7 +102,7 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit { } /** - * @notice Deposits the underlying token to receive pufToken to the `account` + * @inheritdoc IPufStakingPool */ function deposit(address from, address account, uint256 amount) external @@ -112,14 +113,13 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit { } /** - * @notice Deposits the underlying token to receive pufToken to the `account` + * @inheritdoc IPufStakingPool */ function withdraw(address recipient, uint256 amount) external validateAddressAndAmount(recipient, amount) { _burn(msg.sender, amount); uint256 deNormalizedAmount = _denormalizeAmount(amount); - // Send him the token TOKEN.safeTransfer(recipient, deNormalizedAmount); // Using the original deposit amount in the event (in this case it is denormalized amount) @@ -127,7 +127,7 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit { } /** - * @notice Migrates the `amount` of tokens using the allowlsited `migratorContract` to the `destination` address + * @inheritdoc IPufStakingPool */ function migrate(uint256 amount, address migratorContract, address destination) external @@ -139,7 +139,7 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit { } /** - * @notice Migrates the tokens using the allowlisted migrator contract using the EIP712 signature from the depositor + * @inheritdoc IPufStakingPool */ function migrateWithSignature( address depositor, @@ -173,13 +173,15 @@ contract PufToken is IPufStakingPool, ERC20, ERC20Permit { _migrate({ depositor: depositor, amount: amount, destination: destination, migratorContract: migratorContract }); } + /** + * @notice Sets the underlying token deposit cap + */ function setDepositCap(uint256 newDepositCap) external onlyPufferFactory { - uint256 deNormalizedTotalSupply = _denormalizeAmount(totalSupply()); - - if (newDepositCap < deNormalizedTotalSupply) { + if (newDepositCap < totalSupply()) { revert InvalidAmount(); } + emit DepositCapChanged(totalDepositCap, newDepositCap); totalDepositCap = newDepositCap; } diff --git a/mainnet-contracts/src/interface/IPufLocker.sol b/mainnet-contracts/src/interface/IPufLocker.sol index 823b389..3095de3 100644 --- a/mainnet-contracts/src/interface/IPufLocker.sol +++ b/mainnet-contracts/src/interface/IPufLocker.sol @@ -3,39 +3,131 @@ pragma solidity >=0.8.0 <0.9.0; import { Permit } from "../structs/Permit.sol"; +/** + * @title IPufStakingPool + * @author Puffer Finance + * @custom:security-contact security@puffer.fi + */ interface IPufLocker { - // Custom error messages + struct Deposit { + uint128 amount; + uint128 releaseTime; + } + + /** + * @notice Thrown when the token is not allowed + * @dev Signature "0xa29c4986" + */ error TokenNotAllowed(); - error InvalidAmount(); + + /** + * @notice Thrown when lock period is not in the valid range + * @dev Signature "0x2a82a34f" + */ error InvalidLockPeriod(); + + /** + * @notice Thrown index of the deposit is invalid + * @dev Signature "0x6d97cdda" + */ error InvalidDepositIndex(); - error DepositStillLocked(); + + /** + * @notice Thrown when the deposit is locked + * @dev Signature "0xf38b9b5b" + */ + error DepositLocked(); + + /** + * @notice Thrown when there is no withdrawable amount + * @dev Signature "0x1b1d7861" + */ error NoWithdrawableAmount(); + + /** + * @notice Thrown when the recipient address is invalid + * @dev Signature "0x44d99fea" + */ error InvalidRecipientAddress(); - // Events + /** + * @notice Event emitted when a token is allowed or disallowed + * @param token The address of the token + * @param allowed Whether the token is allowed or not + */ event SetTokenIsAllowed(address indexed token, bool allowed); + + /** + * @notice Event emitted when funds are deposited into the locker + * @param user The address of the user who initiated the deposit + * @param token The address of the token being deposited + * @param amount The amount of tokens being deposited + * @param releaseTime The release time of the deposit + */ event Deposited(address indexed user, address indexed token, uint128 amount, uint128 releaseTime); - event Withdrawn(address indexed user, address indexed token, uint128 amount, address recipient); - event LockPeriodsChanged(uint128 previousMinLock, uint128 newMinLock, uint128 previousMaxLock, uint128 newMaxLock); - // Functions - function setIsAllowedToken(address token, bool allowed) external; + /** + * @notice Event emitted when funds are withdrawn from the locker + * @param user The address of the user who initiated the withdrawal + * @param token The address of the token being withdrawn + * @param amount The amount of tokens being withdrawn + * @param recipient The address that will receive the withdrawn funds + */ + event Withdrawn(address indexed user, address indexed token, uint128 amount, address indexed recipient); - function setLockPeriods(uint128 minLockPeriod, uint128 maxLockPeriod) external; + /** + * @notice Event emitted when the lock periods are changed + * @param previousMinLock The previous minimum lock period + * @param newMinLock The new minimum lock period + * @param previousMaxLock The previous maximum lock period + * @param newMaxLock The new maximum lock period + */ + event LockPeriodsChanged(uint128 previousMinLock, uint128 newMinLock, uint128 previousMaxLock, uint128 newMaxLock); + /** + * @notice Deposit tokens into the locker + * @param token The address of the token to deposit + * @param lockPeriod The lock period for the deposit + * @param permitData The permit data for the deposit + */ function deposit(address token, uint128 lockPeriod, Permit calldata permitData) external; + /** + * @notice Withdraws specified deposits for a given token and transfers the funds to the recipient + * @dev If the deposit is still locked, the function will revert + * @param token The address of the token + * @param depositIndexes An array of deposit indexes to be withdrawn + * @param recipient The address to receive the withdrawn funds + */ function withdraw(address token, uint256[] calldata depositIndexes, address recipient) external; + /** + * @notice Get deposits for a specific user and token + * @dev Amount == 0 && releaseTime > 0 = the deposit got withdrawn + * @param user The address of the user + * @param token The address of the token + * @param start The starting index of the deposits + * @param limit The maximum number of deposits to retrieve + * @return deposits An array of Deposit structs representing the deposits + */ function getDeposits(address user, address token, uint256 start, uint256 limit) external view returns (Deposit[] memory); - function getLockPeriods() external view returns (uint128, uint128); - struct Deposit { - uint128 amount; - uint128 releaseTime; - } + /** + * @notice Get all deposits for a specific token and depositor + * @dev Amount == 0 && releaseTime > 0 = the deposit got withdrawn + * @param token The address of the token + * @param depositor The address of the depositor + * @return deposits An array of Deposit structs representing the deposits + */ + function getAllDeposits(address token, address depositor) external view returns (Deposit[] memory); + + /** + * @notice Get the minimum and maximum lock periods allowed for deposits + * @return minLock The minimum lock period + * @return maxLock The maximum lock period + */ + function getLockPeriods() external view returns (uint128 minLock, uint128 maxLock); } diff --git a/mainnet-contracts/src/interface/IPufStakingPool.sol b/mainnet-contracts/src/interface/IPufStakingPool.sol index 07d83b3..6689567 100644 --- a/mainnet-contracts/src/interface/IPufStakingPool.sol +++ b/mainnet-contracts/src/interface/IPufStakingPool.sol @@ -7,32 +7,102 @@ pragma solidity >=0.8.0 <0.9.0; * @custom:security-contact security@puffer.fi */ interface IPufStakingPool { + /** + * @notice Thrown when the account is not valid + * @dev Signature "0x6d187b28" + */ error InvalidAccount(); - error InvalidAmount(); + + /** + * @notice Thrown when signature is expired + * @dev Signature "0xdf4cc36d" + */ error ExpiredSignature(); + + /** + * @notice Thrown when signature is not valid + * @dev Signature "0x8baa579f" + */ error InvalidSignature(); + + /** + * @notice Thrown when the migrator contract is not allowed + * @dev Signature "0x364938c2" + */ error MigratorContractNotAllowed(address migrator); - error Unauthorized(); + + /** + * @notice Thrown when the total deposit cap is reached + * @dev Signature "0xa5b6cbb3" + */ error TotalDepositCapReached(); + /** + * @notice Emitted when tokens are deposited into the staking pool + * @param from The address from which the tokens are deposited + * @param to The address to which the tokens are deposited + * @param amount The amount of tokens deposited + */ event Deposited(address indexed from, address indexed to, uint256 amount); + + /** + * @notice Emitted when tokens are withdrawn from the staking pool + * @param from The address from which the tokens are withdrawn + * @param to The address to which the tokens are withdrawn + * @param amount The amount of tokens withdrawn + */ event Withdrawn(address indexed from, address indexed to, uint256 amount); + + /** + * @notice Emitted when tokens are migrated + * @param depositor The address of the depositor + * @param destination The address of the destination contract + * @param migratorContract The address of the migrator contract + * @param amount The amount of tokens migrated + */ event Migrated( address indexed depositor, address indexed destination, address indexed migratorContract, uint256 amount ); /** - * @notice Function used to deposit the undelrying token + * @notice Emitted when the deposit cap of a PufStakingPool is changed + * @param oldDepositCap The previous deposit cap value + * @param newDepositCap The new deposit cap value + */ + event DepositCapChanged(uint256 oldDepositCap, uint256 newDepositCap); + + /** + * @notice Deposits the underlying token to receive pufToken to the `account` * @param depositor is the msg.sender or a parameter passed from the PufferL2Depositor * @param account is the recipient of the deposit * @param amount is the deposit amount */ function deposit(address depositor, address account, uint256 amount) external; + /** + * @notice Burns the `amount` of pufToken from the sender and returns the underlying token to the `recipient` + * @param recipient is the address that will receive the withdrawn tokens + * @param amount is the amount of tokens to be withdrawn + */ function withdraw(address recipient, uint256 amount) external; + /** + * @notice Migrates the `amount` of tokens using the allowlsited `migratorContract` to the `destination` address + * @param amount The amount of tokens to be migrated + * @param migratorContract The address of the migrator contract + * @param destination The address of the destination contract + */ function migrate(uint256 amount, address migratorContract, address destination) external; + /** + * @notice Migrates the tokens using the allowlisted migrator contract using the EIP712 signature from the depositor + * @param depositor The address of the depositor + * @param migratorContract The address of the migrator contract + * @param destination The address of the destination contract + * @param amount The amount of tokens to be migrated + * @param signatureExpiry The expiry timestamp of the signature + * @param stakerSignature The signature provided by the staker + */ function migrateWithSignature( address depositor, address migratorContract, @@ -41,6 +111,4 @@ interface IPufStakingPool { uint256 signatureExpiry, bytes memory stakerSignature ) external; - - function setDepositCap(uint256 newDepositCap) external; } diff --git a/mainnet-contracts/test/unit/PufLocker.t.sol b/mainnet-contracts/test/unit/PufLocker.t.sol index 80a0d5f..e356f58 100644 --- a/mainnet-contracts/test/unit/PufLocker.t.sol +++ b/mainnet-contracts/test/unit/PufLocker.t.sol @@ -14,6 +14,7 @@ import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy import { IAccessManaged } from "@openzeppelin/contracts/access/manager/IAccessManaged.sol"; import { ERC20Mock } from "../mocks/ERC20Mock.sol"; import { Permit } from "../../src/structs/Permit.sol"; +import { InvalidAmount } from "../../src/Errors.sol"; contract PufLockerTest is UnitTestHelper { PufLocker public pufLocker; @@ -116,7 +117,7 @@ contract PufLockerTest is UnitTestHelper { uint256 amount = 0; Permit memory permit = _signPermit(_testTemps("bob", address(pufLocker), amount, block.timestamp), mockToken.DOMAIN_SEPARATOR()); - vm.expectRevert(abi.encodeWithSelector(IPufLocker.InvalidAmount.selector)); + vm.expectRevert(abi.encodeWithSelector(InvalidAmount.selector)); pufLocker.deposit(address(mockToken), 3600, permit); // Lock for 1 hour with 0 amount vm.stopPrank(); } @@ -158,7 +159,7 @@ contract PufLockerTest is UnitTestHelper { uint256[] memory indexes = new uint256[](1); indexes[0] = 0; - vm.expectRevert(abi.encodeWithSelector(IPufLocker.DepositStillLocked.selector)); + vm.expectRevert(abi.encodeWithSelector(IPufLocker.DepositLocked.selector)); pufLocker.withdraw(address(mockToken), indexes, bob); // Attempt to withdraw before lock period ends vm.stopPrank(); } @@ -228,6 +229,10 @@ contract PufLockerTest is UnitTestHelper { PufLocker.Deposit[] memory depositsPage2 = pufLocker.getDeposits(bob, address(mockToken), 2, 1); assertEq(depositsPage2.length, 1, "Should return 1 deposit"); assertEq(depositsPage2[0].amount, amount3, "Amount of the last deposit should be 50"); + + // Get all deposits + PufLocker.Deposit[] memory allDeposits = pufLocker.getAllDeposits(bob, address(mockToken)); + assertEq(allDeposits.length, 3, "Should return 3 deposits"); vm.stopPrank(); } } diff --git a/mainnet-contracts/test/unit/PufferL2Staking.t.sol b/mainnet-contracts/test/unit/PufferL2Staking.t.sol index 9a93c3a..6423288 100644 --- a/mainnet-contracts/test/unit/PufferL2Staking.t.sol +++ b/mainnet-contracts/test/unit/PufferL2Staking.t.sol @@ -15,6 +15,7 @@ import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { ERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; import { IAccessManaged } from "@openzeppelin/contracts/access/manager/IAccessManaged.sol"; +import { InvalidAmount } from "../../src/Errors.sol"; contract MockToken is ERC20, ERC20Permit { uint8 _dec; // decimals @@ -45,6 +46,13 @@ contract MockMigrator is IMigrator { } contract PufferL2Staking is UnitTestHelper { + /** + * @notice EIP-712 type hash + */ + bytes32 internal constant _MIGRATE_TYPEHASH = keccak256( + "Migrate(address depositor,address migratorContract,address destination,address token,uint256 amount,uint256 signatureExpiry,uint256 nonce)" + ); + PufferL2Depositor depositor; MockToken dai; MockToken sixDecimal; @@ -305,21 +313,65 @@ contract PufferL2Staking is UnitTestHelper { assertEq(dai.balanceOf(mockMigrator), amount, "migrator took the tokens"); } - // function test_migrate_with_signature() public { - // test_allow_migrator(); + function test_migrate_with_signature() public { + test_allow_migrator(); - // uint256 amount = 1 ether; - // // has vm.startPrank inside of it - // test_direct_deposit_dai(amount); + uint256 amount = 1 ether; + // has vm.startPrank inside of it + test_direct_deposit_dai(amount); - // PufToken pufToken = PufToken(depositor.tokens(address(dai))); - // assertEq(pufToken.balanceOf(bob), amount, "bob got pufTokens"); + PufToken pufToken = PufToken(depositor.tokens(address(dai))); + assertEq(pufToken.balanceOf(bob), amount, "bob got pufTokens"); - // pufToken.migrate(amount, mockMigrator, bob); + bytes memory signature; + uint256 signatureExpiry = block.timestamp + 1 days; + + // Bad signature + vm.expectRevert(IPufStakingPool.InvalidSignature.selector); + pufToken.migrateWithSignature({ + depositor: bob, + migratorContract: mockMigrator, + destination: bob, + amount: amount, + signatureExpiry: signatureExpiry, + stakerSignature: signature + }); + + // Expired signature + vm.expectRevert(IPufStakingPool.ExpiredSignature.selector); + pufToken.migrateWithSignature({ + depositor: bob, + migratorContract: mockMigrator, + destination: bob, + amount: amount, + signatureExpiry: block.timestamp - 1, + stakerSignature: signature + }); + + // get bobs SK + (, uint256 bobSK) = makeAddrAndKey("bob"); + + bytes32 innerHash = + keccak256(abi.encode(_MIGRATE_TYPEHASH, bob, mockMigrator, bob, address(dai), amount, signatureExpiry, 0)); // nonce is 0 + bytes32 outerHash = keccak256(abi.encodePacked("\x19\x01", pufToken.DOMAIN_SEPARATOR(), innerHash)); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(bobSK, outerHash); + + signature = abi.encodePacked(r, s, v); // note the order here is different from line above. + + vm.startPrank(makeAddr("bot")); + // Automated bot can use signature from the Bob to do the migration + pufToken.migrateWithSignature({ + depositor: bob, + migratorContract: mockMigrator, + destination: bob, + amount: amount, + signatureExpiry: signatureExpiry, + stakerSignature: signature + }); - // assertEq(pufToken.balanceOf(bob), 0, "bob got 0 pufTokens"); - // assertEq(dai.balanceOf(mockMigrator), amount, "migrator took the tokens"); - // } + assertEq(pufToken.balanceOf(bob), 0, "bob got 0 pufTokens"); + assertEq(dai.balanceOf(mockMigrator), amount, "migrator took the tokens"); + } // deposit unsupported token function testRevert_unsupported_token(uint256 amount) public { @@ -362,7 +414,7 @@ contract PufferL2Staking is UnitTestHelper { function testRevert_zero_eth_deposit() public { vm.startPrank(bob); - vm.expectRevert(IPufStakingPool.InvalidAmount.selector); + vm.expectRevert(InvalidAmount.selector); depositor.depositETH{ value: 0 }(bob, referralCode); } @@ -469,7 +521,7 @@ contract PufferL2Staking is UnitTestHelper { // Try setting the supply cap below the current total supply vm.startPrank(OPERATIONS_MULTISIG); - vm.expectRevert(IPufStakingPool.InvalidAmount.selector); + vm.expectRevert(InvalidAmount.selector); depositor.setDepositCap(address(dai), amount - 1); } }