Closed 0fprod closed 8 months ago
Hello, I think you skip a step in your workflow.
Your reasoning assumes that totlaDscMinted
is 0. But is it really correct to assume that ?
What state does totalDscMinted
really correspond to ? What does the _getAccountInformation
function return ?
Oh Thank you @ibourn !
I totally missed this s_DSCMinted[msg.sender] += amountDscToMint;
in the first function call haha, it changes everything π
In my version of the contract I was doing it the other way around. First I was calling the dsc.mint
and then the mutation of the mapping that holds dsc's per user based on the bool returned π
Let's say Alice wants to mint 10 dsc for the first time. So she can call this function because it is public
Then this gets called
Then this. At this point we assume totalDscMinted and collateralValueInUsd are 0 because its her first time, Alice never deposited collateral.
And then this one. So, since totalDscMinted is 0 we would always return a very high number.
That high number is never going evaluate this expression as true
(userHealthFactor < MIN_HEALTH_FACTOR)
. So, going back to the first function call the tx is not going to be reverted despite Alice having 0 as collateral.Isnt this a mistake? Or my reasoning is wrong?
Thanks