Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: feature: Yield Sharing #1105

Closed
wants to merge 13 commits into from
Closed

Conversation

rackstar
Copy link
Contributor

@rackstar rackstar commented May 6, 2024

Context

Closes #1102

YieldDeposit is not a great contract name, happy to hear better suggestions.

Tasks

https://nexusmutual.slack.com/archives/C06R21K595F/p1711633388892209

Cover buy

  • user deposits 100 weETH which provides a cover equivalent to 1000 weETH
  • write down the current oracle value of weETH/ETH, ex 1.2 ETH for 1 weETH
  • cover amount is 1200 ETH
  • [write down the timestamp]
  • mint an NFT

User withdrawal

  • pull the latest oracle value
  • withdrawable amount = deposit * initial_rate / current_rate
    • ex: 100 -> 100 * 1.2 / 1.3 = 92.30769230769231

Changes proposed in this pull request

  • YieldDeposit contract (need a better name!)
    • deposit
    • withdraw
    • withdrawAvailableYield - manager only

Test plan

  • deposit unit tests
  • withdraw unit tests
  • withdrawAvailableYield unit tests
  • getCurrentTokenPrice calculation unit tests
  • getCurrentTokenValue calculation unit tests
  • user coverAmount unit tests
  • price rate unit tests
    • price rate moving up withdraw / withdrawAvailableYield
    • price rate going down withdraw / withdrawAvailableYield

Checklist

  • Rebased the base branch
  • Attached corresponding Github issue
  • Prefixed the name with the type of change (i.e. feat, chore, test)
  • Performed a self-review of my own code
  • Followed the style guidelines of this project
  • Made corresponding changes to the documentation
  • Didn't generate new warnings
  • Didn't generate failures on existing tests
  • Added tests that prove my fix is effective or that my feature works

Review

When reviewing a PR, please indicate intention in comments using the following emojis:

  • 馃嵃 = Nice to have but not essential.
  • 馃挕 = Suggestion or a comment based on personal opinion
  • 馃敤 = I believe this should be changed.
  • 馃 = I don鈥檛 understand something, do you mind giving me more context?
  • 馃殌 = Feedback

@rackstar rackstar self-assigned this May 6, 2024
@rackstar rackstar requested a review from roxdanila May 6, 2024 07:54
Comment on lines 91 to 92
uint currentRate = getCurrentTokenPrice();
uint withdrawAmount = (principalAmount * initialRates[msg.sender]) / currentRate;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User withdrawal

- pull the latest oracle value
- withdrawable amount = deposit * initial_rate / current_rate
  - ex: 100 -> 100 * 1.2 / 1.3 = 92.30769230769231

@rackstar rackstar changed the title feature: Yield Sharing DRAFT: feature: Yield Sharing May 6, 2024
@roxdanila roxdanila marked this pull request as draft May 23, 2024 14:01
@roxdanila roxdanila closed this Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yield Sharing
2 participants