Skip to content

Commit

Permalink
Merge branch 'master' into integrative-unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
aazhou1 authored Sep 23, 2024
2 parents 4faa1d2 + 795a0e2 commit 4651b95
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/RepoTokenUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ library RepoTokenUtils {
uint256 redemptionTimestamp,
uint256 discountRate
) internal view returns (uint256 presentValue) {
uint256 timeLeftToMaturityDayFraction =
uint256 timeLeftToMaturityDayFraction = block.timestamp > redemptionTimestamp ? 0 :
((redemptionTimestamp - block.timestamp) * purchaseTokenPrecision) / THREESIXTY_DAYCOUNT_SECONDS;

// repoTokenAmountInBaseAssetPrecision / (1 + r * days / 360)
presentValue =
(repoTokenAmountInBaseAssetPrecision * purchaseTokenPrecision) /
(purchaseTokenPrecision + (discountRate * timeLeftToMaturityDayFraction / RATE_PRECISION));

return presentValue > repoTokenAmountInBaseAssetPrecision ? repoTokenAmountInBaseAssetPrecision : presentValue;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Strategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ contract Strategy is BaseStrategy, Pausable, ReentrancyGuard {
* @notice Set the markup that the vault will receive in excess of the oracle rate
* @param newDiscountRateMarkup The new auction rate markup
*/
function setdiscountRateMarkup(
function setDiscountRateMarkup(
uint256 newDiscountRateMarkup
) external onlyManagement {
TERM_VAULT_EVENT_EMITTER.emitDiscountRateMarkupUpdated(
Expand All @@ -202,7 +202,6 @@ contract Strategy is BaseStrategy, Pausable, ReentrancyGuard {
);
discountRateMarkup = newDiscountRateMarkup;
}

/**
* @notice Set the collateral token parameters
* @param tokenAddr The address of the collateral token to be accepted
Expand Down
2 changes: 2 additions & 0 deletions src/TermAuctionList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ library TermAuctionList {
// Filter by specific repo token if provided, address(0) bypasses this filter
if (repoTokenToMatch != address(0) && offer.repoToken != repoTokenToMatch) {
// Not a match, skip
// Move to the next token in the list
current = _getNext(listData, current);
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/TestUSDCOffers.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract TestUSDCSubmitOffer is Setup {
termStrategy.setTimeToMaturityThreshold(3 weeks);
termStrategy.setRepoTokenConcentrationLimit(1e18);
termStrategy.setRequiredReserveRatio(0);
termStrategy.setdiscountRateMarkup(0);
termStrategy.setDiscountRateMarkup(0);
vm.stopPrank();

// start with some initial funds
Expand Down
6 changes: 3 additions & 3 deletions src/test/TestUSDCSellRepoToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ contract TestUSDCSellRepoToken is Setup {
termStrategy.setTimeToMaturityThreshold(10 weeks);
termStrategy.setRepoTokenConcentrationLimit(1e18);
termStrategy.setRequiredReserveRatio(0);
termStrategy.setdiscountRateMarkup(0);
termStrategy.setDiscountRateMarkup(0);
vm.stopPrank();

}
Expand Down Expand Up @@ -350,10 +350,10 @@ contract TestUSDCSellRepoToken is Setup {
assertEq(termStrategy.requiredReserveRatio(), 12345);

vm.expectRevert("!management");
termStrategy.setdiscountRateMarkup(12345);
termStrategy.setDiscountRateMarkup(12345);

vm.prank(management);
termStrategy.setdiscountRateMarkup(12345);
termStrategy.setDiscountRateMarkup(12345);
assertEq(termStrategy.discountRateMarkup(), 12345);

vm.expectRevert("!management");
Expand Down
2 changes: 1 addition & 1 deletion src/test/TestUSDCSubmitOffer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract TestUSDCSubmitOffer is Setup {
termStrategy.setTimeToMaturityThreshold(3 weeks);
termStrategy.setRepoTokenConcentrationLimit(1e18);
termStrategy.setRequiredReserveRatio(0);
termStrategy.setdiscountRateMarkup(0);
termStrategy.setDiscountRateMarkup(0);
vm.stopPrank();

// start with some initial funds
Expand Down

0 comments on commit 4651b95

Please sign in to comment.