@@ -61,23 +61,18 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP {
6161 // backdate the bonds sold to the beginning of the checkpoint.
6262 // Note: All state deltas are derived from the external function input.
6363 uint256 maturityTime = latestCheckpoint + _positionDuration;
64- uint256 shareReservesDelta;
65- uint256 baseDeposit;
66- {
67- uint256 totalGovernanceFee;
68- (
69- baseDeposit,
70- shareReservesDelta,
71- totalGovernanceFee
72- ) = _calculateOpenShort (
64+ (
65+ uint256 baseDeposit ,
66+ uint256 shareReservesDelta ,
67+ uint256 totalGovernanceFee
68+ ) = _calculateOpenShort (
7369 _bondAmount,
7470 vaultSharePrice,
7571 openVaultSharePrice
7672 );
7773
78- // Attribute the governance fees.
79- _governanceFeesAccrued += totalGovernanceFee;
80- }
74+ // Attribute the governance fees.
75+ _governanceFeesAccrued += totalGovernanceFee;
8176
8277 // Take custody of the trader's deposit and ensure that the trader
8378 // doesn't pay more than their max deposit. The trader's deposit is
@@ -87,15 +82,15 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP {
8782 // Note: We don't check the maxDeposit against the output of deposit
8883 // because slippage from a deposit could cause a larger deposit taken
8984 // from the user to pass due to the shares being worth less after deposit.
90- uint256 traderDeposit = _convertToOptionFromBase (
85+ uint256 shareDeposit = _convertToOptionFromBase (
9186 baseDeposit,
9287 vaultSharePrice,
9388 _options
9489 );
95- if (_maxDeposit < traderDeposit ) {
90+ if (_maxDeposit < shareDeposit ) {
9691 revert IHyperdrive.OutputLimit ();
9792 }
98- _deposit (traderDeposit , _options);
93+ _deposit (shareDeposit , _options);
9994
10095 // Apply the state updates caused by opening the short.
10196 // Note: Updating the state using the result using the
@@ -117,18 +112,26 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP {
117112 _mint (assetId, _options.destination, bondAmount);
118113
119114 // Emit an OpenShort event.
115+ uint256 vaultSharePrice_ = vaultSharePrice;
120116 IHyperdrive.Options calldata options = _options;
121117 emit OpenShort (
122118 options.destination,
123119 assetId,
124120 maturityTime,
125121 baseDeposit,
126- baseDeposit.divDown (vaultSharePrice ),
122+ baseDeposit.divDown (vaultSharePrice_ ),
127123 options.asBase,
124+ _convertToBaseFromOption (
125+ // We add the governance fee to the share reserves delta since
126+ // the user is responsible for paying the governance fee.
127+ shareReservesDelta + totalGovernanceFee,
128+ vaultSharePrice_,
129+ options
130+ ),
128131 bondAmount
129132 );
130133
131- return (maturityTime, traderDeposit );
134+ return (maturityTime, shareDeposit );
132135 }
133136
134137 /// @dev Closes a short position with a specified maturity time.
0 commit comments