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: Add acceptNewTerms and rejectNewTerms deadlines to DebtLocker #60

Merged
merged 3 commits into from
Mar 8, 2022
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
10 changes: 8 additions & 2 deletions contracts/DebtLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxiedInternals {
/*** Pool Delegate Functions ***/
/*******************************/

function acceptNewTerms(address refinancer_, bytes[] calldata calls_, uint256 amount_) external override whenProtocolNotPaused {
function acceptNewTerms(address refinancer_, uint256 deadline_, bytes[] calldata calls_, uint256 amount_) external override whenProtocolNotPaused {
require(msg.sender == _getPoolDelegate(), "DL:ANT:NOT_PD");

address loanAddress = _loan;
Expand All @@ -65,7 +65,7 @@ contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxiedInternals {
"DL:ANT:TRANSFER_FAILED"
);

IMapleLoanLike(loanAddress).acceptNewTerms(refinancer_, calls_, uint256(0));
IMapleLoanLike(loanAddress).acceptNewTerms(refinancer_, deadline_, calls_, uint256(0));

// NOTE: This must be set after accepting the new terms, which affects the loan principal.
_principalRemainingAtLastClaim = IMapleLoanLike(loanAddress).principal();
Expand All @@ -83,6 +83,12 @@ contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxiedInternals {
Liquidator(liquidator_).pullFunds(token_, destination_, amount_);
}

function rejectNewTerms(address refinancer_, uint256 deadline_, bytes[] calldata calls_) external override {
lucas-manuel marked this conversation as resolved.
Show resolved Hide resolved
require(msg.sender == _getPoolDelegate(), "DL:ANT:NOT_PD");

IMapleLoanLike(_loan).rejectNewTerms(refinancer_, deadline_, calls_);
}

function setAllowedSlippage(uint256 allowedSlippage_) external override whenProtocolNotPaused {
require(msg.sender == _getPoolDelegate(), "DL:SAS:NOT_PD");
require(allowedSlippage_ <= uint256(10_000), "DL:SAS:INVALID_SLIPPAGE");
Expand Down
11 changes: 10 additions & 1 deletion contracts/interfaces/IDebtLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ interface IDebtLocker is IMapleProxied {
/**
* @dev Accept the new loan terms and trigger a refinance.
* @param refinancer_ The address of the refinancer contract.
* @param deadline_ The deadline of the new terms proposal.
* @param calls_ The array of encoded data that are to be executed as delegatecalls by the refinancer.
* @param amount_ The amount of `fundsAsset` that is to be sent to the Loan as part of the transaction.
*/
function acceptNewTerms(address refinancer_, bytes[] calldata calls_, uint256 amount_) external;
function acceptNewTerms(address refinancer_, uint256 deadline_, bytes[] calldata calls_, uint256 amount_) external;

/**
* @dev Claims funds to send to Pool. Handles funds from payments and liquidations.
Expand Down Expand Up @@ -84,6 +85,14 @@ interface IDebtLocker is IMapleProxied {
*/
function triggerDefault() external;

/**
* @dev Reject the new loan terms.
* @param refinancer_ The address of the refinancer contract.
* @param deadline_ The deadline of the new terms proposal.
* @param calls_ The array of encoded data that are to be executed as delegatecalls by the refinancer.
*/
function rejectNewTerms(address refinancer_, uint256 deadline_, bytes[] calldata calls_) external;

/**
* @dev Sets the allowed slippage for auctioneer (used to determine expected amount to be returned in flash loan).
* @param allowedSlippage_ Basis points representation of allowed percent slippage from market price.
Expand Down
10 changes: 7 additions & 3 deletions contracts/interfaces/Interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ interface IMapleGlobalsLike {

interface IMapleLoanLike {

function acceptNewTerms(address refinancer_, bytes[] calldata calls_, uint256 amount_) external;
function acceptNewTerms(address refinancer_, uint256 deadline_, bytes[] calldata calls_, uint256 amount_) external;

function claimableFunds() external view returns (uint256 claimableFunds_);

function claimFunds(uint256 amount_, address destination_) external;

function collateralAsset() external view returns (address collateralAsset_);

function fundsAsset() external view returns (address fundsAsset_);
Expand All @@ -50,10 +52,12 @@ interface IMapleLoanLike {

function principalRequested() external view returns (uint256 principalRequested_);

function claimFunds(uint256 amount_, address destination_) external;

function repossess(address destination_) external returns (uint256 collateralAssetAmount_, uint256 fundsAssetAmount_);

function refinanceCommitment() external view returns (bytes32 refinanceCommitment_);

function rejectNewTerms(address refinancer_, uint256 deadline_, bytes[] calldata calls_) external;

}

interface IPoolLike {
Expand Down
Loading