feat: add regression-test#495
Merged
Merged
Conversation
|
@ONEONUORA Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
3 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
close #484
close #482
close #483
close #481
This PR implements curve presets (
Linear,Quadratic,Flat), ensures buy and sell quote symmetry for theFlatpreset, and verifies that peer-to-peer key transfers preserve claimable dividend balances.Features & Changes
1. Curve Presets
CurvePresetEnum: Added a new contract enum:Linear(0),Quadratic(1), andFlat(2).DataKey::CurvePreset(Address).compute_bonding_curve_priceto dispatch pricing logic depending on the creator's curve preset:Flat: Returnsbase_price(constant price model regardless of supply/slope).Linear: Returnsbase_price + slope * supply.Quadratic: Returnsbase_price + slope * supply * supply.curve_preset: Option<CurvePreset>toregister_creator. It defaults toCurvePreset::Linearto maintain backwards compatibility with existing tests.get_curve_presetView: Added a read-only entrypoint to query a creator's preset. Reverts withNotRegisteredif the creator doesn't exist.2. Quote and Price Symmetry
sell_keyandget_sell_quoteto calculate the price usingsupply - 1instead ofsupply.sell_keyto avoid falseSellUnderflowerrors when the supply is 0.3. P2P Key Transfer Dividend Preservation
transfer_keyssettlements lock in and preserve both wallets' claimable dividend balances before transferring balances and shifting checkpoints.Integration Tests Added
curve_preset_storage.rs: Verifies that creators can register with different presets, their presets can be queried correctly viaget_curve_preset, and non-existent creators revert withNotRegistered.flat_curve_symmetry_regression.rs: Asserts that buy and sell quotes are symmetric for theFlatpreset at multiple supply levels (0, 5, 20) and for both small and large amounts.transfer_keys_dividend_preservation.rs: Asserts that both the sender's and recipient's claimable balances are unchanged after a transfer, and that both wallets can still claim their pre-transfer dividend amounts.