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

oak 28 #114

Merged
merged 4 commits into from
Nov 19, 2023
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 docs/test-report/mochawesome.html

Large diffs are not rendered by default.

7,625 changes: 44 additions & 7,581 deletions docs/test-report/mochawesome.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/contracts/core/common/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ library Errors {

error ADDRESS_HAS_NO_CODE(address);
error NOT_INITIALIZING();
error TO_WAD_AMOUNT_IS_NEGATIVE(int256);
error COMMON_ALREADY_INITIALIZED();
error MINTER_ALREADY_INITIALIZED();
error SCDP_ALREADY_INITIALIZED();
Expand Down Expand Up @@ -144,6 +145,7 @@ library Errors {
error NOTHING_TO_WITHDRAW(address who, ID, uint256 requested, uint256 principal, uint256 scaled);
error ACCOUNT_KRASSET_NOT_FOUND(address account, ID, address[] accountCollaterals);
error ACCOUNT_COLLATERAL_NOT_FOUND(address account, ID, address[] accountCollaterals);
error ARRAY_INDEX_OUT_OF_BOUNDS(ID element, uint256 index, address[] elements);
error ELEMENT_DOES_NOT_MATCH_PROVIDED_INDEX(ID element, uint256 index, address[] elements);
error NO_FEES_TO_CLAIM(ID asset, address claimer);
error REPAY_OVERFLOW(ID repayAsset, ID seizeAsset, uint256 invalid, uint256 valid);
Expand Down
8 changes: 4 additions & 4 deletions src/contracts/core/common/Modifiers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ contract Modifiers {
}

/**
* @notice Ensure only trusted contracts can act on behalf of `_account`
* @param _accountIsNotMsgSender The address of the collateral asset.
* @notice Check for role if the condition is true.
* @param _shouldCheckRole Should be checking the role.
*/
modifier onlyRoleIf(bool _accountIsNotMsgSender, bytes32 role) {
if (_accountIsNotMsgSender) {
modifier onlyRoleIf(bool _shouldCheckRole, bytes32 role) {
if (_shouldCheckRole) {
Auth.checkRole(role);
}
_;
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/common/Validations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ library Validations {
) internal view {
if (_amount == 0) revert Errors.ZERO_AMOUNT(Errors.id(_collateralAsset));
if (_collateralIndex > self.depositedCollateralAssets[_account].length - 1)
revert Errors.ELEMENT_DOES_NOT_MATCH_PROVIDED_INDEX(
revert Errors.ARRAY_INDEX_OUT_OF_BOUNDS(
Errors.id(_collateralAsset),
_collateralIndex,
self.depositedCollateralAssets[_account]
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/common/funcs/Actions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function burnSCDP(Asset storage _asset, uint256 _burnAmount, address _fromAddr)
/// @param _toAddr the account to mint the assets to
/// @return issued Normalized amount of minted assets.
function mintSCDP(Asset storage _asset, uint256 _mintAmount, address _toAddr) returns (uint256 issued) {
if (!_asset.marketStatus()) revert Errors.MARKET_CLOSED(Errors.id(_asset.anchor), _asset.ticker.toString());
if (!_asset.isMarketOpen()) revert Errors.MARKET_CLOSED(Errors.id(_asset.anchor), _asset.ticker.toString());
issued = mintKrAsset(_mintAmount, _toAddr, _asset.anchor);
unchecked {
sdi().totalDebt += _asset.debtAmountToSDI(_mintAmount, false);
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/common/funcs/Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ library Assets {
return Redstone.getPrice(self.ticker);
}

function marketStatus(Asset storage) internal pure returns (bool) {
function isMarketOpen(Asset storage) internal pure returns (bool) {
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/contracts/core/common/funcs/Math.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.21;

import {WadRay} from "libs/WadRay.sol";
import {PercentageMath} from "libs/PercentageMath.sol";
import {Errors} from "common/Errors.sol";

using WadRay for uint256;
using PercentageMath for uint256;
Expand Down Expand Up @@ -47,6 +48,9 @@ function toWad(uint256 _amount, uint8 _decimals) pure returns (uint256) {
}

function toWad(int256 _amount, uint8 _decimals) pure returns (uint256) {
if (_amount < 0) {
revert Errors.TO_WAD_AMOUNT_IS_NEGATIVE(_amount);
}
return toWad(uint256(_amount), _decimals);
}

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/minter/facets/MinterMintFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract MinterMintFacet is IMinterMintFacet, Modifiers {

MinterState storage s = ms();

if (!asset.marketStatus()) revert Errors.MARKET_CLOSED(Errors.id(_krAsset), asset.ticker.toString());
if (!asset.isMarketOpen()) revert Errors.MARKET_CLOSED(Errors.id(_krAsset), asset.ticker.toString());

uint256 newSupply = IKreskoAsset(_krAsset).totalSupply() + _mintAmount;
if (newSupply > asset.maxDebtMinter) {
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/periphery/DataV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ contract DataV1 is ProxyConnector, IDataV1 {
tSupply: asset.token.totalSupply(),
vSupply: asset.token.balanceOf(VAULT),
price: answer > 0 ? uint256(answer) : 0,
marketStatus: answer > 0 ? true : false,
isMarketOpen: answer > 0 ? true : false,
oracleDecimals: asset.feed.decimals(),
priceRaw: RawPrice(
answer,
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/periphery/IDataV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {VaultAsset} from "vault/VTypes.sol";
interface IDataV1 {
struct DVAsset {
address addr;
bool marketStatus;
bool isMarketOpen;
uint8 oracleDecimals;
string name;
string symbol;
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/periphery/PFuncs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ library PFunc {
name: token.name(),
tSupply: token.totalSupply(),
price: uint256(price.answer),
marketStatus: asset.marketStatus(),
isMarketOpen: asset.isMarketOpen(),
priceRaw: price,
config: asset
});
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/core/periphery/PTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ library PType {
string symbol;
uint256 tSupply;
uint256 price;
bool marketStatus;
bool isMarketOpen;
RawPrice priceRaw;
Asset config;
}
Expand Down
1 change: 1 addition & 0 deletions src/contracts/core/scdp/facets/SCDPSwapFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ contract SCDPSwapFacet is ISCDPSwapFacet, Modifiers {
} else {
amountOut = assetIn.krAssetUSD(_amountIn).wadDiv(assetOut.price());
feeAmount = amountOut.percentMul(feePercentage);
amountOut = amountOut - feeAmount;
feeAmountProtocol = feeAmount.percentMul(protocolFee);
feeAmount -= feeAmountProtocol;
}
Expand Down