What does this pull request do? Explain your changes. (required)
As part of the internal audit process I did a manual code inspection on TenderToken and TenderFarm. In context of that this PR includes some gas optimisations for the TenderToken contract.
sharesToTokens and tokensToShares functions only have public versions however they are used internally in the TenderToken.sol contract a couple of times (e.g. L184, L192). Since these are public functions they make for external calls to its own contract. This adds a bit of gas and we can optimise by adding internal functions
mint function has a check for total pooled tokens being 0, but this check also occurs L171 in TenderToken.sol when tokensToShares() is called. This duplicated storage reads in case it’s not 0 which is fairly inefficient.
What does this pull request do? Explain your changes. (required) As part of the internal audit process I did a manual code inspection on
TenderToken
andTenderFarm
. In context of that this PR includes some gas optimisations for theTenderToken
contract.sharesToTokens
andtokensToShares
functions only havepublic
versions however they are used internally in theTenderToken.sol
contract a couple of times (e.g. L184, L192). Since these are public functions they make for external calls to its own contract. This adds a bit of gas and we can optimise by adding internal functionsProposed fix: https://github.com/Tenderize/tender-core/commit/99c94f2a342b48dc2413efbb23145888bff389d0
mint
function has a check for total pooled tokens being 0, but this check also occurs L171 inTenderToken.sol
whentokensToShares()
is called. This duplicated storage reads in case it’s not 0 which is fairly inefficient.Proposed fix: https://github.com/Tenderize/tender-core/commit/f00b70c95ab6f8a09fafe892d77124b3aebc8863
Specific updates (required)
How did you test each of these updates (required) Adjusted and ran unit tests
Does this pull request close any open issues?