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

Adds more tests to ynLSD #35

Merged
merged 8 commits into from
Mar 13, 2024

Conversation

xhad
Copy link
Contributor

@xhad xhad commented Mar 8, 2024

No description provided.

Copy link

@xhad xhad requested a review from danoctavian March 8, 2024 02:51
assertEq(balance, amount, "Amount not received");

uint256 previewDeposit = ynlsd.previewDeposit(asset, amount);
assertTrue(amount - previewDeposit < 1e18, "Preview deposit does not match expected value");
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

assertEq(balance, amount, "Amount not received");

uint256 ethAmount = ynlsd.convertToETH(asset, amount);
assertTrue(amount - ethAmount < 1e15, "ETH amount should be greater than zero");
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

// Note, STETH returns aprx 9.987e17 SETH for 1 ether

uint256 previewDeposit = ynlsd.previewDeposit(asset, amount);
assertTrue(compareWithThreshold(amount, previewDeposit, 1.2e16), "Preview deposit does not match expected value");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be strictly equal with

        IERC20 asset = IERC20(chainAddresses.lsd.STETH_ADDRESS);
        uint256 amount = 1 ether;
        
        AggregatorV3Interface priceFeed = AggregatorV3Interface(chainAddresses.lsd.STETH_FEED_ADDRESS);
        (, int256 price,,,) = priceFeed.latestRoundData();
        uint256 stethPrice = uint256(price);

        uint expectedDepositPreview = amount * stethPrice / 1e18;
        uint256 previewDeposit = ynlsd.previewDeposit(asset, amount);
        assertEq(previewDeposit, expectedDepositPreview, "Preview deposit does not match expected value");
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@xhad xhad requested a review from danoctavian March 12, 2024 03:06
@danoctavian danoctavian merged commit 29293d8 into release-candidate Mar 13, 2024
@xhad xhad deleted the chad/sc-133/more-yneth-coverage branch March 16, 2024 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants