Repository navigation
feat: implement auto-invest registry contract with rule creation, upd… - #1155
Merged
Chucks1093 merged 12 commits intoOct 20, 2026
Merged
Conversation
…ates, and evaluation logic
|
@extolkom 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! 🚀 |
…rized error, clean test imports
…align Cargo.toml with workspace
…acttype trait bounds
5 tasks
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 GitHub issue #1029 by introducing a dedicated
auto-invest-registrySoroban contract for automated, rule-based creator key purchases. Investors can configure, update, and deactivate purchase rules on-chain, and off-chain execution services can evaluate key eligibility before executing purchases.auto-invest-registrytoCargo.toml.Criteria:key_category(0 = wildcard, non-zero = explicit category),min_rating(scaled100..=500),max_price(i128 > 0),max_per_key(u32 > 0).Rule:id,owner,criteria,active,created_at.register_rule(wallet, criteria): Validates inputs, enforcesMAX_RULES_PER_WALLET = 50, stores rules in registration order, and emitsRuleRegistered.update_rule(rule_id, criteria): Requires owner auth; owner and ID are immutable; fails withRuleDeactivatedif the rule is deactivated; emitsRuleUpdated.deactivate_rule(rule_id): Requires owner auth; disables rule without deleting; fails withRuleAlreadyDeactivatedif already inactive.check_rule_with_context(wallet, key_id, category, rating, price, current_holdings): Pure evaluation against caller-supplied market metrics; iterates active rules in FIFO registration order and returnsCheckResult.check_rule(wallet, key_id, category, rating, price, current_holdings): Delegates directly tocheck_rule_with_context.get_rules(wallet): Returns all registered rules forwalletin registration order.get_rule(rule_id): Fetches a single rule by ID.RuleRegistered(rule_reg) andRuleUpdated(rule_upd) compliant withdocs/contract-event-conventions.md.Design Decisions & Assumptions
creator-keyscontract does not store key categories, category filtering requires metadata supplied by the caller (indexed off-chain). Passing market metrics directly intocheck_ruleavoids unauthenticated state-changing setters, eliminates cross-contract call failure traps, and prevents reentrancy risks.check_ruleandcheck_rule_with_contextrely on caller-supplied data and are explicitly documented as advisory pre-flight validation for automated purchase bots, not an on-chain security gate.min_ratingin100..=500(representing 1.00 to 5.00 stars), matchingaverage_score_scaledincreator-keys.Testing
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceTest Coverage in
auto-invest-registry/src/test.rskey_category == 0) and explicit non-wildcard category behavior.get_rules, including after rule deactivations.update_ruleon deactivated rules (RuleDeactivated).RuleAlreadyDeactivated).MAX_RULES_PER_WALLET = 50(50 succeeds, 51st returnsTooManyRules).RuleRegisteredandRuleUpdated.Checklist
auto-invest-registry/src/test.rscovering every acceptance criterion and error pathcargo fmt --all -- --checkcleanly; explained build tools dependency for local test rundocs/storage-key-invariants.md(isolated namespace, persistent keys with 30-day TTL extension)rule_reg,rule_upd), topics, and payload schemas conform todocs/contract-event-conventions.mdauto-invest-registry/and 1-line workspace registration in rootCargo.tomlwithout touching unrelated cratesCloses #1029