@@ -5,7 +5,7 @@ import { IERC20Upgradeable, IPerpetualTranche, IBondController, ITranche, IFeePo
55import { IVault } from "./_interfaces/IVault.sol " ;
66import { IRolloverVault } from "./_interfaces/IRolloverVault.sol " ;
77import { IERC20Burnable } from "./_interfaces/IERC20Burnable.sol " ;
8- import { TokenAmount, RolloverData, SystemState } from "./_interfaces/CommonTypes.sol " ;
8+ import { TokenAmount, RolloverData, SystemTVL } from "./_interfaces/CommonTypes.sol " ;
99import { UnauthorizedCall, UnauthorizedTransferOut, UnexpectedDecimals, UnexpectedAsset, OutOfBounds, UnacceptableSwap, InsufficientDeployment, DeployedCountOverLimit, InsufficientLiquidity, LastRebalanceTooRecent } from "./_interfaces/ProtocolErrors.sol " ;
1010
1111import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol " ;
@@ -419,7 +419,7 @@ contract RolloverVault is
419419 IERC20Upgradeable underlying_ = underlying;
420420
421421 // Compute perp vault asset split.
422- SystemState memory s = _querySystemState (perp_);
422+ SystemTVL memory s = _querySystemTVL (perp_);
423423 uint256 underlyingAmtIntoPerp = underlyingAmtIn.mulDiv (ONE, ONE + feePolicy.targetSystemRatio ());
424424 uint256 underlyingAmtIntoVault = underlyingAmtIn - underlyingAmtIntoPerp;
425425
@@ -506,10 +506,10 @@ contract RolloverVault is
506506 /// @inheritdoc IVault
507507 function deposit (uint256 underlyingAmtIn ) external override nonReentrant whenNotPaused returns (uint256 ) {
508508 // Compute the mint fees
509- SystemState memory s = _querySystemState (perp);
509+ SystemTVL memory s = _querySystemTVL (perp);
510510 uint256 feePerc = feePolicy.computeFeePerc (
511511 feePolicy.computeDeviationRatio (s),
512- feePolicy.computeDeviationRatio (SystemState ({ perpTVL: s.perpTVL, vaultTVL: s.vaultTVL + underlyingAmtIn }))
512+ feePolicy.computeDeviationRatio (SystemTVL ({ perpTVL: s.perpTVL, vaultTVL: s.vaultTVL + underlyingAmtIn }))
513513 );
514514
515515 // Calculates the fee adjusted amount of vault notes minted when depositing `underlyingAmtIn` of underlying tokens.
@@ -537,12 +537,12 @@ contract RolloverVault is
537537 }
538538
539539 // Compute the redemption fees
540- SystemState memory s = _querySystemState (perp);
540+ SystemTVL memory s = _querySystemTVL (perp);
541541 uint256 vaultNoteSupply = totalSupply ();
542542 uint256 feePerc = feePolicy.computeFeePerc (
543543 feePolicy.computeDeviationRatio (s),
544544 feePolicy.computeDeviationRatio (
545- SystemState ({
545+ SystemTVL ({
546546 perpTVL: s.perpTVL,
547547 vaultTVL: s.vaultTVL.mulDiv (vaultNoteSupply - vaultNoteAmt, vaultNoteSupply)
548548 })
@@ -584,7 +584,7 @@ contract RolloverVault is
584584 IPerpetualTranche perp_ = perp;
585585 IERC20Upgradeable underlying_ = underlying;
586586 uint256 underlyingBalPre = underlying_.balanceOf (address (this ));
587- (uint256 perpAmtOut , , SystemState memory s ) = computeUnderlyingToPerpSwapAmt (underlyingAmtIn);
587+ (uint256 perpAmtOut , , SystemTVL memory s ) = computeUnderlyingToPerpSwapAmt (underlyingAmtIn);
588588
589589 // Revert if insufficient tokens are swapped in or out
590590 if (perpAmtOut <= 0 || underlyingAmtIn <= 0 ) {
@@ -655,24 +655,24 @@ contract RolloverVault is
655655
656656 /// @inheritdoc IRolloverVault
657657 function deviationRatio () external override nonReentrant returns (uint256 ) {
658- return feePolicy.computeDeviationRatio (_querySystemState (perp));
658+ return feePolicy.computeDeviationRatio (_querySystemTVL (perp));
659659 }
660660
661661 /// @inheritdoc IRolloverVault
662662 function computeUnderlyingToPerpSwapAmt (
663663 uint256 underlyingAmtIn
664- ) public returns (uint256 , uint256 , SystemState memory ) {
664+ ) public returns (uint256 , uint256 , SystemTVL memory ) {
665665 IPerpetualTranche perp_ = perp;
666666 // Compute equal value perps to swap out to the user
667- SystemState memory s = _querySystemState (perp_);
667+ SystemTVL memory s = _querySystemTVL (perp_);
668668 uint256 perpAmtOut = underlyingAmtIn.mulDiv (perp_.totalSupply (), s.perpTVL);
669669
670670 //-----------------------------------------------------------------------------
671671 // When user swaps underlying for vault's perps -> perps are minted by the vault
672- // We thus compute fees based on the post-mint subscription state .
672+ // We thus compute fees based on the post-mint system tvl .
673673 uint256 feePerc = feePolicy.computeFeePerc (
674674 feePolicy.computeDeviationRatio (s),
675- feePolicy.computeDeviationRatio (SystemState ({ perpTVL: s.perpTVL + underlyingAmtIn, vaultTVL: s.vaultTVL }))
675+ feePolicy.computeDeviationRatio (SystemTVL ({ perpTVL: s.perpTVL + underlyingAmtIn, vaultTVL: s.vaultTVL }))
676676 );
677677 //-----------------------------------------------------------------------------
678678
@@ -683,19 +683,19 @@ contract RolloverVault is
683683 }
684684
685685 /// @inheritdoc IRolloverVault
686- function computePerpToUnderlyingSwapAmt (uint256 perpAmtIn ) public returns (uint256 , uint256 , SystemState memory ) {
686+ function computePerpToUnderlyingSwapAmt (uint256 perpAmtIn ) public returns (uint256 , uint256 , SystemTVL memory ) {
687687 IPerpetualTranche perp_ = perp;
688688 // Compute equal value underlying tokens to swap out
689- SystemState memory s = _querySystemState (perp_);
689+ SystemTVL memory s = _querySystemTVL (perp_);
690690 uint256 underlyingAmtOut = perpAmtIn.mulDiv (s.perpTVL, perp_.totalSupply ());
691691
692692 //-----------------------------------------------------------------------------
693693 // When user swaps perps for vault's underlying -> perps are redeemed by the vault
694- // We thus compute fees based on the post-burn subscription state .
694+ // We thus compute fees based on the post-burn system tvl .
695695 uint256 feePerc = feePolicy.computeFeePerc (
696696 feePolicy.computeDeviationRatio (s),
697697 feePolicy.computeDeviationRatio (
698- SystemState ({ perpTVL: s.perpTVL - underlyingAmtOut, vaultTVL: s.vaultTVL })
698+ SystemTVL ({ perpTVL: s.perpTVL - underlyingAmtOut, vaultTVL: s.vaultTVL })
699699 )
700700 );
701701 //-----------------------------------------------------------------------------
@@ -846,7 +846,7 @@ contract RolloverVault is
846846 perp_.claimFees (address (this ));
847847 _meldPerps (perp_);
848848
849- SystemState memory s = _querySystemState (perp_);
849+ SystemTVL memory s = _querySystemTVL (perp_);
850850 int256 underlyingAmtIntoPerp = feePolicy.computeRebalanceAmount (s);
851851
852852 // When value is flowing into perp from the vault.
@@ -1068,9 +1068,9 @@ contract RolloverVault is
10681068 emit AssetSynced (token, balance);
10691069 }
10701070
1071- /// @dev Queries the current system state of the perp and vault systems.
1072- function _querySystemState (IPerpetualTranche perp_ ) private returns (SystemState memory ) {
1073- return SystemState ({ perpTVL: perp_.getTVL (), vaultTVL: getTVL () });
1071+ /// @dev Queries the current TVL of the perp and vault systems.
1072+ function _querySystemTVL (IPerpetualTranche perp_ ) private returns (SystemTVL memory ) {
1073+ return SystemTVL ({ perpTVL: perp_.getTVL (), vaultTVL: getTVL () });
10741074 }
10751075
10761076 //--------------------------------------------------------------------------
0 commit comments