struct Trove {
tokens[],
tokenAmts[]
}
- reduced size by replacing strings with error codes like DE0, DE1,...
-0.044 KB
(commit:a0b3814
to772ac4e
)
Contains all the whitelisted collateral assets. Only these assets can be used as collateral into Troves.
- Change the License from
UNLICENSED
toMIT
. - Change the solidity version from
0.6.11
to0.8.6
. - Modified the paths of files imported.
- Removed the usage of "SafeMath.sol". So, arithmetic functions like
add
,sub
is removed. - All the storage variables used are prefixed with
diamondStorage()
function of "LibMojoDiamond.sol" file. - File formatted as per "Prettier".
- Now,
setAddresses()
function is available as 1 function only, inside "MojoDiamond.sol" file. - Reduced the contract size by
0.177 KB
in due to changes in commit hash:ce07138a8908cef874fb016a9149ecb01dee2174
"LibMojoDiamond.sol"
- The state variables of this contract are moved here into diamond storage struct.
struct CollateralParams {
// Safety ratio
uint256 ratio; // 10**18 * the ratio. i.e. ratio = .95 * 10**18 for 95%. More risky collateral has a lower ratio
address oracle;
uint256 decimals;
address priceCurve;
uint256 index;
bool active;
bool isWrapped;
address defaultRouter;
}
struct DiamondStorage {
...
IWhitelist whitelist;
IActivePool activePool;
IDefaultPool defaultPool;
// IStabilityPool stabilityPool;
ICollSurplusPool collSurplusPool;
// status of addresses set
bool addressesSet;
...
...
}
Contains all the active collateral with TCR ≥ 110% (set percentage by protocol) & active debt
- Change the License from
UNLICENSED
toMIT
. - Change the solidity version from
0.6.11
to0.8.6
. - Modified the paths of files imported.
- Removed the usage of "SafeMath.sol". So, arithmetic functions like
add
,sub
is removed. - renamed
YUSDDebt
toaUSMDebt
. poolColl
state variable is replaced byapoolColl
.- All the storage variables used are prefixed with
diamondStorage()
function of "LibMojoDiamond.sol" file. - All the require functions are referenced here from "LibMojoDiamond.sol" file.
- File formatted as per "Prettier".
- renamed the functions:
increaseUSMDebt()
decreaseUSMDebt()
- Added a utility function called
getName()
. - Now,
setAddresses()
function is available as 1 function only, inside "MojoDiamond.sol" file.
"IActivePool.sol"
- Commented the events (repetitive)
"LibMojoDiamond.sol"
- The state variables of this contract are moved here into diamond storage struct.
address borrowerOperationsAddress;
address troveManagerAddress;
address activePoolAddress;
address stabilityPoolAddress;
address defaultPoolAddress;
address troveManagerLiquidationsAddress;
address troveManagerRedemptionsAddress;
address collSurplusPoolAddress;
address hexaFinanceTreasury;
IWhitelist whitelist;
newColls apoolColl;
uint256 aUSMDebt; // USM debt of active pool
- The
require
functions are moved here. whitelist
storage variable is moved here.newColls
struct is moved here.
"MojoCustomBase.sol"
- The “MojoCustomBase.sol” has been refactored to consider gas optimization. And this is achieved by using
calldata
instead ofmemory
data location. whitelist
storage variable used is referenced from "LibMojoDiamond.sol".newColls
struct, used is referenced from "LibMojoDiamond.sol".
Contains all the liquidated collateral & closed debt
- Change the License from
UNLICENSED
toMIT
. - Change the solidity version from
0.6.11
to0.8.6
. - Modified the paths of files imported.
- Removed the usage of "SafeMath.sol". So, arithmetic functions like
add
,sub
is removed. - renamed
YUSDDebt
todUSMDebt
. poolColl
state variable is replaced bydpoolColl
.- All the require functions are referenced here from "LibMojoDiamond.sol" file.
- NEW:
_requireCallerIsActivePool()
- NEW:
- File formatted as per "Prettier".
- renamed the functions:
increaseUSMDebt()
decreaseUSMDebt()
- Added a utility function called
getName()
. - Now,
setAddresses()
function is available as 1 function only, inside "MojoDiamond.sol" file.
"IDefaultPool.sol"
- Commented the events (repetitive)
"LibMojoDiamond.sol"
- The state variables of this contract are moved here into diamond storage struct.
address borrowerOperationsAddress;
address troveManagerAddress;
address activePoolAddress;
address stabilityPoolAddress;
address defaultPoolAddress;
address troveManagerLiquidationsAddress;
address troveManagerRedemptionsAddress;
address collSurplusPoolAddress;
address hexaFinanceTreasury;
address whitelistAddress;
IWhitelist whitelist;
newColls dpoolColl;
uint256 dUSMDebt; // USM debt of default pool
- The
require
functions are moved here. whitelist
storage variable is moved here.newColls
struct is moved here.
"MojoCustomBase.sol"
All required changes are done during "ActivePool.sol" file modification.
This has been dropped as of now. Because there is no plan to use inflationary model for native token (MOJO) in order to incentivize people to stake the minted USM.
Instead the minted stablecoin is supposed to have utility in DApps like gaming, payment sector.
So, we can direct the minted stablecoins (USM) to pools like Liquidity, Lending/Borrowing in DEXes (Uniswap, Curve, etc.) and other DeFi protocols (Aave, Compound, dy/dx, etc.).
Contains all the external functions like Open/Adjust/Close trove
Here, the connected contracts are called here & its functions are used to change the respective state variables.
NO storage variables as such except:
BOOTSTRAP_PERIOD
deploymentTime
The local variables (used in the functions) are maintained in variable container structs so as to avoid
CompilerError: Stack too deep
.
- Change the License from
UNLICENSED
toMIT
. - Change the solidity version from
0.6.11
to0.8.6
. - Modified the paths of files imported.
- Removed the usage of "SafeMath.sol". So, arithmetic functions like
add
,sub
is removed. - Added a utility function called
getName()
. - Now,
setAddresses()
function is available as 1 function only, inside "MojoDiamond.sol" file. stabilityPoolAddress
dereferenced here as there is no plan to include "Stability Pool".- Following structs moved to "LibMojoDiamond.sol" file:
CollateralData
DepositFeeCalc
AdjustTrove_Params
LocalVariables_adjustTrove
LocalVariables_openTrove
CloseTrove_Params
ContractsCache
- Enum
BorrowerOperation
moved to "LibMojoDiamond.sol" file YUSDTokenAddressChanged
event renamed toUSMTokenAddressChanged
YUSDBorrowingFeePaid
event renamed toUSMBorrowingFeePaid
_requireValidMaxFeePercentage
modified by removing recovery mode var.- In
_openTroveInternal
function,- disabled recovery mode check
if
condition removed for recovery mode check & the the snippet modified to:
vars.USMFee = _triggerBorrowingFee( contractsCache.troveManager, contractsCache.usmToken, _USMAmount, vars.VC, // here it is just VC in, which is always larger than USM amount _maxFeePercentage ); _maxFeePercentage = _maxFeePercentage.sub(vars.USMFee.mul(DECIMAL_PRECISION).div(vars.VC));
if-else
condition removed as recovery mode is disabled:
if (vars.isRecoveryMode) { _requireICRisAboveCCR(vars.ICR); // ICR > CCR } else { _requireICRisAboveMCR(vars.ICR); // ICR > MCR vars.newTCR = _getNewTCRFromTroveChange(vars.VC, true, vars.compositeDebt, true); // bools: coll increase, debt increase _requireNewTCRisAboveCCR(vars.newTCR); // new_TCR > CCR }
- Solved Error:
"CompilerError: Stack too deep when compiling inline assembly: Variable headStart is 1 slot(s) too deep inside the stack."
with this:
- Manually found the function which caused this via "comment & compile" for each function. That function was
adjustTrove
. So, without this function, the file compiled successfully. But then the contract size was found to be28.457 KB
(not deployable).- All the
_require...
wrapper functions moved to 'LibMojoDiamond.sol' file. - The size is reduced by commenting the
MojoCustomBase
inheritance. Refer commit:a403f08
. Just call the function of the contract likeIMojoCustomBase(ds.mojoCustomBaseAddress)._sumColl(..)
. Hence, the size got reduced to24.004 KB
. - In
require
statements in "LibMojoDiamond.sol", reduced the size by0.139 KB
by replacing the error messages with error codes like BOE0, BOE1, ... - In
require
statements in "BorrowerOperations.sol", further reduced the size by0.065 KB
by replacing the error messages with error codes like BOE18, BOE19, ... - Reduced
0.308 KB
by modifying theReentrancyGuard
in commit:ce07138a8908cef874fb016a9149ecb01dee2174
- All the
- Make
calldata
type local variables of function tomemory
type. Source.
"IBorrowerOperations.sol"
- changed the LICENSE to MIT
- compiler version changed from
0.6.11
to0.8.6
. - Changed the name from "IYUSDToken.sol" to "IUSMToken.sol".
- renamed the events & its params.
"IUSMToken.sol"
- changed the LICENSE to MIT
- compiler version changed from
0.6.11
to0.8.6
. - Changed the name from "IYUSDToken.sol" to "IUSMToken.sol".
LiquityMath.sol
- changed the LICENSE to MIT
- compiler version changed from
0.6.11
to0.8.6
. - type changed from contract to library.
DECIMAL_PRECISION
,HALF_DECIMAL_PRECISION
are shifted to Diamond library file.
LiquityBase.sol
It is inherited by BorrowerOperations, TroveManager files.
- changed the LICENSE to MIT
- compiler version changed from
0.6.11
to0.8.6
. - all the referenced state variables are called from Diamond lib (instead of defining here) in functions.
- Disabled recovery mode i.e functions like
_checkPotentialRecoveryMode
,_checkRecoveryMode
. - Defined as
abstract
type.Note: the type
contract
type is chosen here mainly for Facets, Proxy Contract (Diamond).
"IMOJOToken.sol"
- compiler version changed from
0.6.11
to0.8.6
. - Changed the name from "IYETIToken.sol" to "IMOJOToken.sol".
"ReentrancyGuard.sol"
- Made changes in the modifier by creating private functions & then calling inside (PR-3515)