Skip to content

Commit

Permalink
Fix/audit fixes round 4 (#28)
Browse files Browse the repository at this point in the history
* fix: AST-2793 and bump forge-std pointer

* fix: AST-2792

* fix: bump starport version to latest
  • Loading branch information
dangerousfood authored Jan 10, 2024
1 parent e494dae commit 081c785
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/enforcers/AstariaV1BorrowerEnforcer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract AstariaV1BorrowerEnforcer is BorrowerEnforcer {
AstariaV1Lib.validateCompoundInterest(
loanAmount,
loanRate,
AstariaV1Lib.getBaseRecallRecallMax(loanTerms.statusData), // recallMax
AstariaV1Lib.getBaseRecallMax(loanTerms.statusData), // recallMax
AstariaV1Lib.getBasePricingDecimals(loanTerms.pricingData) // decimals
);

Expand Down
2 changes: 1 addition & 1 deletion src/enforcers/AstariaV1LenderEnforcer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract AstariaV1LenderEnforcer is LenderEnforcer {
AstariaV1Lib.validateCompoundInterest(
loanAmount,
loanRate,
AstariaV1Lib.getBaseRecallRecallMax(loanTerms.statusData),
AstariaV1Lib.getBaseRecallMax(loanTerms.statusData),
AstariaV1Lib.getBasePricingDecimals(loanTerms.pricingData)
);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/AstariaV1Lib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ library AstariaV1Lib {
}
}

function getBaseRecallRecallMax(bytes memory statusData) internal pure returns (uint256 recallMax) {
function getBaseRecallMax(bytes memory statusData) internal pure returns (uint256 recallMax) {
assembly ("memory-safe") {
recallMax := mload(add(0x80, statusData))
}
Expand Down
2 changes: 1 addition & 1 deletion src/pricing/AstariaV1Pricing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ contract AstariaV1Pricing is CompoundInterestPricing {
if (msg.sender == address(this)) {
uint256 loanRate = abi.decode(loan.terms.pricingData, (BasePricing.Details)).rate;
uint256 loanAmount = loan.debt[0].amount;
uint256 recallMax = AstariaV1Lib.getBaseRecallRecallMax(loan.terms.statusData);
uint256 recallMax = AstariaV1Lib.getBaseRecallMax(loan.terms.statusData);
uint256 decimals = AstariaV1Lib.getBasePricingDecimals(loan.terms.pricingData);

AstariaV1Lib.validateCompoundInterest(loanAmount, loanRate, recallMax, decimals);
Expand Down
5 changes: 1 addition & 4 deletions src/status/BaseRecall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,10 @@ abstract contract BaseRecall {
*/
function getRecallRate(Starport.Loan calldata loan) external view returns (uint256) {
Details memory details = abi.decode(loan.terms.statusData, (Details));
BasePricing.Details memory pricingDetails = abi.decode(loan.terms.pricingData, (BasePricing.Details));
uint256 loanId = loan.getId();

// Calculates the porportion of time elapsed, then multiplies times the max rate
uint256 baseAdjustment = 10 ** pricingDetails.decimals;
uint256 ratio = (((block.timestamp - recalls[loanId].start) * baseAdjustment) / details.recallWindow);
return (details.recallMax * ratio) / baseAdjustment;
return details.recallMax * (block.timestamp - recalls[loanId].start) / details.recallWindow;
}

/**
Expand Down

0 comments on commit 081c785

Please sign in to comment.