Skip to main content

wp_evm_ramses_core/
data.rs

1//! Ramses-family data records.
2//!
3//! Re-exports shared types from `wp-evm-v3-core::data` where the ABI is
4//! identical, and defines Ramses-specific types where it differs.
5//!
6//! # ABI differences from Uniswap V3
7//!
8//! Ramses-fork NFPMs use `int24 tickSpacing` at field position 2 of
9//! `MintParams` (instead of Uniswap V3's `uint24 fee`). The `positions()`
10//! return also uses `int24 tickSpacing` rather than `uint24 fee`.
11//!
12//! Verified against:
13//! - Shadow: `Shadow-Exchange/shadow-core` `contracts/CL/periphery/interfaces/
14//!   INonfungiblePositionManager.sol` (11-field MintParams, 10-field positions())
15//! - Slipstream: `velodrome-finance/slipstream` `contracts/periphery/interfaces/
16//!   INonfungiblePositionManager.sol` (12-field MintParams with sqrtPriceX96,
17//!   12-field positions() with nonce/operator)
18
19use alloy_primitives::{Address, B256, U256};
20
21pub use wp_evm_v3_core::data::{
22    CollectFeesParams, ExactInParams, ExactOutParams, PlanFragment, PoolState, Quote,
23    RemoveAndCollectParams, RemoveLiquidityParams, TickInfo,
24};
25
26/// Parameters for an `add_liquidity` plan on a Ramses-family NFPM.
27///
28/// Uses `tick_spacing: i32` instead of `fee: u32` because Ramses-fork NFPMs
29/// identify pools by `(token0, token1, tickSpacing)` — there is no `fee`
30/// field in `MintParams`.
31///
32/// This replaces `wp_evm_v3_core::data::AddLiquidityParams` for all
33/// Ramses-family protocols (Shadow, Slipstream, Aerodrome).
34#[derive(Debug, Clone, PartialEq, Eq)]
35pub struct RamsesAddLiquidityParams {
36    pub token0: Address,
37    pub token1: Address,
38    /// Pool-identifying tick spacing. Read from `PoolState.tick_spacing`.
39    pub tick_spacing: i32,
40    pub tick_lower: i32,
41    pub tick_upper: i32,
42    pub amount0_desired: U256,
43    pub amount1_desired: U256,
44    pub recipient: Address,
45}
46
47/// Hydrated state of a Ramses-family NFPM position.
48///
49/// Uses `tick_spacing: i32` instead of `fee: u32` because Ramses-fork
50/// `positions()` returns `int24 tickSpacing` at that field position.
51///
52/// Compatible with both Shadow (10-field `positions()` return, no nonce/operator)
53/// and Slipstream / Aerodrome (12-field return, has nonce/operator — those are
54/// dropped since they're not needed by plan/quote functions).
55#[derive(Debug, Clone, PartialEq, Eq)]
56pub struct PositionState {
57    pub token_id: U256,
58    pub owner: Address,
59    pub token0: Address,
60    pub token1: Address,
61    pub tick_spacing: i32,
62    pub tick_lower: i32,
63    pub tick_upper: i32,
64    pub liquidity: u128,
65    pub fees_owed_0: U256,
66    pub fees_owed_1: U256,
67}
68
69/// Per-protocol configuration for a Ramses-family DEX.
70///
71/// Ramses pools are keyed by `(token0, token1, tickSpacing)` instead of
72/// Uniswap V3's `(token0, token1, fee)`. `tick_spacings` enumerates the
73/// valid tick spacings supported by the protocol.
74///
75/// Adding a new Ramses-fork DEX = creating a new protocol facade with a
76/// `pub const CONFIG: RamsesProtocolConfig = ...`. No family code changes.
77///
78/// **CREATE2 deployment**: Shadow / Ramses-core uses an independent
79/// `RamsesV3PoolDeployer` contract (≠ factory) for CREATE2. The
80/// `pool_deployer` field is the actual CREATE2 caller used by
81/// `pool_address::compute`. Velodrome-family protocols (Slipstream /
82/// Aerodrome) deploy via EIP-1167 Clones instead and set
83/// `pool_deployer = Address::ZERO`; their facade `pool_address` body
84/// passes `cfg.factory` as the deployer (the factory contract IS the
85/// CREATE2 caller for clone-pattern deployments).
86#[derive(Debug, Clone, Copy, PartialEq, Eq)]
87pub struct RamsesProtocolConfig {
88    pub factory: Address,
89    /// CREATE2 deployer — `RamsesV3PoolDeployer` for Shadow-pattern,
90    /// `Address::ZERO` for EIP-1167-Clone-pattern (Slipstream / Aerodrome).
91    /// Read via `factory.ramsesV3PoolDeployer()` getter for CREATE2-deploying
92    /// Ramses forks; clone-pattern facades pass `cfg.factory` instead at the
93    /// `pool_address::compute` call site.
94    pub pool_deployer: Address,
95    pub router: Address,
96    pub position_mgr: Address,
97    pub init_code_hash: B256,
98    pub tick_spacings: &'static [i32],
99    pub multicall: Address,
100    pub quoter: Option<Address>,
101    pub voter: Address,
102}