-
Notifications
You must be signed in to change notification settings - Fork 85
WOETH - Fixed yield rate each day #2421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
7db7545
Initial concept
DanielVF e7b5daa
Remove reverts from startYield
DanielVF c400f5f
Remove unneeded import
DanielVF 0054c26
Add yield event, deduplicate startYield()
DanielVF 1606ac6
Tighten startYield()
DanielVF 690e81c
higher daily cap. Still way under safety reasons
DanielVF 5ffec31
There should be no yield on the block that changes happen
DanielVF 441beb6
There's something to compiling
DanielVF 2661656
Allow for negative hardAssets
DanielVF 9edd73b
Formatting cleanup
DanielVF 897acc4
Remove rate
DanielVF 79ab2d7
enhanced yield testing
DanielVF 6c0b17e
add safecasts
sparrowDom d362ea8
remove comment
sparrowDom bea7f4f
go to uint128
DanielVF 779e8e5
nicer ordering
DanielVF 8eebe1a
remove parenthesis
sparrowDom 9ae5a3e
make vars local
sparrowDom 49be3dd
nicer for prettier
DanielVF 72f382b
Cleaner elapsed calc
DanielVF f01c0b2
Cleaner to user IERC20 when not a special OETH need
DanielVF 554570c
Better error message means no override needed
DanielVF dc5473e
Remove unneeded import
DanielVF 6b95b0c
Remove unneeded using
DanielVF 8790f72
Recalc in transfers
DanielVF 3a953ea
Merge remote-tracking branch 'origin/sparrowDom/woeth_hack_proof' int…
sparrowDom b2ea11c
correct bad merge mistakes
sparrowDom 793e37a
add tests for yield start events on deposit mint redeem withdraw
sparrowDom 62fceca
Tighten pass
DanielVF c2434c2
fix compile error
sparrowDom ab81400
fix issue when a yield period should start
sparrowDom 404f407
Correct behavior, lock in no yield for usual period
DanielVF cacb9db
Better name, scheduleYield
DanielVF a15851d
Better name, userAssets
DanielVF e422a5e
Update comments
DanielVF add45c7
_min to pure
DanielVF e9801e4
Begin readme on wOETH
DanielVF 78050ef
The Rappie Simplification
DanielVF a53a8ce
readme update
DanielVF 78377f8
add test for loss of OETH underlying collateral funds by WOETH
sparrowDom dc40fe0
prettier
sparrowDom 72a1292
adjust the gap
sparrowDom 3ea2636
Rebase with deposits and withdraws
DanielVF 5e171f7
All wrapped contracts inherit from WOETH
DanielVF d8b7637
N-02 Unnecessary Casts Fix
DanielVF 8f8363c
Tests for yield doubling
DanielVF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# WOETH token | ||
|
||
An ERC4626 contract that wraps a rebasing token and allows it to be treated as a non-rebasing value accrual token. | ||
|
||
This contract distributes yield slowly over 23 hour periods. This prevents donation attacks against borrowing on lending platforms. | ||
|
||
It is designed to work only with up-only rebasing tokens. The asset token must not make reenterable external calls on transfers. | ||
|
||
We plan on minting at least 1e14 wOETH tokens on a new deploy and sending them to a dead address before any user funds are deposited. | ||
|
||
## Invariants | ||
|
||
### Yield timing | ||
|
||
Yield is distributed evenly per second from the start of a yield period at (`scheduleYield()` + 1) to the end of the period, inclusive. | ||
|
||
An example of a three second yield period. | ||
|
||
[ ~ ][Yield][Yield][Yield][ ][ ] | ||
[schedule][ ][ ][ end ][ ][ ] | ||
|
||
Yield only can happen at the start of a block, and at most once per block. As a result: | ||
|
||
> transfers do not change `totalAssets()` | ||
|
||
> scheduleYield() does not change `totalAssets()` | ||
|
||
> all other actions do not change `totalAssets()`, beyond the OETH transferred to or from the user | ||
|
||
Donations are slowed, and have no effect on the current block. Given that this contract only works off of balances, there is no difference from wOETH's point of view between an OETH donation, and an OETH rebase. | ||
|
||
> sending OETH to the contract, or positive rebasing from OETH, will not change `totalAssets()`. | ||
|
||
Yield is evenly spread. | ||
|
||
> yield given in a second, when yield is active, will be (yieldAssets / YIELD_TIME) either rounded down or rounded up. | ||
|
||
> yield given in a second, when the block timestamp is past the end date, will be 0 | ||
|
||
Because we operate on blockchains with many different block times, the per block yields may vary depending on how many active yield seconds elapse in each. | ||
|
||
### Solvency | ||
|
||
The protocol rounds against the user, in favor of the protocol | ||
|
||
> Any series of actions by a single user in a single block, will not result in an increase in their (OETH + previewRedeem(balance))[^1] | ||
|
||
> At any time, all users of the system can redeem all their wOETH | ||
|
||
> The actual redeem amounts will match previewRedeem()[^1] | ||
|
||
> `previewRedeem()` will never go down, outside of an external loss of OETH balance | ||
|
||
> The `trackedAssets` will never exceed wOETH's balance of OETH, outside of an external loss of OETH balance | ||
|
||
> The sum of `totalAssets()` will never exceed wOETH's balance of OETH, outside of an external loss of OETH balance | ||
|
||
> `trackedAssets - yieldAssets` will never be negative | ||
|
||
### 4626-ness | ||
|
||
This is an ERC4626, as such it should follow correct behaviors for an ERC4626. | ||
|
||
|
||
[^1] When OETH has sufficient transfer resolution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.