Skip to content

Commit 5d84b60

Browse files
authored
feat: update risk engine (#246)
1 parent 37ff1e6 commit 5d84b60

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/core/RiskEngine.sol

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ contract RiskEngine is Ownable, IRiskEngine {
7575
uint amt
7676
)
7777
external
78-
view
7978
returns (bool)
8079
{
8180
uint borrowValue = _valueInWei(token, amt);
@@ -101,7 +100,6 @@ contract RiskEngine is Ownable, IRiskEngine {
101100
uint amt
102101
)
103102
external
104-
view
105103
returns (bool)
106104
{
107105
if (IAccount(account).hasNoDebt()) return true;
@@ -118,7 +116,7 @@ contract RiskEngine is Ownable, IRiskEngine {
118116
@param account Address of account
119117
@return isAccountHealthy Returns whether an account is healthy or not.
120118
*/
121-
function isAccountHealthy(address account) external view returns (bool) {
119+
function isAccountHealthy(address account) external returns (bool) {
122120
return _isAccountHealthy(
123121
_getBalance(account),
124122
_getBorrows(account)
@@ -130,7 +128,7 @@ contract RiskEngine is Ownable, IRiskEngine {
130128
@param account Address of account
131129
@return balance Total account balance
132130
*/
133-
function getBalance(address account) external view returns (uint) {
131+
function getBalance(address account) external returns (uint) {
134132
return _getBalance(account);
135133
}
136134

@@ -139,15 +137,15 @@ contract RiskEngine is Ownable, IRiskEngine {
139137
@param account Address of account
140138
@return borrows Total account borrows
141139
*/
142-
function getBorrows(address account) external view returns (uint) {
140+
function getBorrows(address account) external returns (uint) {
143141
return _getBorrows(account);
144142
}
145143

146144
/* -------------------------------------------------------------------------- */
147145
/* Internal Functions */
148146
/* -------------------------------------------------------------------------- */
149147

150-
function _getBalance(address account) internal view returns (uint) {
148+
function _getBalance(address account) internal returns (uint) {
151149
address[] memory assets = IAccount(account).getAssets();
152150
uint assetsLen = assets.length;
153151
uint totalBalance;
@@ -160,7 +158,7 @@ contract RiskEngine is Ownable, IRiskEngine {
160158
return totalBalance + account.balance;
161159
}
162160

163-
function _getBorrows(address account) internal view returns (uint) {
161+
function _getBorrows(address account) internal returns (uint) {
164162
if (IAccount(account).hasNoDebt()) return 0;
165163
address[] memory borrows = IAccount(account).getBorrows();
166164
uint borrowsLen = borrows.length;
@@ -177,7 +175,6 @@ contract RiskEngine is Ownable, IRiskEngine {
177175

178176
function _valueInWei(address token, uint amt)
179177
internal
180-
view
181178
returns (uint)
182179
{
183180
return oracle.getPrice(token)

src/interface/core/IRiskEngine.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import {IOracle} from "oracle/core/IOracle.sol";
44

55
interface IRiskEngine {
66
function initDep() external;
7-
function getBorrows(address account) external view returns (uint);
8-
function getBalance(address account) external view returns (uint);
9-
function isAccountHealthy(address account) external view returns (bool);
7+
function getBorrows(address account) external returns (uint);
8+
function getBalance(address account) external returns (uint);
9+
function isAccountHealthy(address account) external returns (bool);
1010
function isBorrowAllowed(address account, address token, uint amt)
11-
external view returns (bool);
11+
external returns (bool);
1212
function isWithdrawAllowed(address account, address token, uint amt)
13-
external view returns (bool);
13+
external returns (bool);
1414
function oracle() external view returns (IOracle);
1515
}

0 commit comments

Comments
 (0)