@@ -575,9 +575,9 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
575575 /// @dev Fuzzing test to verify TOKEN_AMOUNT_BUFFER is sufficient
576576 function testFuzz_tokenAmountBuffer (uint256 bondAmount ) public {
577577 bondAmount = bound (bondAmount, 100e18 , 1_000_000e18 );
578- uint256 fundAmount1 = bondAmount / 2 ;
579- (, uint256 cost ) = _calculateMintCost ( bondAmount, true ) ;
580- uint256 fundAmount2 = cost + 10 - fundAmount1;
578+ // Ensure the fund is way more than sufficient
579+ uint256 fundAmount1 = bondAmount * 2 ;
580+ uint256 fundAmount2 = fundAmount1;
581581
582582 // Create orders
583583 IHyperdriveMatchingEngineV2.OrderIntent
@@ -1063,55 +1063,4 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
10631063 (uint8 v , bytes32 r , bytes32 s ) = vm.sign (privateKey, digest);
10641064 return abi.encodePacked (r, s, v);
10651065 }
1066-
1067- /// @dev Calculates the cost and parameters for minting positions.
1068- /// @param _bondMatchAmount The amount of bonds to mint.
1069- /// @param _asBase Whether the cost is in terms of base.
1070- /// @return maturityTime The maturity time for new positions.
1071- /// @return cost The total cost including fees.
1072- function _calculateMintCost (
1073- uint256 _bondMatchAmount ,
1074- bool _asBase
1075- ) internal view returns (uint256 maturityTime , uint256 cost ) {
1076- // Get pool configuration.
1077- IHyperdrive.PoolConfig memory config = hyperdrive.getPoolConfig ();
1078-
1079- // Calculate checkpoint and maturity time.
1080- uint256 latestCheckpoint = hyperdrive.latestCheckpoint ();
1081- maturityTime = latestCheckpoint + config.positionDuration;
1082-
1083- // Get vault share prices.
1084- uint256 vaultSharePrice = hyperdrive.convertToBase (1e18 );
1085- uint256 openVaultSharePrice = hyperdrive
1086- .getCheckpoint (latestCheckpoint)
1087- .vaultSharePrice;
1088- if (openVaultSharePrice == 0 ) {
1089- openVaultSharePrice = vaultSharePrice;
1090- }
1091-
1092- // Calculate the required fund amount.
1093- // NOTE: Round the required fund amount up to overestimate the cost.
1094- cost = _bondMatchAmount.mulDivUp (
1095- vaultSharePrice.max (openVaultSharePrice),
1096- openVaultSharePrice
1097- );
1098-
1099- // Add flat fee.
1100- // NOTE: Round the flat fee calculation up to match other flows.
1101- uint256 flatFee = _bondMatchAmount.mulUp (config.fees.flat);
1102- cost += flatFee;
1103-
1104- // Add governance fee.
1105- // NOTE: Round the governance fee calculation down to match other flows.
1106- uint256 governanceFee = 2 * flatFee.mulDown (config.fees.governanceLP);
1107- cost += governanceFee;
1108-
1109- if (_asBase) {
1110- // NOTE: Round up to overestimate the cost.
1111- cost = hyperdrive.convertToBase (cost.divUp (vaultSharePrice));
1112- } else {
1113- // NOTE: Round up to overestimate the cost.
1114- cost = cost.divUp (vaultSharePrice);
1115- }
1116- }
11171066}
0 commit comments