Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime fv #33

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Strategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ contract Strategy is BaseStrategy, Pausable, ReentrancyGuard {
address newTermController
) external onlyManagement {
require(newTermController != address(0));
require(ITermController(newTermController).getProtocolReserveAddress() != address(0));
address current = address(currTermController);
TERM_VAULT_EVENT_EMITTER.emitTermControllerUpdated(
current,
Expand All @@ -136,11 +137,13 @@ contract Strategy is BaseStrategy, Pausable, ReentrancyGuard {
function setDiscountRateAdapter(
address newAdapter
) external onlyManagement {
ITermDiscountRateAdapter newDiscountRateAdapter = ITermDiscountRateAdapter(newAdapter);
require(address(newDiscountRateAdapter.TERM_CONTROLLER()) != address(0));
TERM_VAULT_EVENT_EMITTER.emitDiscountRateAdapterUpdated(
address(discountRateAdapter),
newAdapter
);
discountRateAdapter = ITermDiscountRateAdapter(newAdapter);
discountRateAdapter = newDiscountRateAdapter;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/term/ITermController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ struct AuctionMetadata {
interface ITermController {
function isTermDeployed(address contractAddress) external view returns (bool);

function getProtocolReserveAddress() external view returns (address);

function getTermAuctionResults(bytes32 termRepoId) external view returns (AuctionMetadata[] memory auctionMetadata, uint8 numOfAuctions);
}
2 changes: 2 additions & 0 deletions src/interfaces/term/ITermDiscountRateAdapter.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.18;

import {ITermController} from "./ITermController.sol";
interface ITermDiscountRateAdapter {
function TERM_CONTROLLER() external view returns (ITermController);
function repoRedemptionHaircut(address) external view returns (uint256);
function getDiscountRate(address repoToken) external view returns (uint256);
}
4 changes: 4 additions & 0 deletions src/test/mocks/MockTermController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ contract MockTermController is ITermController {
return true;
}

function getProtocolReserveAddress() external view returns (address) {
return address(100);
}

function setOracleRate(bytes32 termRepoId, uint256 oracleRate) external {
AuctionMetadata memory metadata;

Expand Down
Loading