feat(#827): add slippage_check_passed event for non-None bounds - #846
Open
dedukpe wants to merge 2 commits into
Open
feat(#827): add slippage_check_passed event for non-None bounds#846dedukpe wants to merge 2 commits into
dedukpe wants to merge 2 commits into
Conversation
…e bounds
When a buy or sell with a non-None max_price/min_proceeds bound passes the
slippage check, emit a SlippageCheckPassedEvent so downstream indexers can
track that the caller's slippage guard was satisfied.
- Add SLIPPAGE_CHECK_PASSED_EVENT_NAME ("slp_ok") event constant
- Add SlippageCheckPassedEvent struct (creator_id, actual_amount, bound, ledger)
- Emit event in assert_buy_price_slippage and assert_sell_proceeds_slippage
- None bounds skip the event (and the check) entirely with no performance cost
Also fixes pre-existing compilation issues exposed by unclosed delimiter:
- Re-indent circuit breaker block inside else branch
- Remove duplicate DataKey variants (RoyaltyConfig, CurveExponent, etc.)
- Remove duplicate storage key functions (holder_cap_bps, last_buy_timestamp)
- Remove duplicate credit_staking_rewards_pool implementation
- Add missing type stubs for incomplete staking/auction merges
- Add 4 new tests verifying event emission behavior
Closes accesslayerorg#827
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@dedukpe 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! 🚀 |
Member
❌ CI Failed —
|
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.
Summary
Adds a
SlippageCheckPassedEventthat is emitted when a buy or sell with a non-Nonemax_price/min_proceedsbound passes the slippage check, giving downstream indexers visibility into slippage guard behavior.Closes #827
Changes
New Event (
slp_ok)SLIPPAGE_CHECK_PASSED_EVENT_NAME—symbol_short!("slp_ok")SlippageCheckPassedEventstruct with fields:creator_id: Address— creator whose key was tradedactual_amount: i128— bonding-curve price (buy) or post-fee proceeds (sell) that was validatedbound: i128— the caller-specified upper/lower bound that was satisfiedledger: u32— ledger sequence at the time of the tradeEmission Points
assert_buy_price_slippage— emits after a successful check whenmax_priceisSomeassert_sell_proceeds_slippage— emits after a successful check whenmin_proceedsisSomeNone, no event is emitted (no performance cost)Tests Added
test_buy_emits_slippage_check_passed_when_bound_providedtest_buy_skips_slippage_event_when_bound_is_nonetest_sell_emits_slippage_check_passed_when_bound_providedtest_sell_skips_slippage_event_when_bound_is_nonePre-existing Fixes
The main branch had a pre-existing unclosed delimiter in
buy_key_with_referrerthat masked ~75 compilation errors from incomplete merges. This PR also:ifblock inside theelsebranchDataKeyvariants (RoyaltyConfig,CurveExponent)holder_cap_bps,last_buy_timestamp)credit_staking_rewards_poolimplementationAuctionConfig,StakingRewardsState,StakePosition, etc.)Acceptance Criteria
SlippageExceededwhen execution price exceedsmax_pricemax_priceSlippageExceededwhen execution price is belowmin_proceedsmin_proceedsNonebounds skip the check entirely with no performance costslippage_check_passedevent is emitted when a non-None bound is satisfiedTest Results