Repository navigation
Conversation
|
@meem08 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! 🚀 |
… merge Merging main brought in CapCannotIncrease (105) and CapTooLow (106) from the holder-cap work, colliding with InvalidImpactTolerance (105) and tripping E0081 so every target failed to compile. Keep main's published codes and renumber the new liquidity-depth error to 107.
Member
|
Conflict |
…merge The main merge brought in the price-alert errors WalletAlertLimitReached (107), KeyAlertLimitReached (108) and AlertNotFound (109), colliding with InvalidImpactTolerance (107) and tripping E0081. Keep main's published codes and append the liquidity-depth error as 110.
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
Implements the key-pair liquidity depth oracle requested in #1035: two new read-only views on the
creator-keysbonding curve contract that return the maximum buyable / sellable amount of keys within a given price-impact tolerance, together with the current price and the price expected after full execution. Intended for per-order pre-validation on the batch trade endpoint.Closes #1035
New API
Semantics
(price_after - price_now).abs() * 10_000 / price_now <= tolerance_bps. For buys the curve walkssupply -> supply + max_amount; for sells it walkssupply -> supply - max_amountand never below zero supply.MAX_DEPTH_SCAN_LIMIT(1 000 000) when uncapped (this only binds when the price never leaves the tolerance, e.g. a flat preset, where the entire scan depth is correctly reported as buyable at any tolerance).get_max_sellat zero supply returnsmax_amount = 0with the current/expected price reported gracefully; a non-positive curve price likewise yields an empty depth instead of a division by zero.KEY_PRICE, creator profile, supply cap, curve config) and never mutate state - asserted by a dedicated test.ContractError::InvalidImpactTolerance(= 105, appended); unregistered keys revertNotRegistered; missing key price revertsKeyPriceNotSet(same ordering as the existing quote views).Changes
creator-keys/src/lib.rs(+242, purely additive):LiquidityDepthQuoteresult structContractError::InvalidImpactTolerance = 105depth_post_trade_price,depth_within_impact_limit,find_max_depth,MAX_DEPTH_SCAN_LIMITnext to the existing curve mathget_max_buy/get_max_sellviews next toget_sell_quotecreator-keys/src/test_issue_1035.rs(new, 17 tests):expected_priceverified againstget_price_at_supplyatsupply +/- max_amount, and maximality (one more key must exceed the tolerance) verified independentlyexpected_price)Testing
cargo test -p creator-keys --lib- 489 passed, 0 failed (includes the 17 new tests)cargo clippy -p creator-keys --all-targets -- -D warnings- cleancargo fmt -p creator-keys -- --check- cleanNotes for reviewers
query_price/get_bid_ask_price's buy side; callers can layer fees/spread on top during pre-validation.