pub struct PoolPosition {
pub owner: Address,
pub tick_lower: i32,
pub tick_upper: i32,
pub liquidity: u128,
pub fee_growth_inside_0_last: U256,
pub fee_growth_inside_1_last: U256,
pub tokens_owed_0: u128,
pub tokens_owed_1: u128,
pub total_amount0_deposited: U256,
pub total_amount1_deposited: U256,
pub total_amount0_collected: u128,
pub total_amount1_collected: u128,
}
Expand description
Represents a concentrated liquidity position in a DEX pool.
This struct tracks a specific liquidity provider’s position within a price range, including the liquidity amount, fee accumulation, and token deposits/withdrawals.
Fields§
§owner: Address
The owner of the position
tick_lower: i32
The lower tick boundary of the position
tick_upper: i32
The upper tick boundary of the position
liquidity: u128
The amount of liquidity in the position
fee_growth_inside_0_last: U256
Fee growth per unit of liquidity for token0 as of the last action on the position
fee_growth_inside_1_last: U256
Fee growth per unit of liquidity for token1 as of the last action on the position
tokens_owed_0: u128
The fees owed to the position for token0
tokens_owed_1: u128
The fees owed to the position for token1
total_amount0_deposited: U256
Total amount of token0 deposited into this position
total_amount1_deposited: U256
Total amount of token1 deposited into this position
total_amount0_collected: u128
Total amount of token0 collected from this position
total_amount1_collected: u128
Total amount of token1 collected from this position
Implementations§
Source§impl PoolPosition
impl PoolPosition
Sourcepub fn new(
owner: Address,
tick_lower: i32,
tick_upper: i32,
liquidity: i128,
) -> Self
pub fn new( owner: Address, tick_lower: i32, tick_upper: i32, liquidity: i128, ) -> Self
Creates a PoolPosition
with the specified parameters.
Sourcepub fn get_position_key(
owner: &Address,
tick_lower: i32,
tick_upper: i32,
) -> String
pub fn get_position_key( owner: &Address, tick_lower: i32, tick_upper: i32, ) -> String
Generates a unique string key for a position based on owner and tick range.
Sourcepub fn update_liquidity(&mut self, liquidity_delta: i128)
pub fn update_liquidity(&mut self, liquidity_delta: i128)
Updates the liquidity amount by the given delta.
Positive values increase liquidity, negative values decrease it. Uses saturating arithmetic to prevent underflow.
Sourcepub fn update_fees(
&mut self,
fee_growth_inside_0: U256,
fee_growth_inside_1: U256,
)
pub fn update_fees( &mut self, fee_growth_inside_0: U256, fee_growth_inside_1: U256, )
Updates the position’s fee tracking based on current fee growth inside the position’s range.
Calculates the fees earned since the last update and adds them to tokens_owed. Updates the last known fee growth values for future calculations.
Sourcepub fn collect_fees(&mut self, amount0: u128, amount1: u128)
pub fn collect_fees(&mut self, amount0: u128, amount1: u128)
Collects fees owed to the position, up to the requested amounts.
Reduces tokens_owed by the collected amounts and tracks total collections. Cannot collect more than what is currently owed.
Sourcepub fn update_amounts(
&mut self,
liquidity_delta: i128,
amount0: U256,
amount1: U256,
)
pub fn update_amounts( &mut self, liquidity_delta: i128, amount0: U256, amount1: U256, )
Updates position token amounts based on liquidity delta.
For positive liquidity delta (mint), tracks deposited amounts. For negative liquidity delta (burn), adds amounts to tokens owed.
Trait Implementations§
Source§impl Clone for PoolPosition
impl Clone for PoolPosition
Source§fn clone(&self) -> PoolPosition
fn clone(&self) -> PoolPosition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PoolPosition
impl Debug for PoolPosition
Source§impl<'de> Deserialize<'de> for PoolPosition
impl<'de> Deserialize<'de> for PoolPosition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'py> IntoPyObject<'py> for PoolPosition
impl<'py> IntoPyObject<'py> for PoolPosition
Source§type Target = PoolPosition
type Target = PoolPosition
Source§type Output = Bound<'py, <PoolPosition as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <PoolPosition as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PartialEq for PoolPosition
impl PartialEq for PoolPosition
Source§impl PyClass for PoolPosition
impl PyClass for PoolPosition
Source§impl PyClassImpl for PoolPosition
impl PyClassImpl for PoolPosition
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// Represents a concentrated liquidity position in a DEX pool.
///
/// This struct tracks a specific liquidity provider's position within a price range,
/// including the liquidity amount, fee accumulation, and token deposits/withdrawals.
const RAW_DOC: &'static CStr = /// Represents a concentrated liquidity position in a DEX pool. /// /// This struct tracks a specific liquidity provider's position within a price range, /// including the liquidity amount, fee accumulation, and token deposits/withdrawals.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature
if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<PoolPosition>
type ThreadChecker = SendablePyClass<PoolPosition>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder PoolPosition
impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder PoolPosition
Source§impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder mut PoolPosition
impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder mut PoolPosition
Source§impl PyTypeInfo for PoolPosition
impl PyTypeInfo for PoolPosition
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type.Source§impl Serialize for PoolPosition
impl Serialize for PoolPosition
impl DerefToPyAny for PoolPosition
impl StructuralPartialEq for PoolPosition
Auto Trait Implementations§
impl Freeze for PoolPosition
impl RefUnwindSafe for PoolPosition
impl Send for PoolPosition
impl Sync for PoolPosition
impl Unpin for PoolPosition
impl UnwindSafe for PoolPosition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
§fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self
into an owned Python object, dropping type information and unbinding it
from the 'py
lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self
into a Python object. Read more