lindy-labs / opus_contracts

Opus Source Code
https://opus.money
Other
0 stars 0 forks source link

feat: rebase protocol owned yangs at shutdown #559

Closed tserg closed 8 months ago

tserg commented 8 months ago

Follow-up to #532.

Upon shutdown, rebase the protocol owned yang amounts to the benefit of all users.

https://github.com/code-423n4/2024-01-opus/blob/4720e9481a4fb20f4ab4140f9cc391a23ede3817/src/core/caretaker.cairo#L231-L243

Note that we first calculate the total backing with the initial yang amount included in order to transfer the assets to the Caretaker, which means that a proportional amount of the initial yang amount is also transferred to the Caretaker, to the benefit of yin holders.

Subsequently, the initial yang amount is then rebased to the benefit of trove owners.

This ensures that the rebasing of the initial yang amount is fair to both parties.