Skip to content

feat(creator-keys): add max_slippage_bps parameter to buy and sell functions - #1065

Open
Samuel-21-eng wants to merge 4 commits into
accesslayerorg:mainfrom
Samuel-21-eng:feature/issue-975-slippage-protection-parameter
Open

Samuel-21-eng wants to merge 4 commits into
accesslayerorg:mainfrom
Samuel-21-eng:feature/issue-975-slippage-protection-parameter

Conversation

@Samuel-21-eng

Copy link
Copy Markdown

Full Description:

1 - Extend buy and sell contract functions (buy_with_slippage, buy_key_with_slippage, buy_keys_with_slippage,
buy_key_with_ref_and_slip, and sell_key_with_slippage) with an optional max_slippage_bps parameter.
2 - Compute price impact (actual_bps) against the current bonding curve state before execution (reference_price
vs execution_price_after_fees).
3 - Account for fees correctly in impact computation (evaluated after protocol fee deduction).
4 - Revert with ContractError::SlippageExceeded (emitting event with actual vs max basis points) when price
impact exceeds max_slippage_bps.
5 - Safely skip the check (opt-in) when max_slippage_bps is None or Some(0).
6 - Add comprehensive unit and integration tests covering all acceptance criteria in
creator-keys/tests/slippage_protection.rs.

closes #975

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.

Add slippage protection parameter to buy and sell functions

1 participant