Skip to content

Commit

Permalink
Merge pull request #33 from term-finance/runtime-fv
Browse files Browse the repository at this point in the history
Runtime fv
  • Loading branch information
aazhou1 authored Sep 12, 2024
2 parents 58d88c2 + ababe5d commit 83a2484
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
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

0 comments on commit 83a2484

Please sign in to comment.