# Table of Contents - [Welcome to DoveSwap V3 | DoveSwap V3](#welcome-to-doveswap-v3-doveswap-v3) - [Protocol Concepts | DoveSwap V3](#protocol-concepts-doveswap-v3) - [Fees | DoveSwap V3](#fees-doveswap-v3) - [Concentrated Liquidity | DoveSwap V3](#concentrated-liquidity-doveswap-v3) - [Range Orders | DoveSwap V3](#range-orders-doveswap-v3) - [Token Integration Issues | DoveSwap V3](#token-integration-issues-doveswap-v3) - [Technical Reference | DoveSwap V3](#technical-reference-doveswap-v3) - [Swaps | DoveSwap V3](#swaps-doveswap-v3) - [Oracle | DoveSwap V3](#oracle-doveswap-v3) - [Core | DoveSwap V3](#core-doveswap-v3) - [Overview | DoveSwap V3](#overview-doveswap-v3) - [DoveSwapV3Factory | DoveSwap V3](#doveswapv3factory-doveswap-v3) - [Periphery | DoveSwap V3](#periphery-doveswap-v3) - [DoveSwapV3PoolDeployer | DoveSwap V3](#doveswapv3pooldeployer-doveswap-v3) - [QuoterV2 | DoveSwap V3](#quoterv2-doveswap-v3) - [DoveSwapV3Pool | DoveSwap V3](#doveswapv3pool-doveswap-v3) - [Deployment Addresses | DoveSwap V3](#deployment-addresses-doveswap-v3) - [TickLens | DoveSwap V3](#ticklens-doveswap-v3) - [V3Migrator | DoveSwap V3](#v3migrator-doveswap-v3) - [NonfungibleTokenPositionDescriptor | DoveSwap V3](#nonfungibletokenpositiondescriptor-doveswap-v3) - [SwapRouter | DoveSwap V3](#swaprouter-doveswap-v3) - [NonfungiblePositionManager | DoveSwap V3](#nonfungiblepositionmanager-doveswap-v3) - [Governance | DoveSwap V3](#governance-doveswap-v3) - [Error Codes | DoveSwap V3](#error-codes-doveswap-v3) - [Tokenomics | DoveSwap V3](#tokenomics-doveswap-v3) - [Real Yield | DoveSwap V3](#real-yield-doveswap-v3) - [Future of DoveSwap | DoveSwap V3](#future-of-doveswap-doveswap-v3) - [Staking Mechanics | DoveSwap V3](#staking-mechanics-doveswap-v3) --- # Welcome to DoveSwap V3 | DoveSwap V3 Welcome to the DoveSwap V3 protocol docs. We're building the most user-friendly DEX experience in DeFi for the zkEVM space. The pages here contain conceptual and technical documentation of the DoveSwap V3 protocol. DoveSwapV3 differs from the original DoveSwap protocol by allowing for more flexible liquidity provision, and allowing for more capital efficiency. The docs for the original DoveSwap protocol can be accessed [here](https://swap-docs.dovish.finance/) . [NextProtocol Concepts](https://dovish.gitbook.io/doveswap-v3/protocol-concepts) Last updated 2 years ago --- # Protocol Concepts | DoveSwap V3 [Concentrated Liquidity](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/concentrated-liquidity) [Fees](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/fees) [Oracle](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle) [Range Orders](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders) [Swaps](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/swaps) [Token Integration Issues](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/token-integration-issues) [PreviousWelcome to DoveSwap V3](https://dovish.gitbook.io/doveswap-v3) [NextConcentrated Liquidity](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/concentrated-liquidity) Last updated 2 years ago --- # Fees | DoveSwap V3 ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/fees#swap-fees) Swap Fees[​](https://docs.uniswap.org/concepts/protocol/fees#swap-fees) Swap fees are distributed pro-rata to all in-range\* liquidity at the time of the swap. If the spot price moves out of a position’s range, the given liquidity is no longer active and does not generate any fees. If the spot price reverses and reenters the position’s range, the position’s liquidity becomes active again and will generate fees. Swap fees are not automatically reinvested as they were in previous versions of DoveSwap. Instead, they are collected separately from the pool and must be manually redeemed when the owner wishes to collect their fees. \*Note: In-range liquidity refers to the liquidity contained in any positions which span both sides of the spot price ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/fees#pool-fees-tiers) Pool Fees Tiers[​](https://docs.uniswap.org/concepts/protocol/fees#pool-fees-tiers) DoveSwap v3 introduces multiple pools for each token pair, each with a different swapping fee. Liquidity providers may initially create pools at three fee levels: 0.05%, 0.30%, and 1%. More fee levels may be added by DoveSwap governance. Breaking pairs into separate pools was previously untenable due to the issue of liquidity fragmentation. Any incentive alignments achieved by more fee optionality invariably resulted in a net loss to traders, due to lower pairwise liquidity and the resulting increase in price impact upon swapping. The introduction of concentrated liquidity decouples total liquidity from price impact. With price impact concerns out of the way, breaking pairs into multiple pools becomes a feasible approach to improving the functionality of a pool for assets previously underserved by the 0.30% swap fee. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/fees#finding-the-right-pool-fee) Finding The Right Pool Fee[​](https://docs.uniswap.org/concepts/protocol/fees#finding-the-right-pool-fee) We anticipate that certain types of assets will gravitate towards specific fee tiers, based on where the incentives for both swappers and liquidity providers come nearest to alignment. We expect low volatility assets (stable coins) will likely congregate in the lowest fee tier, as the price risk for liquidity providers holding these assets is very low, and those swapping will be motivated to pursue an execution price closest to 1:1 as they can get. Similarly, we anticipate more exotic assets, or those traded rarely, will naturally gravitate towards a higher fee - as liquidity providers will be motivated to offset the cost risk of holding these assets for the duration of their position. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/fees#protocol-fees) Protocol Fees[​](https://docs.uniswap.org/concepts/protocol/fees#protocol-fees) DoveSwap v3 has a protocol fee that can be turned on by governance. Compared to v2, governance has more flexibility in choosing the fraction of swap fees that go to the protocol. [PreviousConcentrated Liquidity](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/concentrated-liquidity) [NextOracle](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle) Last updated 2 years ago --- # Concentrated Liquidity | DoveSwap V3 ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/concentrated-liquidity#introduction) Introduction[​](https://docs.uniswap.org/concepts/protocol/concentrated-liquidity#introduction) The defining idea of DoveSwap v3 is concentrated liquidity: liquidity that is allocated within a custom price range. In earlier versions, liquidity was distributed uniformly along the price curve between 0 and infinity. The previously uniform distribution allowed trading across the entire price interval (0, ∞) without any loss of liquidity. However, in many pools, the majority of the liquidity was never used. Consider stablecoin pairs, where the relative price of the two assets stays relatively constant. The liquidity outside the typical price range of a stablecoin pair is rarely touched. For example, the v2 DAI/USDC pair utilizes ~0.50% of the total available capital for trading between $0.99 and $1.01, the price range in which LPs would expect to see the most volume - and consequently earn the most fees. With v3, liquidity providers may concentrate their capital to smaller price intervals than (0, ∞). In a stablecoin/stablecoin pair, for example, an LP may choose to allocate capital solely to the 0.99 - 1.01 range. As a result, traders are offered deeper liquidity around the mid-price, and LPs earn more trading fees with their capital. We call liquidity concentrated to a finite interval a position. LPs may have many different positions per pool, creating individualized price curves that reflect the preferences of each LP. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/concentrated-liquidity#active-liquidity) Active Liquidity[​](https://docs.uniswap.org/concepts/protocol/concentrated-liquidity#active-liquidity) As the price of an asset rises or falls, it may exit the price bounds that LPs have set in a position. When the price exits a position's interval, the position's liquidity is no longer active and no longer earns fees. As price moves in one direction, LPs gain more of the one asset as swappers demand the other, until their entire liquidity consists of only one asset. (In v2, we don't typically see this behavior because LPs rarely reach the upper or lower bound of the price of two assets, i.e., 0 and ∞). If the price ever reenters the interval, the liquidity becomes active again, and in-range LPs begin earning fees once more. Importantly, LPs are free to create as many positions as they see fit, each with its own price interval. Concentrated liquidity serves as a mechanism to let the market decide what a sensible distribution of liquidity is, as rational LPs are incentivize to concentrate their liquidity while ensuring that their liquidity remains active. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/concentrated-liquidity#ticks) Ticks[​](https://docs.uniswap.org/concepts/protocol/concentrated-liquidity#ticks) To achieve concentrated liquidity, the once continuous spectrum of price space has been partitioned with ticks. Ticks are the boundaries between discrete areas in price space. Ticks are spaced such that an increase or decrease of 1 tick represents a 0.01% increase or decrease in price at any point in price space. Ticks function as boundaries for liquidity positions. When a position is created, the provider must choose the lower and upper tick that will represent their position's borders. As the spot price changes during swapping, the pool contract will continuously exchange the outbound asset for the inbound, progressively using all the liquidity available within the current tick interval[1](https://docs.uniswap.org/concepts/protocol/concentrated-liquidity#fn-1) until the next tick is reached. At this point, the contract switches to a new tick and activates any dormant liquidity within a position that has a boundary at the newly active tick. While each pool has the same number of underlying ticks, in practice only a portion of them are able to serve as active ticks. Due to the nature of the v3 smart contracts, tick spacing is directly correlated to the swap fee. Lower fee tiers allow closer potentially active ticks, and higher fees allow a relatively wider spacing of potential active ticks. While inactive ticks have no impact on transaction cost during swaps, crossing an active tick does increase the cost of the transaction in which it is crossed, as the tick crossing will activate the liquidity within any new positions using the given tick as a border. In areas where capital efficiency is paramount, such as stable coin pairs, narrower tick spacing increases the granularity of liquidity provisioning and will likely lower price impact when swapping - the result being significantly improved prices for stable coin swaps. [PreviousProtocol Concepts](https://dovish.gitbook.io/doveswap-v3/protocol-concepts) [NextFees](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/fees) Last updated 2 years ago --- # Range Orders | DoveSwap V3 Customizable liquidity positions, along with single-sided asset provisioning, allow for a new style of swapping with automated market makers: the range order. In typical order book markets, anyone can easily set a limit order: to buy or sell an asset at a specific predetermined price, allowing the order to be filled at an indeterminate time in the future. With DoveSwap V3, one can approximate a limit order by providing a single asset as liquidity within a specific range. Like traditional limit orders, range orders may be set with the expectation they will execute at some point in the future, with the target asset available for withdrawal after the spot price has crossed the full range of the order. Unlike some markets where limit orders may incur fees, the range order maker generates fees while the order is filled. This is due to the range order technically being a form of liquidity provisioning rather than a typical swap. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders#possibilities-of-range-orders) Possibilities of Range orders[​](https://docs.uniswap.org/concepts/protocol/range-orders#possibilities-of-range-orders) The nature of AMM design makes some styles of limit orders possible, while others cannot be replicated. The following are four examples of range orders and their traditional counterparts; the first two are possible, the second two are not. > One important distinction: range orders, unlike traditional limit orders, will be **unfilled** if the spot price crosses the given range and then reverses to recross in the opposite direction before the target asset is withdrawn. While you will be earning LP fees during this time, if the goal is to exit fully in the desired destination asset, you will need to keep an eye on the order and either manually remove your liquidity when the order has been filled or use a third party position manager service to withdraw on your behalf. #### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders#take-profit-orders) Take-Profit Orders[​](https://docs.uniswap.org/concepts/protocol/range-orders#take-profit-orders) > The current price of a DAI / ETH pool is 1,500 DAI / ETH. You would like to sell your ETH for DAI when the price of ETH reaches 1,600 DAI / ETH. This is possible, as the price space above the spot price is denominated in the higher valued asset, ETH. You can provide ETH at a price of 1,600 DAI / ETH and have the order filled when the spot price crosses your position. ![RangeOrder1](https://dovish.gitbook.io/doveswap-v3/~gitbook/image?url=https%3A%2F%2Fdocs.uniswap.org%2Fassets%2Fimages%2FRangeOrder1-b9d8771ff290b67b408790362ac6838e.png&width=300&dpr=4&quality=100&sign=64ae0b09&sv=2) ![RangeOrder1](https://dovish.gitbook.io/doveswap-v3/~gitbook/image?url=https%3A%2F%2Fdocs.uniswap.org%2Fassets%2Fimages%2FRangeOrder2-9578c6d42b3b8d3d062d0956aee84f1c.png&width=300&dpr=4&quality=100&sign=20caeca4&sv=2) * * * #### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders#buy-limit-orders) Buy Limit Orders[​](https://docs.uniswap.org/concepts/protocol/range-orders#buy-limit-orders) > The Current price of a DAI / ETH pool is 1,500 DAI / ETH. You expect that ETH will rebound after it drops to 1,000 at the next market downturn, so you would like to place a range order swapping DAI to ETH at the price of 1,000 DAI / ETH. This is possible, as the price space below the spot price is denominated in the lower-priced asset, DAI. You can provide DAI at the price of 1,000 DAI / ETH, which will be swapped for ETH when the spot price of ETH drops past 1,000 DAI / ETH. As the above examples show, in DoveSwap V3, the two paired assets in a given pool are separated above and below the spot price, with the higher price asset available above the spot price and the lower-priced asset below. The following examples show limit order styles that are unable to be replicated due to the separation of assets in price space. * * * #### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders#buy-stop-orders) Buy Stop Orders[​](https://docs.uniswap.org/concepts/protocol/range-orders#buy-stop-orders) > The current price of a DAI / ETH pool is 1,500 DAI / ETH. You expect the price of ETH to rocket up to 3,000 once it hits 2,000 DAI/ ETH, So you would like to place a range order from DAI to ETH at a price of 2,000 DAI/ETH. This is not possible as the price space above 1,500 DAI / ETH is denominated in ETH - and thus, you cannot provide the DAI necessary at your desired price to be swapped into ETH. * * * #### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders#stop-loss-orders) Stop-Loss Orders[​](https://docs.uniswap.org/concepts/protocol/range-orders#stop-loss-orders) > The current price of a DAI / ETH pool is 1,500 DAI / ETH. You expect once the price of ETH drops to below 1,000, it will tank to 200. So you would like to place a range order from ETH to DAI at a price of 1,000. This is not possible as the price space below the spot price is denominated in DAI, and so you cannot allocate the ETH necessary at 1,000 to be swapped into DAI. * * * ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders#fees) Fees[​](https://docs.uniswap.org/concepts/protocol/range-orders#fees) The fees due to your liquidity position will be denominated in both tokens of the given pair. In any of the above examples, after swapping ETH for DAI, or DAI for ETH, a small amount of both ETH and DAI will be due to your account as liquidity provisioning rewards. Approaches to concentration when setting range orders are up to the user. Selecting a wider range may generate more fees if there is price churn within your range, at the cost of increasing the risk of having your order unfilled if the spot price reverses before completing your full range. [PreviousOracle](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle) [NextSwaps](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/swaps) Last updated 2 years ago --- # Token Integration Issues | DoveSwap V3 Fee-on-transfer and rebasing tokens will not function correctly on v3. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/token-integration-issues#fee-on-transfer-tokens) Fee-on-transfer Tokens[​](https://docs.uniswap.org/concepts/protocol/integration-issues#fee-on-transfer-tokens) Fee-on-transfer tokens will not function with our router contracts. As a workaround, the token creators may create a token wrapper or a customized router. We will not be making a router that supports fee-on-transfer tokens in the future. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/token-integration-issues#rebasing-tokens) Rebasing Tokens[​](https://docs.uniswap.org/concepts/protocol/integration-issues#rebasing-tokens) Rebasing tokens will succeed in pool creation and swapping, but liquidity providers will bear the loss of a negative rebase when their position becomes active, with no way to recover the loss. [PreviousSwaps](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/swaps) [NextTechnical Reference](https://dovish.gitbook.io/doveswap-v3/technical-reference) Last updated 2 years ago --- # Technical Reference | DoveSwap V3 [Overview](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview) [Core](https://dovish.gitbook.io/doveswap-v3/technical-reference/core) [Periphery](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery) [Deployment Addresses](https://dovish.gitbook.io/doveswap-v3/technical-reference/deployment-addresses) [Error Codes](https://dovish.gitbook.io/doveswap-v3/technical-reference/error-codes) [PreviousToken Integration Issues](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/token-integration-issues) [NextOverview](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview) Last updated 2 years ago --- # Swaps | DoveSwap V3 ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/swaps#introduction) Introduction[​](https://docs.uniswap.org/concepts/protocol/swaps#introduction) Swaps are the most common way of interacting with the DoveSwap protocol. For end-users, swapping is straightforward: a user selects an ERC-20 token that they own and a token they would like to trade it for. Executing a swap sells the currently owned tokens for the proportional amount of the tokens desired, minus the swap fee, which is awarded to liquidity providers. Swapping with the DoveSwap protocol is a permissionless process. Swaps using the DoveSwap protocol are different from traditional order book trades in that they are not executed against discrete orders on a first-in-first-out basis — rather, swaps execute against a passive pool of liquidity, with liquidity providers earning fees proportional to their capital committed ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/swaps#price-impact) Price Impact[​](https://docs.uniswap.org/concepts/protocol/swaps#price-impact) In a traditional order-book market, a sizeable market-buy order may deplete the available liquidity of a prior limit-sell and continue to execute against a subsequent limit-sell order at a higher price. The result is the final execution price of the order is somewhere in between the two limit-sell prices against which the order was filled. Price impact affects the execution price of a swap similarly but is a result of a different dynamic. When using an automated market maker, the relative value of one asset in terms of the other continuously shifts during the execution of a swap, leaving the final execution price somewhere between where the relative price started - and ended. This dynamic affects every swap using the DoveSwap protocol, as it is an inextricable part of AMM design. As the amount of liquidity available at different price points can vary, the price impact for a given swap size will change relative to the amount of liquidity available at any given point in price space. The greater the liquidity available at a given price, the lower the price impact for a given swap size. The lesser the liquidity available, the higher the price impact. Approximate price impact is anticipated in real-time via the DoveSwap interface, and warnings appear if unusually high price impact will occur during a swap. Anyone executing a swap will have the ability to assess the circumstances of price impact when needed. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/swaps#slippage) Slippage[​](https://docs.uniswap.org/concepts/protocol/swaps#slippage) The other relevant detail to consider when approaching swaps with the DoveSwap protocol is slippage. Slippage is the term we use to describe alterations to a given price that could occur while a submitted transaction is pending. When transactions are submitted to Ethereum, their order of execution is established by the amount of "gas" offered as a fee for executing each transaction. The higher the fee offered, the faster the transaction is executed. The transactions with a lower gas fee will remain pending for an indeterminate amount of time. During this time, the price environment in which the transaction will eventually be executed will change, as other swaps will be taking place. Slippage tolerances establish a margin of change acceptable to the user beyond price impact. As long as the execution price is within the slippage range, e.g., %1, the transaction will be executed. If the execution price ends up outside of the accepted slippage range, the transaction will fail, and the swap will not occur. A comparable situation in a traditional market would be a market-buy order executed after a delay. One can know the expected price of a market-buy order when submitted, but much can change in the time between submission and execution. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/swaps#safety-checks) Safety Checks[​](https://docs.uniswap.org/concepts/protocol/swaps#safety-checks) Price impact and slippage can both change while a transaction is pending, which is why we have built numerous safety checks into the DoveSwap protocol to protect end-users from drastic changes in the execution environment of their swap. Some of the most commonly encountered safety checks: * **Expired** : A transaction error that occurs if a swap is pending longer than a predetermined deadline. The deadline is a point in time after which the swap will be canceled to protect against unusually long pending periods and the changes in price that typically accompany the passage of time. * **INSUFFICIENT\_OUTPUT\_AMOUNT** : When a user submits a swap, the DoveSwap interface will send an estimate of how much of the purchased token the user should expect to receive. If the anticipated output amount of a swap does not match the estimate within a certain margin of error (the slippage tolerance), the swap will be canceled. This attempts to protect the user from any drastic and unfavorable price changes while their transaction is pending. [PreviousRange Orders](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders) [NextToken Integration Issues](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/token-integration-issues) Last updated 2 years ago --- # Oracle | DoveSwap V3 All DoveSwap v3 pools can serve as oracles, offering access to historical price and liquidity data. This capability unlocks a wide range of on-chain use cases. Historical data is stored as an array of observations. At first, each pool tracks only a single observation, overwriting it as blocks elapse. All DoveSwap v3 pools can serve as oracles, offering access to historical price and liquidity data. This capability unlocks a wide range of on-chain use cases. Historical data is stored as an array of observations. At first, each pool tracks only a single observation, overwriting it as blocks elapse. This limits how far into the past users may access data. However, any party willing to pay the transaction fees may [increase the number of tracked observations](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#increaseobservationcardinalitynext) (up to a maximum of `65535`), expanding the period of data availability to ~9 days or more. Storing price and liquidity history directly in the pool contract substantially reduces the potential for logical errors on the part of the calling contract, and reduces integration costs by eliminating the need to store historical values. Additionally, the v3 oracle's considerable maximum length makes oracle price manipulation significantly more difficult, as the calling contract may cheaply construct a time-weighted average over any arbitrary range inside of (or fully encompassing) the length of the oracle array. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#observations) Observations[​](https://docs.uniswap.org/concepts/protocol/oracle#observations) `Observation`s take the following form: Copy struct Observation { // the block timestamp of the observation uint32 blockTimestamp; // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized int56 tickCumulative; // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) since the pool was first initialized uint160 secondsPerLiquidityCumulativeX128; // whether or not the observation is initialized bool initialized; } Copy `Observation`s may be retrieved via the [`observations`](https://docs.uniswap.org/contracts/v3/reference/core/interfaces/pool/IUniswapV3PoolState#observations) method on v3 pools. However, this is _not_ the recommended way to consume oracle data. Instead, prefer [`observe`](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#observe) : Copy function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); Each time `observe` is called, the caller must specify an array containing any number of seconds ago, denoting the times to return observations from. Note that each of the given times must be more recent (or as old as) the oldest stored observation. Note: if the times don't correspond exactly to a block in which an observation was written, a counterfactual observation will be constructed, removing the need for the caller to interpolate manually. This is one of the primary reasons to use `observe` over `observations`. Note that because the oracle is only updated at most once every block, calling `observe` with a `secondsAgo` value of `0` will return the most recently written observation, which can only be as recent as the beginning of the current block (or older). ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#tick-accumulator) Tick Accumulator[​](https://docs.uniswap.org/concepts/protocol/oracle#tick-accumulator) The tick accumulator stores the cumulative sum of the active tick at the time of the observation. The tick accumulator value increases monotonically and grows by the value of the current tick - per second. To derive the arithmetic mean tick over an interval, the caller needs to retrieve two observations, one after the other, take the delta of the two values, and divide by the time elapsed between them. Calculating a TWAP from the tick accumulator is also covered in the [**whitepaper**](https://uniswap.org/whitepaper-v3.pdf) . Note that using an arithmetic mean tick to derive a price corresponds to a _geometric_ mean price. See [OracleLibrary](https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/libraries/OracleLibrary.sol) for an example of how to use the tick accumulator. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#liquidity-accumulator) Liquidity Accumulator[​](https://docs.uniswap.org/concepts/protocol/oracle#liquidity-accumulator) The liquidity accumulator stores the value of seconds / in-range liquidity at the time of the observation. The liquidity accumulator value increases monotonically and grows by the value of seconds / in-range liquidity - per second. To derive the harmonic mean liquidity over an interval, the caller needs to retrieve two observations, one after the other, take the delta of the two values, then divide the time elapsed by this value. Calculating TWAL is addressed in finer detail in the [**whitepaper**](https://uniswap.org/whitepaper-v3.pdf) . **NOTE** The in-range liquidity accumulator should be used with care. Because the current tick and the current in-range liquidity can be entirely uncorrelated, there are scenarios in which taking the arithmetic mean tick and the harmonic mean liquidity over the same interval in a pool can inaccurately characterize this pool relative to another. For example, if the current tick on pool A is 0 for 5 seconds, and 100 for 5 seconds, the tick accumulator will be 50. If over this same interval, the in-range liquidity was 5000 and 50, the harmonic mean liquidity will be ~99. Compare this to pool B (composed of the same assets) where the tick was 50 and the in-range liquidity was ~99 for 10 seconds. The accumulator values will be identical, but the underlying behavior is of course quite different. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#deriving-price-from-a-tick) Deriving Price From A Tick[​](https://docs.uniswap.org/concepts/protocol/oracle#deriving-price-from-a-tick) > When we use "active tick" or otherwise to refer to the current tick of a pool, we mean the lower tick boundary that is closest to the current price. When a pool is created, each token is assigned to either `token0` or `token1` based on the contract address of the tokens in the pair. Whether or not a token is `token0` or `token1` is meaningless; it is only used to maintain a fixed assignment for the purpose of relative valuation and general logic in the pool contract. Deriving an asset price from the current tick is achievable due to the fixed expression across the pool contract of token0 in terms of token1. * * * An example of finding the price of WETH in a WETH / USDC pool, where WETH is `token0` and USDC is `token1`: You have an oracle reading that shows a return of `tickCumulative` as \[`70_000`, `1_070_000`\], with an elapsed time between the observations of 10 seconds. We can derive the average tick over this interval by taking the difference in accumulator values (`1_070_000` - `70_000` = `1_000_000`), and dividing by the time elapsed (`1_000_000` / `10` = `100_000`). With a tick reading of `100_000`, we can find the value of `token1` (USDC) in terms of `token0` (WETH) by using the current tick as `i` in the formula `p(i) = 1.0001**i` (see 6.1 in the [whitepaper](https://uniswap.org/whitepaper-v3.pdf) ). `1.0001**100_000 ≅ 22015.5` USDC / WETH * * * Ticks are signed integers and can be expressed as a negative number, so for any circumstances where `token0` is of a lower value than `token1`, a negative tick value will be returned by `tickCumulative` and a relative value of `< 0` will be returned by a calculation of `token0` in terms of `token1`.his limits how far into the past users may access data. However, any party willing to pay the transaction fees may increase the number of tracked observations (up to a maximum of `65535`), expanding the period of data availability to ~9 days or more. Storing price and liquidity history directly in the pool contract substantially reduces the potential for logical errors on the part of the calling contract, and reduces integration costs by eliminating the need to store historical values. Additionally, the v3 oracle's considerable maximum length makes oracle price manipulation significantly more difficult, as the calling contract may cheaply construct a time-weighted average over any arbitrary range inside of (or fully encompassing) the length of the oracle array. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#observations-1) Observations[​](https://docs.uniswap.org/concepts/protocol/oracle#observations) `Observation`s take the following form: Copy struct Observation { // the block timestamp of the observation uint32 blockTimestamp; // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized int56 tickCumulative; // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) since the pool was first initialized uint160 secondsPerLiquidityCumulativeX128; // whether or not the observation is initialized bool initialized; } `Observation`s may be retrieved via the `observations` method on v3 pools. However, this is _not_ the recommended way to consume oracle data. Instead, prefer `observe`: Copy function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); Each time `observe` is called, the caller must specify an array containing any number of seconds ago, denoting the times to return observations from. Note that each of the given times must be more recent (or as old as) the oldest stored observation. Note: if the times don't correspond exactly to a block in which an observation was written, a counterfactual observation will be constructed, removing the need for the caller to interpolate manually. This is one of the primary reasons to use `observe` over `observations`. Note that because the oracle is only updated at most once every block, calling `observe` with a `secondsAgo` value of `0` will return the most recently written observation, which can only be as recent as the beginning of the current block (or older). ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#tick-accumulator-1) Tick Accumulator[​](https://docs.uniswap.org/concepts/protocol/oracle#tick-accumulator) The tick accumulator stores the cumulative sum of the active tick at the time of the observation. The tick accumulator value increases monotonically and grows by the value of the current tick - per second. To derive the arithmetic mean tick over an interval, the caller needs to retrieve two observations, one after the other, take the delta of the two values, and divide by the time elapsed between them. Note that using an arithmetic mean tick to derive a price corresponds to a _geometric_ mean price. See OracleLibrary for an example of how to use the tick accumulator. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#liquidity-accumulator-1) Liquidity Accumulator[​](https://docs.uniswap.org/concepts/protocol/oracle#liquidity-accumulator) The liquidity accumulator stores the value of seconds / in-range liquidity at the time of the observation. The liquidity accumulator value increases monotonically and grows by the value of seconds / in-range liquidity - per second. To derive the harmonic mean liquidity over an interval, the caller needs to retrieve two observations, one after the other, take the delta of the two values, then divide the time elapsed by this value. **NOTE** The in-range liquidity accumulator should be used with care. Because the current tick and the current in-range liquidity can be entirely uncorrelated, there are scenarios in which taking the arithmetic mean tick and the harmonic mean liquidity over the same interval in a pool can inaccurately characterize this pool relative to another. For example, if the current tick on pool A is 0 for 5 seconds, and 100 for 5 seconds, the tick accumulator will be 50. If over this same interval, the in-range liquidity was 5000 and 50, the harmonic mean liquidity will be ~99. Compare this to pool B (composed of the same assets) where the tick was 50 and the in-range liquidity was ~99 for 10 seconds. The accumulator values will be identical, but the underlying behavior is of course quite different. ### [](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/oracle#deriving-price-from-a-tick-1) Deriving Price From A Tick[​](https://docs.uniswap.org/concepts/protocol/oracle#deriving-price-from-a-tick) > When we use "active tick" or otherwise to refer to the current tick of a pool, we mean the lower tick boundary that is closest to the current price. When a pool is created, each token is assigned to either `token0` or `token1` based on the contract address of the tokens in the pair. Whether or not a token is `token0` or `token1` is meaningless; it is only used to maintain a fixed assignment for the purpose of relative valuation and general logic in the pool contract. Deriving an asset price from the current tick is achievable due to the fixed expression across the pool contract of token0 in terms of token1. * * * An example of finding the price of WETH in a WETH / USDC pool, where WETH is `token0` and USDC is `token1`: You have an oracle reading that shows a return of `tickCumulative` as \[`70_000`, `1_070_000`\], with an elapsed time between the observations of 10 seconds. We can derive the average tick over this interval by taking the difference in accumulator values (`1_070_000` - `70_000` = `1_000_000`), and dividing by the time elapsed (`1_000_000` / `10` = `100_000`). With a tick reading of `100_000`, we can find the value of `token1` (USDC) in terms of `token0` (WETH) by using the current tick as `i` in the formula `p(i) = 1.0001**i` . `1.0001**100_000 ≅ 22015.5` USDC / WETH * * * Ticks are signed integers and can be expressed as a negative number, so for any circumstances where `token0` is of a lower value than `token1`, a negative tick value will be returned by `tickCumulative` and a relative value of `< 0` will be returned by a calculation of `token0` in terms of `token1`. [PreviousFees](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/fees) [NextRange Orders](https://dovish.gitbook.io/doveswap-v3/protocol-concepts/range-orders) Last updated 2 years ago --- # Core | DoveSwap V3 [DoveSwapV3Factory](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3factory) [DoveSwapV3Pool](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool) [DoveSwapV3PoolDeployer](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pooldeployer) [PreviousOverview](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview) [NextDoveSwapV3Factory](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3factory) Last updated 2 years ago --- # Overview | DoveSwap V3 DoveSwap V3 is a binary smart contract system comprised of many libraries, which together make the Core and Periphery. Core contracts provide fundamental safety guarantees for all parties interacting with DoveSwap. They define the logic of pool generation, the pools themselves, and the interactions involving the respective assets therein. Periphery contracts interact with one or more Core contracts but are not part of the core. They are designed to provide methods of interacting with the core that increase clarity and user safety. External calls will primarily call the periphery interfaces. Externally available functions are all viewable in the reference documentation. ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#core) Core[​](https://docs.uniswap.org/contracts/v3/reference/overview#core) The core consists of a single factory, a pool deployer, and the many pools the factory will create. A significant amount of care and attention has been given to gas optimization in the core contracts. The result is a substantial reduction in gas costs for all protocol interactions compared to V2, at the cost of a reduction in code clarity. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#factory) Factory[​](https://docs.uniswap.org/contracts/v3/reference/overview#factory) The factory defines the logic for generating pools. A pool is defined by two tokens, which make up the asset pair, and a fee. There can be multiple pools of the same asset pair, distinguished only by their swap fee. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#pools) Pools[​](https://docs.uniswap.org/contracts/v3/reference/overview#pools) Pools primarily serve as automated market makers for the paired assets. Additionally, they expose price oracle data and may be used as an asset source for flash transactions. ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#periphery) Periphery[​](https://docs.uniswap.org/contracts/v3/reference/overview#periphery) The periphery is a constellation of smart contracts designed to support domain-specific interactions with the core. As the DoveSwap protocol is a permissionless system, the contracts described below have no special privileges and are only a small subset of possible periphery-like contracts. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#swaprouter) SwapRouter[​](https://docs.uniswap.org/contracts/v3/reference/overview#swaprouter) The swap router supports all the basic requirements of a front-end offering trading. It natively supports single trades (x to y) and multihop trades (e.g. x to y to z). #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#nonfungible-position-manager) Nonfungible Position Manager[​](https://docs.uniswap.org/contracts/v3/reference/overview#nonfungible-position-manager) The position manager handles the logic transactions involving the creation, adjustment, or exiting of positions. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#oracle) Oracle[​](https://docs.uniswap.org/contracts/v3/reference/overview#oracle) The oracle provides price and liquidity data useful for a wide variety of system designs, and is available in every deployed pool. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/overview#periphery-libraries) Periphery Libraries[​](https://docs.uniswap.org/contracts/v3/reference/overview#periphery-libraries) The libraries provide a variety of helper functions developers may need, like calculating pool addresses, safe transfer functions, and more. [PreviousTechnical Reference](https://dovish.gitbook.io/doveswap-v3/technical-reference) [NextCore](https://dovish.gitbook.io/doveswap-v3/technical-reference/core) Last updated 2 years ago --- # DoveSwapV3Factory | DoveSwap V3 Deploys DoveSwapV3 pools and manages ownership and control over pool protocol fees ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3factory#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3factory#createpool) createPool[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#createpool) Copy function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool) Creates a pool for the given two tokens and fee tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments are invalid. **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#parameters) Name Type Description `tokenA` address One of the two tokens in the desired pool `tokenB` address The other of the two tokens in the desired pool `fee` uint24 The desired fee for the pool **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#return-values) Name Type Description `pool` address The address of the newly created pool #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3factory#setowner) setOwner[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#setowner) Copy function setOwner( address _owner ) external Updates the owner of the factory Must be called by the current owner **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#parameters-1) Name Type Description `_owner` address The new owner of the factory #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3factory#enablefeeamount) enableFeeAmount[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#enablefeeamount) Copy function enableFeeAmount( uint24 fee, int24 tickSpacing ) public Enables a fee amount with the given tickSpacing Fee amounts may never be removed once enabled **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Factory#parameters-2) Name Type Description `fee` uint24 The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) `tickSpacing` int24 The spacing between ticks to be enforced for all pools created with the given fee amount [PreviousCore](https://dovish.gitbook.io/doveswap-v3/technical-reference/core) [NextDoveSwapV3Pool](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool) Last updated 2 years ago --- # Periphery | DoveSwap V3 [QuoterV2](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2) [TickLens](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/ticklens) [NonfungiblePositionManager](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager) [NonfungibleTokenPositionDescriptor](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor) [SwapRouter](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter) [V3Migrator](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/v3migrator) [PreviousDoveSwapV3PoolDeployer](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pooldeployer) [NextQuoterV2](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2) Last updated 2 years ago --- # DoveSwapV3PoolDeployer | DoveSwap V3 ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pooldeployer#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3PoolDeployer#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pooldeployer#deploy) deploy[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3PoolDeployer#deploy) Copy function deploy( address factory, address token0, address token1, uint24 fee, int24 tickSpacing ) internal returns (address pool) Deploys a pool with the given parameters by transiently setting the parameters storage slot and then clearing it after deploying the pool. **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3PoolDeployer#parameters) Name Type Description `factory` address The contract address of the DoveSwap V3 factory `token0` address The first token of the pool by address sort order `token1` address The second token of the pool by address sort order `fee` uint24 The fee collected upon every swap in the pool, denominated in hundredths of a bip `tickSpacing` int24 The spacing between usable ticks [PreviousDoveSwapV3Pool](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool) [NextPeriphery](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery) Last updated 2 years ago --- # QuoterV2 | DoveSwap V3 Allows getting the expected amount out or amount in for a given swap without executing the swap These functions are not gas efficient and should _not_ be called on chain. Instead, optimistically execute the swap and check the amounts in the callback. ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2#constructor) constructor[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#constructor) Copy function constructor( ) public #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2#uniswapv3swapcallback) doveswapV3SwapCallback[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#uniswapv3swapcallback) Copy function doveswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes data ) external view override Called to `msg.sender` after executing a swap via IDoveSwapV3Pool#swap. In the implementation you must pay the pool tokens owed for the swap. The caller of this method must be checked to be a DoveSwapV3Pool deployed by the canonical DoveSwapV3Factory. amount0Delta and amount1Delta can both be 0 if no tokens were swapped. **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#parameters) Name Type Description `amount0Delta` int256 The amount of token0 that was sent (negative) or must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of token0 to the pool. |`amount1Delta` | int256 | The amount of token1 that was sent (negative) or must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of token1 to the pool. |`data` | bytes | Any data passed through by the caller via the IDoveSolwapV3PoolActions#swap call #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2#quoteexactinputsingle) quoteExactInputSingle[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#quoteexactinputsingle) Copy function quoteExactInputSingle( ) public override returns (uint256 amountOut, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2#quoteexactinput) quoteExactInput[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#quoteexactinput) Copy function quoteExactInput( ) public override returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2#quoteexactoutputsingle) quoteExactOutputSingle[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#quoteexactoutputsingle) Copy function quoteExactOutputSingle( ) public override returns (uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2#quoteexactoutput) quoteExactOutput[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/QuoterV2#quoteexactoutput) Copy function quoteExactOutput( ) public override returns (uint256 amountIn, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate) [PreviousPeriphery](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery) [NextTickLens](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/ticklens) Last updated 2 years ago --- # DoveSwapV3Pool | DoveSwap V3 ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#blocktimestamp) \_blockTimestamp[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#_blocktimestamp) Copy function _blockTimestamp( ) internal view virtual returns (uint32) Returns the block timestamp truncated to 32 bits, i.e. mod 2\*\*32. This method is overridden in tests. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#snapshotcumulativesinside) snapshotCumulativesInside[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#snapshotcumulativesinside) Copy function snapshotCumulativesInside( int24 tickLower, int24 tickUpper ) external view override noDelegateCall returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside) 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:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters) Name Type Description `tickLower` int24 The lower tick of the range `tickUpper` int24 The upper tick of the range **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#return-values) Name Type Description `tickCumulativeInside` int56 The snapshot of the tick accumulator for the range `secondsPerLiquidityInsideX128` uint160 The snapshot of seconds per liquidity for the range `secondsInside` uint32 The snapshot of seconds per liquidity for the range #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#observe) observe[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#observe) Copy function observe( uint32[] secondsAgos ) external view override noDelegateCall returns (int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s) 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:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-1) Name Type Description `secondsAgos` uint32\[\] From how long ago each cumulative tick and liquidity value should be returned **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#return-values-1) Name Type Description `tickCumulatives` int56\[\] Cumulative tick values as of each `secondsAgos` from the current block timestamp `secondsPerLiquidityCumulativeX128s` uint160\[\] Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block timestamp #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#increaseobservationcardinalitynext) increaseObservationCardinalityNext[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#increaseobservationcardinalitynext) Copy function increaseObservationCardinalityNext( uint16 observationCardinalityNext ) external override lock noDelegateCall 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:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-2) Name Type Description `observationCardinalityNext` uint16 The desired minimum number of observations for the pool to store #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#initialize) initialize[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#initialize) Copy function initialize( uint160 sqrtPriceX96 ) external override Sets the initial price for the pool not locked because it initializes unlocked **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-3) Name Type Description `sqrtPriceX96` uint160 the initial sqrt price of the pool as a Q64.96 #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#mint) mint[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#mint) Copy function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes data ) external override lock returns (uint256 amount0, uint256 amount1) Adds liquidity for the given recipient/tickLower/tickUpper position noDelegateCall is applied indirectly via \_modifyPosition **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-4) Name Type Description `recipient` address The address for which the liquidity will be created `tickLower` int24 The lower tick of the position in which to add liquidity `tickUpper` int24 The upper tick of the position in which to add liquidity `amount` uint128 The amount of liquidity to mint `data` bytes Any data that should be passed through to the callback **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#return-values-2) Name Type Description `amount0` uint256 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback `amount1` uint256 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#collect) collect[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#collect) Copy function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external override lock returns (uint128 amount0, uint128 amount1) 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:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-5) Name Type Description `recipient` address The address which should receive the fees collected `tickLower` int24 The lower tick of the position for which to collect fees `tickUpper` int24 The upper tick of the position for which to collect fees `amount0Requested` uint128 How much token0 should be withdrawn from the fees owed `amount1Requested` uint128 How much token1 should be withdrawn from the fees owed **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#return-values-3) Name Type Description `amount0` uint128 The amount of fees collected in token0 `amount1` uint128 The amount of fees collected in token1 #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#burn) burn[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#burn) Copy function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external override lock returns (uint256 amount0, uint256 amount1) Burn liquidity from the sender and account tokens owed for the liquidity to the position noDelegateCall is applied indirectly via \_modifyPosition **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-6) Name Type Description `tickLower` int24 The lower tick of the position for which to burn liquidity `tickUpper` int24 The upper tick of the position for which to burn liquidity `amount` uint128 How much liquidity to burn **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#return-values-4) Name Type Description `amount0` uint256 The amount of token0 sent to the recipient `amount1` uint256 The amount of token1 sent to the recipient #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#swap) swap[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#swap) Copy function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes data ) external override noDelegateCall returns (int256 amount0, int256 amount1) Swap token0 for token1, or token1 for token0 The caller of this method receives a callback in the form of IDoveswapV3SwapCallback#doveswapV3SwapCallback **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-7) Name Type Description `recipient` address The address to receive the output of the swap `zeroForOne` bool The direction of the swap, true for token0 to token1, false for token1 to token0 `amountSpecified` int256 The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) `sqrtPriceLimitX96` uint160 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap `data` bytes Any data to be passed through to the callback **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#return-values-5) Name Type Description `amount0` int256 The delta of the balance of token0 of the pool, exact when negative, minimum when positive `amount1` int256 The delta of the balance of token1 of the pool, exact when negative, minimum when positive #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#flash) flash[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#flash) Copy function flash( address recipient, uint256 amount0, uint256 amount1, bytes data ) external override lock noDelegateCall 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 IDoveSwapV3FlashCallback#doveswapV3FlashCallback Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling with 0 amount{0,1} and sending the donation amount(s) from the callback **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-8) Name Type Description `recipient` address The address which will receive the token0 and token1 amounts `amount0` uint256 The amount of token0 to send `amount1` uint256 The amount of token1 to send `data` bytes Any data to be passed through to the callback #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#setfeeprotocol) setFeeProtocol[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#setfeeprotocol) Copy function setFeeProtocol( uint8 feeProtocol0, uint8 feeProtocol1 ) external override lock onlyFactoryOwner Set the denominator of the protocol's % share of the fees **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-9) Name Type Description `feeProtocol0` uint8 new protocol fee for token0 of the pool `feeProtocol1` uint8 new protocol fee for token1 of the pool #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pool#collectprotocol) collectProtocol[​](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#collectprotocol) Copy function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external override lock onlyFactoryOwner returns (uint128 amount0, uint128 amount1) Collect the protocol fee accrued to the pool **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#parameters-10) Name Type Description `recipient` address The address to which collected protocol fees should be sent `amount0Requested` uint128 The maximum amount of token0 to send, can be 0 to collect fees in only token1 `amount1Requested` uint128 The maximum amount of token1 to send, can be 0 to collect fees in only token0 **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/core/UniswapV3Pool#return-values-6) Name Type Description `amount0` uint128 The protocol fee collected in token0 `amount1` uint128 The protocol fee collected in token1 [PreviousDoveSwapV3Factory](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3factory) [NextDoveSwapV3PoolDeployer](https://dovish.gitbook.io/doveswap-v3/technical-reference/core/doveswapv3pooldeployer) Last updated 2 years ago --- # Deployment Addresses | DoveSwap V3 v3Factory contract deployed to: `0xdE474Db1Fa59898BC91314328D29507AcD0D593c` multicall contract deployed to: `0xB344D07f505FbccAA592995ec88EBFCbeE97224b` NFTPositionDescriptor contract deployed to: `0xA0412D678C56c27669349ea3c6A71783E5fA6bEe` NFTPositionManager contract deployed to: `0x8Bd4AB4cF017e15D630F325aa4F6362c224b864b` Quoter contract deployed to: `0x3F886B1274bB2ec14e0543c51fe0F9b73C975219` TickLens contract deployed to: `0x0e88C06437891D2a56352eaa2bf0d107472eC0f4` SwapRouter contract deployed to: `0x95bF28C6502a0544c7ADc154BC60D886d9A80a5c` permit2 contract deployed to: `0xc7F96bB93Dd616f961a8875f0f32E56dEB6Fa5a6` Universal Router contract deployed to: `0x7481C16E7782608CcBa70029c0Fd41D78Aa6B56E` [PreviousV3Migrator](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/v3migrator) [NextError Codes](https://dovish.gitbook.io/doveswap-v3/technical-reference/error-codes) Last updated 2 years ago --- # TickLens | DoveSwap V3 ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/ticklens#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/TickLens#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/ticklens#getpopulatedticksinword) getPopulatedTicksInWord[​](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/TickLens#getpopulatedticksinword) Copy function getPopulatedTicksInWord( address pool, int16 tickBitmapIndex ) public returns (struct ITickLens.PopulatedTick[] populatedTicks) Get all the tick data for the populated ticks from a word of the tick bitmap of a pool **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/TickLens#parameters) Name Type Description `pool` address The address of the pool for which to fetch populated tick data `tickBitmapIndex` int16 The index of the word in the tick bitmap for which to parse the bitmap and fetch all the populated ticks **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/lens/TickLens#return-values) Name Type Description `populatedTicks` ITickLens.PopulatedTick\[\] An array of tick data for the given word in the tick bitmap [PreviousQuoterV2](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/quoterv2) [NextNonfungiblePositionManager](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager) Last updated 2 years ago --- # V3Migrator | DoveSwap V3 ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/v3migrator#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/V3Migrator#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/v3migrator#constructor) constructor[​](https://docs.uniswap.org/contracts/v3/reference/periphery/V3Migrator#constructor) Copy function constructor( ) public #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/v3migrator#receive) receive[​](https://docs.uniswap.org/contracts/v3/reference/periphery/V3Migrator#receive) Copy function receive( ) external #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/v3migrator#migrate) migrate[​](https://docs.uniswap.org/contracts/v3/reference/periphery/V3Migrator#migrate) Copy function migrate( ) external [PreviousSwapRouter](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter) [NextDeployment Addresses](https://dovish.gitbook.io/doveswap-v3/technical-reference/deployment-addresses) Last updated 2 years ago --- # NonfungibleTokenPositionDescriptor | DoveSwap V3 Produces a string containing the data URI for a JSON metadata string ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungibleTokenPositionDescriptor#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor#constructor) constructor[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungibleTokenPositionDescriptor#constructor) Copy function constructor( ) publicsol #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor#tokenuri) tokenURI[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungibleTokenPositionDescriptor#tokenuri) Copy function tokenURI( contract INonfungiblePositionManager positionManager, uint256 tokenId ) external returns (string) Produces the URI describing a particular token ID for a position manager Note this URI may be a data: URI with the JSON contents directly inlined **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungibleTokenPositionDescriptor#parameters) Name Type Description `positionManager` contract INonfungiblePositionManager The position manager for which to describe the token `tokenId` uint256 The ID of the token for which to produce a description, which may not be valid **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungibleTokenPositionDescriptor#return-values) Name Type Description `The` contract INonfungiblePositionManager URI of the ERC721-compliant metadata #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor#flipratio) flipRatio[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungibleTokenPositionDescriptor#flipratio) Copy function flipRatio( ) public returns (bool) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor#tokenratiopriority) tokenRatioPriority[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungibleTokenPositionDescriptor#tokenratiopriority) Copy function tokenRatioPriority( ) public returns (int256) [PreviousNonfungiblePositionManager](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager) [NextSwapRouter](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter) Last updated 2 years ago --- # SwapRouter | DoveSwap V3 Router for stateless execution of swaps against DoveSwap V3 > Input parameters are viewable on the **Swap Router Interface** ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter#constructor) constructor[​](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#constructor) Copy function constructor( ) public #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter#uniswapv3swapcallback) doveswapV3SwapCallback[​](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#uniswapv3swapcallback) Copy function doveswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes data ) external Called to `msg.sender` after executing a swap via IDoveSwapV3Pool#swap. In the implementation you must pay the pool tokens owed for the swap. The caller of this method must be checked to be a DoveSwapV3Pool deployed by the canonical DoveSwapV3Factory. amount0Delta and amount1Delta can both be 0 if no tokens were swapped. **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#parameters) Name Type Description `amount0Delta` int256 The amount of token0 that was sent (negative) or must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of token0 to the pool. `amount1Delta` int256 The amount of token1 that was sent (negative) or must be received (positive) by the pool by the end of the swap. If positive, the callback must send that amount of token1 to the pool. `data` bytes Any data passed through by the caller via the IDoveSwapV3PoolActions#swap call #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter#exactinputsingle) exactInputSingle[​](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#exactinputsingle) Copy function exactInputSingle( struct ISwapRouter.ExactInputSingleParams params ) external returns (uint256 amountOut) Swaps `amountIn` of one token for as much as possible of another token **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#parameters-1) Name Type Description `params` struct ISwapRouter.ExactInputSingleParams The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#return-values) Name Type Description `amountOut` uint256 The amount of the received token #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter#exactinput) exactInput[​](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#exactinput) Copy function exactInput( struct ISwapRouter.ExactInputParams params ) external returns (uint256 amountOut) Swaps `amountIn` of one token for as much as possible of another along the specified path **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#parameters-2) Name Type Description `params` struct ISwapRouter.ExactInputParams The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#return-values-1) Name Type Description `amountOut` uint256 The amount of the received token #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter#exactoutputsingle) exactOutputSingle[​](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#exactoutputsingle) Copy function exactOutputSingle( struct ISwapRouter.ExactOutputSingleParams params ) external returns (uint256 amountIn) Swaps as little as possible of one token for `amountOut` of another token **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#parameters-3) Name Type Description `params` struct ISwapRouter.ExactOutputSingleParams The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#return-values-2) Name Type Description `amountIn` uint256 The amount of the input token #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/swaprouter#exactoutput) exactOutput[​](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#exactoutput) Copy function exactOutput( struct ISwapRouter.ExactOutputParams params ) external returns (uint256 amountIn) Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#parameters-4) Name Type Description `params` struct ISwapRouter.ExactOutputParams The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/SwapRouter#return-values-3) Name Type Description `amountIn` uint256 The amount of the input token [PreviousNonfungibleTokenPositionDescriptor](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor) [NextV3Migrator](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/v3migrator) Last updated 2 years ago --- # NonfungiblePositionManager | DoveSwap V3 Wraps DoveSwap V3 positions in the ERC721 non-fungible token interface ### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#functions) Functions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#functions) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#constructor) constructor[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#constructor) Copy function constructor( ) public #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#positions) positions[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#positions) Copy function positions( uint256 tokenId ) external view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1) Returns the position information associated with a given token ID. Throws if the token ID is not valid. **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#parameters) Name Type Description `tokenId` uint256 The ID of the token that represents the position **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#return-values) Name Type Description `nonce` uint96 The nonce for permits `operator` address The address that is approved for spending `token0` address The address of the token0 for a specific pool `token1` address The address of the token1 for a specific pool `fee` uint24 The fee associated with the pool `tickLower` int24 The lower end of the tick range for the position `tickUpper` int24 The higher end of the tick range for the position `liquidity` uint128 The liquidity of the position `feeGrowthInside0LastX128` uint256 The fee growth of token0 as of the last action on the individual position `feeGrowthInside1LastX128` uint256 The fee growth of token1 as of the last action on the individual position `tokensOwed0` uint128 The uncollected amount of token0 owed to the position as of the last computation `tokensOwed1` uint128 The uncollected amount of token1 owed to the position as of the last computation #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#mint) mint[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#mint) Copy function mint( struct INonfungiblePositionManager.MintParams params ) external returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1) Creates a new position wrapped in a NFT Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized a method does not exist, i.e. the pool is assumed to be initialized. **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#parameters-1) Name Type Description `params` struct INonfungiblePositionManager.MintParams The params necessary to mint a position, encoded as `MintParams` in calldata **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#return-values-1) Name Type Description `tokenId` uint256 The ID of the token that represents the minted position `liquidity` uint128 The amount of liquidity for this position `amount0` uint256 The amount of token0 `amount1` uint256 The amount of token1 #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#tokenuri) tokenURI[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#tokenuri) Copy function tokenURI( uint256 tokenId ) public view returns (string) Returns a URI describing a particular token ID **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#parameters-2) Name Type Description `tokenId` uint256 The ID of the token that represents the minted position **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#return-values-2) A base64 string with the URI data. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#baseuri) baseURI[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#baseuri) Copy function baseURI( ) public returns (string) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#increaseliquidity) increaseLiquidity[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#increaseliquidity) Copy function increaseLiquidity( struct INonfungiblePositionManager.IncreaseLiquidityParams params ) external returns (uint128 liquidity, uint256 amount0, uint256 amount1)l Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#parameters-3) Name Type Description `params` struct INonfungiblePositionManager.IncreaseLiquidityParams tokenId The ID of the token for which liquidity is being increased, **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#return-values-3) Name Type Description `liquidity` uint128 The new liquidity amount as a result of the increase `amount0` uint256 The amount of token0 to achieve resulting liquidity `amount1` uint256 The amount of token1 to achieve resulting liquidity #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#decreaseliquidity) decreaseLiquidity[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#decreaseliquidity) Copy function decreaseLiquidity( struct INonfungiblePositionManager.DecreaseLiquidityParams params ) external returns (uint256 amount0, uint256 amount1) Decreases the amount of liquidity in a position and accounts it to the position **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#parameters-4) Name Type Description `params` struct INonfungiblePositionManager.DecreaseLiquidityParams tokenId The ID of the token for which liquidity is being decreased, **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#return-values-4) Name Type Description `amount0` uint256 The amount of token0 accounted to the position's tokens owed `amount1` uint256 The amount of token1 accounted to the position's tokens owed #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#collect) collect[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#collect) Copy function collect( struct INonfungiblePositionManager.CollectParams params ) external returns (uint256 amount0, uint256 amount1) Collects up to a maximum amount of fees owed to a specific position to the recipient **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#parameters-5) Name Type Description `params` struct INonfungiblePositionManager.CollectParams tokenId The ID of the NFT for which tokens are being collected, recipient The account that should receive the tokens, amount0Max The maximum amount of token0 to collect, amount1Max The maximum amount of token1 to collect **Return Values:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#return-values-5) Name Type Description `amount0` uint256 The amount of fees collected in token0 `amount1` uint256 The amount of fees collected in token1 #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#burn) burn[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#burn) Copy function burn( uint256 tokenId ) external Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens must be collected first. **Parameters:**[**​**](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#parameters-6) Name Type Description `tokenId` uint256 The ID of the token that is being burned #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#getandincrementnonce) \_getAndIncrementNonce[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#_getandincrementnonce) Copy function _getAndIncrementNonce( ) internal returns (uint256) #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#getapproved) getApproved[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#getapproved) Copy function getApproved( ) public view returns (address) Returns the account approved for `tokenId` token. Requirements: * `tokenId` must exist. #### [](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungiblepositionmanager#approve) \_approve[​](https://docs.uniswap.org/contracts/v3/reference/periphery/NonfungiblePositionManager#_approve) Copy function _approve( ) internal Overrides \_approve to use the operator in the position, which is packed with the position permit nonce [PreviousTickLens](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/ticklens) [NextNonfungibleTokenPositionDescriptor](https://dovish.gitbook.io/doveswap-v3/technical-reference/periphery/nonfungibletokenpositiondescriptor) Last updated 2 years ago --- # Governance | DoveSwap V3 Coming soon! [PreviousError Codes](https://dovish.gitbook.io/doveswap-v3/technical-reference/error-codes) [NextTokenomics](https://dovish.gitbook.io/doveswap-v3/tokenomics) Last updated 2 years ago --- # Error Codes | DoveSwap V3 LiquidityMath.sol * `LS`: Liquidity Sub * `LA`: Liquidity Add Oracle.sol * `OLD`: The target must be chronologically after the oldest observation * `I`: The pool has not been initialized Position.sol * `NP`: Burn cannot be called for a position with 0 liquidity Tick.sol * `LO`: LiquidityGrossAfter must be less than MaxLiquidity TickMath.sol * `T`: The given tick must be less than, or equal to, the maximum tick * `R`: second inequality must be < because the price can never reach the price at the max tick TransferHelper.sol * `TF`: Transfer Failed : errors with TF if transfer fails UniswapV3Pool.sol * `LOK`: The reentrancy guard. A transaction cannot re-enter the pool mid-swap * `TLU`: The lower tick must be below the upper tick * `TLM`: The lower tick must be greater, or equal to, the minimum tick * `TUM`: The upper tick must be lesser than, or equal to, the maximum tick * `AI`: The pool is already initialized * `M0`: Mint 0, The balance of token0 in the given pool before minting must be less than, or equal to, the balance after minting * `M1`: Mint 1, The balance of token1 in the given pool before minting must be less than, or equal to, the balance after minting * `AS`: `amountSpecified` cannot be zero * `SPL`: Square root price limit * `IIA`: Insufficient input amount, an insufficient amount of input token was sent during the callback * `L`: Liquidity in the pool must be greater than zero for a flash to be executed * `F0`: The balance of token0 in the given pool before the flash transaction must be less than, or equal to, the balance of token0 after the flash plus the fee * `F1`: The balance of token1 in the given pool before the flash transaction must be less than, or equal to, the balance of token1 after the flash plus the fee [PreviousDeployment Addresses](https://dovish.gitbook.io/doveswap-v3/technical-reference/deployment-addresses) [NextGovernance](https://dovish.gitbook.io/doveswap-v3/governance) Last updated 2 years ago --- # Tokenomics | DoveSwap V3 DOV will be the official token of DoveSwap. The main utility of DOV will be in governance. For example, DOV holders will have the ability to turn on fees, or to choose to enact a deflationary model for the token once fees are turned on. Once minted, DOV token's address will be listed here. [](https://dovish.gitbook.io/doveswap-v3/tokenomics#benefits) Benefits --------------------------------------------------------------------------- Once the community takes over the governance role, DOV holders will have ownership over: * DOV governance * DOV community Treasury * The protocol fee switch [](https://dovish.gitbook.io/doveswap-v3/tokenomics#distribution) Distribution ----------------------------------------------------------------------------------- 100 million DOV will be minted at genesis and will become accessible over the course of 3 years. The initial 3 year allocation will be as follows: * 60% to DoveSwap community members via the treasury, liquidity mining incentives, historical liquidity provision etc * 25% to team members and future employees (team allocation is vested over 3 years, with a 6 month cliff) * 15% to investors A perpetual inflation rate of 2% per year will start after 3 years, ensuring continued participation and contribution to DoveSwap [](https://dovish.gitbook.io/doveswap-v3/tokenomics#early-adopter-benefits) Early Adopter Benefits ------------------------------------------------------------------------------------------------------- To rewards historical liquidity providers and early supporters, DoveSwap will be rewarding them with 20% of the circulating supply of DOV over 3 snapshots. Early adopter rewards will be split into 3 snapshots in order to allow broader community management and engagement while also favoring the earliest adopters in terms of rewards. Each snapshot is planned to release 15-20% of the circulating supply of DOV at that point in time Snapshots will be posted to the Twitter and updated here as the program runs. [](https://dovish.gitbook.io/doveswap-v3/tokenomics#liquidity-mining-incentives) Liquidity Mining Incentives ----------------------------------------------------------------------------------------------------------------- The currently incentivized pools are WETH/DOV, WETH/USDC, USDC/USDT, WETH/MATIC. Pool incentives are currently being finetuned before long term rewards programs (>1 month) will be in place. [](https://dovish.gitbook.io/doveswap-v3/tokenomics#buy-and-burn-mechanism) Buy and Burn Mechanism ------------------------------------------------------------------------------------------------------- Fees from swap volume will be used to buy and burn DOV from the WETH/DOV pool. This will provide long term buy pressure for the token as well as reward long term token holders. The burned tokens will be sent to the [`null address`](https://zkevm.polygonscan.com/address/0x000000000000000000000000000000000000dead) . 75% of the swap fees will be used to supply the buy and burn mechanism, with the team getting a portion of protocol revenue proportionate to their token ownership share (25%). For the first phase, the team will be donating their share of protocol revenue to further support the buy and burn mechanism. [PreviousGovernance](https://dovish.gitbook.io/doveswap-v3/governance) [NextStaking Mechanics](https://dovish.gitbook.io/doveswap-v3/staking-mechanics) Last updated 2 years ago --- # Real Yield | DoveSwap V3 WETH is distributed to staked DOV on the Yield page. The WETH is taken from the swap revenues of DoveSwap, and the distribution rate is updated weekly. The swap revenues are 25% of the fee revenues on each pool in DoveSwap. The WETH rewards can be claimed at any time (and they accrue throughout time), and the distribution rate is updated weekly as swap fees are collected weekly. Example: The first weekly distribution for DOV real yield was 0.5 WETH, which accrues to everyone who staked DOV tokens. The free floating DOV supply is ~500k token, after accounting for tokens in the WETH/DOV LP pool and staker contract, so that equates to a real yield value of over 200% even if everyone stakes, which is unlikely. [PreviousStaking Mechanics](https://dovish.gitbook.io/doveswap-v3/staking-mechanics) [NextFuture of DoveSwap](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap) Last updated 2 years ago --- # Future of DoveSwap | DoveSwap V3 [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#usddov-token-plans) $DOV token plans ----------------------------------------------------------------------------------------------------- We have quite a few long term plans for the $DOV token. To address them all, it would be easier to break it down by the different sectors that they are all involved in: ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#doveswap-dex) DoveSwap \[DEX\]: For the initial phase of our DEX, to avoid disrupting the returns of our LP’s, we’ve left the fee switch turned off. However, eventually, we’ll be turning on the fee switch. We’ll be putting in a proposal for the timeline and all $DOV holders will get to vote for whether turning on the fee switch at that point in time is desirable. Update: The fee switch has now been turned on, and details can be found in [Buy and Burn Mechanism](https://dovish.gitbook.io/doveswap-v3/tokenomics#buy-and-burn-mechanism) Fundamentally, this converts the $DOV token to one of value beyond just governance. Because at that point, it will start receiving 10-25% of the trading fees throughout the pools that DoveSwap supports! For some context as to how to calculate how valuable that is as of this writing: We’ve had 37k in the past 24 hours of daily trading volume. Given that 15% of trading fees (0.3%) approximates to about 0.05% The amount that the $DOV token holders would receive is about $18.5 for that one day alone. For a year, assuming 0 growth altogether, that would be about $6.75k in fees accumulated for $DOV holders. And that’s on a TVL of about 550k, which would make it about a 1.2% ROI, without any consideration for future growth and increased trading volumes! So this is just the raw value for holding $DOV tokens alone for their DEX token utility. ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#shrikeperps) ShrikePerps As many of you know, we’ve launched a Perp DEX called ShrikePerps that is live on [https://shrike.dovish.finance/](https://shrike.dovish.finance/) We believe in the potential of our perpetual derivatives on Polygon zkEVM, which we know has much more room for growth. Which is why we know that our governance token $SHK will be released on a limited scale. As promised, our $DOV token will function as an exclusive passport to our empire of protocols. As such, $SHK token sales will be limited to holders of $DOV token holders, with holders of more tokens getting access to much more $SHK tokens! This is an exclusive privilege for our earlier holders, and allows them to get safer perp DEX returns from the perp DEX trading fees (30%), albeit at a lower rate compared to $SHLP holders (70%) Furthermore, managing both a Perp DEX and a DEX is actually beneficial for the long term because we can incentivize the appropriate pools on either to maximize trading volume on both DEX-es! ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#long-term-plans-with-other-products-to-be-launched) Long term plans with other products to be launched Eventually, the $DOV token passport will graduate from just being used for gauging token sale tiers, and we’ll have mechanisms in place for staking/wrapping $DOV token such that our users can get access to revenue streams across all our products. We hope you look forward to it! ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#partnerships-with-other-protocols) Partnerships with other protocols: ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#frax) FRAX DoveSwap is proud to work officially with FRAX to be the first farms on Polygon zkEVM for FRAX assets such as FRAX, frxETH, and sfrxETH. This gives folks on zkEVM the chance to access staked ETH equivalents, and will be a core product for future protocols to come! ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#api3) API3 We've had the pleasure of being invited to be on the API3 OEV alpha program where ShrikePerps actually benefit from frontrunners! Check out the details here: [https://twitter.com/DovishFi/status/1658834829918588940?s=20](https://twitter.com/DovishFi/status/1658834829918588940?s=20) ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#layerswap) Layerswap DoveSwap is proud to be partners with Layerswap to bring easy on-ramp boarding for crypto to Polygon zkEVM. Our users are now able to bring over ETH from CEX-es to Polygon zkEVM in about 2-3 minutes, greatly minimizing time spent on bridges and L1's! ### [](https://dovish.gitbook.io/doveswap-v3/future-of-doveswap#tba-we-have-more-to-come) TBA \[We have more to come!\] [PreviousReal Yield](https://dovish.gitbook.io/doveswap-v3/real-yield) Last updated 2 years ago --- # Staking Mechanics | DoveSwap V3 Staking on most DEXs heavily favors short term liquidity providers. The problem is especially exacerbated on Concentrated Liquidity Market Maker(CLMM) DEXs like UniswapV3. For example, Ribbon Finance ran a short lived incentive program using Uniswap's V3 staker to promote liquidity in their RBN/WETH pool. However, this was exploited by sophisticated individuals setting up an automated strategy that consisted of the following: 1. Depositing liquidity into the minimum possible range. 2. Exiting the position when it went out of range. 3. Selling the received rewards. 4. Swapping into a new minimum range position around the current price. ![](https://dovish.gitbook.io/doveswap-v3/~gitbook/image?url=https%3A%2F%2F1193601336-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FKXlN1p9XkfvxszUZ94RT%252Fuploads%252FaJUoDXGh7P6J7ohxepai%252Fimage.png%3Falt%3Dmedia%26token%3D40c9c4a7-ad7b-41ef-94a9-6874ecfd6d82&width=768&dpr=4&quality=100&sign=47612031&sv=2) The program ended with 77% of the rewards going to just 14 accounts, all using this same strategy. It’s pretty clear that this is not an ideal outcome, both from a liquidity provision perspective, as well as from the perspective of rewarding the RBN community. [](https://dovish.gitbook.io/doveswap-v3/staking-mechanics#our-solution) Our Solution ------------------------------------------------------------------------------------------ Our staking model is designed to reward users for more time spent in the price range, ensuring that everyone is rewarded fairly for their contributions. DoveSwap's innovative staking model includes a vesting period, meaning that if you provide in-range liquidity for less than the vesting period, you receive significantly decreased rewards. This means that individuals who attempt the hyper-concentrated short term liquidity strategy outlined above will get virtually no rewards, and in fact their returns will almost certainly be negative due to swapping and slippage costs. In our current farms the vesting period has been set to 7 days (will be updated). This might differ for future farms. To break it down: If your LP is in range and staked for 4 hours, you'll only make 1/6 of the APR if you choose to unstake. You'll only be able to get your full APR after your tokens are staked for longer than the vesting period. [PreviousTokenomics](https://dovish.gitbook.io/doveswap-v3/tokenomics) [NextReal Yield](https://dovish.gitbook.io/doveswap-v3/real-yield) Last updated 2 years ago ---