Skip to main content

Functions

_blockTimestamp

Returns the block timestamp truncated to 32 bits, i.e. mod 2**32. This method is overridden in tests.

_advancePeriod

Modifier that advances the period (weekly epoch) if the current timestamp has crossed into a new period. This drives Ramses’ period-based accounting for gauge reward distribution.

snapshotCumulativesInside

Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range Snapshots must only be compared to other snapshots, taken over a period for which a position existed. I.e., snapshots cannot be compared if a position is not held for the entire period between when the first snapshot is taken and the second snapshot is taken.

Parameters:

Return Values:

observe

Returns the cumulative tick and liquidity as of each timestamp secondsAgo from the current block timestamp To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, you must call it with secondsAgos = [3600, 0]. The time weighted average tick represents the geometric time weighted average price of the pool, in log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.

Parameters:

Return Values:

timestamp

increaseObservationCardinalityNext

Increase the maximum number of price and liquidity observations that this pool will store This method is no-op if the pool already has an observationCardinalityNext greater than or equal to the input observationCardinalityNext.

Parameters:

initialize

Sets the initial price for the pool not locked because it initializes unlocked

Parameters:

mint

Adds liquidity for the given recipient/index/tickLower/tickUpper position noDelegateCall is applied indirectly via _modifyPosition. The index parameter distinguishes multiple positions by the same owner at the same tick range, and is included in the position key hash: keccak256(abi.encodePacked(owner, index, tickLower, tickUpper)).

Parameters:

Return Values:

collect

Collects tokens owed to a position Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.

Parameters:

Return Values:

burn

Burn liquidity from the sender and account tokens owed for the liquidity to the position noDelegateCall is applied indirectly via _modifyPosition

Parameters:

Return Values:

swap

Swap token0 for token1, or token1 for token0 The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback

Parameters:

Return Values:

flash

Receive token0 and/or token1 and pay it back, plus a fee, in the callback The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling with 0 amount and sending the donation amount(s) from the callback

Parameters:

setFee

Sets the pool’s swap fee dynamically. Can only be called by the factory. Can only be called by the factory. Ramses-specific addition allowing governance to adjust swap fees per pool.

Parameters:

setFeeProtocol

Syncs the pool’s protocol fee from the factory. Called by the factory when the global or pool-specific fee protocol is updated. Takes no parameters — reads the fee directly from IRamsesV3Factory.poolFeeProtocol(address(this)).

collectProtocol

Collect the protocol fee accrued to the pool

Parameters:

Return Values:

Ramses-Specific State

grossFeeGrowthGlobal0X128

The gross fee growth of token0 as a Q128.128. Tracks fees before protocol fee deduction.

grossFeeGrowthGlobal1X128

The gross fee growth of token1 as a Q128.128. Tracks fees before protocol fee deduction.

periods

The pool maintains an array of period snapshots for weekly epoch-based accounting. Each period contains cumulative data used by GaugeV3 to distribute rewards proportionally to liquidity providers based on their time-weighted in-range contribution during each period.

Storage

RamsesV3Pool uses ERC-7201 namespaced storage via the PoolStorage library. All pool state is stored in a structured namespace rather than raw storage slots, improving upgradeability and avoiding storage collisions. Position keys are computed as: keccak256(abi.encodePacked(owner, index, tickLower, tickUpper)) — note the extra index parameter compared to Uniswap V3.