Lesson 12. Quick question about on Handler mintDsc #516
Answered
by
usmanfarooq91
DownShiftDom
asked this question in
Q&A
-
function mintDsc(uint256 amount) public {
(uint256 totalDscMinted, uint256 collateralValueInusd) = dsce.getAccountInformation(msg.sender);
uint256 maxDscToMint = (collateralValueInusd / 2) - totalDscMinted;
if (maxDscToMint < 0) {
return;
}
amount = bound(amount, 0, uint256(maxDscToMint));
if (amount == 0) {
return;
}
vm.startPrank(msg.sender);
dsce.mintDsc(amount);
vm.stopPrank();
}
Can someone explain why in the following code uint256 maxDscToMint = (collateralValueInusd / 2) - totalDscMinted; we divide collateralValueInUsd by 2? Sorry if this is a silly question. Its currently 1am for me and my brain is malfunctioning lol |
Beta Was this translation helpful? Give feedback.
Answered by
usmanfarooq91
Aug 2, 2023
Replies: 1 comment 1 reply
-
Suppose you deposited 100 USD worth of collateral which means you can only mint DSC half of the value of your collateral because protocol is 200% collateralized. So to determine the amount of DSC you can mint you divide it by 2 -> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
DownShiftDom
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suppose you deposited 100 USD worth of collateral which means you can only mint DSC half of the value of your collateral because protocol is 200% collateralized. So to determine the amount of DSC you can mint you divide it by 2 ->
(collateralValueInusd / 2)
and then you minus the amount of DSC you already minted ->(collateralValueInusd / 2) - totalDscMinted
.