Fractional Wrapper
alcueca opened this issue · 1 comments
Exercise name: Fractional Wrapper
Assignment #: 4
Track: Smart contracts
Testing framework: Foundry
Deployment framework: Foundry (forge create)
Node provider: Alchemy
Target network: Optimism-Kovan
Assignment summary
The implementation of financial instruments requires math, sometimes very complex. Ethereum is very limited as a computer, both in storage and in raw computing power. Overcoming this mismatch requires a complete re-thinking about how math is done. The first stumbling block is fixed point math.
As with the previous assignment, users can send a pre-specified erc-20 token, that we will call underlying, to a contract that also is an erc-20, and that we will call Fractional Wrapper.
The Fractional Wrapper contract issues a number of Wrapper tokens to the sender equal to the deposit multiplied by a fractional number, called exchange rate, set by the contract owner. This number is in the range of [0, 1000000000000000000], and available in increments of 10**-27.
At any point, a holder of Wrapper tokens can burn them to recover an amount of underlying equal to the amount of Wrapper tokens burned, divided by the exchange rate.
To complete this assignment you will need to look into Fixed Point Math. This might be a good point to start. We also have fixed point math libraries in Yield Utils v2
Additional Details
None
Peripheral Goals
As the assignments get more complicated to code, they also get more complicated to review, more so for code reviewers that might not be familiar with the use case, such as auditors. Please read this thread and write a few paragraphs as you solve the assignment, to give context to a potential auditor.
This Fractional Wrapper can conform to the ERC4626 specification. Make it so. The implementation of convert* and preview* will be identical in this case (no need to calculate some time-weighted average for convert*).
As the assignments get more complicated to code, they also get more complicated to review, more so for code reviewers that might not be familiar with the use case, such as auditors. Please read this thread and write a few paragraphs as you solve the assignment, to give context to a potential auditor.
This Fractional Wrapper can conform to the ERC4626 specification. Make it so. The implementation of convert* and preview* will be identical in this case (no need to calculate some time-weighted average for convert*).
Note to self, consider an accumulator for the asset balance and proportional ownership, instead of a governor-set exchange rate.