From 2ddcd1c625a84a7c06289182ae0b17a24d8e9fae Mon Sep 17 00:00:00 2001 From: Jeiwan Date: Mon, 13 Nov 2023 19:59:15 +0700 Subject: [PATCH] Explain that tick spacing affects which ticks can be initialized in the ticks bitmap (https://github.com/Jeiwan/uniswapv3-book/issues/75) --- content/docs/milestone_2/tick-bitmap-index.md | 3 ++- content/docs/milestone_4/factory-contract.md | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/content/docs/milestone_2/tick-bitmap-index.md b/content/docs/milestone_2/tick-bitmap-index.md index 5ddaebce..6435710f 100644 --- a/content/docs/milestone_2/tick-bitmap-index.md +++ b/content/docs/milestone_2/tick-bitmap-index.md @@ -93,7 +93,8 @@ function flipTick( } ``` -> Until later in the book, `tickSpacing` is always 1. +> Until later in the book, `tickSpacing` is always 1. Please keep in mind that this value affects which ticks can be initialized: when it +equals 1, all ticks can be flipped; when it's set to a different value, only ticks divisible by the value can be flipped. After finding word and bit positions, we need to make a mask. A mask is a number that has a single 1 flag set at the bit position of the tick. To find the mask, we simply calculate `2**bit_pos` (equivalent of `1 << bit_pos`): diff --git a/content/docs/milestone_4/factory-contract.md b/content/docs/milestone_4/factory-contract.md index c6fbed07..29a41e01 100644 --- a/content/docs/milestone_4/factory-contract.md +++ b/content/docs/milestone_4/factory-contract.md @@ -94,7 +94,9 @@ Thus, each pool is uniquely identified by this set of parameters: Factory contract uses this set of parameters as a unique identifier of a pool and passes it as a salt to generate a new pool contract address. -> From now on, we'll assume the tick spacing of 60 for all our pools, and we'll use 10 for stablecoin pairs. +> From now on, we'll assume the tick spacing of 60 for all our pools, and we'll use 10 for stablecoin pairs. Please notice +that only ticks divisible by these values can be flagged as initialized in the ticks bitmap. For example, only ticks -120, +-60, 0, 60, 120, etc. can be initialized and used in liquidity ranges when tick spacing is 60. ## Factory Implementation