Skip to content

Commit

Permalink
minor proofreading and adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed Oct 18, 2023
1 parent 575af94 commit 3af9cca
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 35 deletions.
2 changes: 2 additions & 0 deletions src/keywords.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"/create-liquidity": [
"liquidity",
"LP",
"lp",
"provide",
"provision",
"supply"
]
Expand Down
2 changes: 1 addition & 1 deletion src/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const TRANSLATIONS: Translation[] = [
export const SOL_ROUTES: Route[] = [
{
path: "initialize",
title: "Pool Initialize"
title: "Initialize Pool"
},
{
path: "create-liquidity",
Expand Down
22 changes: 15 additions & 7 deletions src/pages/create-liquidity/index.html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const description = "Providing Liquidity to a Uniswap V4 Pool"
export const keywords = [
"liquidity",
"LP",
"lp",
"provide",
"provision",
"supply",
]
Expand All @@ -21,14 +23,20 @@ export const codes = [
},
]

const html = `<blockquote>
<p>Expect Uniswap Labs to release an official contract around launch</p>
</blockquote>
<blockquote>
<p>⚠️ Using the test router in production will lead to a loss of funds ⚠️ </p>
</blockquote>
<p>Using the <code>v4-core</code> provided <em>test</em> router, we can provide liquidity to a pool. This should only be used for non-production testing purposes</p>
const html = `<ul>
<li>Provide Liquidity to a Uniswap v4 Pool</li>
</ul>
<p>⚠️ Using the test router in production <strong>will lead to a loss of funds</strong> ⚠️ </p>
<p>Using the <code>v4-core</code> provided <em>test</em> router, we can provide liquidity to a pool. These snippets should only be used for non-production, testing purposes</p>
<p>Creating liquidity involves using periphery contracts. It is <strong>not</strong> recommended to directly provide liquidity with <code>poolManager.modifyPosition</code></p>
<p>Providing liquidity involves 3 primary arguments:</p>
<ul>
<li>Which pool to swap on</li>
<li>The range of the the liquidity, i.e. the upper and lower bounds</li>
<li>A <code>liquidity</code> value that determines input token amounts</li>
</ul>
<p>Please see <a href="https://github.com/Uniswap/v4-periphery/blob/main/contracts/libraries/LiquidityAmounts.sol">LiquidityAmounts</a> for calculating the <code>liquidity</code> value</p>
<h4>Expect Uniswap Labs to release an official contract around launch</h4>
<pre><code class="language-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.20;</span>
Expand Down
16 changes: 11 additions & 5 deletions src/pages/create-liquidity/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
title: Create Liquidity
version: 0.8.20
description: Providing Liquidity to a Uniswap V4 Pool
keywords: [liquidity, LP, provision, supply]
keywords: [liquidity, LP, lp, provide, provision, supply]
---

> Expect Uniswap Labs to release an official contract around launch
* Provide Liquidity to a Uniswap v4 Pool

> ⚠️ Using the test router in production will lead to a loss of funds ⚠️
⚠️ Using the test router in production **will lead to a loss of funds** ⚠️

Using the `v4-core` provided *test* router, we can provide liquidity to a pool. This should only be used for non-production testing purposes
Using the `v4-core` provided *test* router, we can provide liquidity to a pool. These snippets should only be used for non-production, testing purposes

Creating liquidity involves using periphery contracts. It is **not** recommended to directly provide liquidity with `poolManager.modifyPosition`

Providing liquidity involves 3 primary arguments:

* Which pool to swap on
* The range of the the liquidity, i.e. the upper and lower bounds
* A `liquidity` value that determines input token amounts

Creating liquidity involves using periphery contracts. It is **not** recommended to directly provide liquidity with `poolManager.modifyPosition`
Please see [LiquidityAmounts](https://github.com/Uniswap/v4-periphery/blob/main/contracts/libraries/LiquidityAmounts.sol) for calculating the `liquidity` value

#### Expect Uniswap Labs to release an official contract around launch
```solidity
{{{CreateLiquidity}}}
```
Expand Down
2 changes: 1 addition & 1 deletion src/pages/initialize/PoolInitialize.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract PoolInitialize {
uint160 sqrtPriceX96,
bytes calldata hookData
) external {
// sort your tokens! v4 expects: token0 < token1
// sort your tokens! v4 requires token0 < token1
if (token0 > token1) {
(token0, token1) = (token1, token0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/initialize/PoolInitializeExampleInputs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract PoolInitializeExampleInputs {
// floor(sqrt(1) * 2^96)
uint160 startingPrice = 79228162514264337593543950336;

// Custom hook requires a timestamp when initializing it
// Assume the custom hook requires a timestamp when initializing it
bytes memory hookData = abi.encode(block.timestamp);

PoolKey memory pool = PoolKey({
Expand Down
26 changes: 19 additions & 7 deletions src/pages/initialize/index.html.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// metadata
export const version = "0.8.20"
export const title = "Pool Initialization"
export const title = "Initialize a Pool"
export const description = "Initializing a pool in Uniswap v4"

export const keywords = [
Expand All @@ -15,16 +15,28 @@ export const keywords = [
export const codes = [
{
fileName: "PoolInitialize.sol",
code: "Ly8gU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVApwcmFnbWEgc29saWRpdHkgXjAuOC4yMDsKCmltcG9ydCB7SVBvb2xNYW5hZ2VyfSBmcm9tICJAdW5pc3dhcC92NC1jb3JlL2NvbnRyYWN0cy9pbnRlcmZhY2VzL0lQb29sTWFuYWdlci5zb2wiOwppbXBvcnQge0lIb29rc30gZnJvbSAiQHVuaXN3YXAvdjQtY29yZS9jb250cmFjdHMvaW50ZXJmYWNlcy9JSG9va3Muc29sIjsKaW1wb3J0IHtQb29sS2V5fSBmcm9tICJAdW5pc3dhcC92NC1jb3JlL2NvbnRyYWN0cy90eXBlcy9Qb29sS2V5LnNvbCI7CmltcG9ydCB7Q3VycmVuY3lMaWJyYXJ5LCBDdXJyZW5jeX0gZnJvbSAiQHVuaXN3YXAvdjQtY29yZS9jb250cmFjdHMvdHlwZXMvQ3VycmVuY3kuc29sIjsKCmNvbnRyYWN0IFBvb2xJbml0aWFsaXplIHsKICAgIHVzaW5nIEN1cnJlbmN5TGlicmFyeSBmb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5hZ2VyID0gSVBvb2xNYW5hZ2VyKDB4MDEpOwoKICAgIC8vLyBAbm90aWNlIEluaXRpYWxpemUgYSBob29rbGVzcyBwb29sOgogICAgLy8vICAgICAwLjA1JSBzd2FwIGZlZQogICAgLy8vICAgICB0aWNrIHNwYWNpbmcgb2YgMTAKICAgIC8vLyAgICAgc3RhcnRpbmcgcHJpY2Ugb2YgMToxCiAgICBmdW5jdGlvbiBleGFtcGxlQSgpIGV4dGVybmFsIHsKICAgICAgICBhZGRyZXNzIHRva2VuMCA9IGFkZHJlc3MoMHgxMSk7CiAgICAgICAgYWRkcmVzcyB0b2tlbjEgPSBhZGRyZXNzKDB4MjIpOwogICAgICAgIHVpbnQyNCBzd2FwRmVlID0gNTAwOwogICAgICAgIGludDI0IHRpY2tTcGFjaW5nID0gMTA7CgogICAgICAgIC8vIGZsb29yKHNxcnQoMSkgKiAyXjk2KQogICAgICAgIHVpbnQxNjAgc3RhcnRpbmdQcmljZSA9IDc5MjI4MTYyNTE0MjY0MzM3NTkzNTQzOTUwMzM2OwoKICAgICAgICAvLyBob29rbGVzcyBwb29sIGRvZXNudCBleHBlY3QgYW55IGluaXRpYWxpemF0aW9uIGRhdGEKICAgICAgICBieXRlcyBtZW1vcnkgaG9va0RhdGEgPSBuZXcgYnl0ZXMoMCk7CgogICAgICAgIFBvb2xLZXkgbWVtb3J5IHBvb2wgPSBQb29sS2V5KHsKICAgICAgICAgICAgY3VycmVuY3kwOiBDdXJyZW5jeSh0b2tlbjApLAogICAgICAgICAgICBjdXJyZW5jeTE6IEN1cnJlbmN5KHRva2VuMSksCiAgICAgICAgICAgIGZlZTogc3dhcEZlZSwKICAgICAgICAgICAgdGlja1NwYWNpbmc6IHRpY2tTcGFjaW5nLAogICAgICAgICAgICBob29rczogSUhvb2tzKGFkZHJlc3MoMHgwKSkKICAgICAgICB9KTsKICAgICAgICBtYW5hZ2VyLmluaXRpYWxpemUocG9vbCwgc3RhcnRpbmdQcmljZSwgaG9va0RhdGEpO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mcgb2YgMTAKICAgIC8vLyAgICAgc3RhcnRpbmcgcHJpY2Ugb2YgMToxCiAgICBmdW5jdGlvbiBleGFtcGxlQSgpIGV4dGVybmFsIHsKICAgICAgICBhZGRyZXNzIHRva2VuMCA9IGFkZHJlc3MoMHgxMSk7CiAgICAgICAgYWRkcmVzcyB0b2tlbjEgPSBhZGRyZXNzKDB4MjIpOwogICAgICAgIHVpbnQyNCBzd2FwRmVlID0gNTAwOwogICAgICAgIGludDI0IHRpY2tTcGFjaW5nID0gMTA7CgogICAgICAgIC8vIGZsb29yKHNxcnQoMSkgKiAyXjk2KQogICAgICAgIHVpbnQxNjAgc3RhcnRpbmdQcmljZSA9IDc5MjI4MTYyNTE0MjY0MzM3NTkzNTQzOTUwMzM2OwoKICAgICAgICAvLyBob29rbGVzcyBwb29sIGRvZXNudCBleHBlY3QgYW55IGluaXRpYWxpemF0aW9uIGRhdGEKICAgICAgICBieXRlcyBtZW1vcnkgaG9va0RhdGEgPSBuZXcgYnl0ZXMoMCk7CgogICAgICAgIFBvb2xLZXkgbWVtb3J5IHBvb2wgPSBQb29sS2V5KHsKICAgICAgICAgICAgY3VycmVuY3kwOiBDdXJyZW5jeSh0b2tlbjApLAogICAgICAgICAgICBjdXJyZW5jeTE6IEN1cnJlbmN5KHRva2VuMSksCiAgICAgICAgICAgIGZlZTogc3dhcEZlZSwKICAgICAgICAgICAgdGlja1NwYWNpbmc6IHRpY2tTcGFjaW5nLAogICAgICAgICAgICBob29rczogSUhvb2tzKGFkZHJlc3MoMHgwKSkKICAgICAgICB9KTsKICAgICAgICBtYW5hZ2VyLmluaXRpYWxpemUocG9vbCwgc3RhcnRpbmdQcmljZSwgaG9va0RhdGEpOwogICAgfQoKICAgIC8vLyBAbm90aWNlIEluaXRpYWxpemUgYSBwb29sIHdpdGggYSBjdXN0b20gaG9vazoKICAgIC8vLyAgICAgMC4zMCUgc3dhcCBmZWUKICAgIC8vLyAgICAgdGljayBzcGFjaW5nIG9mIDYwCiAgICAvLy8gICAgIHN0YXJ0aW5nIHByaWNlIG9mIDE6MQogICAgLy8vICAgICBob29rJ3MgYmVmb3JlSW5pdGlhbGl6ZSgpIHJlcXVpcmVzIHByb3ZpZGluZyBhIHRpbWVzdGFtcAogICAgZnVuY3Rpb24gZXhhbXBsZUIoKSBleHRlcm5hbCB7CiAgICAgICAgYWRkcmVzcyBob29rID0gYWRkcmVzcygweDgwKTsgLy8gcHJlZml4IGluZGljYXRlcyB0aGUgaG9vayBvbmx5IGhhcyBhIGJlZm9yZUluaXRpYWxpemUoKSBmdW5jdGlvbgogICAgICAgIGFkZHJlc3MgdG9rZW4wID0gYWRkcmVzcygweDExKTsKICAgICAgICBhZGRyZXNzIHRva2VuMSA9IGFkZHJlc3MoMHgyMik7CiAgICAgICAgdWludDI0IHN3YXBGZWUgPSAzMDAwOwogICAgICAgIGludDI0IHRpY2tTcGFjaW5nID0gNjA7CgogICAgICAgIC8vIGZsb29yKHNxcnQoMSkgKiAyXjk2KQogICAgICAgIHVpbnQxNjAgc3RhcnRpbmdQcmljZSA9IDc5MjI4MTYyNTE0MjY0MzM3NTkzNTQzOTUwMzM2OwoKICAgICAgICAvLyBBc3N1bWUgdGhlIGN1c3RvbSBob29rIHJlcXVpcmVzIGEgdGltZXN0YW1wIHdoZW4gaW5pdGlhbGl6aW5nIGl0CiAgICAgICAgYnl0ZXMgbWVtb3J5IGhvb2tEYXRhID0gYWJpLmVuY29kZShibG9jay50aW1lc3RhbXApOwoKICAgICAgICBQb29sS2V5IG1lbW9yeSBwb29sID0gUG9vbEtleSh7CiAgICAgICAgICAgIGN1cnJlbmN5MDogQ3VycmVuY3kodG9rZW4wKSwKICAgICAgICAgICAgY3VycmVuY3kxOiBDdXJyZW5jeSh0b2tlbjEpLAogICAgICAgICAgICBmZWU6IHN3YXBGZWUsCiAgICAgICAgICAgIHRpY2tTcGFjaW5nOiB0aWNrU3BhY2luZywKICAgICAgICAgICAgaG9va3M6IElIb29rcyhob29rKQogICAgICAgIH0pOwogICAgICAgIG1hbmFnZXIuaW5pdGlhbGl6ZShwb29sLCBzdGFydGluZ1ByaWNlLCBob29rRGF0YSk7CiAgICB9Cn0K",
},
]

const html = `<p>A single trading pair (ETH/USDC), can exist as an infinite number of pools in v4. Uniswap v4 does <strong>not</strong> restrict fee tiers to 1%, 0.30%, or 0.05%. The same trading pair can also have an infinite number of hooks.</p>
const html = `<ul>
<li>Create a Uniswap v4 Pool</li>
</ul>
<p>A single trading pair (<em>ETH/USDC</em>), can exist as an infinite number of pools in v4. Uniswap v4 does <strong>not</strong> restrict fee tiers to 1%, 0.30%, or 0.05%. The same trading pair can also have an infinite number of hooks.</p>
<p>Initializing a V3 Pair involved deploying a contract via the factory. In V4, pools are initialized and managed by a single contract: <code>PoolManager</code></p>
<p><em>Think of a <code>PoolKey</code> as the unique identifier for a pool, i.e. like a v3 pair&#39;s contract address</em></p>
<p>Creating a Pool is determined by 5 primary arguments:</p>
<ul>
<li>Trading pair <em>currency0, currency1</em></li>
<li>Fee tier</li>
<li>Tick spacing</li>
<li>Hook</li>
<li>Starting Price</li>
</ul>
<pre><code class="language-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.20;</span>
Expand All @@ -48,7 +60,7 @@ const html = `<p>A single trading pair (ETH/USDC), can exist as an infinite numb
<span class="hljs-keyword">uint160</span> sqrtPriceX96,
<span class="hljs-keyword">bytes</span> <span class="hljs-keyword">calldata</span> hookData
</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> </span>{
<span class="hljs-comment">// sort your tokens! v4 expects: token0 &lt; token1</span>
<span class="hljs-comment">// sort your tokens! v4 requires token0 &lt; token1</span>
<span class="hljs-keyword">if</span> (token0 <span class="hljs-operator">&gt;</span> token1) {
(token0, token1) <span class="hljs-operator">=</span> (token1, token0);
}
Expand All @@ -64,7 +76,7 @@ const html = `<p>A single trading pair (ETH/USDC), can exist as an infinite numb
}
}
</code></pre><h3>Examples of Initializing a V4 Pool</h3>
<p>Remove array element by shifting elements from right to left</p>
<p><em>Hooks are not mandatory, you can create a pool without a hook</em></p>
<pre><code class="language-solidity"><span class="hljs-comment">// SPDX-License-Identifier: MIT</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.8.20;</span>
Expand Down Expand Up @@ -120,7 +132,7 @@ const html = `<p>A single trading pair (ETH/USDC), can exist as an infinite numb
<span class="hljs-comment">// floor(sqrt(1) * 2^96)</span>
<span class="hljs-keyword">uint160</span> startingPrice <span class="hljs-operator">=</span> <span class="hljs-number">79228162514264337593543950336</span>;
<span class="hljs-comment">// Custom hook requires a timestamp when initializing it</span>
<span class="hljs-comment">// Assume the custom hook requires a timestamp when initializing it</span>
<span class="hljs-keyword">bytes</span> <span class="hljs-keyword">memory</span> hookData <span class="hljs-operator">=</span> <span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encode</span>(<span class="hljs-built_in">block</span>.<span class="hljs-built_in">timestamp</span>);
PoolKey <span class="hljs-keyword">memory</span> pool <span class="hljs-operator">=</span> PoolKey({
Expand Down
18 changes: 16 additions & 2 deletions src/pages/initialize/index.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
---
title: Pool Initialization
title: Initialize a Pool
version: 0.8.20
description: Initializing a pool in Uniswap v4
keywords: [pool, initialize, init, create, pair, factory]
---

A single trading pair (ETH/USDC), can exist as an infinite number of pools in v4. Uniswap v4 does **not** restrict fee tiers to 1%, 0.30%, or 0.05%. The same trading pair can also have an infinite number of hooks.
* Create a Uniswap v4 Pool

A single trading pair (*ETH/USDC*), can exist as an infinite number of pools in v4. Uniswap v4 does **not** restrict fee tiers to 1%, 0.30%, or 0.05%. The same trading pair can also have an infinite number of hooks.

Initializing a V3 Pair involved deploying a contract via the factory. In V4, pools are initialized and managed by a single contract: `PoolManager`

*Think of a `PoolKey` as the unique identifier for a pool, i.e. like a v3 pair's contract address*

Creating a Pool is determined by 5 primary arguments:

* Trading pair *currency0, currency1*
* Fee tier
* Tick spacing
* Hook
* Starting Price

```solidity
{{{PoolInitialize}}}
```

### Examples of Initializing a V4 Pool

*Hooks are not mandatory, you can create a pool without a hook*

```solidity
{{{PoolInitializeExampleInputs}}}
```
Loading

0 comments on commit 3af9cca

Please sign in to comment.