Created
April 7, 2023 06:07
-
-
Save JTraversa/fae47e0ca66f6f7a2aa0a2a8b5ad7dd8 to your computer and use it in GitHub Desktop.
YearnSpace-TV _wrapPreview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _wrapPreview( | |
uint256 base_ | |
) internal view virtual override returns (uint256 shares) { | |
IYVToken yvToken = IYVToken(address(sharesToken)); | |
uint256 DEGRADATION_COEFFICIENT = 10 ** 18; | |
uint256 freeFunds = yvToken.totalAssets(); | |
uint256 lockedProfit = yvToken.lockedProfit(); | |
if (lockedProfit > 0) { | |
uint256 lockedFundsRatio = (block.timestamp - | |
yvToken.lastReport()) * yvToken.lockedProfitDegradation(); | |
if (lockedFundsRatio < DEGRADATION_COEFFICIENT) { | |
freeFunds -= | |
lockedProfit - | |
((lockedFundsRatio * lockedProfit) / | |
DEGRADATION_COEFFICIENT); | |
} | |
} | |
shares = (base_ * yvToken.totalSupply()) / freeFunds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment