Repository navigation
Harden router, pool, and cl-pool contract validation and tests - #1267
Merged
Mimah97 merged 5 commits intoOct 16, 2026
Merged
Conversation
…not validate that Closes Vatix-Protocol#1180
…96 and stores a d Closes Vatix-Protocol#1181
…gle is declared u Closes Vatix-Protocol#1182
…ddress and any co Closes Vatix-Protocol#1183
…2-1183 # Conflicts: # packages/contract/contracts/router/src/lib.rs # packages/contract/contracts/router/src/test.rs
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
Harden router, pool, and cl-pool contract validation and tests
What was solved
#1180 — router (packages/contract): initialize does not validate that factory is a contract address
Add a contract-address validation to the router's
initializeinpackages/contract/contracts/router/src/lib.rsso a non-contractfactoryaddress is rejected before storage, and add tests inpackages/contract/contracts/router/src/test.rscovering factory round-trip viaget_factory,NotInitializedpanics forget_factory/get_adminbefore initialization, and rejection of a non-contract factory address.Addressed:
initializemust reject afactoryaddress that is not a deployed contract, panicking with an appropriateRouterError(reuse an existing variant if suitable, otherwise append a new one without renumbering existing discriminants).get_factory.get_factoryreturns the exact address passed toinitialize.#1181 — pool: initialize accepts a zero sqrt_price_x96 and stores a derived tick
Add validation to the pool contract's
initializefunction so it rejects a zerosqrt_price_x96and any price whose derived tick falls outsideMIN_TICK..=MAX_TICK, using the existingPoolError::InvalidTickvariant, and cover the new behavior with tests in the pool test file.Addressed:
packages/contract/contracts/pool/src/lib.rs, after theAlreadyInitializedcheck ininitialize, add a guard that panics withPoolError::InvalidTickwhensqrt_price_x96 == 0.PoolError::InvalidTickwhensqrt_price_to_tick(sqrt_price_x96)is outsideMIN_TICK..=MAX_TICK.#[should_panic]test inpackages/contract/contracts/pool/src/test.rsforinitializewithsqrt_price_x96 = 0expectingPoolError::InvalidTick.#1182 — router (packages/contract): exact_output_single is declared unsupported but the error path is untested
Pin the router contract's exact-output behaviour in tests and document it. Read packages/contract/contracts/router/src/lib.rs to determine whether an exact-output entrypoint exists: if absent, add a test asserting the ExactOutputUnsupported revert (via the closest declared entrypoint) and document the non-goal in the doc comment; if present, add tests asserting amount_in respects amount_in_max and that exceeding it reverts with SlippageExceeded. Keep changes confined to the router crate.
Addressed:
#1183 — cl-pool: set_oracle accepts the pool's own address and any contract as the oracle
Harden cl-pool's
set_oracleso it requires admin/owner authorization and rejects the pool's own address or either token address, adding a newPoolError::InvalidOraclevariant and anAdmin/OwnerDataKey set duringinitialize, with tests covering the new paths.Addressed:
Admin/OwnerDataKey variant and set it ininitializeif not presentset_oraclemust callrequire_authon the configured admin/owner before persistingset_oraclemust panic with a newPoolErrorvariant (e.g.InvalidOracle) whenoracle == env.current_contract_address()Changes
packages/contract/contracts/router/src/lib.rs(modify)packages/contract/contracts/router/src/test.rs(modify)packages/contract/contracts/pool/src/test.rs(modify)packages/contract/contracts/cl-pool/src/test.rs(modify)Approach
Issues
Closes #1180
Closes #1181
Closes #1182
Closes #1183