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

feat: include upfront fee incurred by batch in BatchUpdated #412

Merged
merged 1 commit into from
Sep 6, 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
2 changes: 1 addition & 1 deletion contracts/src/BorrowerOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ contract BorrowerOperations is LiquityBase, AddRemoveManagers, IBorrowerOperatio
}

troveManagerCached.onSetBatchManagerAnnualInterestRate(
msg.sender, batch.entireCollWithoutRedistribution, newDebt, _newAnnualInterestRate
msg.sender, batch.entireCollWithoutRedistribution, newDebt, _newAnnualInterestRate, batchChange.upfrontFee
);
}

Expand Down
3 changes: 2 additions & 1 deletion contracts/src/Interfaces/ITroveEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ interface ITroveEvents {
uint256 _coll,
uint256 _annualInterestRate,
uint256 _annualManagementFee,
uint256 _totalDebtShares
uint256 _totalDebtShares,
uint256 _debtIncreaseFromUpfrontFee
);

event BatchedTroveUpdated(
Expand Down
3 changes: 2 additions & 1 deletion contracts/src/Interfaces/ITroveManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ interface ITroveManager is ILiquityBase {
address _batchAddress,
uint256 _newColl,
uint256 _newDebt,
uint256 _newAnnualInterestRate
uint256 _newAnnualInterestRate,
uint256 _upfrontFee // needed by BatchUpdated event
) external;

struct OnSetInterestBatchManagerParams {
Expand Down
44 changes: 32 additions & 12 deletions contracts/src/TroveManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: batches[batchAddress].coll,
_annualInterestRate: batch.annualInterestRate,
_annualManagementFee: batch.annualManagementFee,
_totalDebtShares: batches[batchAddress].totalDebtShares
_totalDebtShares: batches[batchAddress].totalDebtShares,
_debtIncreaseFromUpfrontFee: 0
});
}

Expand Down Expand Up @@ -681,7 +682,8 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: batch.entireCollWithoutRedistribution,
_annualInterestRate: batch.annualInterestRate,
_annualManagementFee: batch.annualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
_debtIncreaseFromUpfrontFee: 0
});
}

Expand Down Expand Up @@ -1268,7 +1270,10 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: batches[_batchAddress].coll,
_annualInterestRate: batches[_batchAddress].annualInterestRate,
_annualManagementFee: batches[_batchAddress].annualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
// Although the Trove joining the batch pays an upfront fee,
// it is an individual fee, so we don't include it here
_debtIncreaseFromUpfrontFee: 0
});
}

Expand Down Expand Up @@ -1400,7 +1405,8 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: batches[_batchAddress].coll,
_annualInterestRate: batches[_batchAddress].annualInterestRate,
_annualManagementFee: batches[_batchAddress].annualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
_debtIncreaseFromUpfrontFee: 0
});
}
}
Expand Down Expand Up @@ -1507,7 +1513,10 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: batches[_batchAddress].coll,
_annualInterestRate: batches[_batchAddress].annualInterestRate,
_annualManagementFee: batches[_batchAddress].annualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
// Although the Trove being adjusted may pay an upfront fee,
// it is an individual fee, so we don't include it here
_debtIncreaseFromUpfrontFee: 0
});
}

Expand All @@ -1534,7 +1543,8 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: _newBatchColl,
_annualInterestRate: batches[_batchAddress].annualInterestRate,
_annualManagementFee: batches[_batchAddress].annualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
_debtIncreaseFromUpfrontFee: 0
});
} else {
Troves[_troveId].debt = _newTroveDebt;
Expand Down Expand Up @@ -1588,7 +1598,8 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: 0,
_annualInterestRate: _annualInterestRate,
_annualManagementFee: _annualManagementFee,
_totalDebtShares: 0
_totalDebtShares: 0,
_debtIncreaseFromUpfrontFee: 0
});
}

Expand All @@ -1612,15 +1623,17 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: _newColl,
_annualInterestRate: batches[_batchAddress].annualInterestRate,
_annualManagementFee: _newAnnualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
_debtIncreaseFromUpfrontFee: 0
});
}

function onSetBatchManagerAnnualInterestRate(
address _batchAddress,
uint256 _newColl,
uint256 _newDebt,
uint256 _newAnnualInterestRate
uint256 _newAnnualInterestRate,
uint256 _upfrontFee
) external {
_requireCallerIsBorrowerOperations();

Expand All @@ -1637,7 +1650,8 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: _newColl,
_annualInterestRate: _newAnnualInterestRate,
_annualManagementFee: batches[_batchAddress].annualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
_debtIncreaseFromUpfrontFee: _upfrontFee
});
}

Expand Down Expand Up @@ -1696,7 +1710,10 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: batches[_params.newBatchAddress].coll,
_annualInterestRate: batches[_params.newBatchAddress].annualInterestRate,
_annualManagementFee: batches[_params.newBatchAddress].annualManagementFee,
_totalDebtShares: batches[_params.newBatchAddress].totalDebtShares
_totalDebtShares: batches[_params.newBatchAddress].totalDebtShares,
// Although the Trove joining the batch may pay an upfront fee,
// it is an individual fee, so we don't include it here
_debtIncreaseFromUpfrontFee: 0
});
}

Expand Down Expand Up @@ -1827,7 +1844,10 @@ contract TroveManager is LiquityBase, ITroveManager, ITroveEvents {
_coll: batches[_batchAddress].coll,
_annualInterestRate: batches[_batchAddress].annualInterestRate,
_annualManagementFee: batches[_batchAddress].annualManagementFee,
_totalDebtShares: batches[_batchAddress].totalDebtShares
_totalDebtShares: batches[_batchAddress].totalDebtShares,
// Although the Trove leaving the batch may pay an upfront fee,
// it is an individual fee, so we don't include it here
_debtIncreaseFromUpfrontFee: 0
});
}

Expand Down
Loading