|
1 | 1 | // SPDX-License-Identifier: UNLICENSED |
2 | 2 | pragma solidity 0.8.28; |
3 | 3 |
|
4 | | -import { Test } from "forge-std/Test.sol"; |
5 | | -import { IZToken, ZTokenMock } from "../mocks/ZTokenMock.sol"; |
6 | | -import { MockERC20 } from "../mocks/MockERC20.sol"; |
| 4 | +import {Test} from "forge-std/Test.sol"; |
| 5 | + |
| 6 | +import {IZToken, ZTokenMock} from "../mocks/ZTokenMock.sol"; |
| 7 | +import {MockERC20} from "../mocks/MockERC20.sol"; |
| 8 | +import {FixedPointMathLib} from "solady/utils/FixedPointMathLib.sol"; |
| 9 | +import {IERC20} from "forge-std/interfaces/IERC20.sol"; |
7 | 10 |
|
8 | 11 | contract ZToken is Test { |
| 12 | + using FixedPointMathLib for uint256; |
| 13 | + |
9 | 14 | ZTokenMock public zToken; |
10 | 15 | MockERC20 public underlyingToken; |
11 | 16 |
|
@@ -43,15 +48,33 @@ contract ZToken is Test { |
43 | 48 |
|
44 | 49 | function test_Mint_WhenTheAmountIsZero() external { |
45 | 50 | // it reverts |
46 | | - vm.skip(true); |
| 51 | + vm.expectRevert(); |
| 52 | + zToken.mint(0); |
47 | 53 | } |
48 | 54 |
|
49 | | - function test_Mint_WhenTheAmountIsGreaterThanZero() external { |
| 55 | + function test_Mint_WhenTheAmountIsGreaterThanZero(uint256 _zTokenAmount) external { |
| 56 | + _minValue(_zTokenAmount); |
| 57 | + |
| 58 | + uint256 underlyingTokenAmount = zToken.mint(_zTokenAmount); |
| 59 | + |
50 | 60 | // it converts the zToken amount to underlying value |
| 61 | + assertEq(zToken.getExchangeRate().mulDiv(_zTokenAmount, FixedPointMathLib.WAD), underlyingTokenAmount); |
51 | 62 | // it transfers the underlying tokens to the contract |
| 63 | + assertEq(IERC20(address(underlyingToken)).balanceOf(address(zToken)), underlyingTokenAmount); |
52 | 64 | // it mints the corresponding zTokens to the user |
| 65 | + assertEq(zToken.balanceOf(address(this)), _zTokenAmount); |
53 | 66 | // it updates the total cash balance |
| 67 | + assertEq(zToken.getTotalCash(), underlyingTokenAmount); |
54 | 68 | // it updates the reserve values and interest rate |
55 | | - vm.skip(true); |
| 69 | + assertEq(zToken.getReserves(), 0); |
| 70 | + } |
| 71 | + |
| 72 | + function test_Mint_WhenMultipleDepositAtInterval() external { |
| 73 | + // it reserve should be zero |
| 74 | + // it interest rate should still be zerp |
| 75 | + } |
| 76 | + |
| 77 | + function _minValue(uint256 _amount) internal view { |
| 78 | + _amount = bound(_amount, 1e18, type(uint64).max); |
56 | 79 | } |
57 | 80 | } |
0 commit comments