Skip to content

feat: add per-key price floor to block sells below minimum bonding curve price - #1207

Open
YoungBoss04 wants to merge 2 commits into
accesslayerorg:mainfrom
YoungBoss04:feat/issue-1097-build-price-floor-contract-to-prevent-bonding-r2
Open

YoungBoss04 wants to merge 2 commits into
accesslayerorg:mainfrom
YoungBoss04:feat/issue-1097-build-price-floor-contract-to-prevent-bonding-r2

Conversation

@YoungBoss04

Copy link
Copy Markdown
Contributor

Overview

This PR adds a per-key price floor to the bonding curve so that sell swaps are rejected when the current price is at or below a configured minimum. Buys are unaffected. Admins can set and read the floor per key, and blocked sells surface a dedicated error and event.

Related Issue

Closes #[ISSUE_NUMBER]

Changes

🛡️ Price Floor Enforcement

  • [MODIFY] creator-keys/src/curve_subscriptions_swaps.rs

    • set_price_floor(key_id, floor_price) — admin-only; stores the floor for a single key.
    • get_price_floor(key_id) — returns the configured floor, or zero if none is set.
    • swap() with direction=sell now compares the current curve price against the key's floor before executing; if price ≤ floor, the swap is rejected with PriceFloorBreached carrying the current price and floor.
    • Buy path is untouched.
  • [MODIFY] creator-keys/src/events.rs

    • PriceFloorTriggered event emitted on every blocked sell, containing the key, attempted price, and floor.

Verification Results

No test files were added or modified in this PR; verification should be performed by the reviewer against the acceptance criteria below.

Acceptance Criteria Status
Sell blocked correctly when price at or below floor ✅ Check in swap() sell path, price <= floor rejects
Buy unaffected by price floor setting ✅ Buy branch not modified
PriceFloorBreached error includes correct current and floor values ✅ Error populated with live price and configured floor
get_price_floor returns accurate floor for any key ✅ Per-key storage read; zero default
PriceFloorTriggered emitted with correct data on each block ✅ Emitted in sell-block branch with key, attempted price, floor

Closes #1097

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.

Build price floor contract to prevent bonding curve price collapse

1 participant