Cyfrin / foundry-defi-stablecoin-cu

250 stars 117 forks source link

How stablecoin pegged to $1? #39

Closed emrekocak1 closed 9 months ago

emrekocak1 commented 1 year ago

There is always a much more stablecoin against collateral because of the over-collateralization. If the liquidation percentage is 50%, then the stablecoin's price should be above $1.50. This is probably a dummy question but I couldn't figure it out.

theirrationalone commented 1 year ago

Let's say you have $2 in your bank, and you need to have a loan of $1.... Bank shall check your balance and it will calculate that even after loan allotment, you will still have $1 remained in your account eventually bank agreed to allot you loan by commencing a deed that you shall maintain your interests, threshold.

Since you took a loan from your bank, bank has right to charge some amount Or liquidate|seize|forfeit, if you don't pay interest on time.

Here you need to be persist on at least 100% collateralized always by paying interests. Bank can suffer heavy loss here why??

Since bank is providing you a loan on 100% guarantee | collateralization. But, What?? If you don't pay any interests therefore you even don't need to pay interests since you took a loan exactly the amount you had in your bank after withdrawing $1 from your bank and bank still expecting that you shall maintain your account upto the due date, but you don't and eloped during at before the due date after taking another loan from a company on the basis of your bank account balance Or statements. That company also gave you a loan of $1 on same terms&conditions, Since you still have $1 in your bank and you still have 100% amount of $1 that's true for both company as well as bank so nobody can't liquidate you till now.

Time passed... And bank freezed Or liquidated your account with a doubtful loss of interest. And eventually, after some time, that company also went to your bank to liquidate you 😂😂...

Company showed agreement and claimed their loan amount with 1% interest.

Now let's calculate the bank's loss.....

Your bank balance: $2 Loan from bank : $1 Interest: 1% for example Threshold: 100%

.... Time passed...... But before due date....

You withdraw $1 Your remaining bank balance: $1 Loan from company: $1 Interest: 1% Threshold: 100% You eloped...

.... Time passed.... On due date:...

You have your $1 + $1 loan from bank + $1 loan from company === $3 in hand.

Bank: $1 loan + $0.01 + $1 withdraw from bank + $1 + $0.01 loan + interest to company ===

= 1 + 1 + 1 + 0.01 + 0.01 ==> $3.02 - $1 remaining account balance

= $2.02 Loss.

That's why we need to maintain at least 150% collateral, this way even if we tranfer our dsc to somebody, we can't be eloped and we have to maintain 150% of it otherwise protocol has given facility to everyone participating into protocol to liquidate anybody if they reach below 150%.... So as a ceil proportion you need to maintain upto 200% collaterals.

I can be wrong ❌ here also, Please feel free to correct ✅ me.... 😉

emrekocak1 commented 1 year ago

Appreciate your detailed explanation. But I understood this over-collateralization. I wonder when this "dsc" token goes to the market, how it's pegged to $1? In the contract, there is much more USD for a DSC token. (This USD comes from collateral)

For example, if I give $10 worth of WETH and I take 5 DSC, the DSC price should be $2.

Are there other factors affecting this price?

theirrationalone commented 1 year ago

Maybe, I got Your question...

As in fact, The currect price of 1 Eth == $2000 (weth) hypo, Okay...

Now, our dsc weth token is pegged to $1 always cause it is stable. Therefore in future when 1 eth price start raising to $1, then automatically.. Eventually, our dsc weth token will be raised to $1.Since, let's say now we're in future and 1 eth prices became equals to $1 So now since we're in future now, when we retrieve our 1 dsc weth prices using aggregator it will give us 1$ in return.

E. G. :

Date: 26 Aug 2023 -> 1 eth == $2000, then 1 dsc weth token also == $2000.

Likewise....

Date 21 Aug 2051 -> 1 eth == $1, then 1 dsc weth token also == $1.

In fact, since...

Date 09 Nov 2083 -> 1 eth == $0.5, then 1 dsc weth token == $0.5 no doubt. ,

We used $1 as our unit, if u wish you can choose 0.5 Or 2000 as the $ unit. Psychological fact.

That's why it is exogenous, whenever dollar changes our dsc will also chase dollar. That's why it is dollar pegged.

Hope it helps, Maybe 😅😅😅

scoolj commented 1 year ago

Interesting perspective. Why do we have to pegged $1 = 1 sdc. What is the implication if we pegged $2 == 1dsc?

theirrationalone commented 1 year ago

Interesting perspective. Why do we have to pegged $1 = 1 sdc. What is the implication if we pegged $2 == 1dsc?

No effect to dsc even if we take this case... It is stable & anchored with $,

It's always based on Dollar ($) and its different frequencies on economic factors.

You're saying, what if $2 == 1 dsc., here dsc is still stable... $2 is a off chain data from chainlink oracle and since we're using some function here to calc. Usd equivalent values based on some tokens.

scoolj commented 1 year ago

Interesting perspective. Why do we have to pegged $1 = 1 sdc. What is the implication if we pegged $2 == 1dsc?

No effect to dsc even if we take this case... It is stable & anchored with $,

It's always based on Dollar ($) and its different frequencies on economic factors.

You're saying, what if $2 == 1 dsc., here dsc is still stable... $2 is a off chain data from chainlink oracle and since we're using some function here to calc. Usd equivalent values based on some tokens.

Nice!! Thank you.

theirrationalone commented 1 year ago

Heyy @scoolj !, to make your understanding crystal clear, I'm giving One more Simple example 😅

Pegged | Anchored to $: Dollar $ Prices risen in the real world. With ZERO Delay, DSC has risen again, equaling Dollar $. That's The STABILITY We're Talking about.

Glad I could help, It's been a pleasure collaborating with you. ♥ ;)

snnbotchway commented 1 year ago

@emrekocak1, The collateral and liquidation mechanisms are not the only factors ensuring that $1=1 DSC. In fact, their primary function is to safeguard the protocol against fluctuations in collateral prices concerning the USD.

The central and most significant factor in maintaining the 1:1 peg of $1 to 1 DSC is the reliance on Oracle price feeds. These oracles consistently convert collateral values to USD, and the entire protocol logic revolves around these USD values of the collateral assets. This ensures that the stablecoin's value remains tightly linked to the US dollar.

PatrickAlphaC commented 9 months ago

Love this conversation, thanks all!

theirrationalone commented 9 months ago

Love this conversation, thanks all!

Looking for one more GOAT, DSC (full of all possible bugs) implementation (with some T&C Promises) and auditing 🤩🤩🤩🤩🤩.... Imagining patrick's GOAT Foundry Jesus PIC 😍

PatrickAlphaC commented 8 months ago

Love this conversation, thanks all!

Looking for one more GOAT, DSC (full of all possible bugs) implementation (with some T&C Promises) and auditing 🤩🤩🤩🤩🤩.... Imagining patrick's GOAT Foundry Jesus PIC 😍

🫡🫡🫡🫡