From 79d9237b9becf9798554a9bc6818558d03bae24d Mon Sep 17 00:00:00 2001 From: C4 <81770958+code423n4@users.noreply.github.com> Date: Sun, 18 Sep 2022 22:23:34 +0200 Subject: [PATCH] Report for issue #110 updated by RaymondFam --- data/RaymondFam-G.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data/RaymondFam-G.md b/data/RaymondFam-G.md index 3b90b0a..1882e43 100644 --- a/data/RaymondFam-G.md +++ b/data/RaymondFam-G.md @@ -64,4 +64,10 @@ https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443-L } } ``` -Note: "Checked" math, which is default in 0.8.0 is not free. The compiler will add some overflow checks, somehow similar to those implemented by `SafeMath`. While it is reasonable to expect these checks to be less expensive than the current `SafeMath`, one should keep in mind that these checks will increase the cost of "basic math operation" that were not previously covered. This particularly concerns variable increments in for loops. Considering no arithmetic overflow/underflow is going to happen here, `unchecked { ++i ;}` to use the previous wrapping behavior further saves gas in the above for loop. \ No newline at end of file +Note: "Checked" math, which is default in 0.8.0 is not free. The compiler will add some overflow checks, somehow similar to those implemented by `SafeMath`. While it is reasonable to expect these checks to be less expensive than the current `SafeMath`, one should keep in mind that these checks will increase the cost of "basic math operation" that were not previously covered. This particularly concerns variable increments in for loops. Considering no arithmetic overflow/underflow is going to happen here, `unchecked { ++i ;}` to use the previous wrapping behavior further saves gas in the above for loop. + +## Turn `convertToAssets()` and `convertToShares()` into Inline Codes +https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/SemiFungibleVault.sol#L143-L153 +https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/SemiFungibleVault.sol#L159-L168 + +`previewRedeem()` and `previewDeposit()` respectively route from their returned values to `convertToAssets()` and `convertToShares()`, when the latter's codes could correspondingly be included inline with the former just like it has been done for `previewMint()` and `previewWithdraw()`. This will reduce gas both in contract size and method calling. \ No newline at end of file