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

Invariant testing #846

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5cdb838
Merge pull request #1 from liquity/main
cupOJoseph Jan 21, 2025
a4fb2f3
SF library import and remappings
cupOJoseph Jan 21, 2025
5e1eb39
Merge pull request #2 from NeriteOrg/stream
cupOJoseph Jan 22, 2025
7d21df8
add implementation to bold token and fix tests
cupOJoseph Jan 22, 2025
4912314
Merge pull request #3 from NeriteOrg/stream-tests
cupOJoseph Jan 22, 2025
815c134
sf permit test complete
cupOJoseph Jan 27, 2025
9bae527
Merge pull request #4 from NeriteOrg/stream-tests
cupOJoseph Jan 27, 2025
e73b63b
Merge branch 'liquity:main' into main
cupOJoseph Jan 27, 2025
403f21f
added flow test
d10r Jan 27, 2025
e44bc10
Merge pull request #5 from d10r/main
cupOJoseph Jan 27, 2025
870a082
fix inits for bold token
cupOJoseph Jan 28, 2025
07fa5e9
add new feeds
cupOJoseph Jan 28, 2025
0e333d1
Merge pull request #13 from NeriteOrg/relayers
cupOJoseph Jan 28, 2025
6926f4e
replace deal with direct mint
cupOJoseph Jan 29, 2025
ac9d0e9
Add limits
cupOJoseph Jan 30, 2025
9657a98
fix overflow
cupOJoseph Jan 30, 2025
5d3aaf0
Merge pull request #12 from NeriteOrg/init-tests
cupOJoseph Jan 30, 2025
7653dad
Merge pull request #14 from NeriteOrg/debt-limits
cupOJoseph Jan 30, 2025
7a020d4
add delegation of votesTokens
cupOJoseph Jan 30, 2025
5f405fe
Merge pull request #15 from NeriteOrg/debt-limit-tests
cupOJoseph Jan 30, 2025
ca62077
corrected price feeds
cupOJoseph Jan 31, 2025
0a085bb
update outline of feeds
cupOJoseph Jan 31, 2025
60a4d72
Merge pull request #16 from NeriteOrg/oracle-relayers
cupOJoseph Jan 31, 2025
d87de36
validate the storage layout of BoldToken
d10r Jan 31, 2025
24a544f
Merge pull request #17 from d10r/storage_test
cupOJoseph Feb 2, 2025
cb61ab7
Merge pull request #18 from liquity/main
cupOJoseph Feb 2, 2025
a0dd79e
replace new col oracles
cupOJoseph Feb 2, 2025
a6b723b
add aggregator
cupOJoseph Feb 2, 2025
b957c04
Merge pull request #19 from NeriteOrg/relayer-fix
cupOJoseph Feb 2, 2025
8a3e4af
feat: invariant testing
GalloDaSballo Feb 14, 2025
6627e07
fix: echidna linking
GalloDaSballo Feb 15, 2025
b41b1a1
chore: move the SF dependency to foundry
GalloDaSballo Feb 15, 2025
3f8891a
feat: finally works
GalloDaSballo Feb 15, 2025
d6b97c4
fix: troveManagerTester
GalloDaSballo Feb 17, 2025
cec1c6a
chore: note if some properties break
GalloDaSballo Feb 17, 2025
9422df5
fix: cleanup urgent redemptions
GalloDaSballo Feb 17, 2025
4e30a7f
fix: check MIN_DEBT if not shutdown
GalloDaSballo Feb 17, 2025
75481eb
fix: ghost varaibles in all handlers
GalloDaSballo Feb 17, 2025
b10b007
feat: all targets
GalloDaSballo Feb 17, 2025
e41aa00
chore: gitignore
GalloDaSballo Feb 17, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "contracts/lib/V2-gov"]
path = contracts/lib/V2-gov
url = https://github.com/liquity/V2-gov
[submodule "contracts/lib/superfluid-protocol-monorepo"]
path = contracts/lib/superfluid-protocol-monorepo
url = https://github.com/superfluid-finance/protocol-monorepo
5 changes: 5 additions & 0 deletions contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ testMatrix.json

# E2E broadcast logs
/broadcast-e2e

# Recon
medusa
echidna
crytic-export
39 changes: 39 additions & 0 deletions contracts/echidna.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

testMode: "assertion"
prefix: "optimize_"
coverage: true
corpusDir: "echidna"
balanceAddr: 0x1043561a8829300000
balanceContract: 0x1043561a8829300000
filterFunctions: []
cryticArgs: ["--foundry-compile-all","--compile-libraries=(CallUtils,0xf01),(CallbackUtils,0xf02),(BaseRelayRecipient,0xf03),(SuperfluidPoolDeployerLibrary,0xf04),(SolvencyHelperLibrary,0xf06),(SlotsBitmapLibrary,0xf08),(SuperfluidGovDeployerLibrary,0xf09),(SuperfluidHostDeployerLibrary,0xf0a),(SuperfluidCFAv1DeployerLibrary,0xf0b),(SuperfluidIDAv1DeployerLibrary,0xf0c),(SuperfluidPoolLogicDeployerLibrary,0xf0d),(SuperfluidGDAv1DeployerLibrary,0xf0e),(CFAv1ForwarderDeployerLibrary,0xf0f),(GDAv1ForwarderDeployerLibrary,0xf10),(SuperTokenDeployerLibrary,0xf11),(SuperfluidPoolNFTLogicDeployerLibrary,0xf12), (ProxyDeployerLibrary,0xf13),(TokenDeployerLibrary,0xf14),(SuperTokenFactoryDeployerLibrary,0xf15),(SuperfluidPeripheryDeployerLibrary,0xf16)"]
deployContracts: [
["0xf01", "CallUtils"],
["0xf02", "CallbackUtils"],
["0xf03", "BaseRelayRecipient"],
["0xf04", "SuperfluidPoolDeployerLibrary"],
["0xf06", "SolvencyHelperLibrary"],
["0xf08", "SlotsBitmapLibrary"],

["0xf09", "SuperfluidGovDeployerLibrary"],
["0xf0a", "SuperfluidHostDeployerLibrary"],
["0xf0b", "SuperfluidCFAv1DeployerLibrary"],
["0xf0c", "SuperfluidIDAv1DeployerLibrary"],
["0xf0d", "SuperfluidPoolLogicDeployerLibrary"],
["0xf0e", "SuperfluidGDAv1DeployerLibrary"],
["0xf0f", "CFAv1ForwarderDeployerLibrary"],
["0xf10", "GDAv1ForwarderDeployerLibrary"],
["0xf11", "SuperTokenDeployerLibrary"],
["0xf12", "SuperfluidPoolNFTLogicDeployerLibrary"],
["0xf13", "ProxyDeployerLibrary"],
["0xf14", "TokenDeployerLibrary"],
["0xf15", "SuperTokenFactoryDeployerLibrary"],
["0xf16", "SuperfluidPeripheryDeployerLibrary"]

]
deployer: "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496"
contractAddr: "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496"
shrinkLimit: 100000

## Deploy ERC1820RegistryCompiled as we don't have access to vm.etch
deployBytecodes: [["0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24", "608060405234801561001057600080fd5b506109c5806100206000396000f3fe608060405234801561001057600080fd5b50600436106100a5576000357c010000000000000000000000000000000000000000000000000000000090048063a41e7d5111610078578063a41e7d51146101d4578063aabbb8ca1461020a578063b705676514610236578063f712f3e814610280576100a5565b806329965a1d146100aa5780633d584063146100e25780635df8122f1461012457806365ba36c114610152575b600080fd5b6100e0600480360360608110156100c057600080fd5b50600160a060020a038135811691602081013591604090910135166102b6565b005b610108600480360360208110156100f857600080fd5b5035600160a060020a0316610570565b60408051600160a060020a039092168252519081900360200190f35b6100e06004803603604081101561013a57600080fd5b50600160a060020a03813581169160200135166105bc565b6101c26004803603602081101561016857600080fd5b81019060208101813564010000000081111561018357600080fd5b82018360208201111561019557600080fd5b803590602001918460018302840111640100000000831117156101b757600080fd5b5090925090506106b3565b60408051918252519081900360200190f35b6100e0600480360360408110156101ea57600080fd5b508035600160a060020a03169060200135600160e060020a0319166106ee565b6101086004803603604081101561022057600080fd5b50600160a060020a038135169060200135610778565b61026c6004803603604081101561024c57600080fd5b508035600160a060020a03169060200135600160e060020a0319166107ef565b604080519115158252519081900360200190f35b61026c6004803603604081101561029657600080fd5b508035600160a060020a03169060200135600160e060020a0319166108aa565b6000600160a060020a038416156102cd57836102cf565b335b9050336102db82610570565b600160a060020a031614610339576040805160e560020a62461bcd02815260206004820152600f60248201527f4e6f7420746865206d616e616765720000000000000000000000000000000000604482015290519081900360640190fd5b6103428361092a565b15610397576040805160e560020a62461bcd02815260206004820152601a60248201527f4d757374206e6f7420626520616e204552433136352068617368000000000000604482015290519081900360640190fd5b600160a060020a038216158015906103b85750600160a060020a0382163314155b156104ff5760405160200180807f455243313832305f4143434550545f4d4147494300000000000000000000000081525060140190506040516020818303038152906040528051906020012082600160a060020a031663249cb3fa85846040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182600160a060020a0316600160a060020a031681526020019250505060206040518083038186803b15801561047e57600080fd5b505afa158015610492573d6000803e3d6000fd5b505050506040513d60208110156104a857600080fd5b5051146104ff576040805160e560020a62461bcd02815260206004820181905260248201527f446f6573206e6f7420696d706c656d656e742074686520696e74657266616365604482015290519081900360640190fd5b600160a060020a03818116600081815260208181526040808320888452909152808220805473ffffffffffffffffffffffffffffffffffffffff19169487169485179055518692917f93baa6efbd2244243bfee6ce4cfdd1d04fc4c0e9a786abd3a41313bd352db15391a450505050565b600160a060020a03818116600090815260016020526040812054909116151561059a5750806105b7565b50600160a060020a03808216600090815260016020526040902054165b919050565b336105c683610570565b600160a060020a031614610624576040805160e560020a62461bcd02815260206004820152600f60248201527f4e6f7420746865206d616e616765720000000000000000000000000000000000604482015290519081900360640190fd5b81600160a060020a031681600160a060020a0316146106435780610646565b60005b600160a060020a03838116600081815260016020526040808220805473ffffffffffffffffffffffffffffffffffffffff19169585169590951790945592519184169290917f605c2dbf762e5f7d60a546d42e7205dcb1b011ebc62a61736a57c9089d3a43509190a35050565b600082826040516020018083838082843780830192505050925050506040516020818303038152906040528051906020012090505b92915050565b6106f882826107ef565b610703576000610705565b815b600160a060020a03928316600081815260208181526040808320600160e060020a031996909616808452958252808320805473ffffffffffffffffffffffffffffffffffffffff19169590971694909417909555908152600284528181209281529190925220805460ff19166001179055565b600080600160a060020a038416156107905783610792565b335b905061079d8361092a565b156107c357826107ad82826108aa565b6107b85760006107ba565b815b925050506106e8565b600160a060020a0390811660009081526020818152604080832086845290915290205416905092915050565b6000808061081d857f01ffc9a70000000000000000000000000000000000000000000000000000000061094c565b909250905081158061082d575080155b1561083d576000925050506106e8565b61084f85600160e060020a031961094c565b909250905081158061086057508015155b15610870576000925050506106e8565b61087a858561094c565b909250905060018214801561088f5750806001145b1561089f576001925050506106e8565b506000949350505050565b600160a060020a0382166000908152600260209081526040808320600160e060020a03198516845290915281205460ff1615156108f2576108eb83836107ef565b90506106e8565b50600160a060020a03808316600081815260208181526040808320600160e060020a0319871684529091529020549091161492915050565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff161590565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082526004820183905260009182919060208160248189617530fa90519096909550935050505056fea165627a7a72305820377f4a2d4301ede9949f163f319021a6e9c687c292a5e2b2c4734c126b524e6c0029"]]
1 change: 1 addition & 0 deletions contracts/lib/superfluid-protocol-monorepo
86 changes: 86 additions & 0 deletions contracts/medusa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"fuzzing": {
"workers": 16,
"workerResetLimit": 50,
"timeout": 0,
"testLimit": 0,
"callSequenceLength": 100,
"corpusDirectory": "medusa",
"coverageEnabled": true,
"deploymentOrder": [
"CryticTester"
],
"targetContracts": [
"CryticTester"
],
"targetContractsBalances": [
"0x27b46536c66c8e3000000"
],
"constructorArgs": {},
"deployerAddress": "0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496",
"senderAddresses": [
"0x10000"
],
"blockNumberDelayMax": 60480,
"blockTimestampDelayMax": 604800,
"blockGasLimit": 125000000,
"transactionGasLimit": 12500000,
"testing": {
"stopOnFailedTest": false,
"stopOnFailedContractMatching": false,
"stopOnNoTests": true,
"testAllContracts": false,
"traceAll": false,
"assertionTesting": {
"enabled": true,
"testViewMethods": true,
"panicCodeConfig": {
"failOnCompilerInsertedPanic": false,
"failOnAssertion": true,
"failOnArithmeticUnderflow": false,
"failOnDivideByZero": false,
"failOnEnumTypeConversionOutOfBounds": false,
"failOnIncorrectStorageAccess": false,
"failOnPopEmptyArray": false,
"failOnOutOfBoundsArrayAccess": false,
"failOnAllocateTooMuchMemory": false,
"failOnCallUninitializedVariable": false
}
},
"propertyTesting": {
"enabled": true,
"testPrefixes": [
"invariant_"
]
},
"optimizationTesting": {
"enabled": true,
"testPrefixes": [
"optimize_"
]
}
},
"chainConfig": {
"codeSizeCheckDisabled": true,
"cheatCodes": {
"cheatCodesEnabled": true,
"enableFFI": false
}
}
},
"compilation": {
"platform": "crytic-compile",
"platformConfig": {
"target": ".",
"solcVersion": "",
"exportDirectory": "",
"args": [
"--foundry-compile-all"
]
}
},
"logging": {
"level": "info",
"logDirectory": ""
}
}
3 changes: 3 additions & 0 deletions contracts/remappings.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
openzeppelin/=lib/V2-gov/lib/openzeppelin-contracts/
@superfluid-finance/=lib/superfluid-protocol-monorepo/packages/

27 changes: 18 additions & 9 deletions contracts/script/DeployLiquity2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,
address internal stakingV1;
address internal lusd;

uint256 MAX_INT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;

// Curve
ICurveStableswapNGFactory curveStableswapFactory;
// https://docs.curve.fi/deployments/amm/#stableswap-ng
Expand Down Expand Up @@ -190,6 +192,7 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,
uint256 SCR;
uint256 LIQUIDATION_PENALTY_SP;
uint256 LIQUIDATION_PENALTY_REDISTRIBUTION;
uint256 debtLimit;
}

struct DeploymentVars {
Expand Down Expand Up @@ -227,6 +230,9 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,
string memory saltStr = vm.envOr("SALT", block.timestamp.toString());
SALT = keccak256(bytes(saltStr));

//setup SF factories
ISuperTokenFactory superTokenFactory = ISuperTokenFactory(0x0000000000000000000000000000000000000000);

if (vm.envBytes("DEPLOYER").length == 20) {
// address
deployer = vm.envAddress("DEPLOYER");
Expand Down Expand Up @@ -262,18 +268,18 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,
// Deploy Bold or pick up existing deployment
bytes memory boldBytecode = bytes.concat(type(BoldToken).creationCode, abi.encode(deployer));
address boldAddress = vm.computeCreate2Address(SALT, keccak256(boldBytecode));
BoldToken boldToken;
IBoldToken boldToken;

if (deploymentMode.eq(DEPLOYMENT_MODE_USE_EXISTING_BOLD)) {
require(boldAddress.code.length > 0, string.concat("BOLD not found at ", boldAddress.toHexString()));
boldToken = BoldToken(boldAddress);
boldToken = IBoldToken(payable(boldAddress));

// Check BOLD is untouched
require(boldToken.totalSupply() == 0, "Some BOLD has been minted!");
require(boldToken.collateralRegistryAddress() == address(0), "Collateral registry already set");
require(boldToken.owner() == deployer, "Not BOLD owner");
require(BoldToken(payable(address(boldToken))).owner() == deployer, "Not BOLD owner");
} else {
boldToken = new BoldToken{salt: SALT}(deployer);
boldToken = IBoldToken(address(new BoldToken{salt: SALT}(deployer, superTokenFactory)));
assert(address(boldToken) == boldAddress);
}

Expand Down Expand Up @@ -322,9 +328,9 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,

TroveManagerParams[] memory troveManagerParamsArray = new TroveManagerParams[](3);
// TODO: move params out of here
troveManagerParamsArray[0] = TroveManagerParams(150e16, 110e16, 110e16, 5e16, 10e16); // WETH
troveManagerParamsArray[1] = TroveManagerParams(150e16, 120e16, 110e16, 5e16, 10e16); // wstETH
troveManagerParamsArray[2] = TroveManagerParams(150e16, 120e16, 110e16, 5e16, 10e16); // rETH
troveManagerParamsArray[0] = TroveManagerParams(150e16, 110e16, 110e16, 5e16, 10e16, MAX_INT/2); // WETH
troveManagerParamsArray[1] = TroveManagerParams(150e16, 120e16, 110e16, 5e16, 10e16, MAX_INT/2); // wstETH
troveManagerParamsArray[2] = TroveManagerParams(150e16, 120e16, 110e16, 5e16, 10e16, MAX_INT/2); // rETH

string[] memory collNames = new string[](2);
string[] memory collSymbols = new string[](2);
Expand Down Expand Up @@ -526,7 +532,7 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,

DeploymentVars memory vars;
vars.numCollaterals = troveManagerParamsArray.length;
r.boldToken = BoldToken(_deployGovernanceParams.bold);
r.boldToken = IBoldToken(payable(_deployGovernanceParams.bold));

// USDC and USDC-BOLD pool
r.usdcCurvePool = _deployCurvePool(r.boldToken, USDC);
Expand Down Expand Up @@ -588,9 +594,11 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,
_deployAddressesRegistry(troveManagerParamsArray[vars.i]);
vars.addressesRegistries[vars.i] = addressesRegistry;
vars.troveManagers[vars.i] = ITroveManager(troveManagerAddress);
//updateDebtLimit
r.collateralRegistry.updateDebtLimit(vars.i, troveManagerParamsArray[vars.i].debtLimit);
}

r.collateralRegistry = new CollateralRegistry(r.boldToken, vars.collaterals, vars.troveManagers);
r.collateralRegistry = new CollateralRegistry(r.boldToken, vars.collaterals, vars.troveManagers, msg.sender);
r.hintHelpers = new HintHelpers(r.collateralRegistry);
r.multiTroveGetter = new MultiTroveGetter(r.collateralRegistry);

Expand Down Expand Up @@ -635,6 +643,7 @@ contract DeployLiquity2Script is DeployGovernance, UniPriceConverter, StdCheats,
_troveManagerParams.CCR,
_troveManagerParams.MCR,
_troveManagerParams.SCR,
_troveManagerParams.debtLimit,
_troveManagerParams.LIQUIDATION_PENALTY_SP,
_troveManagerParams.LIQUIDATION_PENALTY_REDISTRIBUTION
);
Expand Down
27 changes: 27 additions & 0 deletions contracts/src/ActivePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity 0.8.24;

import "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import "openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Votes.sol";
import "openzeppelin-contracts/contracts/utils/math/Math.sol";

import "./Dependencies/Constants.sol";
Expand Down Expand Up @@ -61,6 +62,9 @@ contract ActivePool is IActivePool {
// Last time at which the aggregate batch fees and weighted sum were updated
uint256 public lastAggBatchManagementFeesUpdateTime;

address public governor;
address public delegateRepresentative;

// --- Events ---

event CollTokenAddressChanged(address _newCollTokenAddress);
Expand Down Expand Up @@ -88,6 +92,9 @@ contract ActivePool is IActivePool {

// Allow funds movements between Liquity contracts
collToken.approve(defaultPoolAddress, type(uint256).max);

governor = 0x108f48E558078C8eF2eb428E0774d7eCd01F6B1d;
delegateRepresentative = 0x108f48E558078C8eF2eb428E0774d7eCd01F6B1d;
}

// --- Getters for public variables. Required by IPool interface ---
Expand Down Expand Up @@ -342,4 +349,24 @@ contract ActivePool is IActivePool {
function _requireCallerIsTroveManager() internal view {
require(msg.sender == troveManagerAddress, "ActivePool: Caller is not TroveManager");
}

modifier onlyGovernor() {
require(msg.sender == governor, "ActivePool: Caller is not Governor");
_;
}

function setGovernor(address _governor) external onlyGovernor {
governor = _governor;
}

function setDelegateRepresentative(address _delegateRepresentative) external onlyGovernor {
delegateRepresentative = _delegateRepresentative;
}

//Delegate collateral tokens to delegateRepresentativecollToken
//Anyone can call this safely
function delegateTokens() external {
ERC20Votes(address(collToken)).delegate(delegateRepresentative);
}

}
7 changes: 7 additions & 0 deletions contracts/src/AddressesRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ contract AddressesRegistry is Ownable, IAddressesRegistry {
// Minimum collateral ratio for individual troves
uint256 public immutable MCR;

// Debt limit for the system
uint256 public debtLimit;

// Liquidation penalty for troves offset to the SP
uint256 public immutable LIQUIDATION_PENALTY_SP;
// Liquidation penalty for troves redistributed
Expand All @@ -43,6 +46,7 @@ contract AddressesRegistry is Ownable, IAddressesRegistry {
error InvalidCCR();
error InvalidMCR();
error InvalidSCR();
error InvalidDebtLimit();
error SPPenaltyTooLow();
error SPPenaltyGtRedist();
error RedistPenaltyTooHigh();
Expand Down Expand Up @@ -71,19 +75,22 @@ contract AddressesRegistry is Ownable, IAddressesRegistry {
uint256 _ccr,
uint256 _mcr,
uint256 _scr,
uint256 _debtLimit,
uint256 _liquidationPenaltySP,
uint256 _liquidationPenaltyRedistribution
) Ownable(_owner) {
if (_ccr <= 1e18 || _ccr >= 2e18) revert InvalidCCR();
if (_mcr <= 1e18 || _mcr >= 2e18) revert InvalidMCR();
if (_scr <= 1e18 || _scr >= 2e18) revert InvalidSCR();
if (_debtLimit <= 0) revert InvalidDebtLimit();
if (_liquidationPenaltySP < MIN_LIQUIDATION_PENALTY_SP) revert SPPenaltyTooLow();
if (_liquidationPenaltySP > _liquidationPenaltyRedistribution) revert SPPenaltyGtRedist();
if (_liquidationPenaltyRedistribution > MAX_LIQUIDATION_PENALTY_REDISTRIBUTION) revert RedistPenaltyTooHigh();

CCR = _ccr;
SCR = _scr;
MCR = _mcr;
debtLimit = _debtLimit;
LIQUIDATION_PENALTY_SP = _liquidationPenaltySP;
LIQUIDATION_PENALTY_REDISTRIBUTION = _liquidationPenaltyRedistribution;
}
Expand Down
Loading
Loading