Struct cyclos_core::states::tick_bitmap::TickBitmapState
source · [−]Expand description
Stores info for a single bitmap word. Each word represents 256 packed tick initialized boolean values.
Emulates a solidity mapping, where word_position is the key and
PDA of [BITMAP_SEED, token_0, token_1, fee, word_pos]
Fields
bump: u8Bump to identify PDA
word_pos: i16The bitmap key. To find word position from a tick, divide the tick by tick spacing to get a 24 bit compressed result, then right shift to obtain the most significant 16 bits.
word: [u64; 4]Packed initialized state
Implementations
sourceimpl TickBitmapState
impl TickBitmapState
sourcepub fn flip_bit(&mut self, bit_pos: u8)
pub fn flip_bit(&mut self, bit_pos: u8)
Flips the initialized state for a given bit from false to true, or vice versa
Arguments
self- The bitmap state corresponding to the tick’s word positionbit_pos- The rightmost 8 bits of the tick
sourcepub fn next_initialized_bit(&self, bit_pos: u8, lte: bool) -> NextBit
pub fn next_initialized_bit(&self, bit_pos: u8, lte: bool) -> NextBit
Returns the bitmap index (0 - 255) for the next initialized tick.
If no initialized tick is available, returns the first bit (index 0) the word in lte case, and the last bit in gte case.
Unlike Uniswap, this checks for equality in lte = false case. Externally ensure that
compressed + 1 is used to derive the word_pos(for bitmap account) and bit_pos.
Obtain the actual tick using
(next + 255 * word_pos) * spacingArguments
self- The mapping in which to compute the next initialized tickbit_pos- The starting bit positionlte- Whether to search for the next initialized tick to the left (less than or equal to the starting tick)
Trait Implementations
sourceimpl AccountDeserialize for TickBitmapState
impl AccountDeserialize for TickBitmapState
sourcefn try_deserialize(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize(buf: &mut &[u8]) -> Result<Self>
Deserializes previously initialized account data. Should fail for all
uninitialized accounts, where the bytes are zeroed. Implementations
should be unique to a particular account type so that one can never
successfully deserialize the data of one account type into another.
For example, if the SPL token program were to implement this trait,
it should be impossible to deserialize a Mint account into a token
Account. Read more
sourceimpl Clone for TickBitmapState
impl Clone for TickBitmapState
sourcefn clone(&self) -> TickBitmapState
fn clone(&self) -> TickBitmapState
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Default for TickBitmapState
impl Default for TickBitmapState
sourcefn default() -> TickBitmapState
fn default() -> TickBitmapState
Returns the “default value” for a type. Read more
sourceimpl Discriminator for TickBitmapState
impl Discriminator for TickBitmapState
fn discriminator() -> [u8; 8]
sourceimpl Owner for TickBitmapState
impl Owner for TickBitmapState
sourceimpl Zeroable for TickBitmapState
impl Zeroable for TickBitmapState
impl Copy for TickBitmapState
impl Pod for TickBitmapState
impl ZeroCopy for TickBitmapState
Auto Trait Implementations
impl RefUnwindSafe for TickBitmapState
impl Send for TickBitmapState
impl Sync for TickBitmapState
impl Unpin for TickBitmapState
impl UnwindSafe for TickBitmapState
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> CheckedBitPattern for T where
T: AnyBitPattern,
impl<T> CheckedBitPattern for T where
T: AnyBitPattern,
type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during is_valid_bit_pattern. Read more
fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret bits as &Self.
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more