-
Notifications
You must be signed in to change notification settings - Fork 1
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
simulate new repo token sale #44
Conversation
WalkthroughThe changes in this pull request focus on modifying the calculation of Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
src/Strategy.sol (1)
384-390
: Improved calculation of simulated liquidity ratioThe changes in the
simulateTransaction
function improve the calculation of thesimulatedLiquidityRatio
. The new implementation handles the case whereassetValue
is zero and uses a more precise calculation method.However, there are a couple of points to consider:
- The precision of the calculation has been increased by multiplying by 10^18, which aligns with the comment from the previous review.
- The condition for zero
assetValue
is now handled explicitly, which is a good practice.Consider extracting this calculation into a separate private function for better code organization and reusability. For example:
+ function _calculateLiquidityRatio(uint256 liquidBalance, uint256 proceeds, uint256 assetValue) private pure returns (uint256) { + if (assetValue == 0) { + return 0; + } + return (liquidBalance - proceeds) * 10 ** 18 / assetValue; + } function simulateTransaction( address repoToken, uint256 amount ) external view returns ( uint256 simulatedWeightedMaturity, uint256 simulatedRepoTokenConcentrationRatio, uint256 simulatedLiquidityRatio ) { // ... (existing code) - uint256 assetValue = _totalAssetValue(liquidBalance); - - if (assetValue == 0) {simulatedLiquidityRatio = 0;} - else { - simulatedLiquidityRatio = (liquidBalance - proceeds) * 10 ** 18 / assetValue; - } + simulatedLiquidityRatio = _calculateLiquidityRatio(liquidBalance, proceeds, _totalAssetValue(liquidBalance)); // ... (rest of the function) }This refactoring would improve code readability and make it easier to reuse this calculation if needed elsewhere in the contract.
For a new repo token that hasn't been sold yet, the asset value of this new repo token is omitted from the liquid concentration calculation since it is not in the repo token list yet in the simulation.
Summary by CodeRabbit
New Features
Bug Fixes