Skip to content

Commit

Permalink
Make policypool an internal variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gnpar committed Apr 5, 2024
1 parent 5bb5ce2 commit 12dc05d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions contracts/StableSwapPayoutHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ contract StableSwapPayoutHandler is
bytes32 public constant POLICY_CREATOR_ROLE = keccak256("POLICY_CREATOR_ROLE");
bytes32 public constant SWAP_PRICER_ROLE = keccak256("SWAP_PRICER_ROLE");

/// @custom:oz-upgrades-unsafe-allow state-variable-immutable

/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IERC20Metadata internal immutable _outStable;

IPolicyPool internal _pool;
ERC4626CashFlowLender internal _cashflowLender;
SwapLibrary.SwapConfig internal _swapConfig;
uint256 internal _swapPrice;
Expand Down Expand Up @@ -102,6 +105,7 @@ contract StableSwapPayoutHandler is
address admin
) internal onlyInitializing {
_cashflowLender = cashflowLender_;
_pool = _cashflowLender.riskModule().policyPool();
_setupRole(DEFAULT_ADMIN_ROLE, admin);

_swapConfig = swapConfig_;
Expand All @@ -113,14 +117,10 @@ contract StableSwapPayoutHandler is
}

modifier onlyPolicyPool() {
require(_msgSender() == address(_pool()), "StableSwapPayoutHandler: The caller must be the PolicyPool");
require(_msgSender() == address(_pool), "StableSwapPayoutHandler: The caller must be the PolicyPool");
_;
}

function _pool() internal view returns (IPolicyPool) {
return _cashflowLender.riskModule().policyPool();
}

/**
* @param interfaceId see {IERC165}
*/
Expand Down Expand Up @@ -268,11 +268,11 @@ contract StableSwapPayoutHandler is
function recoverPolicy(uint256 tokenId) external {
require(ownerOf(tokenId) == _msgSender(), "StableSwapPayoutHandler: you must own the NFT to recover the policy");
_burn(tokenId);
IERC721(address(_pool())).safeTransferFrom(address(this), _msgSender(), tokenId);
IERC721(address(_pool)).safeTransferFrom(address(this), _msgSender(), tokenId);
}

function currency() public view returns (IERC20Metadata) {
return _pool().currency();
return _pool.currency();
}

function outStable() public view returns (IERC20Metadata) {
Expand All @@ -291,6 +291,10 @@ contract StableSwapPayoutHandler is
return _swapConfig;
}

function pool() public view returns (IPolicyPool) {
return _pool;
}

/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
Expand Down

0 comments on commit 12dc05d

Please sign in to comment.