Skip to content

Commit

Permalink
revert when fund frozen for getMergeByR
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-clippy committed Feb 1, 2024
1 parent efdc650 commit 3800f0d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion contracts/fund/PrimaryMarketV5.sol
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,10 @@ contract PrimaryMarketV5 is IPrimaryMarketV5, ReentrancyGuard, ITrancheIndexV2,
/// @return inB Spent BISHOP amount
/// @return outQ Received QUEEN amount
/// @return feeQ QUEEN amount charged as merge fee
function getMergeForR(
function getMergeByR(
uint256 inR
) public view override returns (uint256 inB, uint256 outQ, uint256 feeQ) {
require(!IFundV5(fund).frozen(), "Fund frozen");
inB = inR.mul(_weightB);
uint256 splitRatio = IFundV5(fund).splitRatio();
uint256 outQBeforeFee = inR.divideDecimal(splitRatio);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IPrimaryMarketV5.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IPrimaryMarketV5 {

function getMerge(uint256 inB) external view returns (uint256 inR, uint256 outQ, uint256 feeQ);

function getMergeForR(
function getMergeByR(
uint256 inR
) external view returns (uint256 inB, uint256 outQ, uint256 feeQ);

Expand Down
4 changes: 2 additions & 2 deletions contracts/swap/FlashSwapRouterV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract FlashSwapRouterV3 is ITranchessSwapCallee, ITrancheIndexV2, Ownable {
) external returns (uint256 quoteDelta, uint256 rookDelta) {
rookDelta = inR;
// Calculate merge result of BISHOP and ROOK into QUEEN
(uint256 inB, uint256 outQ, ) = IPrimaryMarketV5(fund.primaryMarket()).getMergeForR(inR);
(uint256 inB, uint256 outQ, ) = IPrimaryMarketV5(fund.primaryMarket()).getMergeByR(inR);
uint256 quoteAmount = IStableSwap(tranchessRouter.getSwap(fund.tokenB(), tokenQuote))
.getQuoteIn(inB);
// Calculate the redemption from QUEEN to underlying
Expand Down Expand Up @@ -138,7 +138,7 @@ contract FlashSwapRouterV3 is ITranchessSwapCallee, ITrancheIndexV2, Ownable {
uint256 inR
) external {
// Calculate merge result of BISHOP and ROOK into QUEEN
(uint256 inB, , ) = IPrimaryMarketV5(fund.primaryMarket()).getMergeForR(inR);
(uint256 inB, , ) = IPrimaryMarketV5(fund.primaryMarket()).getMergeByR(inR);
// Send the user's ROOK to this router
fund.trancheTransferFrom(TRANCHE_R, msg.sender, address(this), inR, version);
bytes memory data = abi.encode(
Expand Down

0 comments on commit 3800f0d

Please sign in to comment.