mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
liquity updates done
This commit is contained in:
parent
6211c526d8
commit
7b17bc9d40
|
@ -23,10 +23,8 @@ contract Events {
|
||||||
uint withdrawAmount,
|
uint withdrawAmount,
|
||||||
uint borrowAmount,
|
uint borrowAmount,
|
||||||
uint repayAmount,
|
uint repayAmount,
|
||||||
uint getDepositId,
|
uint[] getIds,
|
||||||
uint setWithdrawId,
|
uint[] setIds
|
||||||
uint getRepayId,
|
|
||||||
uint setBorrowId
|
|
||||||
);
|
);
|
||||||
event LogClaimCollateralFromRedemption(address indexed borrower, uint amount, uint setId);
|
event LogClaimCollateralFromRedemption(address indexed borrower, uint amount, uint setId);
|
||||||
|
|
||||||
|
|
|
@ -42,23 +42,23 @@ abstract contract LiquityResolver is Events, Helpers {
|
||||||
uint[] setIds
|
uint[] setIds
|
||||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
|
||||||
uint _depositAmount = getUint(getIds[0], depositAmount);
|
depositAmount = getUint(getIds[0], depositAmount);
|
||||||
uint _borrowAmount = getUint(getIds[1], borrowAmount);
|
borrowAmount = getUint(getIds[1], borrowAmount);
|
||||||
|
|
||||||
_depositAmount = _depositAmount == uint(-1) ? address(this).balance : _depositAmount;
|
depositAmount = depositAmount == uint(-1) ? address(this).balance : depositAmount;
|
||||||
|
|
||||||
borrowerOperations.openTrove{value: _depositAmount}(
|
borrowerOperations.openTrove{value: depositAmount}(
|
||||||
maxFeePercentage,
|
maxFeePercentage,
|
||||||
_borrowAmount,
|
borrowAmount,
|
||||||
upperHint,
|
upperHint,
|
||||||
lowerHint
|
lowerHint
|
||||||
);
|
);
|
||||||
|
|
||||||
setUint(setIds[0], _depositAmount);
|
setUint(setIds[0], depositAmount);
|
||||||
setUint(setIds[1], _borrowAmount);
|
setUint(setIds[1], borrowAmount);
|
||||||
|
|
||||||
_eventName = "LogOpen(address,uint256,uint256,uint256,uint256[],uint256[])";
|
_eventName = "LogOpen(address,uint256,uint256,uint256,uint256[],uint256[])";
|
||||||
_eventParam = abi.encode(address(this), maxFeePercentage, _depositAmount, _borrowAmount, getIds, setIds);
|
_eventParam = abi.encode(address(this), maxFeePercentage, depositAmount, borrowAmount, getIds, setIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,37 +200,40 @@ abstract contract LiquityResolver is Events, Helpers {
|
||||||
* @param repayAmount Amount of LUSD to repay
|
* @param repayAmount Amount of LUSD to repay
|
||||||
* @param upperHint Address of the Trove near the upper bound of where the user's Trove should now sit in the ordered Trove list
|
* @param upperHint Address of the Trove near the upper bound of where the user's Trove should now sit in the ordered Trove list
|
||||||
* @param lowerHint Address of the Trove near the lower bound of where the user's Trove should now sit in the ordered Trove list
|
* @param lowerHint Address of the Trove near the lower bound of where the user's Trove should now sit in the ordered Trove list
|
||||||
* @param getDepositId Optional storage slot to retrieve the ETH to deposit
|
* @param getIds Optional Get Ids for deposit, withdraw, borrow & repay
|
||||||
* @param setWithdrawId Optional storage slot to store the withdrawn ETH to
|
* @param setIds Optional Set Ids for deposit, withdraw, borrow & repay
|
||||||
* @param getRepayId Optional storage slot to retrieve the LUSD to repay
|
|
||||||
* @param setBorrowId Optional storage slot to store the LUSD borrowed
|
|
||||||
*/
|
*/
|
||||||
function adjust(
|
function adjust(
|
||||||
uint maxFeePercentage,
|
uint maxFeePercentage,
|
||||||
uint withdrawAmount,
|
|
||||||
uint depositAmount,
|
uint depositAmount,
|
||||||
|
uint withdrawAmount,
|
||||||
uint borrowAmount,
|
uint borrowAmount,
|
||||||
uint repayAmount,
|
uint repayAmount,
|
||||||
address upperHint,
|
address upperHint,
|
||||||
address lowerHint,
|
address lowerHint,
|
||||||
uint getDepositId,
|
uint[] getIds,
|
||||||
uint setWithdrawId,
|
uint[] setIds
|
||||||
uint getRepayId,
|
|
||||||
uint setBorrowId
|
|
||||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
if (getDepositId != 0 && depositAmount != 0) {
|
|
||||||
revert("adjust(): Cannot supply a depositAmount if a non-zero getDepositId is supplied");
|
|
||||||
}
|
|
||||||
if (getRepayId != 0 && repayAmount != 0) {
|
|
||||||
revert("adjust(): Cannot supply a repayAmount if a non-zero getRepayId is supplied");
|
|
||||||
}
|
|
||||||
AdjustTrove memory adjustTrove;
|
AdjustTrove memory adjustTrove;
|
||||||
|
|
||||||
adjustTrove.maxFeePercentage = maxFeePercentage;
|
adjustTrove.maxFeePercentage = maxFeePercentage;
|
||||||
adjustTrove.withdrawAmount = withdrawAmount;
|
|
||||||
adjustTrove.depositAmount = getUint(getDepositId, depositAmount);
|
depositAmount = getUint(getIds[0], depositAmount);
|
||||||
adjustTrove.borrowAmount = borrowAmount;
|
adjustTrove.depositAmount = depositAmount == uint(-1) ? address(this).balance : depositAmount;
|
||||||
adjustTrove.repayAmount = getUint(getRepayId, repayAmount);
|
|
||||||
|
withdrawAmount = getUint(getIds[1], withdrawAmount);
|
||||||
|
adjustTrove.withdrawAmount = withdrawAmount == uint(-1) ? troveManager.getTroveColl(address(this)) : withdrawAmount;
|
||||||
|
|
||||||
|
adjustTrove.borrowAmount = getUint(getIds[2], borrowAmount);
|
||||||
|
|
||||||
|
repayAmount = getUint(getIds[3], repayAmount);
|
||||||
|
if (repayAmount == uint(-1)) {
|
||||||
|
uint _lusdBal = lusdToken.balanceOf(address(this));
|
||||||
|
uint _totalDebt = troveManager.getTroveDebt(address(this));
|
||||||
|
repayAmount = _lusdBal > _totalDebt ? _totalDebt : _lusdBal;
|
||||||
|
}
|
||||||
|
adjustTrove.repayAmount = repayAmount;
|
||||||
|
|
||||||
adjustTrove.isBorrow = borrowAmount > 0;
|
adjustTrove.isBorrow = borrowAmount > 0;
|
||||||
|
|
||||||
borrowerOperations.adjustTrove{value: adjustTrove.depositAmount}(
|
borrowerOperations.adjustTrove{value: adjustTrove.depositAmount}(
|
||||||
|
@ -242,14 +245,13 @@ abstract contract LiquityResolver is Events, Helpers {
|
||||||
lowerHint
|
lowerHint
|
||||||
);
|
);
|
||||||
|
|
||||||
// Allow other spells to use the withdrawn collateral
|
setUint(setIds[0], depositAmount);
|
||||||
setUint(setWithdrawId, withdrawAmount);
|
setUint(setIds[1], withdrawAmount);
|
||||||
|
setUint(setIds[2], borrowAmount);
|
||||||
|
setUint(setIds[3], repayAmount);
|
||||||
|
|
||||||
// Allow other spells to use the borrowed amount
|
_eventName = "LogAdjust(address,uint256,uint256,uint256,uint256,uint256,uint256[],uint256[])";
|
||||||
setUint(setBorrowId, borrowAmount);
|
_eventParam = abi.encode(address(this), maxFeePercentage, depositAmount, withdrawAmount, borrowAmount, repayAmount, getIds, setIds);
|
||||||
|
|
||||||
_eventName = "LogAdjust(address,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256)";
|
|
||||||
_eventParam = abi.encode(address(this), maxFeePercentage, depositAmount, withdrawAmount, borrowAmount, repayAmount, getDepositId, setWithdrawId, getRepayId, setBorrowId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user