Skip to content

Commit

Permalink
Merge pull request #343 from tranchess/dev-terry-redeem-br
Browse files Browse the repository at this point in the history
Fix equivalent total supplies in MaturityFund
  • Loading branch information
bill-clippy authored Apr 7, 2024
2 parents 8b72821 + 329d317 commit ebe30ad
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions contracts/fund/MaturityFund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,33 @@ contract MaturityFund is
}

/// @notice Equivalent ROOK supply, as if all QUEEN are split.
function getEquivalentTotalR() public view override returns (uint256) {
function getEquivalentTotalR() public view override onlyNotFrozen returns (uint256) {
return _totalSupplies[TRANCHE_Q].multiplyDecimal(splitRatio).add(_totalSupplies[TRANCHE_R]);
}

/// @notice Equivalent BISHOP supply, as if all QUEEN are split.
function getEquivalentTotalB() public view override returns (uint256) {
function getEquivalentTotalB() public view override onlyNotFrozen returns (uint256) {
return getEquivalentTotalR().mul(weightB);
}

/// @notice Equivalent QUEEN supply, as if all BISHOP and ROOK are merged.
function getEquivalentTotalQ() public view override returns (uint256) {
return _totalSupplies[TRANCHE_R].divideDecimal(splitRatio).add(_totalSupplies[TRANCHE_Q]);
if (!frozen) {
return
_totalSupplies[TRANCHE_R].divideDecimal(splitRatio).add(_totalSupplies[TRANCHE_Q]);
} else {
uint256 settledDay = getSettledDay();
uint256 navB = _historicalNavB[settledDay];
uint256 navR = _historicalNavR[settledDay];
uint256 navSum = navB.mul(weightB).add(navR);
uint256 amountQFromB = _totalSupplies[TRANCHE_B].mul(navB).div(navSum).divideDecimal(
splitRatio
);
uint256 amountQFromR = _totalSupplies[TRANCHE_R].mul(navR).div(navSum).divideDecimal(
splitRatio
);
return _totalSupplies[TRANCHE_Q].add(amountQFromB).add(amountQFromR);
}
}

/// @notice Return the rebalance matrix at a given index. A zero struct is returned
Expand Down

0 comments on commit ebe30ad

Please sign in to comment.