ubiquity / ubiquity-dollar

Ubiquity Dollar (uAD) smart contracts and user interface.
https://uad.ubq.fi
Apache License 2.0
31 stars 82 forks source link

Feat/fractional pool #922

Closed rndquu closed 2 months ago

rndquu commented 3 months ago

This PR introduces fractional mint/redeem of the Dollar token based on the collateral ratio which represents how many tokens user has to provide in collateral and governance tokens.

How it worked before:

How it works in this PR

Example 1 (collateral ratio is 100%):

You may see that the behaviour is the same as in the previous code version when collateral ratio is 100%.

Example 2 (collateral ratio is 90%):

The main reason why we need the fractional feature from the start is to incentivise initial investors (who staked collateral to get UBQ tokens) to put liquidity in the protocol. The plan is to set collateral ratio to 95% from the start so that initial investors could mint Dollar tokens with a 5% discount which is both profitable for investors and useful for protocol (i.e. Dollar token) liquidity.

The code works the same way as in one of the popular stablecoins.

Notice:

  1. We let the admin to set the collateral ratio value while the popular stablecoin protocol uses dynamic collateral ratio. Dynamic collateral ratio works this way: if stablecoin USD price is >$1.00 for some time then global collateral ratio is dicreased, on the contrary if stablecoin USD price is <$1.00 for some time then global collateral ratio is increased. We omit this mechanic for simplicity.
  2. There is also the mechanic of decollateralization and recollateralization which works this way: a) If collateral ratio is increased from 90% to 100% (dynamically or admin set it) then the pool contains 10% of missing collateral so users can deposit collateral to the pool in exchange for Governance tokens (with some premium) until the actual collateral value hits 100%. It is called recollateralization. b) On the contrary, in case of decollateralization, if collateral ratio is decreased from 100% to 90% then the pool contains 10% of excess collateral. Users can burn their Governance tokens in exchange for collateral until the actual collateral value is 90%. Initially we plan to set collateral ratio to 95% and leave it at that level. Besides users can override fractional mechanic on mint. But should we want to update collateral ratio from 95% to some other value after the deployment we'll have to add decollateralization and recollateralization methods to the protocol so that users could rebalance the pool.

P.S. Sadly this PR modifies already audited contracts so we'll have to find somebody from the Sherlock's audit to check the updates P.P.S Diamond storage check workflow is failing which is expected and is ok since the contracts are not deployed yet. P.P.P.S. I will update mainnet and development deploy script in another PR

ubiquibot-continuous-deploys[bot] commented 3 months ago
abd3024
5fc9468
535dafb
a9cd4a6
92bc566