Skip to content

feat: add regression-test#495

Merged
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
ONEONUORA:regression-test
Jun 27, 2026
Merged

feat: add regression-test#495
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
ONEONUORA:regression-test

Conversation

@ONEONUORA

Copy link
Copy Markdown
Contributor

close #484
close #482
close #483
close #481

This PR implements curve presets (Linear, Quadratic, Flat), ensures buy and sell quote symmetry for the Flat preset, and verifies that peer-to-peer key transfers preserve claimable dividend balances.

Features & Changes

1. Curve Presets

  • CurvePreset Enum: Added a new contract enum: Linear (0), Quadratic (1), and Flat (2).
  • Persistent Storage: Associated each creator with their curve preset in contract state via DataKey::CurvePreset(Address).
  • Curve-based Pricing: Updated compute_bonding_curve_price to dispatch pricing logic depending on the creator's curve preset:
    • Flat: Returns base_price (constant price model regardless of supply/slope).
    • Linear: Returns base_price + slope * supply.
    • Quadratic: Returns base_price + slope * supply * supply.
  • Registration Parameter: Added curve_preset: Option<CurvePreset> to register_creator. It defaults to CurvePreset::Linear to maintain backwards compatibility with existing tests.
  • get_curve_preset View: Added a read-only entrypoint to query a creator's preset. Reverts with NotRegistered if the creator doesn't exist.

2. Quote and Price Symmetry

  • Symmetry Realization: Adjusted sell_key and get_sell_quote to calculate the price using supply - 1 instead of supply.
  • Symmetric Quotes: This guarantees that the cost to buy a key at supply $S$ exactly matches the proceeds from selling it at supply $S+1$ across all presets.
  • Safety Checks: Checked the seller's key balance before computing the supply in sell_key to avoid false SellUnderflow errors when the supply is 0.

3. P2P Key Transfer Dividend Preservation

  • Confirmed that transfer_keys settlements lock in and preserve both wallets' claimable dividend balances before transferring balances and shifting checkpoints.

Integration Tests Added

  1. curve_preset_storage.rs: Verifies that creators can register with different presets, their presets can be queried correctly via get_curve_preset, and non-existent creators revert with NotRegistered.
  2. flat_curve_symmetry_regression.rs: Asserts that buy and sell quotes are symmetric for the Flat preset at multiple supply levels (0, 5, 20) and for both small and large amounts.
  3. 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.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit b160998 into accesslayerorg:main Jun 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment