-
Notifications
You must be signed in to change notification settings - Fork 17
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
Adds more tests to ynLSD #35
Changes from 1 commit
b884b9e
92e149d
56a8f48
8880d90
1edae2e
7205862
69a24c6
5f0d43a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,12 @@ import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.s | |
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; | ||
import {ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {AggregatorV3Interface} from "../../../src/external/chainlink/AggregatorV3Interface.sol"; | ||
import {IPausable} from "../../../src/external/eigenlayer/v0.1.0/interfaces//IPausable.sol"; | ||
import {ILSDStakingNode} from "../../../src/interfaces/ILSDStakingNode.sol"; | ||
import {TestLSDStakingNodeV2} from "../mocks/TestLSDStakingNodeV2.sol"; | ||
import {TestYnLSDV2} from "../mocks/TestYnLSDV2.sol"; | ||
import {ynBase} from "../../../src/ynBase.sol"; | ||
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
import {AggregatorV3Interface} from "src/external/chainlink/AggregatorV3Interface.sol"; | ||
import {IPausable} from "src/external/eigenlayer/v0.1.0/interfaces//IPausable.sol"; | ||
import {ILSDStakingNode} from "src/interfaces/ILSDStakingNode.sol"; | ||
import {TestLSDStakingNodeV2} from "test/foundry/mocks/TestLSDStakingNodeV2.sol"; | ||
import {TestYnLSDV2} from "test/foundry/mocks/TestYnLSDV2.sol"; | ||
import {ynBase} from "src/ynBase.sol"; | ||
|
||
|
||
contract ynLSDAssetTest is IntegrationBaseTest { | ||
|
@@ -202,6 +199,34 @@ contract ynLSDAssetTest is IntegrationBaseTest { | |
// Assert that totalAssets reflects the deposit | ||
assertEq(totalAssetsAfterDeposit, expectedBalance, "Total assets do not reflect the deposit"); | ||
} | ||
|
||
function testPreviewDeposit() public { | ||
IERC20 asset = IERC20(chainAddresses.lsd.STETH_ADDRESS); | ||
uint256 amount = 1 ether; | ||
|
||
// Obtain STETH | ||
(bool success, ) = chainAddresses.lsd.STETH_ADDRESS.call{value: amount + 1}(""); | ||
require(success, "ETH transfer failed"); | ||
uint256 balance = asset.balanceOf(address(this)); | ||
assertEq(balance, amount, "Amount not received"); | ||
|
||
uint256 previewDeposit = ynlsd.previewDeposit(asset, amount); | ||
assertTrue(amount - previewDeposit < 1e18, "Preview deposit does not match expected value"); | ||
} | ||
|
||
function testConvertToETH() public { | ||
IERC20 asset = IERC20(chainAddresses.lsd.STETH_ADDRESS); | ||
uint256 amount = 1 ether; | ||
|
||
// Obtain STETH | ||
(bool success, ) = chainAddresses.lsd.STETH_ADDRESS.call{value: amount + 1}(""); | ||
require(success, "ETH transfer failed"); | ||
uint256 balance = asset.balanceOf(address(this)); | ||
assertEq(balance, amount, "Amount not received"); | ||
|
||
uint256 ethAmount = ynlsd.convertToETH(asset, amount); | ||
assertTrue(amount - ethAmount < 1e15, "ETH amount should be greater than zero"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use compareWithThreshold? and why is the range so wide here as much as 1e15? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
} | ||
} | ||
|
||
contract ynLSDAdminTest is IntegrationBaseTest { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertion should be stronger
can we use compareWithThreshold?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1edae2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated