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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce yield rate tiers #11

Merged
merged 4 commits into from
Oct 29, 2024

Conversation

igorsenych-cw
Copy link
Collaborator

@igorsenych-cw igorsenych-cw commented Oct 28, 2024

Main changes

This pull request updates the yield calculation mechanism by replacing the YieldRate with two new structs: YieldTieredRate and RateTier. This change introduces tiered yield rates with balance caps, allowing different portions of a user's balance to accrue yield at different rates.

New structures declaration

    /**
     * @dev Structure representing a yield rate schedule that becomes effective from a specific day.
     * Contains multiple tiers, each applying a specific rate up to a balance cap.
     *
     * Fields:
     * - `effectiveDay`: The day index from which this yield rate schedule becomes effective.
     * - `tiers`: An array of `RateTier` structs defining the rate tiers.
     */
    struct YieldTieredRate {
        RateTier[] tiers;
        uint16 effectiveDay;
    }

    /**
     * @dev Structure representing a yield rate tier within a schedule.
     * Applies a specific rate to a portion of the balance up to a specified cap.
     *
     * Fields:
     * - `rate`: The yield rate value (scaled by RATE_FACTOR).
     * - `cap`: The maximum balance amount for which this rate applies.
     */
    struct RateTier {
        uint48 rate;
        uint64 cap;
    }

Yield calculation adjustments:

Yield is now calculated by applying different rates to different segments of a user's balance based on the defined tiers.
The calculation functions have been updated to iterate over the RateTier array within each YieldTieredRate.

Example:

  • Tier 1: Up to 500 BRLC, the yield is calculated at a 5% rate.
  • Tier 2: For the next 1000 BRLC, the yield is calculated at a 3% rate.
  • Tier 3: A 1% yield rate is applied for the rest of the balance.

Test Coverage

The new changes have yet to be tested.

@igorsenych-cw igorsenych-cw merged commit b98b481 into yield-streamer-v2 Oct 29, 2024
0 of 6 checks passed
@igorsenych-cw igorsenych-cw deleted the yield-streamer-v2-rate-tiers branch October 29, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant