diff --git a/.github/workflows/search.yaml b/.github/workflows/search.yaml index 08c9f2c629..addea3f6ce 100644 --- a/.github/workflows/search.yaml +++ b/.github/workflows/search.yaml @@ -2,14 +2,14 @@ name: Algolia Search on: schedule: - - cron: "0 10 * * *" + - cron: '0 10 * * *' jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Run Scraper - run: | - brew install jq - docker run -e "APPLICATION_ID=${{ secrets.ALGOLIA_APP_ID }}" -e "API_KEY=${{ secrets.API_KEY }}" -e "CONFIG=$(cat ./config.json | jq -r tostring)" algolia/docsearch-scraper \ No newline at end of file + - uses: actions/checkout@v2 + - name: Run Scraper + run: | + brew install jq + docker run -e "APPLICATION_ID=${{ secrets.ALGOLIA_APP_ID }}" -e "API_KEY=${{ secrets.API_KEY }}" -e "CONFIG=$(cat ./config.json | jq -r tostring)" algolia/docsearch-scraper diff --git a/README.md b/README.md index dc1db3232b..8bf47ef07d 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. # Contributing to Uniswap Docs + Contributing to the docs site is a great way to get involved in the dev community and help other devs along the way! Check out our guidelines [here](https://github.com/Uniswap/uniswap-docs/blob/main/CONTRIBUTING.md). # How to generate markdown files from solidity Natspec comments @@ -40,7 +41,6 @@ Edit config.json file with Create a markdown file in its respective versioned docs, or versioned SDK, directory. - ## Installation ```console diff --git a/SDK_versioned_docs/version-1.0.0/guides/_category_.json b/SDK_versioned_docs/version-1.0.0/guides/_category_.json index 92fca5fc3e..bb10c2893b 100644 --- a/SDK_versioned_docs/version-1.0.0/guides/_category_.json +++ b/SDK_versioned_docs/version-1.0.0/guides/_category_.json @@ -1,6 +1,5 @@ { - "label": "Guides", - "position": 1, - "collapsed": false - - } \ No newline at end of file + "label": "Guides", + "position": 1, + "collapsed": false +} diff --git a/SDK_versioned_docs/version-1.0.0/reference/02-data.md b/SDK_versioned_docs/version-1.0.0/reference/02-data.md index 44e32e81b4..3b461f5a0e 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/02-data.md +++ b/SDK_versioned_docs/version-1.0.0/reference/02-data.md @@ -16,7 +16,7 @@ This function fetches Uniswap reserve data for a given token address on a given export async function getTokenReserves( tokenAddress: string, chainIdOrProvider: ChainIdOrProvider = 1 -): Promise; +): Promise ``` ## Input Parameters @@ -29,13 +29,10 @@ export async function getTokenReserves( ## Example Usage ```typescript -const tokenAddress = "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359"; // DAI Mainnet -const chainIdOrProvider: ChainIdOrProvider = 1; // could be e.g. window.ethereum instead +const tokenAddress = '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359' // DAI Mainnet +const chainIdOrProvider: ChainIdOrProvider = 1 // could be e.g. window.ethereum instead -const tokenReserves: TokenReservesNormalized = await getTokenReserves( - tokenAddress, - chainIdOrProvider -); +const tokenReserves: TokenReservesNormalized = await getTokenReserves(tokenAddress, chainIdOrProvider) /* { diff --git a/SDK_versioned_docs/version-1.0.0/reference/03-computation.md b/SDK_versioned_docs/version-1.0.0/reference/03-computation.md index 83c32b8b6e..c4203caa64 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/03-computation.md +++ b/SDK_versioned_docs/version-1.0.0/reference/03-computation.md @@ -17,7 +17,7 @@ This function computes market details for the passed reserves data. Markets are export function getMarketDetails( optionalReservesInput: OptionalReserves, optionalReservesOutput: OptionalReserves -): MarketDetails; +): MarketDetails ``` ## Input Parameters @@ -30,9 +30,9 @@ export function getMarketDetails( ## Example Usage ```typescript -const reserves: ChainIdOrProvider = await getTokenReserves(tokenAddress); +const reserves: ChainIdOrProvider = await getTokenReserves(tokenAddress) -const marketDetails: MarketDetails = getMarketDetails(undefined, reserves); // ETH<>ERC20 +const marketDetails: MarketDetails = getMarketDetails(undefined, reserves) // ETH<>ERC20 /* { @@ -75,7 +75,7 @@ export function getTradeDetails( tradeExact: TRADE_EXACT, _tradeAmount: BigNumberish, marketDetails: MarketDetails -): TradeDetails; +): TradeDetails ``` ## Input Parameters @@ -89,17 +89,13 @@ export function getTradeDetails( ## Example Usage ```typescript -const _purchaseAmount: BigNumber = new BigNumber("2.5"); -const _decimals: number = 18; -const tradeAmount: BigNumber = _purchaseAmount.multipliedBy(10 ** _decimals); -const marketDetails: MarketDetails = getMarketDetails(undefined, reserves); // ETH<>ERC20 +const _purchaseAmount: BigNumber = new BigNumber('2.5') +const _decimals: number = 18 +const tradeAmount: BigNumber = _purchaseAmount.multipliedBy(10 ** _decimals) +const marketDetails: MarketDetails = getMarketDetails(undefined, reserves) // ETH<>ERC20 // buy exactly 2.5 of an 18 decimal ERC20 with ETH -const tradeDetails: TradeDetails = getTradeDetails( - TRADE_EXACT.OUTPUT, - tradeAmount, - marketDetails -); +const tradeDetails: TradeDetails = getTradeDetails(TRADE_EXACT.OUTPUT, tradeAmount, marketDetails) /* { diff --git a/SDK_versioned_docs/version-1.0.0/reference/04-format.md b/SDK_versioned_docs/version-1.0.0/reference/04-format.md index b6615a7002..3a40ea31a7 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/04-format.md +++ b/SDK_versioned_docs/version-1.0.0/reference/04-format.md @@ -10,10 +10,7 @@ This function formats values to a specified number of significant digits. ## Function Signature ```typescript -export function formatSignificant( - bigNumberish: BigNumberish, - options?: FormatSignificantOptions -): string; +export function formatSignificant(bigNumberish: BigNumberish, options?: FormatSignificantOptions): string ``` ## Input Parameters @@ -26,7 +23,7 @@ export function formatSignificant( ## Example Usage ```typescript -const formatted: string = formatSignificant("123456", { significantDigits: 3 }); // 1.23 +const formatted: string = formatSignificant('123456', { significantDigits: 3 }) // 1.23 ``` # formatSignificantDecimals @@ -40,7 +37,7 @@ export function formatSignificantDecimals( bigNumberish: BigNumberish, decimals: number, options?: FormatSignificantOptions -): string; +): string ``` ## Input Parameters @@ -54,9 +51,9 @@ export function formatSignificantDecimals( ## Example Usage ```typescript -const formatted: string = formatSignificantDecimals("1234560000000000000", 18, { +const formatted: string = formatSignificantDecimals('1234560000000000000', 18, { significantDigits: 3, -}); // 1.23 +}) // 1.23 ``` # formatFixed @@ -66,10 +63,7 @@ This function formats values to a specified number of decimal places. ## Function Signature ```typescript -export function formatFixed( - bigNumberish: BigNumberish, - options?: FormatFixedOptions -): string; +export function formatFixed(bigNumberish: BigNumberish, options?: FormatFixedOptions): string ``` ## Input Parameters @@ -82,7 +76,7 @@ export function formatFixed( ## Example Usage ```typescript -const formatted: string = formatFixed("1.2345", { decimalPlaces: 2 }); // 1.23 +const formatted: string = formatFixed('1.2345', { decimalPlaces: 2 }) // 1.23 ``` # formatFixedDecimals @@ -92,11 +86,7 @@ This function formats token and ethereum values to a specified number of decimal ## Function Signature ```typescript -export function formatFixedDecimals( - bigNumberish: BigNumberish, - decimals: number, - options?: FormatFixedOptions -): string; +export function formatFixedDecimals(bigNumberish: BigNumberish, decimals: number, options?: FormatFixedOptions): string ``` ## Input Parameters @@ -110,7 +100,7 @@ export function formatFixedDecimals( ## Example Usage ```typescript -const formatted: string = formatFixedDecimals("1234560000000000000", 18, { +const formatted: string = formatFixedDecimals('1234560000000000000', 18, { decimalPlaces: 2, -}); // 1.23 +}) // 1.23 ``` diff --git a/SDK_versioned_docs/version-1.0.0/reference/05-orchestration.md b/SDK_versioned_docs/version-1.0.0/reference/05-orchestration.md index 42faf9d43e..af1f21754c 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/05-orchestration.md +++ b/SDK_versioned_docs/version-1.0.0/reference/05-orchestration.md @@ -14,10 +14,7 @@ The function facilitates trading an exact amount of ETH for a specified token. ## Function Signature ```typescript -export function tradeExactEthForTokensWithData( - reserves: OptionalReserves, - ethAmount: BigNumberish -): TradeDetails; +export function tradeExactEthForTokensWithData(reserves: OptionalReserves, ethAmount: BigNumberish): TradeDetails ``` ## Input Parameters @@ -30,10 +27,7 @@ export function tradeExactEthForTokensWithData( ## Example Usage ```typescript -const tradeDetails: TradeDetails = tradeExactEthForTokensWithData( - reserves, - "1000000000000000000" -); +const tradeDetails: TradeDetails = tradeExactEthForTokensWithData(reserves, '1000000000000000000') ``` # tradeExactEthForTokens @@ -47,7 +41,7 @@ export async function tradeExactEthForTokens( tokenAddress: string, ethAmount: BigNumberish, chainIdOrProvider?: ChainIdOrProvider -): Promise; +): Promise ``` ## Input Parameters @@ -61,10 +55,7 @@ export async function tradeExactEthForTokens( ## Example Usage ```typescript -const tradeDetails: TradeDetails = await tradeExactEthForTokens( - tokenAddress, - "1000000000000000000" -); +const tradeDetails: TradeDetails = await tradeExactEthForTokens(tokenAddress, '1000000000000000000') ``` # tradeEthForExactTokensWithData @@ -74,10 +65,7 @@ The function facilitates trading ETH for an exact amount of a specified token. ## Function Signature ```typescript -export function tradeEthForExactTokensWithData( - reserves: OptionalReserves, - tokenAmount: BigNumberish -): TradeDetails; +export function tradeEthForExactTokensWithData(reserves: OptionalReserves, tokenAmount: BigNumberish): TradeDetails ``` ## Input Parameters @@ -90,10 +78,7 @@ export function tradeEthForExactTokensWithData( ## Example Usage ```typescript -const tradeDetails: TradeDetails = tradeEthForExactTokensWithData( - reserves, - "1000000000000000000" -); +const tradeDetails: TradeDetails = tradeEthForExactTokensWithData(reserves, '1000000000000000000') ``` # tradeEthForExactTokens @@ -107,7 +92,7 @@ export async function tradeEthForExactTokens( tokenAddress: string, tokenAmount: BigNumberish, chainIdOrProvider?: ChainIdOrProvider -): Promise; +): Promise ``` ## Input Parameters @@ -121,10 +106,7 @@ export async function tradeEthForExactTokens( ## Example Usage ```typescript -const tradeDetails: TradeDetails = await tradeEthForExactTokens( - tokenAddress, - "1000000000000000000" -); +const tradeDetails: TradeDetails = await tradeEthForExactTokens(tokenAddress, '1000000000000000000') ``` # tradeExactTokensForEthWithData @@ -134,10 +116,7 @@ The function facilitates trading an exact amount of a specified token for ETH. ## Function Signature ```typescript -export function tradeExactTokensForEthWithData( - reserves: OptionalReserves, - tokenAmount: BigNumberish -): TradeDetails; +export function tradeExactTokensForEthWithData(reserves: OptionalReserves, tokenAmount: BigNumberish): TradeDetails ``` ## Input Parameters @@ -150,10 +129,7 @@ export function tradeExactTokensForEthWithData( ## Example Usage ```typescript -const tradeDetails: TradeDetails = tradeExactTokensForEthWithData( - reserves, - "1000000000000000000" -); +const tradeDetails: TradeDetails = tradeExactTokensForEthWithData(reserves, '1000000000000000000') ``` # tradeExactTokensForEth @@ -167,7 +143,7 @@ export async function tradeExactTokensForEth( tokenAddress: string, tokenAmount: BigNumberish, chainIdOrProvider?: ChainIdOrProvider -): Promise; +): Promise ``` ## Input Parameters @@ -181,10 +157,7 @@ export async function tradeExactTokensForEth( ## Example Usage ```typescript -const tradeDetails: TradeDetails = await tradeExactTokensForEth( - tokenAddress, - "1000000000000000000" -); +const tradeDetails: TradeDetails = await tradeExactTokensForEth(tokenAddress, '1000000000000000000') ``` # tradeTokensForExactEthWithData @@ -194,10 +167,7 @@ The function facilitates trading a specified token for an exact amount of ETH. ## Function Signature ```typescript -export function tradeTokensForExactEthWithData( - reserves: OptionalReserves, - ethAmount: BigNumberish -): TradeDetails; +export function tradeTokensForExactEthWithData(reserves: OptionalReserves, ethAmount: BigNumberish): TradeDetails ``` ## Input Parameters @@ -210,10 +180,7 @@ export function tradeTokensForExactEthWithData( ## Example Usage ```typescript -const tradeDetails: TradeDetails = tradeTokensForExactEthWithData( - reserves, - "1000000000000000000" -); +const tradeDetails: TradeDetails = tradeTokensForExactEthWithData(reserves, '1000000000000000000') ``` # tradeTokensForExactEth @@ -227,7 +194,7 @@ export async function tradeTokensForExactEth( tokenAddress: string, ethAmount: BigNumberish, chainIdOrProvider?: ChainIdOrProvider -): Promise; +): Promise ``` ## Input Parameters @@ -241,10 +208,7 @@ export async function tradeTokensForExactEth( ## Example Usage ```typescript -const tradeDetails: TradeDetails = await tradeTokensForExactEth( - tokenAddress, - "1000000000000000000" -); +const tradeDetails: TradeDetails = await tradeTokensForExactEth(tokenAddress, '1000000000000000000') ``` # tradeExactTokensForTokensWithData @@ -258,7 +222,7 @@ export function tradeExactTokensForTokensWithData( reservesInput: OptionalReserves, reservesOutput: OptionalReserves, tokenAmount: BigNumberish -): TradeDetails; +): TradeDetails ``` ## Input Parameters @@ -275,8 +239,8 @@ export function tradeExactTokensForTokensWithData( const tradeDetails: TradeDetails = tradeExactTokensForTokensWithData( reservesInput, reservesOutput, - "1000000000000000000" -); + '1000000000000000000' +) ``` # tradeExactTokensForTokens @@ -291,7 +255,7 @@ export async function tradeExactTokensForTokens( tokenAddressOutput: string, tokenAmount: BigNumberish, chainIdOrProvider?: ChainIdOrProvider -): Promise; +): Promise ``` ## Input Parameters @@ -309,8 +273,8 @@ export async function tradeExactTokensForTokens( const tradeDetails: TradeDetails = await tradeExactTokensForTokens( tokenAddressInput, tokenAddressOutput, - "1000000000000000000" -); + '1000000000000000000' +) ``` # tradeTokensForExactTokensWithData @@ -324,7 +288,7 @@ export function tradeTokensForExactTokensWithData( reservesInput: OptionalReserves, reservesOutput: OptionalReserves, tokenAmount: BigNumberish -): TradeDetails; +): TradeDetails ``` ## Input Parameters @@ -341,8 +305,8 @@ export function tradeTokensForExactTokensWithData( const tradeDetails: TradeDetails = tradeTokensForExactTokensWithData( reservesInput, reservesOutput, - "1000000000000000000" -); + '1000000000000000000' +) ``` # tradeTokensForExactTokens @@ -357,7 +321,7 @@ export async function tradeTokensForExactTokens( tokenAddressOutput: string, tokenAmount: BigNumberish, chainIdOrProvider?: ChainIdOrProvider -): Promise; +): Promise ``` ## Input Parameters @@ -375,6 +339,6 @@ export async function tradeTokensForExactTokens( const tradeDetails: TradeDetails = await tradeTokensForExactTokens( tokenAddressInput, tokenAddressOutput, - "1000000000000000000" -); + '1000000000000000000' +) ``` diff --git a/SDK_versioned_docs/version-1.0.0/reference/06-transact.md b/SDK_versioned_docs/version-1.0.0/reference/06-transact.md index 136e17f618..80b7698274 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/06-transact.md +++ b/SDK_versioned_docs/version-1.0.0/reference/06-transact.md @@ -15,7 +15,7 @@ export function getExecutionDetails( maxSlippage?: number, deadline?: number, recipient?: string -): ExecutionDetails; +): ExecutionDetails ``` ## Input Parameters @@ -32,14 +32,9 @@ export function getExecutionDetails( Method arguments are returned as one of: `BigNumber`, `number`, or `string`. `BigNumber`s are large number objects, `numbers` are small numbers in base 10, and `string`s are addresses. ```typescript -const tradeDetails: TradeDetails = tradeExactEthForTokensWithData( - reserves, - "1000000000000000000" -); - -const executionDetails: ExecutionDetails = await getExecutionDetails( - tradeDetails -); +const tradeDetails: TradeDetails = tradeExactEthForTokensWithData(reserves, '1000000000000000000') + +const executionDetails: ExecutionDetails = await getExecutionDetails(tradeDetails) /* { diff --git a/SDK_versioned_docs/version-1.0.0/reference/07-constants.md b/SDK_versioned_docs/version-1.0.0/reference/07-constants.md index 4854e2f983..7e74eb35eb 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/07-constants.md +++ b/SDK_versioned_docs/version-1.0.0/reference/07-constants.md @@ -6,13 +6,13 @@ title: Constants Below is an exhaustive list of all external constants used in the SDK. ```typescript -import BigNumber from "bignumber.js"; +import BigNumber from 'bignumber.js' -import ERC20 from "./abis/ERC20.json"; -import FACTORY from "./abis/FACTORY.json"; -import EXCHANGE from "./abis/EXCHANGE.json"; +import ERC20 from './abis/ERC20.json' +import FACTORY from './abis/FACTORY.json' +import EXCHANGE from './abis/EXCHANGE.json' -export const ETH = "ETH"; +export const ETH = 'ETH' export enum SUPPORTED_CHAIN_ID { Mainnet = 1, @@ -21,42 +21,42 @@ export enum SUPPORTED_CHAIN_ID { Kovan = 42, } -export const FACTORY_ADDRESS: { [key: number]: string } = {}; +export const FACTORY_ADDRESS: { [key: number]: string } = {} -export const FACTORY_ABI: string = JSON.stringify(FACTORY); -export const EXCHANGE_ABI: string = JSON.stringify(EXCHANGE); +export const FACTORY_ABI: string = JSON.stringify(FACTORY) +export const EXCHANGE_ABI: string = JSON.stringify(EXCHANGE) export enum TRADE_TYPE { - ETH_TO_TOKEN = "ETH_TO_TOKEN", - TOKEN_TO_ETH = "TOKEN_TO_ETH", - TOKEN_TO_TOKEN = "TOKEN_TO_TOKEN", + ETH_TO_TOKEN = 'ETH_TO_TOKEN', + TOKEN_TO_ETH = 'TOKEN_TO_ETH', + TOKEN_TO_TOKEN = 'TOKEN_TO_TOKEN', } export enum TRADE_EXACT { - INPUT = "INPUT", - OUTPUT = "OUTPUT", + INPUT = 'INPUT', + OUTPUT = 'OUTPUT', } export enum TRADE_METHODS { - ethToTokenSwapInput = "ethToTokenSwapInput", - ethToTokenTransferInput = "ethToTokenTransferInput", - ethToTokenSwapOutput = "ethToTokenSwapOutput", - ethToTokenTransferOutput = "ethToTokenTransferOutput", - tokenToEthSwapInput = "tokenToEthSwapInput", - tokenToEthTransferInput = "tokenToEthTransferInput", - tokenToEthSwapOutput = "tokenToEthSwapOutput", - tokenToEthTransferOutput = "tokenToEthTransferOutput", - tokenToTokenSwapInput = "tokenToTokenSwapInput", - tokenToTokenTransferInput = "tokenToTokenTransferInput", - tokenToTokenSwapOutput = "tokenToTokenSwapOutput", - tokenToTokenTransferOutput = "tokenToTokenTransferOutput", + ethToTokenSwapInput = 'ethToTokenSwapInput', + ethToTokenTransferInput = 'ethToTokenTransferInput', + ethToTokenSwapOutput = 'ethToTokenSwapOutput', + ethToTokenTransferOutput = 'ethToTokenTransferOutput', + tokenToEthSwapInput = 'tokenToEthSwapInput', + tokenToEthTransferInput = 'tokenToEthTransferInput', + tokenToEthSwapOutput = 'tokenToEthSwapOutput', + tokenToEthTransferOutput = 'tokenToEthTransferOutput', + tokenToTokenSwapInput = 'tokenToTokenSwapInput', + tokenToTokenTransferInput = 'tokenToTokenTransferInput', + tokenToTokenSwapOutput = 'tokenToTokenSwapOutput', + tokenToTokenTransferOutput = 'tokenToTokenTransferOutput', } -export const TRADE_METHOD_IDS: { [key: string]: string } = {}; +export const TRADE_METHOD_IDS: { [key: string]: string } = {} export enum FIXED_UNDERFLOW_BEHAVIOR { - ZERO = "ZERO", - LESS_THAN = "LESS_THAN", - ONE_DIGIT = "ONE_DIGIT", + ZERO = 'ZERO', + LESS_THAN = 'LESS_THAN', + ONE_DIGIT = 'ONE_DIGIT', } ``` diff --git a/SDK_versioned_docs/version-1.0.0/reference/08-types.md b/SDK_versioned_docs/version-1.0.0/reference/08-types.md index ed7790453c..15af25d9e0 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/08-types.md +++ b/SDK_versioned_docs/version-1.0.0/reference/08-types.md @@ -6,30 +6,20 @@ title: Types Below is an exhaustive list of all the external types used in the SDK. ```typescript -import BigNumber from "bignumber.js"; -import { ethers } from "ethers"; +import BigNumber from 'bignumber.js' +import { ethers } from 'ethers' -import { - SUPPORTED_CHAIN_ID, - TRADE_TYPE, - TRADE_EXACT, - FIXED_UNDERFLOW_BEHAVIOR, -} from "./constants"; +import { SUPPORTED_CHAIN_ID, TRADE_TYPE, TRADE_EXACT, FIXED_UNDERFLOW_BEHAVIOR } from './constants' -export type BigNumberish = BigNumber | ethers.utils.BigNumber | string | number; +export type BigNumberish = BigNumber | ethers.utils.BigNumber | string | number //// types for on-chain, submitted, and normalized data -export type ChainIdOrProvider = - | SUPPORTED_CHAIN_ID - | ethers.providers.AsyncSendable - | ethers.providers.Provider; +export type ChainIdOrProvider = SUPPORTED_CHAIN_ID | ethers.providers.AsyncSendable | ethers.providers.Provider // type guard for ChainIdOrProvider -export function isChainId( - chainIdOrProvider: ChainIdOrProvider -): chainIdOrProvider is SUPPORTED_CHAIN_ID { - const chainId: SUPPORTED_CHAIN_ID = chainIdOrProvider as SUPPORTED_CHAIN_ID; - return typeof chainId === "number"; +export function isChainId(chainIdOrProvider: ChainIdOrProvider): chainIdOrProvider is SUPPORTED_CHAIN_ID { + const chainId: SUPPORTED_CHAIN_ID = chainIdOrProvider as SUPPORTED_CHAIN_ID + return typeof chainId === 'number' } // type guard for ChainIdOrProvider @@ -37,147 +27,130 @@ export function isLowLevelProvider( chainIdOrProvider: ChainIdOrProvider ): chainIdOrProvider is ethers.providers.AsyncSendable { if (isChainId(chainIdOrProvider)) { - return false; + return false } else { - const provider: ethers.providers.AsyncSendable = - chainIdOrProvider as ethers.providers.AsyncSendable; - return "send" in provider || "sendAsync" in provider; + const provider: ethers.providers.AsyncSendable = chainIdOrProvider as ethers.providers.AsyncSendable + return 'send' in provider || 'sendAsync' in provider } } export interface Token { - chainId?: SUPPORTED_CHAIN_ID; - address?: string; - decimals: number; + chainId?: SUPPORTED_CHAIN_ID + address?: string + decimals: number } export interface TokenAmount { - token: Token; - amount: BigNumberish; + token: Token + amount: BigNumberish } export interface TokenAmountNormalized { - token: Token; - amount: BigNumber; + token: Token + amount: BigNumber } export interface TokenReserves { - token: Token; - exchange?: Token; - ethReserve: TokenAmount; - tokenReserve: TokenAmount; + token: Token + exchange?: Token + ethReserve: TokenAmount + tokenReserve: TokenAmount } export interface TokenReservesNormalized { - token: Token; - exchange?: Token; - ethReserve: TokenAmountNormalized; - tokenReserve: TokenAmountNormalized; + token: Token + exchange?: Token + ethReserve: TokenAmountNormalized + tokenReserve: TokenAmountNormalized } export interface EthReserves { - token: Token; + token: Token } // type for input data -export type OptionalReserves = TokenReserves | EthReserves | undefined; +export type OptionalReserves = TokenReserves | EthReserves | undefined // type guard for OptionalReserves -export function areTokenReserves( - reserves: OptionalReserves -): reserves is TokenReserves { - const tokenReserves: TokenReserves = reserves as TokenReserves; +export function areTokenReserves(reserves: OptionalReserves): reserves is TokenReserves { + const tokenReserves: TokenReserves = reserves as TokenReserves return ( - tokenReserves !== undefined && - tokenReserves.ethReserve !== undefined && - tokenReserves.tokenReserve !== undefined - ); + tokenReserves !== undefined && tokenReserves.ethReserve !== undefined && tokenReserves.tokenReserve !== undefined + ) } // type guard for OptionalReserves -export function areETHReserves( - reserves: OptionalReserves -): reserves is EthReserves { - const tokenReserves: TokenReserves = reserves as TokenReserves; +export function areETHReserves(reserves: OptionalReserves): reserves is EthReserves { + const tokenReserves: TokenReserves = reserves as TokenReserves return ( - tokenReserves !== undefined && - tokenReserves.ethReserve === undefined && - tokenReserves.tokenReserve === undefined - ); + tokenReserves !== undefined && tokenReserves.ethReserve === undefined && tokenReserves.tokenReserve === undefined + ) } // type for output data -export type NormalizedReserves = TokenReservesNormalized | EthReserves; +export type NormalizedReserves = TokenReservesNormalized | EthReserves // type guard for NormalizedReserves -export function areTokenReservesNormalized( - reserves: NormalizedReserves -): reserves is TokenReservesNormalized { - const tokenReservesNormalized: TokenReservesNormalized = - reserves as TokenReservesNormalized; - return ( - tokenReservesNormalized.ethReserve !== undefined && - tokenReservesNormalized.tokenReserve !== undefined - ); +export function areTokenReservesNormalized(reserves: NormalizedReserves): reserves is TokenReservesNormalized { + const tokenReservesNormalized: TokenReservesNormalized = reserves as TokenReservesNormalized + return tokenReservesNormalized.ethReserve !== undefined && tokenReservesNormalized.tokenReserve !== undefined } //// types for computed data export interface Rate { - rate: BigNumber; - rateInverted: BigNumber; + rate: BigNumber + rateInverted: BigNumber } export interface MarketDetails { - tradeType: TRADE_TYPE; - inputReserves: NormalizedReserves; - outputReserves: NormalizedReserves; - marketRate: Rate; + tradeType: TRADE_TYPE + inputReserves: NormalizedReserves + outputReserves: NormalizedReserves + marketRate: Rate } export interface TradeDetails { - marketDetailsPre: MarketDetails; - marketDetailsPost: MarketDetails; - tradeType: TRADE_TYPE; - tradeExact: TRADE_EXACT; - inputAmount: TokenAmountNormalized; - outputAmount: TokenAmountNormalized; - executionRate: Rate; - marketRateSlippage: BigNumber; - executionRateSlippage: BigNumber; + marketDetailsPre: MarketDetails + marketDetailsPost: MarketDetails + tradeType: TRADE_TYPE + tradeExact: TRADE_EXACT + inputAmount: TokenAmountNormalized + outputAmount: TokenAmountNormalized + executionRate: Rate + marketRateSlippage: BigNumber + executionRateSlippage: BigNumber } -export type MethodArgument = BigNumber | number | string; +export type MethodArgument = BigNumber | number | string export interface ExecutionDetails { - exchangeAddress: string; - methodName: string; - methodId: string; - value: BigNumber; - methodArguments: MethodArgument[]; + exchangeAddress: string + methodName: string + methodId: string + value: BigNumber + methodArguments: MethodArgument[] } //// types for formatting data -export type FlexibleFormat = BigNumber.Format | boolean; +export type FlexibleFormat = BigNumber.Format | boolean // type guard for FlexibleFormat -export function isFormat( - flexibleFormat: FlexibleFormat -): flexibleFormat is BigNumber.Format { - const format: BigNumber.Format = flexibleFormat as BigNumber.Format; - return typeof format !== "boolean"; +export function isFormat(flexibleFormat: FlexibleFormat): flexibleFormat is BigNumber.Format { + const format: BigNumber.Format = flexibleFormat as BigNumber.Format + return typeof format !== 'boolean' } export interface FormatSignificantOptions { - significantDigits: number; - roundingMode: BigNumber.RoundingMode; - forceIntegerSignificance: boolean; - format: FlexibleFormat; + significantDigits: number + roundingMode: BigNumber.RoundingMode + forceIntegerSignificance: boolean + format: FlexibleFormat } export interface FormatFixedOptions { - decimalPlaces: number; - roundingMode: BigNumber.RoundingMode; - dropTrailingZeros: boolean; - underflowBehavior: FIXED_UNDERFLOW_BEHAVIOR; - format: FlexibleFormat; + decimalPlaces: number + roundingMode: BigNumber.RoundingMode + dropTrailingZeros: boolean + underflowBehavior: FIXED_UNDERFLOW_BEHAVIOR + format: FlexibleFormat } ``` diff --git a/SDK_versioned_docs/version-1.0.0/reference/_category_.json b/SDK_versioned_docs/version-1.0.0/reference/_category_.json index 0485de6e24..dc5ee95f28 100644 --- a/SDK_versioned_docs/version-1.0.0/reference/_category_.json +++ b/SDK_versioned_docs/version-1.0.0/reference/_category_.json @@ -1,6 +1,5 @@ { - "label": "Reference", - "position": 2, - "collapsed": false - - } \ No newline at end of file + "label": "Reference", + "position": 2, + "collapsed": false +} diff --git a/SDK_versioned_docs/version-2.0.0/README.md b/SDK_versioned_docs/version-2.0.0/README.md index df684db1fe..23c6116fc6 100644 --- a/SDK_versioned_docs/version-2.0.0/README.md +++ b/SDK_versioned_docs/version-2.0.0/README.md @@ -2,15 +2,15 @@ id: introduction sidebar_position: 1 --- + # The Uniswap V2 SDK -Welcome to the Uniswap Protocol V2 SDK. Here you can find documentation for tools used to interact with the Uniswap protocol in a javascript environment. +Welcome to the Uniswap Protocol V2 SDK. Here you can find documentation for tools used to interact with the Uniswap protocol in a javascript environment. Here you can find easily searchable references for the SDK. For deeper dives, we recommend referencing the [**SDK Github**](https://github.com/Uniswap/uniswap-v2-sdk) repo directly. # Uniswap V2 SDK -* [**V2 SDK Github**](https://github.com/Uniswap/uniswap-v2-sdk) -* [**SDK Core Github**](https://github.com/Uniswap/uniswap-sdk-core) -* [**SDK NPM Package**](https://www.npmjs.com/package/@uniswap/v2-sdk) - +- [**V2 SDK Github**](https://github.com/Uniswap/uniswap-v2-sdk) +- [**SDK Core Github**](https://github.com/Uniswap/uniswap-sdk-core) +- [**SDK NPM Package**](https://www.npmjs.com/package/@uniswap/v2-sdk) diff --git a/SDK_versioned_docs/version-2.0.0/guides/01-quick-start.md b/SDK_versioned_docs/version-2.0.0/guides/01-quick-start.md index a1907e4bb6..5f3ffa1e29 100644 --- a/SDK_versioned_docs/version-2.0.0/guides/01-quick-start.md +++ b/SDK_versioned_docs/version-2.0.0/guides/01-quick-start.md @@ -16,15 +16,15 @@ To run code from the SDK in your application, use an `import` or `require` state ## ES6 (import) ```typescript -import { ChainId } from "@uniswap/sdk"; -console.log(`The chainId of mainnet is ${ChainId.MAINNET}.`); +import { ChainId } from '@uniswap/sdk' +console.log(`The chainId of mainnet is ${ChainId.MAINNET}.`) ``` ## CommonJS (require) ```typescript -const UNISWAP = require("@uniswap/sdk"); -console.log(`The chainId of mainnet is ${UNISWAP.ChainId.MAINNET}.`); +const UNISWAP = require('@uniswap/sdk') +console.log(`The chainId of mainnet is ${UNISWAP.ChainId.MAINNET}.`) ``` # Reference diff --git a/SDK_versioned_docs/version-2.0.0/guides/02-fetching-data.md b/SDK_versioned_docs/version-2.0.0/guides/02-fetching-data.md index 1e519f2052..f68b078907 100644 --- a/SDK_versioned_docs/version-2.0.0/guides/02-fetching-data.md +++ b/SDK_versioned_docs/version-2.0.0/guides/02-fetching-data.md @@ -29,24 +29,21 @@ The next piece of data we need is **decimals**. One option here is to simply pass in the correct value, which we may know is `18`. At this point, we're ready to represent DAI as a [Token](../reference/token): ```typescript -import { ChainId, Token } from "@uniswap/sdk"; +import { ChainId, Token } from '@uniswap/sdk' -const chainId = ChainId.MAINNET; -const tokenAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; // must be checksummed -const decimals = 18; +const chainId = ChainId.MAINNET +const tokenAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F' // must be checksummed +const decimals = 18 -const DAI = new Token(chainId, tokenAddress, decimals); +const DAI = new Token(chainId, tokenAddress, decimals) ``` If we don't know or don't want to hardcode the value, we could look it up ourselves via any method of retrieving on-chain data in a function that looks something like: ```typescript -import { ChainId } from "@uniswap/sdk"; +import { ChainId } from '@uniswap/sdk' -async function getDecimals( - chainId: ChainId, - tokenAddress: string -): Promise { +async function getDecimals(chainId: ChainId, tokenAddress: string): Promise { // implementation details } ``` @@ -56,14 +53,14 @@ async function getDecimals( If we don't want to provide or look up the value ourselves, we can ask the SDK to look it up for us with [Fetcher.fetchTokenData](../reference/fetcher#fetchtokendata) ```typescript -import { ChainId, Token, Fetcher } from "@uniswap/sdk"; +import { ChainId, Token, Fetcher } from '@uniswap/sdk' -const chainId = ChainId.MAINNET; -const tokenAddress = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; // must be checksummed +const chainId = ChainId.MAINNET +const tokenAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F' // must be checksummed // note that you may want/need to handle this async code differently, // for example if top-level await is not an option -const DAI: Token = await Fetcher.fetchTokenData(chainId, tokenAddress); +const DAI: Token = await Fetcher.fetchTokenData(chainId, tokenAddress) ``` By default, this method will use the [default provider defined by ethers.js](https://docs.ethers.io/v5/api/providers/#providers-getDefaultProvider). @@ -75,31 +72,25 @@ If you're using another library, you'll have to fetch the data separately. Finally, we can talk about **symbol** and **name**. Because these fields aren't used anywhere in the SDK itself, they're optional, and can be provided if you want to use them in your application. However, the SDK will not fetch them for you, so you'll have to provide them: ```typescript -import { ChainId, Token } from "@uniswap/sdk"; +import { ChainId, Token } from '@uniswap/sdk' -const DAI = new Token( - ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", - 18, - "DAI", - "Dai Stablecoin" -); +const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18, 'DAI', 'Dai Stablecoin') ``` or: ```typescript -import { ChainId, Token, Fetcher } from "@uniswap/sdk"; +import { ChainId, Token, Fetcher } from '@uniswap/sdk' // note that you may want/need to handle this async code differently, // for example if top-level await is not an option const DAI = await Fetcher.fetchTokenData( ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", + '0x6B175474E89094C44Da98b954EedeAC495271d0F', undefined, - "DAI", - "Dai Stablecoin" -); + 'DAI', + 'Dai Stablecoin' +) ``` # Case 2: Pairs @@ -121,32 +112,23 @@ The data we need is the _reserves_ of the pair. To read more about reserves, see One option here is to simply pass in values which we've fetched ourselves to create a [Pair](../reference/pair): ```typescript -import { ChainId, Token, WETH, Pair, TokenAmount } from "@uniswap/sdk"; +import { ChainId, Token, WETH, Pair, TokenAmount } from '@uniswap/sdk' -const DAI = new Token( - ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", - 18 -); +const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18) async function getPair(): Promise { - const pairAddress = Pair.getAddress(DAI, WETH[DAI.chainId]); + const pairAddress = Pair.getAddress(DAI, WETH[DAI.chainId]) const reserves = [ /* use pairAddress to fetch reserves here */ - ]; - const [reserve0, reserve1] = reserves; - - const tokens = [DAI, WETH[DAI.chainId]]; - const [token0, token1] = tokens[0].sortsBefore(tokens[1]) - ? tokens - : [tokens[1], tokens[0]]; - - const pair = new Pair( - new TokenAmount(token0, reserve0), - new TokenAmount(token1, reserve1) - ); - return pair; + ] + const [reserve0, reserve1] = reserves + + const tokens = [DAI, WETH[DAI.chainId]] + const [token0, token1] = tokens[0].sortsBefore(tokens[1]) ? tokens : [tokens[1], tokens[0]] + + const pair = new Pair(new TokenAmount(token0, reserve0), new TokenAmount(token1, reserve1)) + return pair } ``` @@ -157,17 +139,13 @@ Note that these values can change as frequently as every block, and should be ke If we don't want to look up the value ourselves, we can ask the SDK to look them up for us with [Fetcher.fetchTokenData](../reference/fetcher#fetchtokendata): ```typescript -import { ChainId, Token, WETH, Fetcher } from "@uniswap/sdk"; +import { ChainId, Token, WETH, Fetcher } from '@uniswap/sdk' -const DAI = new Token( - ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", - 18 -); +const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18) // note that you may want/need to handle this async code differently, // for example if top-level await is not an option -const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]); +const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]) ``` By default, this method will use the [default provider defined by ethers.js](https://docs.ethers.io/v5/api/providers/#providers-getDefaultProvider). If you're already using ethers.js in your application, you may pass in your provider as a 3rd argument. If you're using another library, you'll have to fetch the data separately. diff --git a/SDK_versioned_docs/version-2.0.0/guides/03-pricing.md b/SDK_versioned_docs/version-2.0.0/guides/03-pricing.md index 30d8607f61..672cff64b0 100644 --- a/SDK_versioned_docs/version-2.0.0/guides/03-pricing.md +++ b/SDK_versioned_docs/version-2.0.0/guides/03-pricing.md @@ -18,22 +18,18 @@ Let's consider the mid price for DAI-WETH (that is, the amount of DAI per 1 WETH The simplest way to get the DAI-WETH mid price is to observe the pair directly: ```typescript -import { ChainId, Token, WETH, Fetcher, Route } from "@uniswap/sdk"; +import { ChainId, Token, WETH, Fetcher, Route } from '@uniswap/sdk' -const DAI = new Token( - ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", - 18 -); +const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18) // note that you may want/need to handle this async code differently, // for example if top-level await is not an option -const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]); +const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]) -const route = new Route([pair], WETH[DAI.chainId]); +const route = new Route([pair], WETH[DAI.chainId]) -console.log(route.midPrice.toSignificant(6)); // 201.306 -console.log(route.midPrice.invert().toSignificant(6)); // 0.00496756 +console.log(route.midPrice.toSignificant(6)) // 201.306 +console.log(route.midPrice.invert().toSignificant(6)) // 0.00496756 ``` You may be wondering why we have to construct a _route_ to get the mid price, as opposed to simply getting it from the pair (which, after all, includes all the necessary data). The reason is simple: a route forces us to be opinionated about the _direction_ of trading. Routes consist of one or more pairs, and an input token (which fully defines a trading path). In this case, we passed WETH as the input token, meaning we're interested in a WETH -> DAI trade. @@ -47,28 +43,20 @@ Finally, you may have noticed that we're formatting the price to 6 significant d For the sake of example, let's imagine a direct pair between DAI and WETH _doesn't exist_. In order to get a DAI-WETH mid price we'll need to pick a valid route. Imagine both DAI and WETH have pairs with a third token, USDC. In that case, we can calculate an indirect mid price through the USDC pairs: ```typescript -import { ChainId, Token, WETH, Fetcher, Route } from "@uniswap/sdk"; - -const USDC = new Token( - ChainId.MAINNET, - "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - 6 -); -const DAI = new Token( - ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", - 18 -); +import { ChainId, Token, WETH, Fetcher, Route } from '@uniswap/sdk' + +const USDC = new Token(ChainId.MAINNET, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 6) +const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18) // note that you may want/need to handle this async code differently, // for example if top-level await is not an option -const USDCWETHPair = await Fetcher.fetchPairData(USDC, WETH[ChainId.MAINNET]); -const DAIUSDCPair = await Fetcher.fetchPairData(DAI, USDC); +const USDCWETHPair = await Fetcher.fetchPairData(USDC, WETH[ChainId.MAINNET]) +const DAIUSDCPair = await Fetcher.fetchPairData(DAI, USDC) -const route = new Route([USDCWETHPair, DAIUSDCPair], WETH[ChainId.MAINNET]); +const route = new Route([USDCWETHPair, DAIUSDCPair], WETH[ChainId.MAINNET]) -console.log(route.midPrice.toSignificant(6)); // 202.081 -console.log(route.midPrice.invert().toSignificant(6)); // 0.00494851 +console.log(route.midPrice.toSignificant(6)) // 202.081 +console.log(route.midPrice.invert().toSignificant(6)) // 0.00494851 ``` # Execution Price @@ -78,37 +66,20 @@ Mid prices are great representations of the _current_ state of a route, but what Imagine we're interested in trading 1 WETH for DAI: ```typescript -import { - ChainId, - Token, - WETH, - Fetcher, - Trade, - Route, - TokenAmount, - TradeType, -} from "@uniswap/sdk"; - -const DAI = new Token( - ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", - 18 -); +import { ChainId, Token, WETH, Fetcher, Trade, Route, TokenAmount, TradeType } from '@uniswap/sdk' + +const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18) // note that you may want/need to handle this async code differently, // for example if top-level await is not an option -const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]); +const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]) -const route = new Route([pair], WETH[DAI.chainId]); +const route = new Route([pair], WETH[DAI.chainId]) -const trade = new Trade( - route, - new TokenAmount(WETH[DAI.chainId], "1000000000000000000"), - TradeType.EXACT_INPUT -); +const trade = new Trade(route, new TokenAmount(WETH[DAI.chainId], '1000000000000000000'), TradeType.EXACT_INPUT) -console.log(trade.executionPrice.toSignificant(6)); -console.log(trade.nextMidPrice.toSignificant(6)); +console.log(trade.executionPrice.toSignificant(6)) +console.log(trade.nextMidPrice.toSignificant(6)) ``` Notice that we're constructing a trade of 1 WETH for as much DAI as possible, _given the current reserves of the direct pair_. The execution price represents the average DAI/WETH price for this trade. Of course, the reserves of any pair can change every block, which would affect the execution price. diff --git a/SDK_versioned_docs/version-2.0.0/guides/04-trading.md b/SDK_versioned_docs/version-2.0.0/guides/04-trading.md index d89b9d9541..e5822a0ff5 100644 --- a/SDK_versioned_docs/version-2.0.0/guides/04-trading.md +++ b/SDK_versioned_docs/version-2.0.0/guides/04-trading.md @@ -14,36 +14,19 @@ This guide will focus exclusively on sending a transaction to the [currently rec Let's say we want to trade 1 WETH for as much DAI as possible: ```typescript -import { - ChainId, - Token, - WETH, - Fetcher, - Trade, - Route, - TokenAmount, - TradeType, -} from "@uniswap/sdk"; - -const DAI = new Token( - ChainId.MAINNET, - "0x6B175474E89094C44Da98b954EedeAC495271d0F", - 18 -); +import { ChainId, Token, WETH, Fetcher, Trade, Route, TokenAmount, TradeType } from '@uniswap/sdk' + +const DAI = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18) // note that you may want/need to handle this async code differently, // for example if top-level await is not an option -const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]); +const pair = await Fetcher.fetchPairData(DAI, WETH[DAI.chainId]) -const route = new Route([pair], WETH[DAI.chainId]); +const route = new Route([pair], WETH[DAI.chainId]) -const amountIn = "1000000000000000000"; // 1 WETH +const amountIn = '1000000000000000000' // 1 WETH -const trade = new Trade( - route, - new TokenAmount(WETH[DAI.chainId], amountIn), - TradeType.EXACT_INPUT -); +const trade = new Trade(route, new TokenAmount(WETH[DAI.chainId], amountIn), TradeType.EXACT_INPUT) ``` So, we've constructed a trade entity, but how do we use it to actually send a transaction? There are still a few pieces we need to put in place. @@ -64,15 +47,15 @@ function swapExactETHForTokens(uint amountOutMin, address[] calldata path, addre Jumping back to our trading code, we can construct all the necessary parameters: ```typescript -import { Percent } from "@uniswap/sdk"; +import { Percent } from '@uniswap/sdk' -const slippageTolerance = new Percent("50", "10000"); // 50 bips, or 0.50% +const slippageTolerance = new Percent('50', '10000') // 50 bips, or 0.50% -const amountOutMin = trade.minimumAmountOut(slippageTolerance).raw; // needs to be converted to e.g. hex -const path = [WETH[DAI.chainId].address, DAI.address]; -const to = ""; // should be a checksummed recipient address -const deadline = Math.floor(Date.now() / 1000) + 60 * 20; // 20 minutes from the current Unix time -const value = trade.inputAmount.raw; // // needs to be converted to e.g. hex +const amountOutMin = trade.minimumAmountOut(slippageTolerance).raw // needs to be converted to e.g. hex +const path = [WETH[DAI.chainId].address, DAI.address] +const to = '' // should be a checksummed recipient address +const deadline = Math.floor(Date.now() / 1000) + 60 * 20 // 20 minutes from the current Unix time +const value = trade.inputAmount.raw // // needs to be converted to e.g. hex ``` The slippage tolerance encodes _how large of a price movement we're willing to tolerate before our trade will fail to execute_. Since Ethereum transactions are broadcast and confirmed in an adversarial environment, this tolerance is the best we can do to protect ourselves against price movements. We use this slippage tolerance to calculate the _minumum_ amount of DAI we must receive before our trade reverts, thanks to [minimumAmountOut](../reference/trade#minimumamountout-since-204). Note that this code calculates this worst-case outcome _assuming that the current price, i.e the route's mid price,_ is fair (usually a good assumption because of arbitrage). diff --git a/SDK_versioned_docs/version-2.0.0/guides/05-getting-pair-addresses.md b/SDK_versioned_docs/version-2.0.0/guides/05-getting-pair-addresses.md index 3b7d365230..f04a41729c 100644 --- a/SDK_versioned_docs/version-2.0.0/guides/05-getting-pair-addresses.md +++ b/SDK_versioned_docs/version-2.0.0/guides/05-getting-pair-addresses.md @@ -32,16 +32,16 @@ Thanks to some [fancy footwork in the factory](https://github.com/Uniswap/uniswa This example makes use of the [Uniswap SDK](../reference/getting-started). In reality, the SDK computes pair addresses behind the scenes, obviating the need to compute them manually like this. ```typescript -import { FACTORY_ADDRESS, INIT_CODE_HASH } from "@uniswap/sdk"; -import { pack, keccak256 } from "@ethersproject/solidity"; -import { getCreate2Address } from "@ethersproject/address"; +import { FACTORY_ADDRESS, INIT_CODE_HASH } from '@uniswap/sdk' +import { pack, keccak256 } from '@ethersproject/solidity' +import { getCreate2Address } from '@ethersproject/address' -const token0 = "0xCAFE000000000000000000000000000000000000"; // change me! -const token1 = "0xF00D000000000000000000000000000000000000"; // change me! +const token0 = '0xCAFE000000000000000000000000000000000000' // change me! +const token1 = '0xF00D000000000000000000000000000000000000' // change me! const pair = getCreate2Address( FACTORY_ADDRESS, - keccak256(["bytes"], [pack(["address", "address"], [token0, token1])]), + keccak256(['bytes'], [pack(['address', 'address'], [token0, token1])]), INIT_CODE_HASH -); +) ``` diff --git a/SDK_versioned_docs/version-2.0.0/guides/_category_.json b/SDK_versioned_docs/version-2.0.0/guides/_category_.json index 92fca5fc3e..bb10c2893b 100644 --- a/SDK_versioned_docs/version-2.0.0/guides/_category_.json +++ b/SDK_versioned_docs/version-2.0.0/guides/_category_.json @@ -1,6 +1,5 @@ { - "label": "Guides", - "position": 1, - "collapsed": false - - } \ No newline at end of file + "label": "Guides", + "position": 1, + "collapsed": false +} diff --git a/SDK_versioned_docs/version-2.0.0/reference/02-token.md b/SDK_versioned_docs/version-2.0.0/reference/02-token.md index 5f5478d9b8..2594428cff 100644 --- a/SDK_versioned_docs/version-2.0.0/reference/02-token.md +++ b/SDK_versioned_docs/version-2.0.0/reference/02-token.md @@ -12,15 +12,9 @@ The Token entity represents an ERC-20 token at a specific address on a specific # Example ```typescript -import { ChainId, Token } from "@uniswap/sdk"; - -const token = new Token( - ChainId.MAINNET, - "0xc0FFee0000000000000000000000000000000000", - 18, - "HOT", - "Caffeine" -); +import { ChainId, Token } from '@uniswap/sdk' + +const token = new Token(ChainId.MAINNET, '0xc0FFee0000000000000000000000000000000000', 18, 'HOT', 'Caffeine') ``` # Properties @@ -28,7 +22,7 @@ const token = new Token( ## chainId ```typescript -chainId: ChainId; +chainId: ChainId ``` See [ChainId](other-exports/#chainid) @@ -36,13 +30,13 @@ See [ChainId](other-exports/#chainid) ## address ```typescript -address: string; +address: string ``` ## decimals ```typescript -decimals: number; +decimals: number ``` ## symbol diff --git a/SDK_versioned_docs/version-2.0.0/reference/03-pair.md b/SDK_versioned_docs/version-2.0.0/reference/03-pair.md index 476bfa1e3e..f8f7f941d0 100644 --- a/SDK_versioned_docs/version-2.0.0/reference/03-pair.md +++ b/SDK_versioned_docs/version-2.0.0/reference/03-pair.md @@ -12,27 +12,12 @@ The Pair entity represents a Uniswap pair with a balance of each of its pair tok # Example ```typescript -import { ChainId, Token, TokenAmount, Pair } from "@uniswap/sdk"; - -const HOT = new Token( - ChainId.MAINNET, - "0xc0FFee0000000000000000000000000000000000", - 18, - "HOT", - "Caffeine" -); -const NOT = new Token( - ChainId.MAINNET, - "0xDeCAf00000000000000000000000000000000000", - 18, - "NOT", - "Caffeine" -); - -const pair = new Pair( - new TokenAmount(HOT, "2000000000000000000"), - new TokenAmount(NOT, "1000000000000000000") -); +import { ChainId, Token, TokenAmount, Pair } from '@uniswap/sdk' + +const HOT = new Token(ChainId.MAINNET, '0xc0FFee0000000000000000000000000000000000', 18, 'HOT', 'Caffeine') +const NOT = new Token(ChainId.MAINNET, '0xDeCAf00000000000000000000000000000000000', 18, 'NOT', 'Caffeine') + +const pair = new Pair(new TokenAmount(HOT, '2000000000000000000'), new TokenAmount(NOT, '1000000000000000000')) ``` # Static Methods @@ -50,7 +35,7 @@ Computes the pair address for the passed [Tokens](token). See [Pair Addresses](. ## liquidityToken ```typescript -liquidityToken: Token; +liquidityToken: Token ``` A Token representing the liquidity token for the pair. See [Pair (ERC-20)](../../../protocol/V2/reference/smart-contracts/pair-erc-20). @@ -58,7 +43,7 @@ A Token representing the liquidity token for the pair. See [Pair (ERC-20)](../.. ## token0 ```typescript -token0: Token; +token0: Token ``` See [Token0](../../../protocol/V2/reference/smart-contracts/pair#token0). @@ -66,7 +51,7 @@ See [Token0](../../../protocol/V2/reference/smart-contracts/pair#token0). ## token1 ```typescript -token1: Token; +token1: Token ``` See [Token1](../../../protocol/V2/reference/smart-contracts/pair#token1). @@ -74,7 +59,7 @@ See [Token1](../../../protocol/V2/reference/smart-contracts/pair#token1). ## reserve0 ```typescript -reserve0: TokenAmount; +reserve0: TokenAmount ``` The reserve of token0. @@ -82,7 +67,7 @@ The reserve of token0. ## reserve1 ```typescript -reserve1: TokenAmount; +reserve1: TokenAmount ``` The reserve of token1. diff --git a/SDK_versioned_docs/version-2.0.0/reference/04-route.md b/SDK_versioned_docs/version-2.0.0/reference/04-route.md index 9c9b7cecaf..816d0a3956 100644 --- a/SDK_versioned_docs/version-2.0.0/reference/04-route.md +++ b/SDK_versioned_docs/version-2.0.0/reference/04-route.md @@ -12,28 +12,13 @@ The Route entity represents one or more ordered Uniswap pairs with a fully speci # Example ```typescript -import { ChainId, Token, TokenAmount, Pair, Route } from "@uniswap/sdk"; - -const HOT = new Token( - ChainId.MAINNET, - "0xc0FFee0000000000000000000000000000000000", - 18, - "HOT", - "Caffeine" -); -const NOT = new Token( - ChainId.MAINNET, - "0xDeCAf00000000000000000000000000000000000", - 18, - "NOT", - "Caffeine" -); -const HOT_NOT = new Pair( - new TokenAmount(HOT, "2000000000000000000"), - new TokenAmount(NOT, "1000000000000000000") -); - -const route = new Route([HOT_NOT], NOT); +import { ChainId, Token, TokenAmount, Pair, Route } from '@uniswap/sdk' + +const HOT = new Token(ChainId.MAINNET, '0xc0FFee0000000000000000000000000000000000', 18, 'HOT', 'Caffeine') +const NOT = new Token(ChainId.MAINNET, '0xDeCAf00000000000000000000000000000000000', 18, 'NOT', 'Caffeine') +const HOT_NOT = new Pair(new TokenAmount(HOT, '2000000000000000000'), new TokenAmount(NOT, '1000000000000000000')) + +const route = new Route([HOT_NOT], NOT) ``` # Properties @@ -57,7 +42,7 @@ The full path from input token to output token. ## input ```typescript -input: string; +input: string ``` The input token. @@ -65,7 +50,7 @@ The input token. ## output ```typescript -output: string; +output: string ``` The output token. @@ -73,7 +58,7 @@ The output token. ## midPrice ```typescript -midPrice: Price; +midPrice: Price ``` Returns the current mid price along the route. diff --git a/SDK_versioned_docs/version-2.0.0/reference/05-trade.md b/SDK_versioned_docs/version-2.0.0/reference/05-trade.md index fffb81ba59..062ead9185 100644 --- a/SDK_versioned_docs/version-2.0.0/reference/05-trade.md +++ b/SDK_versioned_docs/version-2.0.0/reference/05-trade.md @@ -12,40 +12,14 @@ The Trade entity represents a fully specified trade along a route. This entity s # Example ```typescript -import { - ChainId, - Token, - TokenAmount, - Pair, - TradeType, - Route, -} from "@uniswap/sdk"; - -const HOT = new Token( - ChainId.MAINNET, - "0xc0FFee0000000000000000000000000000000000", - 18, - "HOT", - "Caffeine" -); -const NOT = new Token( - ChainId.MAINNET, - "0xDeCAf00000000000000000000000000000000000", - 18, - "NOT", - "Caffeine" -); -const HOT_NOT = new Pair( - new TokenAmount(HOT, "2000000000000000000"), - new TokenAmount(NOT, "1000000000000000000") -); -const NOT_TO_HOT = new Route([HOT_NOT], NOT); - -const trade = new Trade( - NOT_TO_HOT, - new TokenAmount(NOT, "1000000000000000"), - TradeType.EXACT_INPUT -); +import { ChainId, Token, TokenAmount, Pair, TradeType, Route } from '@uniswap/sdk' + +const HOT = new Token(ChainId.MAINNET, '0xc0FFee0000000000000000000000000000000000', 18, 'HOT', 'Caffeine') +const NOT = new Token(ChainId.MAINNET, '0xDeCAf00000000000000000000000000000000000', 18, 'NOT', 'Caffeine') +const HOT_NOT = new Pair(new TokenAmount(HOT, '2000000000000000000'), new TokenAmount(NOT, '1000000000000000000')) +const NOT_TO_HOT = new Route([HOT_NOT], NOT) + +const trade = new Trade(NOT_TO_HOT, new TokenAmount(NOT, '1000000000000000'), TradeType.EXACT_INPUT) ``` # Properties @@ -53,7 +27,7 @@ const trade = new Trade( ## route ```typescript -route: Route; +route: Route ``` The [path](route#path) property of the route should be passed as the path parameter to router functions. @@ -61,7 +35,7 @@ The [path](route#path) property of the route should be passed as the path parame ## tradeType ```typescript -tradeType: TradeType; +tradeType: TradeType ``` `TradeType.EXACT_INPUT` corresponds to `swapExact*For*` router functions. `TradeType.EXACT_OUTPUT` corresponds to `swap*ForExact*` router functions. @@ -69,7 +43,7 @@ tradeType: TradeType; ## inputAmount ```typescript -inputAmount: TokenAmount; +inputAmount: TokenAmount ``` For exact input trades, this value should be passed as amountIn to router functions. For exact output trades, this value should be multiplied by a factor >1, representing slippage tolerance, and passed as amountInMax to router functions. @@ -77,7 +51,7 @@ For exact input trades, this value should be passed as amountIn to router functi ## outputAmount ```typescript -outputAmount: TokenAmount; +outputAmount: TokenAmount ``` For exact output trades, this value should be passed as amountOut to router functions. For exact input trades, this value should be multiplied by a factor <1, representing slippage tolerance, and passed as amountOutMin to router functions. @@ -85,7 +59,7 @@ For exact output trades, this value should be passed as amountOut to router func ## executionPrice ```typescript -executionPrice: Price; +executionPrice: Price ``` The average price that the trade would execute at. @@ -93,7 +67,7 @@ The average price that the trade would execute at. ## nextMidPrice ```typescript -nextMidPrice: Price; +nextMidPrice: Price ``` What the new mid price would be if the trade were to execute. @@ -101,7 +75,7 @@ What the new mid price would be if the trade were to execute. ## slippage ```typescript -slippage: Percent; +slippage: Percent ``` The slippage incurred by the trade. diff --git a/SDK_versioned_docs/version-2.0.0/reference/06-fractions.md b/SDK_versioned_docs/version-2.0.0/reference/06-fractions.md index b8697463a7..26fafdca0b 100644 --- a/SDK_versioned_docs/version-2.0.0/reference/06-fractions.md +++ b/SDK_versioned_docs/version-2.0.0/reference/06-fractions.md @@ -16,19 +16,19 @@ The base class which all subsequent fraction classes extend. **Not meant to be u ### numerator ```typescript -numerator: JSBI; +numerator: JSBI ``` ### denominator ```typescript -denominator: JSBI; +denominator: JSBI ``` ### quotient ```typescript -quotient: JSBI; +quotient: JSBI ``` Performs floor division. @@ -100,10 +100,10 @@ Responsible for formatting percentages (10% instead of 0.1). ## Example ```typescript -import { Percent } from "@uniswap/sdk"; +import { Percent } from '@uniswap/sdk' -const percent = new Percent("60", "100"); -console.log(percent.toSignificant(2)); // 60 +const percent = new Percent('60', '100') +console.log(percent.toSignificant(2)) // 60 ``` ### toSignificant @@ -125,18 +125,12 @@ Responsible for formatting token amounts with specific decimal places. ## Example ```typescript -import { Token, TokenAmount } from "@uniswap/sdk"; - -const FRIED = new Token( - ChainId.MAINNET, - "0xfa1aFe1000000000000000000000000000000000", - 18, - "FRIED", - "Beans" -); - -const tokenAmount = new TokenAmount(FRIED, "3000000000000000000"); -console.log(tokenAmount.toExact()); // 3 +import { Token, TokenAmount } from '@uniswap/sdk' + +const FRIED = new Token(ChainId.MAINNET, '0xfa1aFe1000000000000000000000000000000000', 18, 'FRIED', 'Beans') + +const tokenAmount = new TokenAmount(FRIED, '3000000000000000000') +console.log(tokenAmount.toExact()) // 3 ``` ## Properties @@ -144,13 +138,13 @@ console.log(tokenAmount.toExact()); // 3 ### token ```typescript -token: Token; +token: Token ``` ### raw ```typescript -raw: JSBI; +raw: JSBI ``` Returns the full token amount, unadjusted for decimals. @@ -194,23 +188,13 @@ Responsible for denominating the relative price between two tokens. Denominator ## Example ```typescript -import { ChainId, WETH as WETHs, Token, Price } from "@uniswap/sdk"; - -const WETH = WETHs[ChainId.MAINNET]; -const ABC = new Token( - ChainId.MAINNET, - "0xabc0000000000000000000000000000000000000", - 18, - "ABC" -); - -const price = new Price( - WETH, - ABC, - "1000000000000000000", - "123000000000000000000" -); -console.log(price.toSignificant(3)); // 123 +import { ChainId, WETH as WETHs, Token, Price } from '@uniswap/sdk' + +const WETH = WETHs[ChainId.MAINNET] +const ABC = new Token(ChainId.MAINNET, '0xabc0000000000000000000000000000000000000', 18, 'ABC') + +const price = new Price(WETH, ABC, '1000000000000000000', '123000000000000000000') +console.log(price.toSignificant(3)) // 123 ``` This example shows theĀ ETH/XYZ price, where ETH is the base token, and XYZ is the quote token. The price is constructed from an amount of XYZ (the numerator) / an amount of WETH (the denominator). @@ -228,19 +212,19 @@ fromRoute(route: Route): Price ### baseToken ```typescript -baseToken: Token; +baseToken: Token ``` ### quoteToken ```typescript -quoteToken: Token; +quoteToken: Token ``` ### scalar ```typescript -scalar: Fraction; +scalar: Fraction ``` Used to adjust the price for the decimals of the base and quote tokens. @@ -248,7 +232,7 @@ Used to adjust the price for the decimals of the base and quote tokens. ### raw ```typescript -raw: Fraction; +raw: Fraction ``` Returns the raw price, unadjusted for decimals. @@ -256,7 +240,7 @@ Returns the raw price, unadjusted for decimals. ### adjusted ```typescript -adjusted: Fraction; +adjusted: Fraction ``` Returns the price, adjusted for decimals. diff --git a/SDK_versioned_docs/version-2.0.0/reference/08-other-exports.md b/SDK_versioned_docs/version-2.0.0/reference/08-other-exports.md index 06423e6b68..18b7641508 100644 --- a/SDK_versioned_docs/version-2.0.0/reference/08-other-exports.md +++ b/SDK_versioned_docs/version-2.0.0/reference/08-other-exports.md @@ -6,7 +6,7 @@ title: Other Exports # JSBI ```typescript -import { JSBI } from "@uniswap/sdk"; +import { JSBI } from '@uniswap/sdk' // import JSBI from 'jsbi' ``` @@ -15,7 +15,7 @@ The default export from [jsbi](https://github.com/GoogleChromeLabs/jsbi). # BigintIsh ```typescript -import { BigintIsh } from "@uniswap/sdk"; +import { BigintIsh } from '@uniswap/sdk' // type BigintIsh = JSBI | bigint | string ``` @@ -24,7 +24,7 @@ A union type comprised of all types that can be cast to a JSBI instance. # ChainId ```typescript -import { ChainId } from "@uniswap/sdk"; +import { ChainId } from '@uniswap/sdk' // enum ChainId { // MAINNET = 1, // ROPSTEN = 3, @@ -39,7 +39,7 @@ A enum denominating supported chain IDs. # TradeType ```typescript -import { TradeType } from "@uniswap/sdk"; +import { TradeType } from '@uniswap/sdk' // enum TradeType { // EXACT_INPUT, // EXACT_OUTPUT @@ -51,7 +51,7 @@ A enum denominating supported trade types. # Rounding ```typescript -import { Rounding } from "@uniswap/sdk"; +import { Rounding } from '@uniswap/sdk' // enum Rounding { // ROUND_DOWN, // ROUND_HALF_UP, @@ -64,7 +64,7 @@ A enum denominating supported rounding options. # FACTORY_ADDRESS ```typescript -import { FACTORY_ADDRESS } from "@uniswap/sdk"; +import { FACTORY_ADDRESS } from '@uniswap/sdk' ``` The [factory address](../../../protocol/V2/reference/smart-contracts/factory#address). @@ -72,7 +72,7 @@ The [factory address](../../../protocol/V2/reference/smart-contracts/factory#add # INIT_CODE_HASH ```typescript -import { INIT_CODE_HASH } from "@uniswap/sdk"; +import { INIT_CODE_HASH } from '@uniswap/sdk' ``` See [pair addresses](../../../protocol/V2/guides/smart-contract-integration/getting-pair-addresses). @@ -80,7 +80,7 @@ See [pair addresses](../../../protocol/V2/guides/smart-contract-integration/gett # MINIMUM_LIQUIDITY ```typescript -import { MINIMUM_LIQUIDITY } from "@uniswap/sdk"; +import { MINIMUM_LIQUIDITY } from '@uniswap/sdk' ``` See [minimum liquidity](../../../protocol/V2/reference/smart-contracts/pair#minimum-liquidity). @@ -88,19 +88,19 @@ See [minimum liquidity](../../../protocol/V2/reference/smart-contracts/pair#mini # InsufficientReservesError ```typescript -import { InsufficientReservesError } from "@uniswap/sdk"; +import { InsufficientReservesError } from '@uniswap/sdk' ``` # InsufficientInputAmountError ```typescript -import { InsufficientInputAmountError } from "@uniswap/sdk"; +import { InsufficientInputAmountError } from '@uniswap/sdk' ``` # WETH ```typescript -import { WETH } from "@uniswap/sdk"; +import { WETH } from '@uniswap/sdk' ``` An object whose values are [WETH](../../../protocol/V2/reference/smart-contracts/router-02#weth) [Token](token) instances, indexed by [ChainId](#chainid). diff --git a/SDK_versioned_docs/version-2.0.0/reference/_category_.json b/SDK_versioned_docs/version-2.0.0/reference/_category_.json index e376bc8103..dc5ee95f28 100644 --- a/SDK_versioned_docs/version-2.0.0/reference/_category_.json +++ b/SDK_versioned_docs/version-2.0.0/reference/_category_.json @@ -1,5 +1,5 @@ { - "label": "Reference", - "position": 2, - "collapsed": false - } \ No newline at end of file + "label": "Reference", + "position": 2, + "collapsed": false +} diff --git a/SDK_versioned_docs/version-3.0.0/guides/01-quick-start.md b/SDK_versioned_docs/version-3.0.0/guides/01-quick-start.md index cf8cc686f4..7c0453b664 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/01-quick-start.md +++ b/SDK_versioned_docs/version-3.0.0/guides/01-quick-start.md @@ -19,7 +19,7 @@ npm i --save-dev @uniswap/sdk-core # Usage ```javascript -import { Pool } from "@uniswap/v3-sdk"; +import { Pool } from '@uniswap/v3-sdk' ``` # Next Steps diff --git a/SDK_versioned_docs/version-3.0.0/guides/02-using-ethers.md b/SDK_versioned_docs/version-3.0.0/guides/02-using-ethers.md index 06965ab4b5..b8a483f9a6 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/02-using-ethers.md +++ b/SDK_versioned_docs/version-3.0.0/guides/02-using-ethers.md @@ -43,30 +43,30 @@ We'll need to import ethers, and set up our environment variables so we can quer For this example, we're using an infura endpoint. If you don't have access to an infura endpoint, you can setup a free account [here](https://infura.io/). ```typescript -import { ethers } from "ethers"; -import { Address } from "cluster"; +import { ethers } from 'ethers' +import { Address } from 'cluster' -const provider = new ethers.providers.JsonRpcProvider(""); +const provider = new ethers.providers.JsonRpcProvider('') ``` The first thing we'll need to do is to tell Ethers where to look for our chain data. To do this, we'll create a local variable with the contract address of the V3 pool we're trying to query: ```typescript -const poolAddress = "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"; +const poolAddress = '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8' ``` Now we'll need the interface for the functions of the pool contract that we'll be calling: ```typescript const poolImmutablesAbi = [ - "function factory() external view returns (address)", - "function token0() external view returns (address)", - "function token1() external view returns (address)", - "function fee() external view returns (uint24)", - "function tickSpacing() external view returns (int24)", - "function maxLiquidityPerTick() external view returns (uint128)", -]; + 'function factory() external view returns (address)', + 'function token0() external view returns (address)', + 'function token1() external view returns (address)', + 'function fee() external view returns (uint24)', + 'function tickSpacing() external view returns (int24)', + 'function maxLiquidityPerTick() external view returns (uint128)', +] ``` ## Using ethers.js "Contract" @@ -74,23 +74,19 @@ const poolImmutablesAbi = [ Once that is setup, we'll create a new instance of a "Contract" using `ethers.js`. This isn't a smart contract itself, but rather a local model of one that helps us move data around off-chain: ```typescript -const poolContract = new ethers.Contract( - poolAddress, - poolImmutablesAbi, - provider -); +const poolContract = new ethers.Contract(poolAddress, poolImmutablesAbi, provider) ``` Now we'll create an interface with all the data we're going to return, each assigned to its appropriate type: ```typescript interface Immutables { - factory: Address; - token0: Address; - token1: Address; - fee: number; - tickSpacing: number; - maxLiquidityPerTick: number; + factory: Address + token0: Address + token1: Address + fee: number + tickSpacing: number + maxLiquidityPerTick: number } ``` @@ -107,8 +103,8 @@ async function getPoolImmutables() { fee: await poolContract.fee(), tickSpacing: await poolContract.tickSpacing(), maxLiquidityPerTick: await poolContract.maxLiquidityPerTick(), - }; - return PoolImmutables; + } + return PoolImmutables } ``` @@ -118,8 +114,8 @@ Finally, we can call our function, and print out the returned data in our consol ```typescript getPoolImmutables().then((result) => { - console.log(result); -}); + console.log(result) +}) ``` To call our function, we'll navigate to our project directory within our console, and use the following command: @@ -148,47 +144,42 @@ If everything worked correctly, you should see something like this: ## The Final Script ```typescript -import { ethers } from "ethers"; -import { Address } from "cluster"; +import { ethers } from 'ethers' +import { Address } from 'cluster' -const provider = new ethers.providers.JsonRpcProvider(""); +const provider = new ethers.providers.JsonRpcProvider('') -const poolAddress = "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"; +const poolAddress = '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8' const poolImmutablesAbi = [ - "function factory() external view returns (address)", - "function token0() external view returns (address)", - "function token1() external view returns (address)", - "function fee() external view returns (uint24)", - "function tickSpacing() external view returns (int24)", - "function maxLiquidityPerTick() external view returns (uint128)", -]; - -const poolContract = new ethers.Contract( - poolAddress, - poolImmutablesAbi, - provider -); + 'function factory() external view returns (address)', + 'function token0() external view returns (address)', + 'function token1() external view returns (address)', + 'function fee() external view returns (uint24)', + 'function tickSpacing() external view returns (int24)', + 'function maxLiquidityPerTick() external view returns (uint128)', +] + +const poolContract = new ethers.Contract(poolAddress, poolImmutablesAbi, provider) interface Immutables { - factory: Address; - token0: Address; - token1: Address; - fee: number; - tickSpacing: number; - maxLiquidityPerTick: number; + factory: Address + token0: Address + token1: Address + fee: number + tickSpacing: number + maxLiquidityPerTick: number } async function getPoolImmutables() { - const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = - await Promise.all([ - poolContract.factory(), - poolContract.token0(), - poolContract.token1(), - poolContract.fee(), - poolContract.tickSpacing(), - poolContract.maxLiquidityPerTick(), - ]); + const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = await Promise.all([ + poolContract.factory(), + poolContract.token0(), + poolContract.token1(), + poolContract.fee(), + poolContract.tickSpacing(), + poolContract.maxLiquidityPerTick(), + ]) const immutables: Immutables = { factory, @@ -197,11 +188,11 @@ async function getPoolImmutables() { fee, tickSpacing, maxLiquidityPerTick, - }; - return immutables; + } + return immutables } getPoolImmutables().then((result) => { - console.log(result); -}); + console.log(result) +}) ``` diff --git a/SDK_versioned_docs/version-3.0.0/guides/03-creating-a-pool.md b/SDK_versioned_docs/version-3.0.0/guides/03-creating-a-pool.md index 2411e84d0a..1052c5bdfd 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/03-creating-a-pool.md +++ b/SDK_versioned_docs/version-3.0.0/guides/03-creating-a-pool.md @@ -12,24 +12,18 @@ First we will replace the abi that we previously wrote out manually with a libra Depending on your local configuration, you may need to update your tsconfig.json to allow importing of `json` files with `"resolveJsonModule": true,`. ```typescript -import { ethers } from "ethers"; -import { Pool } from "@uniswap/v3-sdk"; -import { Token } from "@uniswap/sdk-core"; -import { abi as IUniswapV3PoolABI } from "@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json"; +import { ethers } from 'ethers' +import { Pool } from '@uniswap/v3-sdk' +import { Token } from '@uniswap/sdk-core' +import { abi as IUniswapV3PoolABI } from '@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json' ``` Now we'll update the `Contract` object with our imported ABI - and keep the pool address and provider the same as the previous example. ```typescript -const provider = new ethers.providers.JsonRpcProvider( - "https://mainnet.infura.io/v3/" -); -const poolAddress = "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"; -const poolContract = new ethers.Contract( - poolAddress, - IUniswapV3PoolABI, - provider -); +const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/') +const poolAddress = '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8' +const poolContract = new ethers.Contract(poolAddress, IUniswapV3PoolABI, provider) ``` ## Creating The Interfaces @@ -38,41 +32,40 @@ Create two interfaces with types that are appropriate for the data we need. We w ```typescript interface Immutables { - factory: string; - token0: string; - token1: string; - fee: number; - tickSpacing: number; - maxLiquidityPerTick: ethers.BigNumber; + factory: string + token0: string + token1: string + fee: number + tickSpacing: number + maxLiquidityPerTick: ethers.BigNumber } interface State { - liquidity: ethers.BigNumber; - sqrtPriceX96: ethers.BigNumber; - tick: number; - observationIndex: number; - observationCardinality: number; - observationCardinalityNext: number; - feeProtocol: number; - unlocked: boolean; + liquidity: ethers.BigNumber + sqrtPriceX96: ethers.BigNumber + tick: number + observationIndex: number + observationCardinality: number + observationCardinalityNext: number + feeProtocol: number + unlocked: boolean } ``` ## Fetching Immutable Data -Fetch the immutable data from the deployed V3 pool contract and return it to create a model of the pool. +Fetch the immutable data from the deployed V3 pool contract and return it to create a model of the pool. ```typescript async function getPoolImmutables() { - const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = - await Promise.all([ - poolContract.factory(), - poolContract.token0(), - poolContract.token1(), - poolContract.fee(), - poolContract.tickSpacing(), - poolContract.maxLiquidityPerTick(), - ]); + const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = await Promise.all([ + poolContract.factory(), + poolContract.token0(), + poolContract.token1(), + poolContract.fee(), + poolContract.tickSpacing(), + poolContract.maxLiquidityPerTick(), + ]) const immutables: Immutables = { factory, @@ -81,8 +74,8 @@ async function getPoolImmutables() { fee, tickSpacing, maxLiquidityPerTick, - }; - return immutables; + } + return immutables } ``` @@ -94,10 +87,7 @@ Fetch the state data in with the same `Promise.all` style. This approach queries ```typescript async function getPoolState() { - const [liquidity, slot] = await Promise.all([ - poolContract.liquidity(), - poolContract.slot0(), - ]); + const [liquidity, slot] = await Promise.all([poolContract.liquidity(), poolContract.slot0()]) const PoolState: State = { liquidity, @@ -108,9 +98,9 @@ async function getPoolState() { observationCardinalityNext: slot[4], feeProtocol: slot[5], unlocked: slot[6], - }; + } - return PoolState; + return PoolState } ``` @@ -122,14 +112,11 @@ Create a function called `main`, which calls previously written functions, and u ```typescript async function main() { - const [immutables, state] = await Promise.all([ - getPoolImmutables(), - getPoolState(), - ]); + const [immutables, state] = await Promise.all([getPoolImmutables(), getPoolState()]) - const TokenA = new Token(3, immutables.token0, 6, "USDC", "USD Coin"); + const TokenA = new Token(3, immutables.token0, 6, 'USDC', 'USD Coin') - const TokenB = new Token(3, immutables.token1, 18, "WETH", "Wrapped Ether"); + const TokenB = new Token(3, immutables.token1, 18, 'WETH', 'Wrapped Ether') const poolExample = new Pool( TokenA, @@ -138,11 +125,11 @@ async function main() { state.sqrtPriceX96.toString(), state.liquidity.toString(), state.tick - ); - console.log(poolExample); + ) + console.log(poolExample) } -main(); +main() ``` If everything is working, the script should return something like this: @@ -178,54 +165,46 @@ Pool { ## The Final Script ```typescript -import { ethers } from "ethers"; -import { Pool } from "@uniswap/v3-sdk"; -import { Token } from "@uniswap/sdk-core"; -import { abi as IUniswapV3PoolABI } from "@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json"; +import { ethers } from 'ethers' +import { Pool } from '@uniswap/v3-sdk' +import { Token } from '@uniswap/sdk-core' +import { abi as IUniswapV3PoolABI } from '@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json' -const provider = new ethers.providers.JsonRpcProvider( - "https://mainnet.infura.io/v3/" -); +const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/') +const poolAddress = '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8' -const poolAddress = "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8"; - -const poolContract = new ethers.Contract( - poolAddress, - IUniswapV3PoolABI, - provider -); +const poolContract = new ethers.Contract(poolAddress, IUniswapV3PoolABI, provider) interface Immutables { - factory: string; - token0: string; - token1: string; - fee: number; - tickSpacing: number; - maxLiquidityPerTick: ethers.BigNumber; + factory: string + token0: string + token1: string + fee: number + tickSpacing: number + maxLiquidityPerTick: ethers.BigNumber } interface State { - liquidity: ethers.BigNumber; - sqrtPriceX96: ethers.BigNumber; - tick: number; - observationIndex: number; - observationCardinality: number; - observationCardinalityNext: number; - feeProtocol: number; - unlocked: boolean; + liquidity: ethers.BigNumber + sqrtPriceX96: ethers.BigNumber + tick: number + observationIndex: number + observationCardinality: number + observationCardinalityNext: number + feeProtocol: number + unlocked: boolean } async function getPoolImmutables() { - const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = - await Promise.all([ - poolContract.factory(), - poolContract.token0(), - poolContract.token1(), - poolContract.fee(), - poolContract.tickSpacing(), - poolContract.maxLiquidityPerTick(), - ]); + const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = await Promise.all([ + poolContract.factory(), + poolContract.token0(), + poolContract.token1(), + poolContract.fee(), + poolContract.tickSpacing(), + poolContract.maxLiquidityPerTick(), + ]) const immutables: Immutables = { factory, @@ -234,15 +213,12 @@ async function getPoolImmutables() { fee, tickSpacing, maxLiquidityPerTick, - }; - return immutables; + } + return immutables } async function getPoolState() { - const [liquidity, slot] = await Promise.all([ - poolContract.liquidity(), - poolContract.slot0(), - ]); + const [liquidity, slot] = await Promise.all([poolContract.liquidity(), poolContract.slot0()]) const PoolState: State = { liquidity, @@ -253,20 +229,17 @@ async function getPoolState() { observationCardinalityNext: slot[4], feeProtocol: slot[5], unlocked: slot[6], - }; + } - return PoolState; + return PoolState } async function main() { - const [immutables, state] = await Promise.all([ - getPoolImmutables(), - getPoolState(), - ]); + const [immutables, state] = await Promise.all([getPoolImmutables(), getPoolState()]) - const TokenA = new Token(3, immutables.token0, 6, "USDC", "USD Coin"); + const TokenA = new Token(3, immutables.token0, 6, 'USDC', 'USD Coin') - const TokenB = new Token(3, immutables.token1, 18, "WETH", "Wrapped Ether"); + const TokenB = new Token(3, immutables.token1, 18, 'WETH', 'Wrapped Ether') const poolExample = new Pool( TokenA, @@ -275,10 +248,9 @@ async function main() { state.sqrtPriceX96.toString(), state.liquidity.toString(), state.tick - ); - console.log(poolExample); + ) + console.log(poolExample) } -main(); - +main() ``` diff --git a/SDK_versioned_docs/version-3.0.0/guides/04-fetching-prices.md b/SDK_versioned_docs/version-3.0.0/guides/04-fetching-prices.md index 15c38486f7..a322a7f8e8 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/04-fetching-prices.md +++ b/SDK_versioned_docs/version-3.0.0/guides/04-fetching-prices.md @@ -21,10 +21,10 @@ const DAI_USDC_POOL = new Pool( state.sqrtPriceX96.toString(), state.liquidity.toString(), state.tick -); +) -const token0Price = DAI_USDC_POOL.token0Price; -const token1Price = DAI_USDC_POOL.token1Price; +const token0Price = DAI_USDC_POOL.token0Price +const token1Price = DAI_USDC_POOL.token1Price ``` ### Understanding sqrtPrice @@ -107,8 +107,8 @@ It's worth noting that the numerator is misleadingly listed _below_ the denomina The denominator is `Q192`. To break this number down recall the following constants defined in the SDK: ```typescript -export const Q96 = JSBI.exponentiate(JSBI.BigInt(2), JSBI.BigInt(96)); -export const Q192 = JSBI.exponentiate(Q96, JSBI.BigInt(2)); +export const Q96 = JSBI.exponentiate(JSBI.BigInt(2), JSBI.BigInt(96)) +export const Q192 = JSBI.exponentiate(Q96, JSBI.BigInt(2)) ``` Thus, the denominator for the `token0Price` also matches the math derived above where `Q192` is `(2 ** 96) * (2 ** 96)` which is the same as `(2 ** 192)`. diff --git a/SDK_versioned_docs/version-3.0.0/guides/05-creating-a-trade.md b/SDK_versioned_docs/version-3.0.0/guides/05-creating-a-trade.md index cbc6942c48..b663829f92 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/05-creating-a-trade.md +++ b/SDK_versioned_docs/version-3.0.0/guides/05-creating-a-trade.md @@ -14,19 +14,19 @@ The quoter is a smart contract that retrieves estimated output or input amounts Create the quoter contract object by importing the [ABI](https://docs.soliditylang.org/en/v0.7.0/abi-spec.html) from the [uniswap-v3-periphery](https://www.npmjs.com/package/@uniswap/v3-periphery) npm package. ```ts -import { abi as QuoterABI } from "@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json"; +import { abi as QuoterABI } from '@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json' ``` assign your [ethereum endpoint provider](https://ethereum.org/en/developers/docs/nodes-and-clients/nodes-as-a-service/), in this case, Infura. ```ts -const provider = new ethers.providers.JsonRpcProvider(""); +const provider = new ethers.providers.JsonRpcProvider('') ``` Provide the [deployment address of the quoter contract](https://github.com/Uniswap/uniswap-v3-periphery/blob/main/deploys.md). ```ts -const quoterContract = new ethers.Contract(quoterAddress, QuoterABI, provider); +const quoterContract = new ethers.Contract(quoterAddress, QuoterABI, provider) ``` ## Using callStatic To Return A Quote @@ -53,7 +53,7 @@ Note this function uses the `Immutables` interface defined in the earlier guides ```ts async function main() { - const amountIn = 1500; + const amountIn = 1500 const quotedAmountOut = await quoterContract.callStatic.quoteExactInputSingle( immutables.token0, @@ -61,7 +61,7 @@ async function main() { immutables.fee, amountIn.toString(), 0 - ); + ) } ``` @@ -70,7 +70,7 @@ async function main() { Create a [Route](https://github.com/Uniswap/uniswap-v3-sdk/blob/7c3aedd0cf9441d03607e258734eada44a73863d/src/entities/route.ts) object and assign it to a variable `swapRoute` ```ts -const swapRoute = new Route([poolExample], TokenA, TokenB); +const swapRoute = new Route([poolExample], TokenA, TokenB) ``` Create an [Unchecked Trade](https://github.com/Uniswap/uniswap-v3-sdk/blob/7c3aedd0cf9441d03607e258734eada44a73863d/src/entities/trade.ts#L346), a type of trade that is useful when we have retrieved a quote prior to the construction of the trade object. @@ -79,12 +79,9 @@ Create an [Unchecked Trade](https://github.com/Uniswap/uniswap-v3-sdk/blob/7c3ae const uncheckedTradeExample = await Trade.createUncheckedTrade({ route: swapRoute, inputAmount: CurrencyAmount.fromRawAmount(TokenA, amountIn.toString()), - outputAmount: CurrencyAmount.fromRawAmount( - TokenB, - quotedAmountOut.toString() - ), + outputAmount: CurrencyAmount.fromRawAmount(TokenB, quotedAmountOut.toString()), tradeType: TradeType.EXACT_INPUT, -}); +}) ``` ## Print The Quote And Trade To Your Console @@ -92,8 +89,8 @@ const uncheckedTradeExample = await Trade.createUncheckedTrade({ Print the `Quote` and the `UncheckedTrade` to the console. ```ts -console.log("The quoted amount out is", quotedAmountOut.toString()); -console.log("The unchecked trade object is", uncheckedTradeExample); +console.log('The quoted amount out is', quotedAmountOut.toString()) +console.log('The unchecked trade object is', uncheckedTradeExample) ``` If everything is working, you should see something similar to this returned in your console. @@ -115,59 +112,54 @@ The unchecked trade object is Trade { ## The Full Example ```ts -import { ethers } from "ethers"; -import { Pool } from "@uniswap/v3-sdk"; -import { CurrencyAmount, Token, TradeType } from "@uniswap/sdk-core"; -import { abi as IUniswapV3PoolABI } from "@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json"; -import { Route } from "@uniswap/v3-sdk"; -import { Trade } from "@uniswap/v3-sdk"; -import { abi as QuoterABI } from "@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json"; +import { ethers } from 'ethers' +import { Pool } from '@uniswap/v3-sdk' +import { CurrencyAmount, Token, TradeType } from '@uniswap/sdk-core' +import { abi as IUniswapV3PoolABI } from '@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json' +import { Route } from '@uniswap/v3-sdk' +import { Trade } from '@uniswap/v3-sdk' +import { abi as QuoterABI } from '@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json' -const provider = new ethers.providers.JsonRpcProvider(""); +const provider = new ethers.providers.JsonRpcProvider('') // USDC-WETH pool address on mainnet for fee tier 0.05% -const poolAddress = "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"; +const poolAddress = '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640' -const poolContract = new ethers.Contract( - poolAddress, - IUniswapV3PoolABI, - provider -); +const poolContract = new ethers.Contract(poolAddress, IUniswapV3PoolABI, provider) -const quoterAddress = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6"; +const quoterAddress = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6' -const quoterContract = new ethers.Contract(quoterAddress, QuoterABI, provider); +const quoterContract = new ethers.Contract(quoterAddress, QuoterABI, provider) interface Immutables { - factory: string; - token0: string; - token1: string; - fee: number; - tickSpacing: number; - maxLiquidityPerTick: ethers.BigNumber; + factory: string + token0: string + token1: string + fee: number + tickSpacing: number + maxLiquidityPerTick: ethers.BigNumber } interface State { - liquidity: ethers.BigNumber; - sqrtPriceX96: ethers.BigNumber; - tick: number; - observationIndex: number; - observationCardinality: number; - observationCardinalityNext: number; - feeProtocol: number; - unlocked: boolean; + liquidity: ethers.BigNumber + sqrtPriceX96: ethers.BigNumber + tick: number + observationIndex: number + observationCardinality: number + observationCardinalityNext: number + feeProtocol: number + unlocked: boolean } async function getPoolImmutables() { - const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = - await Promise.all([ - poolContract.factory(), - poolContract.token0(), - poolContract.token1(), - poolContract.fee(), - poolContract.tickSpacing(), - poolContract.maxLiquidityPerTick(), - ]); + const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = await Promise.all([ + poolContract.factory(), + poolContract.token0(), + poolContract.token1(), + poolContract.fee(), + poolContract.tickSpacing(), + poolContract.maxLiquidityPerTick(), + ]) const immutables: Immutables = { factory, @@ -176,16 +168,13 @@ async function getPoolImmutables() { fee, tickSpacing, maxLiquidityPerTick, - }; - return immutables; + } + return immutables } async function getPoolState() { // note that data here can be desynced if the call executes over the span of two or more blocks. - const [liquidity, slot] = await Promise.all([ - poolContract.liquidity(), - poolContract.slot0(), - ]); + const [liquidity, slot] = await Promise.all([poolContract.liquidity(), poolContract.slot0()]) const PoolState: State = { liquidity, @@ -196,22 +185,19 @@ async function getPoolState() { observationCardinalityNext: slot[4], feeProtocol: slot[5], unlocked: slot[6], - }; + } - return PoolState; + return PoolState } async function main() { // query the state and immutable variables of the pool - const [immutables, state] = await Promise.all([ - getPoolImmutables(), - getPoolState(), - ]); + const [immutables, state] = await Promise.all([getPoolImmutables(), getPoolState()]) // create instances of the Token object to represent the two tokens in the given pool - const TokenA = new Token(3, immutables.token0, 6, "USDC", "USD Coin"); + const TokenA = new Token(3, immutables.token0, 6, 'USDC', 'USD Coin') - const TokenB = new Token(3, immutables.token1, 18, "WETH", "Wrapped Ether"); + const TokenB = new Token(3, immutables.token1, 18, 'WETH', 'Wrapped Ether') // create an instance of the pool object for the given pool const poolExample = new Pool( @@ -221,10 +207,10 @@ async function main() { state.sqrtPriceX96.toString(), //note the description discrepancy - sqrtPriceX96 and sqrtRatioX96 are interchangable values state.liquidity.toString(), state.tick - ); + ) // assign an input amount for the swap - const amountIn = 1500; + const amountIn = 1500 // call the quoter contract to determine the amount out of a swap, given an amount in const quotedAmountOut = await quoterContract.callStatic.quoteExactInputSingle( @@ -233,26 +219,23 @@ async function main() { immutables.fee, amountIn.toString(), 0 - ); + ) // create an instance of the route object in order to construct a trade object - const swapRoute = new Route([poolExample], TokenA, TokenB); + const swapRoute = new Route([poolExample], TokenA, TokenB) // create an unchecked trade instance const uncheckedTradeExample = await Trade.createUncheckedTrade({ route: swapRoute, inputAmount: CurrencyAmount.fromRawAmount(TokenA, amountIn.toString()), - outputAmount: CurrencyAmount.fromRawAmount( - TokenB, - quotedAmountOut.toString() - ), + outputAmount: CurrencyAmount.fromRawAmount(TokenB, quotedAmountOut.toString()), tradeType: TradeType.EXACT_INPUT, - }); + }) // print the quote and the unchecked trade instance in the console - console.log("The quoted amount out is", quotedAmountOut.toString()); - console.log("The unchecked trade object is", uncheckedTradeExample); + console.log('The quoted amount out is', quotedAmountOut.toString()) + console.log('The unchecked trade object is', uncheckedTradeExample) } -main(); +main() ``` diff --git a/SDK_versioned_docs/version-3.0.0/guides/06-auto-router.md b/SDK_versioned_docs/version-3.0.0/guides/06-auto-router.md index 0c1591ad1c..4f31c437b6 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/06-auto-router.md +++ b/SDK_versioned_docs/version-3.0.0/guides/06-auto-router.md @@ -22,7 +22,7 @@ To integrate with the Auto Router, you will use the [smart-order-router](https:/ Import `AlphaRouter` from the smart-order-router package to get started. ```typescript -import { AlphaRouter } from "@uniswap/smart-order-router"; +import { AlphaRouter } from '@uniswap/smart-order-router' ``` ## Initializing the AlphaRouter @@ -37,7 +37,7 @@ The `AlphaRouter` class contains methods for generating optimized routes. To cre | provider | [required] | A JSON RPC endpoint, e.g., Infura. | ```typescript -const router = new AlphaRouter({ chainId: 1, provider: web3Provider }); +const router = new AlphaRouter({ chainId: 1, provider: web3Provider }) ``` ## Calling `route` @@ -69,27 +69,15 @@ Once you instantiate `AlphaRouter` call `route` with the following parameters: This example gets a route for a WETH-USDC swap. ```typescript -const WETH = new Token( - 1, - "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - 18, - "WETH", - "Wrapped Ether" -); +const WETH = new Token(1, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether') -const USDC = new Token( - ChainId.MAINNET, - "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - 6, - "USDC", - "USD//C" -); +const USDC = new Token(ChainId.MAINNET, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 6, 'USDC', 'USD//C') const route = await router.route(wethAmount, USDC, TradeType.EXACT_INPUT, { recipient: myAddress, slippageTolerance: new Percent(5, 100), deadline: Math.floor(Date.now() / 1000 + 1800), -}); +}) ``` ## Submitting a Transaction @@ -98,17 +86,17 @@ The object returned from calling `route` is a `SwapRoute` object with the follow ```typescript export type SwapRoute = { - quote: CurrencyAmount; - quoteGasAdjusted: CurrencyAmount; - estimatedGasUsed: BigNumber; - estimatedGasUsedQuoteToken: CurrencyAmount; - estimatedGasUsedUSD: CurrencyAmount; - gasPriceWei: BigNumber; - trade: Trade; - route: RouteWithValidQuote[]; - blockNumber: BigNumber; - methodParameters?: MethodParameters; -}; + quote: CurrencyAmount + quoteGasAdjusted: CurrencyAmount + estimatedGasUsed: BigNumber + estimatedGasUsedQuoteToken: CurrencyAmount + estimatedGasUsedUSD: CurrencyAmount + gasPriceWei: BigNumber + trade: Trade + route: RouteWithValidQuote[] + blockNumber: BigNumber + methodParameters?: MethodParameters +} ``` Use the quoted gas price and generated call data as inputs for the transaction, as done below: diff --git a/SDK_versioned_docs/version-3.0.0/guides/_category_.json b/SDK_versioned_docs/version-3.0.0/guides/_category_.json index 8de50f2c68..c694eb5b29 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/_category_.json +++ b/SDK_versioned_docs/version-3.0.0/guides/_category_.json @@ -1,6 +1,5 @@ { - "label": "Guides", - "position": 2, - "collapsed": false - - } \ No newline at end of file + "label": "Guides", + "position": 2, + "collapsed": false +} diff --git a/SDK_versioned_docs/version-3.0.0/guides/liquidity/04-minting-positions.md b/SDK_versioned_docs/version-3.0.0/guides/liquidity/04-minting-positions.md index b043d617de..5354dea6bd 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/liquidity/04-minting-positions.md +++ b/SDK_versioned_docs/version-3.0.0/guides/liquidity/04-minting-positions.md @@ -15,21 +15,21 @@ In summary, the following is what you will learn in this guide: 4. Construct the calldata for adding to a position. 5. Construct the calldata for removing from a position. - ## Setting up the pool First, call the constructor to create an instance of a Uniswap v3 pool. For example, the following code creates a DAI-USDC 0.05% pool. ```typescript - const DAI_USDC_POOL = new Pool( - DAI, - USDC, - immutables.fee, - state.sqrtPriceX96.toString(), - state.liquidity.toString(), - state.tick - ); +const DAI_USDC_POOL = new Pool( + DAI, + USDC, + immutables.fee, + state.sqrtPriceX96.toString(), + state.liquidity.toString(), + state.tick +) ``` + The input parameters are the two token addresses, the fee tier (0.05%), the current pool price, the current liquidity, and the current tick. Reference [the previous guide](https://docs.uniswap.org/sdk/guides/creating-a-pool) to understand how to retrieve these necessary parameters for setting up instances of existing pools. ## Creating a Position Instance @@ -38,23 +38,24 @@ A position represents the price range for a specific pool that LPs choose to pro ```typescript const position = new Position({ - pool: DAI_USDC_POOL, - liquidity: state.liquidity * 0.0002, - tickLower: nearestUsableTick(state.tick, immutables.tickSpacing) - immutables.tickSpacing * 2, - tickUpper: nearestUsableTick(state.tick, immutables.tickSpacing) + immutables.tickSpacing * 2 - }) + pool: DAI_USDC_POOL, + liquidity: state.liquidity * 0.0002, + tickLower: nearestUsableTick(state.tick, immutables.tickSpacing) - immutables.tickSpacing * 2, + tickUpper: nearestUsableTick(state.tick, immutables.tickSpacing) + immutables.tickSpacing * 2, +}) ``` You can retrieve the variable inputs (like `state.liquidity` and `immutables.tickSpacing`) from fetching the state data as shown in the previous guide. After you fetch these variables, call the Position constructor and input the parameters: `pool`, `liquidity`, `tickLower`, and `tickUpper`: -- The `pool` parameter takes in the pool instance from step 1. -- The `liquidity` parameter specifies how much liquidity to add. This examples adds a fraction of the current liquidity in the pool: 0.0002 times the amount of current liquidity. In production, this could be a parameter inputted into the function adjustable by the end-user. -- The `tickLower` and `tickUpper` parameters specify the price range at which to provide liquidity. This example calls `nearestUsableTick` to get the current useable tick and adjust the lower parameter to be below it by 2 * `tickSpacing` and the upper to be above it by 2 * `tickSpacing`. This guarantees that the provided liquidity is "in range", meaning it will be earning fees upon minting this position. + +- The `pool` parameter takes in the pool instance from step 1. +- The `liquidity` parameter specifies how much liquidity to add. This examples adds a fraction of the current liquidity in the pool: 0.0002 times the amount of current liquidity. In production, this could be a parameter inputted into the function adjustable by the end-user. +- The `tickLower` and `tickUpper` parameters specify the price range at which to provide liquidity. This example calls `nearestUsableTick` to get the current useable tick and adjust the lower parameter to be below it by 2 _ `tickSpacing` and the upper to be above it by 2 _ `tickSpacing`. This guarantees that the provided liquidity is "in range", meaning it will be earning fees upon minting this position. ## Minting the Position -To create the calldata for minting a position, use the function defined in the SDK called `addCallParameters` which takes in a position (of type `Position`) and an option (of type `AddLiquidityOptions`). `AddLiquidityOptions` are either `MintOptions` for minting a new position or `IncreaseOptions` for adding liquidity to an existing position. Below, the example outlines the parameters needed to mint a new position and passes in a valid `MintOptions` struct to the SDK function `addCallParameters`. +To create the calldata for minting a position, use the function defined in the SDK called `addCallParameters` which takes in a position (of type `Position`) and an option (of type `AddLiquidityOptions`). `AddLiquidityOptions` are either `MintOptions` for minting a new position or `IncreaseOptions` for adding liquidity to an existing position. Below, the example outlines the parameters needed to mint a new position and passes in a valid `MintOptions` struct to the SDK function `addCallParameters`. `MintOptions` are constructed from `CommonAddLiquidityOptions & MintSpecificOptions`. To see all potential parameters that can be inputted here is the reference for [`CommonAddLiquidityOptions`](https://docs.uniswap.org/sdk/reference/interfaces/CommonAddLiquidityOptions): @@ -86,6 +87,7 @@ export interface CommonAddLiquidityOptions { token1Permit?: PermitOptions } ``` + and here is the reference for [`MintSpecificOptions`](https://docs.uniswap.org/sdk/reference/interfaces/MintSpecificOptions): ```typescript @@ -105,14 +107,13 @@ export interface MintSpecificOptions { You can omit the parameters that are not required. In order to create the most basic valid `MintOptions` struct just set the `slippageTolerance`, `deadline`, and `recipient` which is constructed below: ```typescript - const deadline = block.timestamp + 200; +const deadline = block.timestamp + 200 - const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, { - slippageTolerance: new Percent(50, 10_000), - recipient: sender, - deadline: deadline - }); +const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, { + slippageTolerance: new Percent(50, 10_000), + recipient: sender, + deadline: deadline, +}) ``` -where `slippageTolerance` is set to 0.005%, `recipient` is set to the sender address which is an input to this function, and `deadline` is set to the current `block.timestamp` plus some arbitrary amount, for this example. The parameter `slippageTolerance` refers to the percentage that the price can change for the transaction to still succeed. If a price slips beyond the percentage specified, the transaction will not go through. Set `recipient` to the address that will own the newly minted NFT position. Set `deadline` to the timebound at which this transaction can still be submitted. - +where `slippageTolerance` is set to 0.005%, `recipient` is set to the sender address which is an input to this function, and `deadline` is set to the current `block.timestamp` plus some arbitrary amount, for this example. The parameter `slippageTolerance` refers to the percentage that the price can change for the transaction to still succeed. If a price slips beyond the percentage specified, the transaction will not go through. Set `recipient` to the address that will own the newly minted NFT position. Set `deadline` to the timebound at which this transaction can still be submitted. diff --git a/SDK_versioned_docs/version-3.0.0/guides/liquidity/05-adding-liquidity.md b/SDK_versioned_docs/version-3.0.0/guides/liquidity/05-adding-liquidity.md index ffbec09a5d..953e39dfdd 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/liquidity/05-adding-liquidity.md +++ b/SDK_versioned_docs/version-3.0.0/guides/liquidity/05-adding-liquidity.md @@ -48,9 +48,9 @@ To construct the `IncreaseOptions` struct, specify `slippageTolerance`, `deadlin Use [the functions](https://docs.openzeppelin.com/contracts/2.x/api/token/erc721#ERC721Enumerable-tokenOfOwnerByIndex-address-uint256-) `tokensByIndex` or `tokenOfOwnerByIndex` to fetch `tokenId`s for ERC721s. ```typescript -const {calldata ,value} = NonfungiblePositionManager.addCallParameters(position, { - slippageTolerance: new Percent(50, 10_000), - deadline: deadline, - tokenId: 1 - }); +const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, { + slippageTolerance: new Percent(50, 10_000), + deadline: deadline, + tokenId: 1, +}) ``` diff --git a/SDK_versioned_docs/version-3.0.0/guides/liquidity/06-removing-liquidity.md b/SDK_versioned_docs/version-3.0.0/guides/liquidity/06-removing-liquidity.md index f655f0dcd0..9836bec0e5 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/liquidity/06-removing-liquidity.md +++ b/SDK_versioned_docs/version-3.0.0/guides/liquidity/06-removing-liquidity.md @@ -49,9 +49,10 @@ export interface RemoveLiquidityOptions { } ``` -To remove liquidity from a position, set the parameters for `tokenId`, `liquidityPercentage`, `slippageTolerance`, `deadline`, and `collectOptions`. +To remove liquidity from a position, set the parameters for `tokenId`, `liquidityPercentage`, `slippageTolerance`, `deadline`, and `collectOptions`. + +The reference for `CollectOptions` is -The reference for `CollectOptions` is ```typescript export interface CollectOptions { /** @@ -77,28 +78,28 @@ export interface CollectOptions { ``` The parameter inputs are outlined below for `RemoveLiquidityOptions`: -- the`tokenId` is again set to 1 for this example, but refers to the unique id of the position nft. -- `liquidityPercentage` represents the amount of liquidity to remove. Adjust this parameter based on how much liquidity you want to remove. Set it to `Percent(1)` to remove all liquidity. -- This example sets `slipppageTolerance` and `deadline` to the same values as the previous examples. -- `collectOptions` defines the tokens to be collected and are passed onto `collect`. This example collects the maximum amount of DAI and USDC. -When collecting fees in ETH, you must precompute the fees owed to protect against reentrancy attacks. In order to set a safety check, set the minimum fees owed in `expectedCurrencyOwed0` and `expectedCurrencyOwed1`. To calculate this, quote the `collect` function and store the amounts. The interface does similar behavior [here](https://github.com/Uniswap/uniswap-interface/blob/eff512deb8f0ab832eb8d1834f6d1a20219257d0/src/hooks/useV3PositionFees.ts#L32). For this example, it is not necessary to set a minimum amount of fees to collect because there is no concern with reentrancy for tokens (DAI/USDC). +- the`tokenId` is again set to 1 for this example, but refers to the unique id of the position nft. +- `liquidityPercentage` represents the amount of liquidity to remove. Adjust this parameter based on how much liquidity you want to remove. Set it to `Percent(1)` to remove all liquidity. +- This example sets `slipppageTolerance` and `deadline` to the same values as the previous examples. +- `collectOptions` defines the tokens to be collected and are passed onto `collect`. This example collects the maximum amount of DAI and USDC. +When collecting fees in ETH, you must precompute the fees owed to protect against reentrancy attacks. In order to set a safety check, set the minimum fees owed in `expectedCurrencyOwed0` and `expectedCurrencyOwed1`. To calculate this, quote the `collect` function and store the amounts. The interface does similar behavior [here](https://github.com/Uniswap/uniswap-interface/blob/eff512deb8f0ab832eb8d1834f6d1a20219257d0/src/hooks/useV3PositionFees.ts#L32). For this example, it is not necessary to set a minimum amount of fees to collect because there is no concern with reentrancy for tokens (DAI/USDC). ```typescript -const {calldata, value} = NonfungiblePositionManager.removeCallParameters(position, { - tokenId: 1, - liquidityPercentage: new Percent(1), - slippageTolerance: new Percent(50, 10_000), - deadline: deadline, - collectOptions: { - expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(DAI, 0), - expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(USDC, 0), - recipient: sender - }} - ); +const { calldata, value } = NonfungiblePositionManager.removeCallParameters(position, { + tokenId: 1, + liquidityPercentage: new Percent(1), + slippageTolerance: new Percent(50, 10_000), + deadline: deadline, + collectOptions: { + expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(DAI, 0), + expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(USDC, 0), + recipient: sender, + }, +}) ``` ## The example code -You now know how to mint a liquidity position, add liquidity, and remove liquidity. Here's the [full example code](https://github.com/Uniswap/uniswap-docs/blob/main/sdk-examples/AddAndRemoveLiquidity.tsx) for reference. \ No newline at end of file +You now know how to mint a liquidity position, add liquidity, and remove liquidity. Here's the [full example code](https://github.com/Uniswap/uniswap-docs/blob/main/sdk-examples/AddAndRemoveLiquidity.tsx) for reference. diff --git a/SDK_versioned_docs/version-3.0.0/guides/liquidity/07-swap-and-add.md b/SDK_versioned_docs/version-3.0.0/guides/liquidity/07-swap-and-add.md index 2da8cfe797..84d2ed767f 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/liquidity/07-swap-and-add.md +++ b/SDK_versioned_docs/version-3.0.0/guides/liquidity/07-swap-and-add.md @@ -18,8 +18,8 @@ npm install @uniswap/smart-order-router ``` ```typescript -import { AlphaRouter } from "@uniswap/smart-order-router"; -const router = new AlphaRouter({ chainId: 1, provider: web3Provider }); +import { AlphaRouter } from '@uniswap/smart-order-router' +const router = new AlphaRouter({ chainId: 1, provider: web3Provider }) ``` ## Fetching calldata from `routeToRatio` @@ -129,19 +129,19 @@ The `SwapToRatioRoute` object will have the properties listed out in the type be ```typescript type SwapToRatioRoute = { - quote: CurrencyAmount; - quoteGasAdjusted: CurrencyAmount; - optimalRatio: Fraction; - postSwapTargetPool: Pool; - estimatedGasUsed: BigNumber; - estimatedGasUsedQuoteToken: CurrencyAmount; - estimatedGasUsedUSD: CurrencyAmount; - gasPriceWei: BigNumber; - trade: Trade; - route: RouteWithValidQuote[]; - blockNumber: BigNumber; - methodParameters?: MethodParameters; -}; + quote: CurrencyAmount + quoteGasAdjusted: CurrencyAmount + optimalRatio: Fraction + postSwapTargetPool: Pool + estimatedGasUsed: BigNumber + estimatedGasUsedQuoteToken: CurrencyAmount + estimatedGasUsedUSD: CurrencyAmount + gasPriceWei: BigNumber + trade: Trade + route: RouteWithValidQuote[] + blockNumber: BigNumber + methodParameters?: MethodParameters +} ``` Use the quoted gas price defined as `gasPriceWei` in the above `SwapToRatioRoute` object above and generated call data as inputs for the transaction, as done below: diff --git a/SDK_versioned_docs/version-3.0.0/guides/liquidity/_category_.json b/SDK_versioned_docs/version-3.0.0/guides/liquidity/_category_.json index f32945ce56..f9a4a1c91d 100644 --- a/SDK_versioned_docs/version-3.0.0/guides/liquidity/_category_.json +++ b/SDK_versioned_docs/version-3.0.0/guides/liquidity/_category_.json @@ -1,6 +1,5 @@ { - "label": "Interacting with Pool Liquidity", - "position": 6, - "collapsed": true - - } \ No newline at end of file + "label": "Interacting with Pool Liquidity", + "position": 6, + "collapsed": true +} diff --git a/SDK_versioned_docs/version-3.0.0/widgets/_category_.json b/SDK_versioned_docs/version-3.0.0/widgets/_category_.json index 16b3d33eb1..539e1314ae 100644 --- a/SDK_versioned_docs/version-3.0.0/widgets/_category_.json +++ b/SDK_versioned_docs/version-3.0.0/widgets/_category_.json @@ -2,4 +2,4 @@ "label": "Swap Widget", "position": 3, "collapsed": true -} \ No newline at end of file +} diff --git a/SDK_versioned_docs/version-3.0.0/widgets/swap-widget-api.md b/SDK_versioned_docs/version-3.0.0/widgets/swap-widget-api.md index 3c7d248eb0..77b8814ef5 100644 --- a/SDK_versioned_docs/version-3.0.0/widgets/swap-widget-api.md +++ b/SDK_versioned_docs/version-3.0.0/widgets/swap-widget-api.md @@ -12,27 +12,27 @@ sidebar_position: 3 ## Required Parameters {#required-parameters} -| Prop Name | Prop Type | Default Value | Description | -| --- | --- | --- | --- | -| `jsonRpcEndpoint` | `string` | `undefined` | URI of your JSON-RPC endpoint. Strongly recommended in order to provide trade quotes prior to the user connecting a wallet. If none is provided, the widget will be completely disabled until the user connects a wallet. Once a wallet is connected, the widget will use the walletā€™s JSON-RPC. See [Understanding the Swap Widget States](../swap-widget#understanding-widget-states). | -| `provider` | `any` | `undefined` | An [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider. This is required to swap. | +| Prop Name | Prop Type | Default Value | Description | +| ----------------- | --------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `jsonRpcEndpoint` | `string` | `undefined` | URI of your JSON-RPC endpoint. Strongly recommended in order to provide trade quotes prior to the user connecting a wallet. If none is provided, the widget will be completely disabled until the user connects a wallet. Once a wallet is connected, the widget will use the walletā€™s JSON-RPC. See [Understanding the Swap Widget States](../swap-widget#understanding-widget-states). | +| `provider` | `any` | `undefined` | An [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider. This is required to swap. | ## Optional Parameters {#optional-parameters} -| Prop Name | Prop Type | Default Value | Description | -| --- | --- | --- | --- | -| `convenienceFee` | `number` | `undefined` | Optionally, you may charge a convenience fee on top of swaps executed through your web app. The allowed range is 1 to 100 basis points (inclusive of 100) consistent with the Uniswap v3 Periphery contract. | -| `convenienceFeeRecipient` | `{[chainId: number]: string}` | `undefined` | The address to receive the convenience fee on each network. Required if `convenienceFee` is provided. | -| `defaultInputTokenAddress` | `{[chainId: number]: string}` | `string` or `'NATIVE'` | Address of the token to be selected by default in the input field (e.g. USDC) for each network chain ID. If left empty the widget will use the native token of the connected chain as default. This can be explicitly defined by the special string `'NATIVE'`. For convenience you may pass a single string instead of a `chainId` mapping. In this case, the widget will assume that string corresponds to an L1 Ethereum address with `chaindId=1`. Any addresses provided in this parameter must be included in the `tokenList`. | -| `defaultInputTokenAmount` | `number` | `0` | Default amount for the input field (e.g. 1 ETH). This value will respect the decimals of the `defaultInputTokenAddress`. This parameter is valid only if `defaultInputTokenAddress` is also set. This parameter is mutually exclusive with `defaultOutputTokenAmount`, so you may set only one `ofĀ defaultInputTokenAmountĀ and` `defaultOutputTokenAmount`. | -| `defaultOutputTokenAddress` | `{[chainId: number]: string}` | `string` or `undefined` | Address of the token to be selected by default in the input field (e.g. USDC) for each network chain ID. None if left empty. Any addresses provided in this parameter must be included in the `tokenList`. | -| `defaultOutputTokenAmount` | `number` | `0` | Default amount for the input field (e.g. 100 USDC). This value will respect the decimals of the `defaultOutputTokenAddress`. This parameter is mutually exclusive with `defaultInputTokenAmount`, so you may set only one `ofĀ defaultInputTokenAmountĀ and` `defaultOutputTokenAmount`. | -| `locale` | `SupportedLocale` | `en-US` | Specifies an explicit locale to use for the widget interface. This can be set to one of the values exported by the library in [`SUPPORTED_LOCALES`](https://github.com/Uniswap/interface/blob/main/src/constants/locales.ts). | -| `onConnectWallet` | `() => void` | `undefined` | If passed, the ā€œConnect your walletā€ message will be clickable, and clicking it will trigger this handler function. This can be used to trigger your own wallet connection flow from the widget. | -| `onError` | `ErrorHandler` | `undefined` | An error handler which receives any errors that occur in the widget. This can be used for collecting error metrics. | -| `theme` | `Theme` | `lightTheme` | Specifies a custom theme (colors, font, and border radii). See [Customizing the Theme](../swap-widget#customizing-theme). | -| `tokenList` | `string` | `TokenInfo[]` | Specifies the set of tokens that appear by default in the token selector list. Accepts either a URI of a token list as defined by the Token Lists standard, or an inline array of tokens. If none is provided, the Uniswap Labs default token list will be used. See [Customizing the Default Token List](../swap-widget#customizing-default-token-list). | -| `width` | `number` or `string` | `360` | Specifies the width of the widget. If specified as a number, this is in pixels; otherwise, it is interpreted as a CSS `` data type. Recommended width is 360px. Minimum width is 270px. See [Customizing the Width](../swap-widget#customizing-width). | +| Prop Name | Prop Type | Default Value | Description | +| --------------------------- | ----------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `convenienceFee` | `number` | `undefined` | Optionally, you may charge a convenience fee on top of swaps executed through your web app. The allowed range is 1 to 100 basis points (inclusive of 100) consistent with the Uniswap v3 Periphery contract. | +| `convenienceFeeRecipient` | `{[chainId: number]: string}` | `undefined` | The address to receive the convenience fee on each network. Required if `convenienceFee` is provided. | +| `defaultInputTokenAddress` | `{[chainId: number]: string}` | `string` or `'NATIVE'` | Address of the token to be selected by default in the input field (e.g. USDC) for each network chain ID. If left empty the widget will use the native token of the connected chain as default. This can be explicitly defined by the special string `'NATIVE'`. For convenience you may pass a single string instead of a `chainId` mapping. In this case, the widget will assume that string corresponds to an L1 Ethereum address with `chaindId=1`. Any addresses provided in this parameter must be included in the `tokenList`. | +| `defaultInputTokenAmount` | `number` | `0` | Default amount for the input field (e.g. 1 ETH). This value will respect the decimals of the `defaultInputTokenAddress`. This parameter is valid only if `defaultInputTokenAddress` is also set. This parameter is mutually exclusive with `defaultOutputTokenAmount`, so you may set only one `of defaultInputTokenAmount and` `defaultOutputTokenAmount`. | +| `defaultOutputTokenAddress` | `{[chainId: number]: string}` | `string` or `undefined` | Address of the token to be selected by default in the input field (e.g. USDC) for each network chain ID. None if left empty. Any addresses provided in this parameter must be included in the `tokenList`. | +| `defaultOutputTokenAmount` | `number` | `0` | Default amount for the input field (e.g. 100 USDC). This value will respect the decimals of the `defaultOutputTokenAddress`. This parameter is mutually exclusive with `defaultInputTokenAmount`, so you may set only one `of defaultInputTokenAmount and` `defaultOutputTokenAmount`. | +| `locale` | `SupportedLocale` | `en-US` | Specifies an explicit locale to use for the widget interface. This can be set to one of the values exported by the library in [`SUPPORTED_LOCALES`](https://github.com/Uniswap/interface/blob/main/src/constants/locales.ts). | +| `onConnectWallet` | `() => void` | `undefined` | If passed, the ā€œConnect your walletā€ message will be clickable, and clicking it will trigger this handler function. This can be used to trigger your own wallet connection flow from the widget. | +| `onError` | `ErrorHandler` | `undefined` | An error handler which receives any errors that occur in the widget. This can be used for collecting error metrics. | +| `theme` | `Theme` | `lightTheme` | Specifies a custom theme (colors, font, and border radii). See [Customizing the Theme](../swap-widget#customizing-theme). | +| `tokenList` | `string` | `TokenInfo[]` | Specifies the set of tokens that appear by default in the token selector list. Accepts either a URI of a token list as defined by the Token Lists standard, or an inline array of tokens. If none is provided, the Uniswap Labs default token list will be used. See [Customizing the Default Token List](../swap-widget#customizing-default-token-list). | +| `width` | `number` or `string` | `360` | Specifies the width of the widget. If specified as a number, this is in pixels; otherwise, it is interpreted as a CSS `` data type. Recommended width is 360px. Minimum width is 270px. See [Customizing the Width](../swap-widget#customizing-width). | ## Subscribing to Events diff --git a/SDK_versions.json b/SDK_versions.json index bec93a3f0a..ce55d2648f 100644 --- a/SDK_versions.json +++ b/SDK_versions.json @@ -1,5 +1 @@ -[ - "3.0.0", - "2.0.0", - "1.0.0" -] +["3.0.0", "2.0.0", "1.0.0"] diff --git a/babel.config.js b/babel.config.js index e00595dae7..6752648189 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,3 @@ module.exports = { presets: [require.resolve('@docusaurus/core/lib/babel/preset')], -}; +} diff --git a/config.json b/config.json index ee28d7889d..d047e94637 100644 --- a/config.json +++ b/config.json @@ -1,11 +1,7 @@ { "index_name": "v3-docs", - "start_urls": [ - "https://docs.uniswap.org/" - ], - "sitemap_urls": [ - "https://docs.uniswap.org/sitemap.xml" - ], + "start_urls": ["https://docs.uniswap.org/"], + "sitemap_urls": ["https://docs.uniswap.org/sitemap.xml"], "sitemap_alternate_links": true, "stop_urls": [], "selectors": { @@ -26,23 +22,9 @@ "strip_chars": " .,;:#", "custom_settings": { "separatorsToIndex": "_", - "attributesForFaceting": [ - "language", - "version", - "type", - "docusaurus_tag" - ], - "attributesToRetrieve": [ - "hierarchy", - "content", - "anchor", - "url", - "url_without_anchor", - "type" - ] + "attributesForFaceting": ["language", "version", "type", "docusaurus_tag"], + "attributesToRetrieve": ["hierarchy", "content", "anchor", "url", "url_without_anchor", "type"] }, - "conversation_id": [ - "833762294" - ], + "conversation_id": ["833762294"], "nb_hits": 1335 -} \ No newline at end of file +} diff --git a/docusaurus.config.js b/docusaurus.config.js index 8e15b1f47a..0963327825 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -1,121 +1,121 @@ module.exports = { - title: "Uniswap", - tagline: "Documentation and Guides", - url: "https://docs.uniswap.org/", - baseUrl: "/", - onBrokenLinks: "warn", - onBrokenMarkdownLinks: "ignore", - favicon: "img/favicon.png", - organizationName: "Uniswap", // Usually your GitHub org/user name. - projectName: "Uniswap-docs", // Usually your repo name. + title: 'Uniswap', + tagline: 'Documentation and Guides', + url: 'https://docs.uniswap.org/', + baseUrl: '/', + onBrokenLinks: 'warn', + onBrokenMarkdownLinks: 'ignore', + favicon: 'img/favicon.png', + organizationName: 'Uniswap', // Usually your GitHub org/user name. + projectName: 'Uniswap-docs', // Usually your repo name. themeConfig: { - image: "img/twitter_card_bg.jpg", + image: 'img/twitter_card_bg.jpg', prism: { - additionalLanguages: ["solidity"], + additionalLanguages: ['solidity'], }, algolia: { - apiKey: "32465e2ab6f7554ff014e64c0d92171c", - indexName: "v3-docs", - appId: "S0IDD0YGLZ", + apiKey: '32465e2ab6f7554ff014e64c0d92171c', + indexName: 'v3-docs', + appId: 'S0IDD0YGLZ', }, navbar: { - title: "Uniswap Docs", + title: 'Uniswap Docs', logo: { - alt: "Uniswap Unicorn", - src: "img/uni_dark_icon.svg", + alt: 'Uniswap Unicorn', + src: 'img/uni_dark_icon.svg', }, items: [ { - type: "docsVersionDropdown", + type: 'docsVersionDropdown', //// Optional - position: "left", + position: 'left', dropdownActiveClassDisabled: true, - docsPluginId: "default", - className: "persistent", + docsPluginId: 'default', + className: 'persistent', }, { - to: "/protocol/reference/smart-contracts", - label: "Contracts", - position: "left", - className: "V3_active", + to: '/protocol/reference/smart-contracts', + label: 'Contracts', + position: 'left', + className: 'V3_active', }, { - to: "/sdk/introduction", - label: "SDK", - position: "left", - className: "V3_active", + to: '/sdk/introduction', + label: 'SDK', + position: 'left', + className: 'V3_active', }, { - to: "/sdk/widgets/swap-widget", - label: "Widgets", - position: "left", - className: "V3_active", + to: '/sdk/widgets/swap-widget', + label: 'Widgets', + position: 'left', + className: 'V3_active', }, { - to: "/sdk/subgraph/subgraph-data", - label: "Subgraph (API)", - position: "left", - className: "V3_active", + to: '/sdk/subgraph/subgraph-data', + label: 'Subgraph (API)', + position: 'left', + className: 'V3_active', }, { - to: "/protocol/concepts/governance/overview", - label: "Governance", - position: "left", - className: "V3_active", + to: '/protocol/concepts/governance/overview', + label: 'Governance', + position: 'left', + className: 'V3_active', }, { - to: "/protocol/V2/guides/smart-contract-integration/quick-start", - label: "Contracts", - position: "left", - className: "V2_active", + to: '/protocol/V2/guides/smart-contract-integration/quick-start', + label: 'Contracts', + position: 'left', + className: 'V2_active', }, { - to: "/sdk/2.0.0/", - label: "SDK", - position: "left", - className: "V2_active", + to: '/sdk/2.0.0/', + label: 'SDK', + position: 'left', + className: 'V2_active', }, { - to: "/protocol/V2/reference/API/overview", - label: "Subgraph (API)", - position: "left", - className: "V2_active", + to: '/protocol/V2/reference/API/overview', + label: 'Subgraph (API)', + position: 'left', + className: 'V2_active', }, { - to: "/protocol/concepts/governance/overview", - label: "Governance", - position: "left", - className: "V2_active", + to: '/protocol/concepts/governance/overview', + label: 'Governance', + position: 'left', + className: 'V2_active', }, { - to: "/protocol/V1/guides/connect-to-uniswap", - label: "Contracts", - position: "left", - className: "V1_active", + to: '/protocol/V1/guides/connect-to-uniswap', + label: 'Contracts', + position: 'left', + className: 'V1_active', }, { - to: "/sdk/1.0.0/", - label: "SDK", - position: "left", - className: "V1_active", + to: '/sdk/1.0.0/', + label: 'SDK', + position: 'left', + className: 'V1_active', }, { - label: "Whitepaper", - to: "https://uniswap.org/whitepaper-v3.pdf", - position: "right", - className: "persistent", + label: 'Whitepaper', + to: 'https://uniswap.org/whitepaper-v3.pdf', + position: 'right', + className: 'persistent', }, { - href: "https://github.com/uniswap/uniswap-docs", - label: "GitHub", - position: "right", - className: "persistent", + href: 'https://github.com/uniswap/uniswap-docs', + label: 'GitHub', + position: 'right', + className: 'persistent', }, { - href: "https://unigrants.org/", - label: "Grants", - position: "right", - className: "persistent", + href: 'https://unigrants.org/', + label: 'Grants', + position: 'right', + className: 'persistent', }, ], }, @@ -123,86 +123,86 @@ module.exports = { // style: "dark", links: [ { - title: "Developers", + title: 'Developers', items: [ { - label: "Bug Bounty", - href: "https://github.com/Uniswap/uniswap-v3-periphery/blob/main/bug-bounty.md", + label: 'Bug Bounty', + href: 'https://github.com/Uniswap/uniswap-v3-periphery/blob/main/bug-bounty.md', }, { - label: "#dev-chat", - href: "https://discord.gg/ybKVQUWb4s", + label: '#dev-chat', + href: 'https://discord.gg/ybKVQUWb4s', }, { - label: "Whitepaper", - href: "https://uniswap.org/whitepaper-v3.pdf", + label: 'Whitepaper', + href: 'https://uniswap.org/whitepaper-v3.pdf', }, ], }, { - title: "Github", + title: 'Github', items: [ { - label: "uniswap-v3-core", - href: "https://github.com/Uniswap/uniswap-v3-core", + label: 'uniswap-v3-core', + href: 'https://github.com/Uniswap/uniswap-v3-core', }, { - label: "uniswap-v3-sdk", - href: "https://github.com/Uniswap/uniswap-v3-sdk", + label: 'uniswap-v3-sdk', + href: 'https://github.com/Uniswap/uniswap-v3-sdk', }, { - label: "uniswap-v3-periphery", - href: "https://github.com/Uniswap/uniswap-v3-periphery", + label: 'uniswap-v3-periphery', + href: 'https://github.com/Uniswap/uniswap-v3-periphery', }, { - label: "Deployment addresses", - href: "https://github.com/Uniswap/uniswap-v3-periphery/blob/main/deploys.md", + label: 'Deployment addresses', + href: 'https://github.com/Uniswap/uniswap-v3-periphery/blob/main/deploys.md', }, ], }, { - title: "Ecosystem", + title: 'Ecosystem', items: [ { - label: "Home", - href: "https://uniswap.org/", + label: 'Home', + href: 'https://uniswap.org/', }, { - label: "App", - href: "https://app.uniswap.org/", + label: 'App', + href: 'https://app.uniswap.org/', }, { - label: "Analytics", - href: "https://info.uniswap.org/home", + label: 'Analytics', + href: 'https://info.uniswap.org/home', }, { - label: "Token Lists", - href: "https://tokenlists.org/", + label: 'Token Lists', + href: 'https://tokenlists.org/', }, { - label: "Brand Assets", - href: "https://uniswap.org/Uniswap_brand_assets.zip", + label: 'Brand Assets', + href: 'https://uniswap.org/Uniswap_brand_assets.zip', }, ], }, { - title: "Community", + title: 'Community', items: [ { - label: "Governance", - href: "https://gov.uniswap.org/", + label: 'Governance', + href: 'https://gov.uniswap.org/', }, { - label: "Discord", - href: "https://discord.gg/ybKVQUWb4s", + label: 'Discord', + href: 'https://discord.gg/ybKVQUWb4s', }, { - label: "Twitter", - href: "https://twitter.com/Uniswap", + label: 'Twitter', + href: 'https://twitter.com/Uniswap', }, { - label: "Blog", - href: "https://uniswap.org/blog/", + label: 'Blog', + href: 'https://uniswap.org/blog/', }, ], }, @@ -211,7 +211,7 @@ module.exports = { }, colorMode: { // "light" | "dark" - defaultMode: "dark", + defaultMode: 'dark', // Hides the switch in the navbar // Useful if you want to support a single color mode @@ -224,61 +224,59 @@ module.exports = { }, presets: [ [ - "@docusaurus/preset-classic", + '@docusaurus/preset-classic', { docs: { - path: "protocol", - routeBasePath: "protocol/", - sidebarPath: require.resolve("./sidebars.js"), - editUrl: "https://github.com/uniswap/uniswap-docs/tree/main/", + path: 'protocol', + routeBasePath: 'protocol/', + sidebarPath: require.resolve('./sidebars.js'), + editUrl: 'https://github.com/uniswap/uniswap-docs/tree/main/', includeCurrentVersion: false, versions: { V3: { - banner: "none", + banner: 'none', }, V2: { - banner: "none", + banner: 'none', }, V1: { - banner: "none", + banner: 'none', }, }, }, googleAnalytics: { - trackingID: "UA-128182339-7", + trackingID: 'UA-128182339-7', anonymizeIP: true, }, theme: { - customCss: require.resolve("./src/css/custom.css"), - customCss2: require.resolve("./src/css/colors.css"), + customCss: require.resolve('./src/css/custom.css'), + customCss2: require.resolve('./src/css/colors.css'), }, }, ], ], plugins: [ [ - "@docusaurus/plugin-content-docs", + '@docusaurus/plugin-content-docs', { - id: "SDK", - path: "sdk", - routeBasePath: "sdk/", - sidebarPath: require.resolve("./sdkSidebars.js"), - remarkPlugins: [ - [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}], - ], + id: 'SDK', + path: 'sdk', + routeBasePath: 'sdk/', + sidebarPath: require.resolve('./sdkSidebars.js'), + remarkPlugins: [[require('@docusaurus/remark-plugin-npm2yarn'), { sync: true }]], includeCurrentVersion: false, versions: { - "3.0.0": { - banner: "none", + '3.0.0': { + banner: 'none', }, - "2.0.0": { - banner: "none", + '2.0.0': { + banner: 'none', }, - "1.0.0": { - banner: "none", + '1.0.0': { + banner: 'none', }, }, }, ], ], -}; +} diff --git a/sdk-examples/AddAndRemoveLiquidity.tsx b/sdk-examples/AddAndRemoveLiquidity.tsx index dd373d6f0a..19196c3713 100644 --- a/sdk-examples/AddAndRemoveLiquidity.tsx +++ b/sdk-examples/AddAndRemoveLiquidity.tsx @@ -1,45 +1,36 @@ -import { - Pool, - Position, - NonfungiblePositionManager, - nearestUsableTick, - } from '@uniswap/v3-sdk/' +import { Pool, Position, NonfungiblePositionManager, nearestUsableTick } from '@uniswap/v3-sdk/' -import { ethers } from "ethers"; -import { Percent, Token, CurrencyAmount } from "@uniswap/sdk-core"; -import { abi as IUniswapV3PoolABI } from "@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json"; +import { ethers } from 'ethers' +import { Percent, Token, CurrencyAmount } from '@uniswap/sdk-core' +import { abi as IUniswapV3PoolABI } from '@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json' // default uses ā€œhttp://localhost:8545ā€ // can also input your own connection with "https://mainnet.infura.io/v3/" as an input -const provider = new ethers.providers.JsonRpcProvider(); +const provider = new ethers.providers.JsonRpcProvider() // pool address for DAI/USDC 0.05% -const poolAddress = "0x6c6bc977e13df9b0de53b251522280bb72383700"; +const poolAddress = '0x6c6bc977e13df9b0de53b251522280bb72383700' -const poolContract = new ethers.Contract( - poolAddress, - IUniswapV3PoolABI, - provider -); +const poolContract = new ethers.Contract(poolAddress, IUniswapV3PoolABI, provider) interface Immutables { - factory: string; - token0: string; - token1: string; - fee: number; - tickSpacing: number; - maxLiquidityPerTick: ethers.BigNumber; + factory: string + token0: string + token1: string + fee: number + tickSpacing: number + maxLiquidityPerTick: ethers.BigNumber } interface State { - liquidity: ethers.BigNumber; - sqrtPriceX96: ethers.BigNumber; - tick: number; - observationIndex: number; - observationCardinality: number; - observationCardinalityNext: number; - feeProtocol: number; - unlocked: boolean; + liquidity: ethers.BigNumber + sqrtPriceX96: ethers.BigNumber + tick: number + observationIndex: number + observationCardinality: number + observationCardinalityNext: number + feeProtocol: number + unlocked: boolean } async function getPoolImmutables() { @@ -50,12 +41,12 @@ async function getPoolImmutables() { fee: await poolContract.fee(), tickSpacing: await poolContract.tickSpacing(), maxLiquidityPerTick: await poolContract.maxLiquidityPerTick(), - }; - return immutables; + } + return immutables } async function getPoolState() { - const slot = await poolContract.slot0(); + const slot = await poolContract.slot0() const PoolState: State = { liquidity: await poolContract.liquidity(), sqrtPriceX96: slot[0], @@ -65,18 +56,17 @@ async function getPoolState() { observationCardinalityNext: slot[4], feeProtocol: slot[5], unlocked: slot[6], - }; - return PoolState; + } + return PoolState } - async function liquidityExamples(sender: string, exampleType: number) { - const immutables = await getPoolImmutables(); - const state = await getPoolState(); - const DAI = new Token(1, immutables.token0, 18, "DAI", "Stablecoin"); - const USDC = new Token(1, immutables.token1, 18, "USDC", "USD Coin"); - const block = await provider.getBlock(provider.getBlockNumber()); - const deadline = block.timestamp + 200; + const immutables = await getPoolImmutables() + const state = await getPoolState() + const DAI = new Token(1, immutables.token0, 18, 'DAI', 'Stablecoin') + const USDC = new Token(1, immutables.token1, 18, 'USDC', 'USD Coin') + const block = await provider.getBlock(provider.getBlockNumber()) + const deadline = block.timestamp + 200 //create a pool const DAI_USDC_POOL = new Pool( @@ -86,7 +76,7 @@ async function liquidityExamples(sender: string, exampleType: number) { state.sqrtPriceX96.toString(), state.liquidity.toString(), state.tick - ); + ) // create a position with the pool // the position is in-range, specified by the lower and upper tick @@ -94,45 +84,43 @@ async function liquidityExamples(sender: string, exampleType: number) { const position = new Position({ pool: DAI_USDC_POOL, liquidity: state.liquidity.div(5000).toString(), - tickLower: nearestUsableTick(state.tick, immutables.tickSpacing) - immutables.tickSpacing * 2, - tickUpper: nearestUsableTick(state.tick, immutables.tickSpacing) + immutables.tickSpacing * 2 + tickLower: nearestUsableTick(state.tick, immutables.tickSpacing) - immutables.tickSpacing * 2, + tickUpper: nearestUsableTick(state.tick, immutables.tickSpacing) + immutables.tickSpacing * 2, }) - - // Example 0: Setting up calldata for minting a Position + // Example 0: Setting up calldata for minting a Position if (exampleType == 0) { const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, { - slippageTolerance: new Percent(50, 10_000), - recipient: sender, - deadline: deadline - }); + slippageTolerance: new Percent(50, 10_000), + recipient: sender, + deadline: deadline, + }) } - // Example 1: Setting up calldata for adding liquidity to Position + // Example 1: Setting up calldata for adding liquidity to Position if (exampleType == 1) { - const {calldata ,value} = NonfungiblePositionManager.addCallParameters(position, { - slippageTolerance: new Percent(50, 10_000), - deadline: deadline, - tokenId: 1 - }); + const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, { + slippageTolerance: new Percent(50, 10_000), + deadline: deadline, + tokenId: 1, + }) } - // Example 2: Setting up calldata for removing liquidity from Position + // Example 2: Setting up calldata for removing liquidity from Position if (exampleType == 2) { - - const {calldata, value} = NonfungiblePositionManager.removeCallParameters(position, { - tokenId: 1, - liquidityPercentage: new Percent(1), - slippageTolerance: new Percent(50, 10_000), - deadline: deadline, - collectOptions: { - expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(DAI, 0), - expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(USDC, 0), - recipient: sender - }} - ); - } + const { calldata, value } = NonfungiblePositionManager.removeCallParameters(position, { + tokenId: 1, + liquidityPercentage: new Percent(1), + slippageTolerance: new Percent(50, 10_000), + deadline: deadline, + collectOptions: { + expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(DAI, 0), + expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(USDC, 0), + recipient: sender, + }, + }) } +} // call the example function by passing the sender, e.g.: // liquidityExamples("0xDA9dfA130Df4dE4673b89022EE50ff26f6EA73Cf", 0) diff --git a/sdkSidebars.js b/sdkSidebars.js index f366ff10f4..4f29923ec6 100644 --- a/sdkSidebars.js +++ b/sdkSidebars.js @@ -1,8 +1,8 @@ module.exports = { - mySidebar: [ - { - type: 'autogenerated', - dirName: '.', // generate sidebar slice from the docs folder (or versioned_docs/) - }, - ], - }; \ No newline at end of file + mySidebar: [ + { + type: 'autogenerated', + dirName: '.', // generate sidebar slice from the docs folder (or versioned_docs/) + }, + ], +} diff --git a/sidebars.js b/sidebars.js index f366ff10f4..4f29923ec6 100644 --- a/sidebars.js +++ b/sidebars.js @@ -1,8 +1,8 @@ module.exports = { - mySidebar: [ - { - type: 'autogenerated', - dirName: '.', // generate sidebar slice from the docs folder (or versioned_docs/) - }, - ], - }; \ No newline at end of file + mySidebar: [ + { + type: 'autogenerated', + dirName: '.', // generate sidebar slice from the docs folder (or versioned_docs/) + }, + ], +} diff --git a/src/components/HomepageFeatures.js b/src/components/HomepageFeatures.js index 16f820b103..69edfacf45 100644 --- a/src/components/HomepageFeatures.js +++ b/src/components/HomepageFeatures.js @@ -1,6 +1,6 @@ -import React from 'react'; -import clsx from 'clsx'; -import styles from './HomepageFeatures.module.css'; +import React from 'react' +import clsx from 'clsx' +import styles from './HomepageFeatures.module.css' const FeatureList = [ { @@ -8,8 +8,8 @@ const FeatureList = [ Svg: require('../../static/img/undraw_docusaurus_mountain.svg').default, description: ( <> - Docusaurus was designed from the ground up to be easily installed and - used to get your website up and running quickly. + Docusaurus was designed from the ground up to be easily installed and used to get your website up and running + quickly. ), }, @@ -18,8 +18,8 @@ const FeatureList = [ Svg: require('../../static/img/undraw_docusaurus_tree.svg').default, description: ( <> - Docusaurus lets you focus on your docs, and we'll do the chores. Go - ahead and move your docs into the docs directory. + Docusaurus lets you focus on your docs, and we'll do the chores. Go ahead and move your docs into the{' '} + docs directory. ), }, @@ -28,14 +28,14 @@ const FeatureList = [ Svg: require('../../static/img/undraw_docusaurus_react.svg').default, description: ( <> - Extend or customize your website layout by reusing React. Docusaurus can - be extended while reusing the same header and footer. + Extend or customize your website layout by reusing React. Docusaurus can be extended while reusing the same + header and footer. ), }, -]; +] -function Feature({Svg, title, description}) { +function Feature({ Svg, title, description }) { return (
@@ -46,7 +46,7 @@ function Feature({Svg, title, description}) {

{description}

- ); + ) } export default function HomepageFeatures() { @@ -60,5 +60,5 @@ export default function HomepageFeatures() { - ); + ) } diff --git a/src/css/colors.css b/src/css/colors.css index 39acdeb0c2..92aa914aea 100644 --- a/src/css/colors.css +++ b/src/css/colors.css @@ -82,11 +82,10 @@ --ifm-font-color-base: var(--ifm-color-content); --ifm-font-color-base-inverse: var(--ifm-color-content-inverse); --ifm-font-color-secondary: var(--ifm-color-content-secondary); - --ifm-font-family-base: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, - Cantarell, Noto Sans, sans-serif, BlinkMacSystemFont, "Segoe UI", Helvetica, - Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; - --ifm-font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, - "Liberation Mono", "Courier New", monospace; + --ifm-font-family-base: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif, + BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', + 'Segoe UI Symbol'; + --ifm-font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; --ifm-font-size-base: 100%; --ifm-font-weight-light: 300; --ifm-font-weight-normal: 400; @@ -102,8 +101,7 @@ --ifm-transition-timing-default: cubic-bezier(0.08, 0.52, 0.52, 1); --ifm-global-shadow-lw: 0 1px 2px 0 rgba(0, 0, 0, 0.1); --ifm-global-shadow-md: 0 5px 40px rgba(0, 0, 0, 0.2); - --ifm-global-shadow-tl: 0 12px 28px 0 rgba(0, 0, 0, 0.2), - 0 2px 4px 0 rgba(0, 0, 0, 0.1); + --ifm-global-shadow-tl: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1); --ifm-z-index-dropdown: 100; --ifm-z-index-fixed: 200; --ifm-z-index-overlay: 400; @@ -189,7 +187,7 @@ --ifm-breadcrumb-size-multiplier: 1; --ifm-breadcrumb-separator: url( data:image/svg + xml;utf8, - + ); --ifm-breadcrumb-separator-filter: none; --ifm-breadcrumb-separator-size: 0.5rem; @@ -203,9 +201,7 @@ --ifm-button-padding-vertical: 0.375rem; --ifm-button-size-multiplier: 1; --ifm-button-transition-duration: var(--ifm-transition-fast); - --ifm-button-border-radius: calc( - var(--ifm-global-radius) * var(--ifm-button-size-multiplier) - ); + --ifm-button-border-radius: calc(var(--ifm-global-radius) * var(--ifm-button-size-multiplier)); --ifm-button-group-margin: 2px; --ifm-card-background-color: var(--ifm-background-surface-color); --ifm-card-border-radius: calc(var(--ifm-global-radius) * 2); @@ -237,7 +233,7 @@ --ifm-menu-link-padding-vertical: 0.375rem; --ifm-menu-link-sublist-icon: url( data:image/svg + xml;utf8, - + ); --ifm-menu-link-sublist-icon-filter: none; --ifm-navbar-background-color: var(--ifm-background-surface-color); @@ -255,12 +251,10 @@ --ifm-navbar-search-input-placeholder-color: var(--ifm-color-emphasis-500); --ifm-navbar-search-input-icon: url( data:image/svg + xml;utf8, - + ); --ifm-navbar-sidebar-width: 80vw; - --ifm-pagination-border-radius: calc( - var(--ifm-global-radius) * var(--ifm-pagination-size-multiplier) - ); + --ifm-pagination-border-radius: calc(var(--ifm-global-radius) * var(--ifm-pagination-size-multiplier)); --ifm-pagination-color-active: var(--ifm-color-primary); --ifm-pagination-font-size: 1rem; --ifm-pagination-item-active-background: var(--ifm-hover-overlay); diff --git a/src/css/custom.css b/src/css/custom.css index 9e1d852892..48b0e7e1d1 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -7,7 +7,7 @@ /* You can override the default Infima variables here. */ -@import url("https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,500;1,400&family=Inter:wght@400;500;600&display=swap"); +@import url('https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,500;1,400&family=Inter:wght@400;500;600&display=swap'); :root { --ifm-color-primary: #3578e5; @@ -39,8 +39,7 @@ --ifm-global-shadow-lw: 0 1px 10px 0 rgba(0, 0, 0, 0.1); --ifm-global-shadow-md: 0 5px 40px rgba(0, 0, 0, 0.1); - --ifm-global-shadow-tl: 0 12px 28px 0 rgba(0, 0, 0, 0.2), - 0 2px 4px 0 rgba(0, 0, 0, 0.1); + --ifm-global-shadow-tl: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1); --ifm-global-spacing: 1.5rem; /* --ifm-navbar-background-color: rgba(255, 0.2); */ @@ -50,7 +49,7 @@ html { scroll-behavior: smooth; } -html[data-theme="dark"] { +html[data-theme='dark'] { --ifm-color-primary: white; --ifm-color-primary-dark: #5a91ea; @@ -62,41 +61,33 @@ html[data-theme="dark"] { background-position: 0px -30vh; background-repeat: no-repeat; - background-image: radial-gradient( - 50% 50% at 50% 50%, - rgba(33, 114, 229, 0.1) 0%, - rgba(33, 36, 41, 0) 100% - ); + background-image: radial-gradient(50% 50% at 50% 50%, rgba(33, 114, 229, 0.1) 0%, rgba(33, 36, 41, 0) 100%); /* any other colors you wish to overwrite */ } -html[data-theme="light"] { +html[data-theme='light'] { --ifm-color-primary: black; /* --ifm-color-secondary: white; */ /* --ifm-background-color: #F1F1F2; */ background-position: 0px -30vh; background-repeat: no-repeat; - background-image: radial-gradient( - 50% 50% at 50% 50%, - rgba(255, 0, 122, 0.1) 0%, - rgba(255, 255, 255, 0) 100% - ); + background-image: radial-gradient(50% 50% at 50% 50%, rgba(255, 0, 122, 0.1) 0%, rgba(255, 255, 255, 0) 100%); /* any other colors you wish to overwrite */ } .html { - font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, - Cantarell, Noto Sans, sans-serif, BlinkMacSystemFont, "Segoe UI", Helvetica, - Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif, + BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', + 'Segoe UI Symbol'; font-size: 16px; font-variant: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); - font-feature-settings: "ss01" on, "ss02" on, "cv01" on, "cv03" on; + font-feature-settings: 'ss01' on, 'ss02' on, 'cv01' on, 'cv03' on; font-weight: 400; } @@ -149,12 +140,12 @@ h4 { align-items: center; } -html[data-theme="dark"] .navbar { +html[data-theme='dark'] .navbar { /* background-color: none; */ border-bottom: var(--ifm-toc-border-color) 1px solid; } -html[data-theme="light"] .navbar { +html[data-theme='light'] .navbar { /* background-color: none; */ border-bottom: var(--ifm-toc-border-color) 1px solid; } @@ -203,9 +194,8 @@ html[data-theme="light"] .navbar { font-weight: 400; } -html[data-theme="dark"] .navbar__logo { - filter: invert(100%) sepia(0%) saturate(7500%) hue-rotate(337deg) - brightness(112%) contrast(104%); +html[data-theme='dark'] .navbar__logo { + filter: invert(100%) sepia(0%) saturate(7500%) hue-rotate(337deg) brightness(112%) contrast(104%); } .docusaurus-highlight-code-line { @@ -255,7 +245,7 @@ iframe { width: auto; } -.widget-examples { +.widget-examples { background: none; } @@ -298,21 +288,21 @@ iframe { margin-top: 3rem; } -html[data-theme="light"] .admonition-note { +html[data-theme='light'] .admonition-note { background: #e8e8e8; } -html[data-theme="dark"] .admonition-note { +html[data-theme='dark'] .admonition-note { background: none; color: var(--ifm-color-white); border: 1px solid var(--ifm-color-emphasis-300); } -html[data-theme="dark"] .admonition-icon svg { +html[data-theme='dark'] .admonition-icon svg { fill: var(--ifm-color-white); } -html[data-theme="light"] .DocSearch { +html[data-theme='light'] .DocSearch { /* --docsearch-primary-color: var(--ifm-color-primary); */ /* --docsearch-text-color: var(--ifm-font-color-base); */ --docsearch-muted-color: var(--ifm-color-emphasis-900); @@ -334,7 +324,7 @@ html[data-theme="light"] .DocSearch { --docsearch-searchbox-shadow: none; } -html[data-theme="dark"] .DocSearch { +html[data-theme='dark'] .DocSearch { /* --docsearch-text-color: var(--ifm-font-color-100); */ --docsearch-muted-color: var(--ifm-color-secondary-darkest); --docsearch-container-background: rgba(47, 55, 69, 0.7); @@ -359,36 +349,36 @@ html[data-theme="dark"] .DocSearch { --docsearch-searchbox-shadow: inset 0 0 0 2px var(--ifm-color-emphasis-200); } -html[data-theme="light"] .DocSearch-Hit { +html[data-theme='light'] .DocSearch-Hit { background-color: transparent; } -html[data-theme="light"] .DocSearch-Hit :focus { +html[data-theme='light'] .DocSearch-Hit :focus { background-color: var(--ifm-color-emphasis-100); } -html[data-theme="light"] .DocSearch-Hit :hover { +html[data-theme='light'] .DocSearch-Hit :hover { background-color: var(--ifm-color-emphasis-100); } -html[data-theme="light"] .DocSearch-Hit { +html[data-theme='light'] .DocSearch-Hit { background-color: transparent; } -html[data-theme="dark"] .DocSearch-Hit { +html[data-theme='dark'] .DocSearch-Hit { background-color: transparent; } -html[data-theme="dark"] .DocSearch-Hit :focus { +html[data-theme='dark'] .DocSearch-Hit :focus { background-color: var(--ifm-color-emphasis-100); } -html[data-theme="dark"] .DocSearch-Hit :hover { +html[data-theme='dark'] .DocSearch-Hit :hover { background-color: var(--ifm-color-emphasis-100); } -html[data-theme="dark"] .DocSearch-Hit a :hover { +html[data-theme='dark'] .DocSearch-Hit a :hover { background-color: transparent; } -html[data-theme="dark"] .DocSearch-Hit a { +html[data-theme='dark'] .DocSearch-Hit a { background-color: var(--ifm-color-emphasis-0); } diff --git a/src/pages/index.js b/src/pages/index.js index 944ce2cf31..22cb166f0b 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,18 +1,18 @@ -import React from "react"; -import Layout from "@theme/Layout"; -import Link from "@docusaurus/Link"; -import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; +import React from 'react' +import Layout from '@theme/Layout' +import Link from '@docusaurus/Link' +import useDocusaurusContext from '@docusaurus/useDocusaurusContext' -import "./styles.module.css"; -import styled from "@emotion/styled"; +import './styles.module.css' +import styled from '@emotion/styled' -import Discord from "@site/static/img/discord.svg"; -import UGP from "@site/static/img/UGP.png"; +import Discord from '@site/static/img/discord.svg' +import UGP from '@site/static/img/UGP.png' -import ThemedImage from "@theme/ThemedImage"; -import useBaseUrl from "@docusaurus/useBaseUrl"; +import ThemedImage from '@theme/ThemedImage' +import useBaseUrl from '@docusaurus/useBaseUrl' -import SearchBar from "@theme-original/SearchBar"; +import SearchBar from '@theme-original/SearchBar' import { InformationCircleIcon, @@ -20,115 +20,115 @@ import { BookOpenIcon, ChatIcon, CodeIcon, -} from "@heroicons/react/outline"; +} from '@heroicons/react/outline' export const actions = [ { - title: "What is Uniswap", - href: "#", + title: 'What is Uniswap', + href: '#', icon: InformationCircleIcon, - to: "./protocol/introduction", + to: './protocol/introduction', text: `Learn about the core concepts of the Uniswap Protocol. Swaps, Pools, Concentrated Liquidity and more.`, }, { - title: "Smart contract overview", - href: "#", + title: 'Smart contract overview', + href: '#', icon: BookOpenIcon, - to: "./protocol/reference/smart-contracts", + to: './protocol/reference/smart-contracts', text: `Learn about the architecture of the Uniswap Protocol smart contracts made up of the Core and Periphery libraries.`, }, { - title: "V3 SDK", - href: "#", + title: 'V3 SDK', + href: '#', icon: QuestionMarkCircleIcon, - to: "./sdk/introduction", + to: './sdk/introduction', text: `The SDK is designed to assist developers when interacting with the protocol in any environment that can execute JavaScript.`, }, -]; +] export const github = [ { - title: "uniswap-v3-core", - href: "https://github.com/Uniswap/uniswap-v3-core", + title: 'uniswap-v3-core', + href: 'https://github.com/Uniswap/uniswap-v3-core', icon: CodeIcon, }, { - title: "uniswap-v3-sdk", - href: "https://github.com/Uniswap/uniswap-v3-sdk", + title: 'uniswap-v3-sdk', + href: 'https://github.com/Uniswap/uniswap-v3-sdk', icon: CodeIcon, }, { - title: "uniswap-v3-periphery", - href: "https://github.com/Uniswap/uniswap-v3-periphery", + title: 'uniswap-v3-periphery', + href: 'https://github.com/Uniswap/uniswap-v3-periphery', icon: CodeIcon, }, { - title: "Deployment addresses", - href: "https://github.com/Uniswap/uniswap-v3-periphery/blob/main/deploys.md", + title: 'Deployment addresses', + href: 'https://github.com/Uniswap/uniswap-v3-periphery/blob/main/deploys.md', }, { - title: "@uniswap/widgets", - href: "https://www.npmjs.com/package/@uniswap/widgets", + title: '@uniswap/widgets', + href: 'https://www.npmjs.com/package/@uniswap/widgets', icon: CodeIcon, }, -]; +] export const Guides = [ { - title: "SDK Quick Start", - text: "Integrate with the Uniswap Protocol using JavaScript", - to: "./sdk/guides/quick-start", + title: 'SDK Quick Start', + text: 'Integrate with the Uniswap Protocol using JavaScript', + to: './sdk/guides/quick-start', }, { - title: "Embedding a Swap Widget", - text: "Let your users trade tokens without leaving your dApp", - to: "./sdk/widgets/swap-widget", + title: 'Embedding a Swap Widget', + text: 'Let your users trade tokens without leaving your dApp', + to: './sdk/widgets/swap-widget', }, { - title: "Implementing a Swap", - text: "Start swapping from a smart contract in Solidity", - to: "./protocol/guides/swaps/single-swaps", + title: 'Implementing a Swap', + text: 'Start swapping from a smart contract in Solidity', + to: './protocol/guides/swaps/single-swaps', }, { - title: "Providing Liquidity", - text: "Provide liquidity from a smart contract in Solidity", - to: "./protocol/guides/providing-liquidity/setting-up", + title: 'Providing Liquidity', + text: 'Provide liquidity from a smart contract in Solidity', + to: './protocol/guides/providing-liquidity/setting-up', }, { - title: "Building an Oracle", - text: "Learn how Uniswap v3 pools can serve as oracles", - to: "./protocol/concepts/V3-overview/oracle", + title: 'Building an Oracle', + text: 'Learn how Uniswap v3 pools can serve as oracles', + to: './protocol/concepts/V3-overview/oracle', }, -]; +] export const quick = [ { - title: "Smart Contracts", - text: "Start swapping from a smart contract", - to: "./protocol/reference/smart-contracts", + title: 'Smart Contracts', + text: 'Start swapping from a smart contract', + to: './protocol/reference/smart-contracts', }, { - title: "SDK", - text: "Start swapping from a smart contract", - to: "./sdk/introduction", + title: 'SDK', + text: 'Start swapping from a smart contract', + to: './sdk/introduction', }, { - title: "Widgets", - text: "Get started with the swap widget", - to: "./sdk/widgets/swap-widget", + title: 'Widgets', + text: 'Get started with the swap widget', + to: './sdk/widgets/swap-widget', }, { - title: "Whitepaper", - text: "Read the Uniswap V3 whitepaper", - to: "https://uniswap.org/whitepaper-v3.pdf", + title: 'Whitepaper', + text: 'Read the Uniswap V3 whitepaper', + to: 'https://uniswap.org/whitepaper-v3.pdf', }, -]; +] const Container = styled.div` display: flex; flex-direction: column; margin: 0 auto; -`; +` const Row = styled.div` display: grid; @@ -148,7 +148,7 @@ const Row = styled.div` @media (max-width: 640px) { grid-template-columns: 1fr; } -`; +` const TwoRow = styled(Row)` grid-template-columns: 1fr 1fr; @@ -160,7 +160,7 @@ const TwoRow = styled(Row)` @media (max-width: 640px) { grid-template-columns: 1fr; } -`; +` const Card = styled.div` display: flex; @@ -183,7 +183,7 @@ const Card = styled.div` @media (max-width: 960px) { width: 100%; } -`; +` const CenterCard = styled(Card)` min-width: 250px; @@ -202,7 +202,7 @@ const CenterCard = styled(Card)` p { margin-bottom: 0px; } -`; +` const ShadowCard = styled(Card)` box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.05); @@ -210,7 +210,7 @@ const ShadowCard = styled(Card)` backdrop-filter: blur(10px); min-height: 200px; /* background-color: var(--ifm-color-emphasis-0); */ -`; +` const WideCard = styled(ShadowCard)` max-height: auto; @@ -220,7 +220,7 @@ const WideCard = styled(ShadowCard)` max-height: fit-content; width: fit-content; } -`; +` const IconWrapper = styled.div` width: 32px; @@ -229,7 +229,7 @@ const IconWrapper = styled.div` align-items: center; justify-content: center; border-radius: 4px; -`; +` const TopSection = styled.div` width: 100%; @@ -238,7 +238,7 @@ const TopSection = styled.div` display: flex; flex-direction: row; margin-bottom: 1rem; -`; +` const LinkRow = styled.div` width: 100%; @@ -249,7 +249,7 @@ const LinkRow = styled.div` a h3 { color: black !important; } -`; +` const DocsHeader = styled.div` display: flex; @@ -259,14 +259,14 @@ const DocsHeader = styled.div` overflow: hidden; width: 100%; position: relative; -`; +` const StyledImage = styled(ThemedImage)` position: relative; z-index: -1; width: 100%; object-fit: cover; -`; +` const StyledTitleImage = styled(StyledImage)` width: 100%; @@ -276,40 +276,37 @@ const StyledTitleImage = styled(StyledImage)` position: absolute; opacity: 0.2; mask-image: linear-gradient(rgba(0, 0, 0, 1), transparent); -`; +` const StyledGithubIcon = styled.div` svg { fill: var(--ifm-font-color-base); } -`; +` const HideMedium = styled.div` @media (max-width: 960px) { display: none; } -`; +` export default function Home() { return ( - +
-

Welcome to the Uniswap Docs

+

Welcome to the Uniswap Docs

- {" "} + {' '} {/*

{actions.map((action) => ( - + - + -

- {action.title} -

-

{action.text}

+

{action.title}

+

{action.text}

))} @@ -377,30 +369,26 @@ export default function Home() {

Getting Started

- Explore these docs to get started integrating the Uniswap Protocol - in your dApp, smart contract or project. + Explore these docs to get started integrating the Uniswap Protocol in your dApp, smart contract or + project.

{Guides.map((action) => ( - - + + -
-

{action.title}

+
+

{action.title}

-

{action.text}

+

{action.text}

))} @@ -416,22 +404,13 @@ export default function Home() {

Developer Links

-

- The Uniswap codebase is comprised of an ecosystem of open source - components. -

+

The Uniswap codebase is comprised of an ecosystem of open source components.

{github.map((action) => ( - - + + - - + + testlogo @@ -471,12 +450,10 @@ export default function Home() { -

- {action.title} -

+

{action.title}

@@ -511,15 +488,15 @@ export default function Home() {
-

{action.title}

+

{action.title}

- + - +

Discord

Hop in to the #dev-chat to get realtime help.

- + - +

Forum

Discuss governance and more.

@@ -560,17 +531,10 @@ export default function Home() { - + - + @@ -608,7 +572,7 @@ export default function Home() { /> - {" "} + {' '}

GitHub

@@ -619,33 +583,32 @@ export default function Home() { - +
-

Uniswap Grants Program

-

- Uniswap Governance offers grant funding for people who are - building apps, tools, and activities for Uniswap Protocol users, - builders, and community members.{" "} +

Uniswap Grants Program

+

+ Uniswap Governance offers grant funding for people who are building apps, tools, and activities for + Uniswap Protocol users, builders, and community members.{' '}

- ); + ) } diff --git a/src/theme/DocVersionSuggestions/index.js b/src/theme/DocVersionSuggestions/index.js index ace0bc2848..b5bc85aa24 100644 --- a/src/theme/DocVersionSuggestions/index.js +++ b/src/theme/DocVersionSuggestions/index.js @@ -4,18 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -import React from 'react'; -import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; -import Link from '@docusaurus/Link'; -import Translate from '@docusaurus/Translate'; -import { - useActivePlugin, - useActiveVersion, - useDocVersionSuggestions, -} from '@theme/hooks/useDocs'; -import {useDocsPreferredVersion} from '@docusaurus/theme-common'; +import React from 'react' +import useDocusaurusContext from '@docusaurus/useDocusaurusContext' +import Link from '@docusaurus/Link' +import Translate from '@docusaurus/Translate' +import { useActivePlugin, useActiveVersion, useDocVersionSuggestions } from '@theme/hooks/useDocs' +import { useDocsPreferredVersion } from '@docusaurus/theme-common' -function UnreleasedVersionLabel({siteTitle, versionLabel}) { +function UnreleasedVersionLabel({ siteTitle, versionLabel }) { return ( {versionLabel}, - }}> - { - 'This is unreleased documentation for the Uniswap Protocol.' - } + }} + > + {'This is unreleased documentation for the Uniswap Protocol.'} - ); + ) } -function UnmaintainedVersionLabel({siteTitle, versionLabel}) { +function UnmaintainedVersionLabel({ siteTitle, versionLabel }) { return ( {versionLabel}, - }}> + }} + > { 'This is documentation for {siteTitle} {versionLabel}, a previously released version of the {siteTitle} protocol.' } - ); + ) } -function LatestVersionSuggestionLabel({versionLabel, to, onClick}) { +function LatestVersionSuggestionLabel({ versionLabel, to, onClick }) { return ( + description="The label used for the latest version suggestion link label" + > latest version ), - }}> - { - 'For the most recent version, see {latestVersionLink} ({versionLabel}).' - } + }} + > + {'For the most recent version, see {latestVersionLink} ({versionLabel}).'} - ); + ) } -const getVersionMainDoc = (version) => - version.docs.find((doc) => doc.id === version.mainDocId); +const getVersionMainDoc = (version) => version.docs.find((doc) => doc.id === version.mainDocId) function DocVersionSuggestions() { const { - siteConfig: {title: siteTitle}, - } = useDocusaurusContext(); - const {pluginId} = useActivePlugin({ + siteConfig: { title: siteTitle }, + } = useDocusaurusContext() + const { pluginId } = useActivePlugin({ failfast: true, - }); - const {savePreferredVersionName} = useDocsPreferredVersion(pluginId); - const activeVersion = useActiveVersion(pluginId); - const { - latestDocSuggestion, - latestVersionSuggestion, - } = useDocVersionSuggestions(pluginId); // No suggestion to be made + }) + const { savePreferredVersionName } = useDocsPreferredVersion(pluginId) + const activeVersion = useActiveVersion(pluginId) + const { latestDocSuggestion, latestVersionSuggestion } = useDocVersionSuggestions(pluginId) // No suggestion to be made if (!latestVersionSuggestion) { - return <>; + return <> } // try to link to same doc in latest version (not always possible) // fallback to main doc of latest version - const latestVersionSuggestedDoc = - latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion); + const latestVersionSuggestedDoc = latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion) return (
{activeVersion.name === 'current' ? ( - + ) : ( - + )}
@@ -120,7 +105,7 @@ function DocVersionSuggestions() { />
- ); + ) } -export default DocVersionSuggestions; +export default DocVersionSuggestions diff --git a/src/theme/NavbarItem.js b/src/theme/NavbarItem.js index 5bcfa03da5..fd886c63ac 100644 --- a/src/theme/NavbarItem.js +++ b/src/theme/NavbarItem.js @@ -1,27 +1,24 @@ -import React from "react"; -import OriginalNavBarItem from "@theme-original/NavbarItem"; -import { useLocation } from "@docusaurus/router"; +import React from 'react' +import OriginalNavBarItem from '@theme-original/NavbarItem' +import { useLocation } from '@docusaurus/router' export default function NavbarItem(props) { - const { pathname } = useLocation(); + const { pathname } = useLocation() - let versionDoc = pathname.split("/"); - let activeNav = null; + let versionDoc = pathname.split('/') + let activeNav = null - if (versionDoc[2] === "V2" || versionDoc[2] === "2.0.0") { - activeNav = "V2"; - } else if (versionDoc[2] === "V1" || versionDoc[2] === "1.0.0") { - activeNav = "V1"; + if (versionDoc[2] === 'V2' || versionDoc[2] === '2.0.0') { + activeNav = 'V2' + } else if (versionDoc[2] === 'V1' || versionDoc[2] === '1.0.0') { + activeNav = 'V1' } else { - activeNav = "V3"; + activeNav = 'V3' } return ( <> - + - ); + ) } diff --git a/versioned_docs/version-V1/guides/01-connect-to-uniswap.md b/versioned_docs/version-V1/guides/01-connect-to-uniswap.md index 05fb390061..98a19a67e9 100644 --- a/versioned_docs/version-V1/guides/01-connect-to-uniswap.md +++ b/versioned_docs/version-V1/guides/01-connect-to-uniswap.md @@ -15,13 +15,13 @@ The factory contract can be instantiated using the factory address and ABI: ```javascript // mainnet -const factory = "0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95"; +const factory = '0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95' // testnets -const ropsten = "0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351"; -const rinkeby = "0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36"; -const kovan = "0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30"; -const gƶrli = "0x6Ce570d02D73d4c384b46135E87f8C592A8c86dA"; +const ropsten = '0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351' +const rinkeby = '0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36' +const kovan = '0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30' +const gƶrli = '0x6Ce570d02D73d4c384b46135E87f8C592A8c86dA' ``` ### Factory Interface @@ -31,82 +31,82 @@ Creating the factory interface in web3 requires the **factory address** and the ```javascript const factoryABI = [ { - name: "NewExchange", + name: 'NewExchange', inputs: [ - { type: "address", name: "token", indexed: true }, - { type: "address", name: "exchange", indexed: true }, + { type: 'address', name: 'token', indexed: true }, + { type: 'address', name: 'exchange', indexed: true }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "initializeFactory", + name: 'initializeFactory', outputs: [], - inputs: [{ type: "address", name: "template" }], + inputs: [{ type: 'address', name: 'template' }], constant: false, payable: false, - type: "function", + type: 'function', gas: 35725, }, { - name: "createExchange", - outputs: [{ type: "address", name: "out" }], - inputs: [{ type: "address", name: "token" }], + name: 'createExchange', + outputs: [{ type: 'address', name: 'out' }], + inputs: [{ type: 'address', name: 'token' }], constant: false, payable: false, - type: "function", + type: 'function', gas: 187911, }, { - name: "getExchange", - outputs: [{ type: "address", name: "out" }], - inputs: [{ type: "address", name: "token" }], + name: 'getExchange', + outputs: [{ type: 'address', name: 'out' }], + inputs: [{ type: 'address', name: 'token' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 715, }, { - name: "getToken", - outputs: [{ type: "address", name: "out" }], - inputs: [{ type: "address", name: "exchange" }], + name: 'getToken', + outputs: [{ type: 'address', name: 'out' }], + inputs: [{ type: 'address', name: 'exchange' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 745, }, { - name: "getTokenWithId", - outputs: [{ type: "address", name: "out" }], - inputs: [{ type: "uint256", name: "token_id" }], + name: 'getTokenWithId', + outputs: [{ type: 'address', name: 'out' }], + inputs: [{ type: 'uint256', name: 'token_id' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 736, }, { - name: "exchangeTemplate", - outputs: [{ type: "address", name: "out" }], + name: 'exchangeTemplate', + outputs: [{ type: 'address', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 633, }, { - name: "tokenCount", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenCount', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 663, }, -]; +] ``` ```javascript -const factoryContract = new web3.eth.Contract(factoryABI, factoryAddress); +const factoryContract = new web3.eth.Contract(factoryABI, factoryAddress) ``` # Exchange Contracts @@ -116,7 +116,7 @@ const factoryContract = new web3.eth.Contract(factoryABI, factoryAddress); There is a separate exchange contract for every ERC20 token. The `getExchange` method in the factory contract can be used to find the Ethereum address associated with an ERC20 token address. ```javascript -const exchangeAddress = factoryContract.methods.getExchange(tokenAddress); +const exchangeAddress = factoryContract.methods.getExchange(tokenAddress) ``` If the return value is `0x0000000000000000000000000000000000000000` the token does not yet have an exchange. @@ -128,493 +128,493 @@ Creating an exchange interface in web3 requires the **exchange address** and the ```javascript const exchangeABI = [ { - name: "TokenPurchase", + name: 'TokenPurchase', inputs: [ - { type: "address", name: "buyer", indexed: true }, - { type: "uint256", name: "eth_sold", indexed: true }, - { type: "uint256", name: "tokens_bought", indexed: true }, + { type: 'address', name: 'buyer', indexed: true }, + { type: 'uint256', name: 'eth_sold', indexed: true }, + { type: 'uint256', name: 'tokens_bought', indexed: true }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "EthPurchase", + name: 'EthPurchase', inputs: [ - { type: "address", name: "buyer", indexed: true }, - { type: "uint256", name: "tokens_sold", indexed: true }, - { type: "uint256", name: "eth_bought", indexed: true }, + { type: 'address', name: 'buyer', indexed: true }, + { type: 'uint256', name: 'tokens_sold', indexed: true }, + { type: 'uint256', name: 'eth_bought', indexed: true }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "AddLiquidity", + name: 'AddLiquidity', inputs: [ - { type: "address", name: "provider", indexed: true }, - { type: "uint256", name: "eth_amount", indexed: true }, - { type: "uint256", name: "token_amount", indexed: true }, + { type: 'address', name: 'provider', indexed: true }, + { type: 'uint256', name: 'eth_amount', indexed: true }, + { type: 'uint256', name: 'token_amount', indexed: true }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "RemoveLiquidity", + name: 'RemoveLiquidity', inputs: [ - { type: "address", name: "provider", indexed: true }, - { type: "uint256", name: "eth_amount", indexed: true }, - { type: "uint256", name: "token_amount", indexed: true }, + { type: 'address', name: 'provider', indexed: true }, + { type: 'uint256', name: 'eth_amount', indexed: true }, + { type: 'uint256', name: 'token_amount', indexed: true }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "Transfer", + name: 'Transfer', inputs: [ - { type: "address", name: "_from", indexed: true }, - { type: "address", name: "_to", indexed: true }, - { type: "uint256", name: "_value", indexed: false }, + { type: 'address', name: '_from', indexed: true }, + { type: 'address', name: '_to', indexed: true }, + { type: 'uint256', name: '_value', indexed: false }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "Approval", + name: 'Approval', inputs: [ - { type: "address", name: "_owner", indexed: true }, - { type: "address", name: "_spender", indexed: true }, - { type: "uint256", name: "_value", indexed: false }, + { type: 'address', name: '_owner', indexed: true }, + { type: 'address', name: '_spender', indexed: true }, + { type: 'uint256', name: '_value', indexed: false }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "setup", + name: 'setup', outputs: [], - inputs: [{ type: "address", name: "token_addr" }], + inputs: [{ type: 'address', name: 'token_addr' }], constant: false, payable: false, - type: "function", + type: 'function', gas: 175875, }, { - name: "addLiquidity", - outputs: [{ type: "uint256", name: "out" }], + name: 'addLiquidity', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "min_liquidity" }, - { type: "uint256", name: "max_tokens" }, - { type: "uint256", name: "deadline" }, + { type: 'uint256', name: 'min_liquidity' }, + { type: 'uint256', name: 'max_tokens' }, + { type: 'uint256', name: 'deadline' }, ], constant: false, payable: true, - type: "function", + type: 'function', gas: 82605, }, { - name: "removeLiquidity", + name: 'removeLiquidity', outputs: [ - { type: "uint256", name: "out" }, - { type: "uint256", name: "out" }, + { type: 'uint256', name: 'out' }, + { type: 'uint256', name: 'out' }, ], inputs: [ - { type: "uint256", name: "amount" }, - { type: "uint256", name: "min_eth" }, - { type: "uint256", name: "min_tokens" }, - { type: "uint256", name: "deadline" }, + { type: 'uint256', name: 'amount' }, + { type: 'uint256', name: 'min_eth' }, + { type: 'uint256', name: 'min_tokens' }, + { type: 'uint256', name: 'deadline' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 116814, }, { - name: "__default__", + name: '__default__', outputs: [], inputs: [], constant: false, payable: true, - type: "function", + type: 'function', }, { - name: "ethToTokenSwapInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'ethToTokenSwapInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "min_tokens" }, - { type: "uint256", name: "deadline" }, + { type: 'uint256', name: 'min_tokens' }, + { type: 'uint256', name: 'deadline' }, ], constant: false, payable: true, - type: "function", + type: 'function', gas: 12757, }, { - name: "ethToTokenTransferInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'ethToTokenTransferInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "min_tokens" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, + { type: 'uint256', name: 'min_tokens' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, ], constant: false, payable: true, - type: "function", + type: 'function', gas: 12965, }, { - name: "ethToTokenSwapOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'ethToTokenSwapOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_bought" }, - { type: "uint256", name: "deadline" }, + { type: 'uint256', name: 'tokens_bought' }, + { type: 'uint256', name: 'deadline' }, ], constant: false, payable: true, - type: "function", + type: 'function', gas: 50455, }, { - name: "ethToTokenTransferOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'ethToTokenTransferOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_bought" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, + { type: 'uint256', name: 'tokens_bought' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, ], constant: false, payable: true, - type: "function", + type: 'function', gas: 50663, }, { - name: "tokenToEthSwapInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToEthSwapInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_sold" }, - { type: "uint256", name: "min_eth" }, - { type: "uint256", name: "deadline" }, + { type: 'uint256', name: 'tokens_sold' }, + { type: 'uint256', name: 'min_eth' }, + { type: 'uint256', name: 'deadline' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 47503, }, { - name: "tokenToEthTransferInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToEthTransferInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_sold" }, - { type: "uint256", name: "min_eth" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, + { type: 'uint256', name: 'tokens_sold' }, + { type: 'uint256', name: 'min_eth' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 47712, }, { - name: "tokenToEthSwapOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToEthSwapOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "eth_bought" }, - { type: "uint256", name: "max_tokens" }, - { type: "uint256", name: "deadline" }, + { type: 'uint256', name: 'eth_bought' }, + { type: 'uint256', name: 'max_tokens' }, + { type: 'uint256', name: 'deadline' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 50175, }, { - name: "tokenToEthTransferOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToEthTransferOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "eth_bought" }, - { type: "uint256", name: "max_tokens" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, + { type: 'uint256', name: 'eth_bought' }, + { type: 'uint256', name: 'max_tokens' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 50384, }, { - name: "tokenToTokenSwapInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToTokenSwapInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_sold" }, - { type: "uint256", name: "min_tokens_bought" }, - { type: "uint256", name: "min_eth_bought" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "token_addr" }, + { type: 'uint256', name: 'tokens_sold' }, + { type: 'uint256', name: 'min_tokens_bought' }, + { type: 'uint256', name: 'min_eth_bought' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'token_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 51007, }, { - name: "tokenToTokenTransferInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToTokenTransferInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_sold" }, - { type: "uint256", name: "min_tokens_bought" }, - { type: "uint256", name: "min_eth_bought" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, - { type: "address", name: "token_addr" }, + { type: 'uint256', name: 'tokens_sold' }, + { type: 'uint256', name: 'min_tokens_bought' }, + { type: 'uint256', name: 'min_eth_bought' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, + { type: 'address', name: 'token_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 51098, }, { - name: "tokenToTokenSwapOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToTokenSwapOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_bought" }, - { type: "uint256", name: "max_tokens_sold" }, - { type: "uint256", name: "max_eth_sold" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "token_addr" }, + { type: 'uint256', name: 'tokens_bought' }, + { type: 'uint256', name: 'max_tokens_sold' }, + { type: 'uint256', name: 'max_eth_sold' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'token_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 54928, }, { - name: "tokenToTokenTransferOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToTokenTransferOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_bought" }, - { type: "uint256", name: "max_tokens_sold" }, - { type: "uint256", name: "max_eth_sold" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, - { type: "address", name: "token_addr" }, + { type: 'uint256', name: 'tokens_bought' }, + { type: 'uint256', name: 'max_tokens_sold' }, + { type: 'uint256', name: 'max_eth_sold' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, + { type: 'address', name: 'token_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 55019, }, { - name: "tokenToExchangeSwapInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToExchangeSwapInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_sold" }, - { type: "uint256", name: "min_tokens_bought" }, - { type: "uint256", name: "min_eth_bought" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "exchange_addr" }, + { type: 'uint256', name: 'tokens_sold' }, + { type: 'uint256', name: 'min_tokens_bought' }, + { type: 'uint256', name: 'min_eth_bought' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'exchange_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 49342, }, { - name: "tokenToExchangeTransferInput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToExchangeTransferInput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_sold" }, - { type: "uint256", name: "min_tokens_bought" }, - { type: "uint256", name: "min_eth_bought" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, - { type: "address", name: "exchange_addr" }, + { type: 'uint256', name: 'tokens_sold' }, + { type: 'uint256', name: 'min_tokens_bought' }, + { type: 'uint256', name: 'min_eth_bought' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, + { type: 'address', name: 'exchange_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 49532, }, { - name: "tokenToExchangeSwapOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToExchangeSwapOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_bought" }, - { type: "uint256", name: "max_tokens_sold" }, - { type: "uint256", name: "max_eth_sold" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "exchange_addr" }, + { type: 'uint256', name: 'tokens_bought' }, + { type: 'uint256', name: 'max_tokens_sold' }, + { type: 'uint256', name: 'max_eth_sold' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'exchange_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 53233, }, { - name: "tokenToExchangeTransferOutput", - outputs: [{ type: "uint256", name: "out" }], + name: 'tokenToExchangeTransferOutput', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "uint256", name: "tokens_bought" }, - { type: "uint256", name: "max_tokens_sold" }, - { type: "uint256", name: "max_eth_sold" }, - { type: "uint256", name: "deadline" }, - { type: "address", name: "recipient" }, - { type: "address", name: "exchange_addr" }, + { type: 'uint256', name: 'tokens_bought' }, + { type: 'uint256', name: 'max_tokens_sold' }, + { type: 'uint256', name: 'max_eth_sold' }, + { type: 'uint256', name: 'deadline' }, + { type: 'address', name: 'recipient' }, + { type: 'address', name: 'exchange_addr' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 53423, }, { - name: "getEthToTokenInputPrice", - outputs: [{ type: "uint256", name: "out" }], - inputs: [{ type: "uint256", name: "eth_sold" }], + name: 'getEthToTokenInputPrice', + outputs: [{ type: 'uint256', name: 'out' }], + inputs: [{ type: 'uint256', name: 'eth_sold' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 5542, }, { - name: "getEthToTokenOutputPrice", - outputs: [{ type: "uint256", name: "out" }], - inputs: [{ type: "uint256", name: "tokens_bought" }], + name: 'getEthToTokenOutputPrice', + outputs: [{ type: 'uint256', name: 'out' }], + inputs: [{ type: 'uint256', name: 'tokens_bought' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 6872, }, { - name: "getTokenToEthInputPrice", - outputs: [{ type: "uint256", name: "out" }], - inputs: [{ type: "uint256", name: "tokens_sold" }], + name: 'getTokenToEthInputPrice', + outputs: [{ type: 'uint256', name: 'out' }], + inputs: [{ type: 'uint256', name: 'tokens_sold' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 5637, }, { - name: "getTokenToEthOutputPrice", - outputs: [{ type: "uint256", name: "out" }], - inputs: [{ type: "uint256", name: "eth_bought" }], + name: 'getTokenToEthOutputPrice', + outputs: [{ type: 'uint256', name: 'out' }], + inputs: [{ type: 'uint256', name: 'eth_bought' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 6897, }, { - name: "tokenAddress", - outputs: [{ type: "address", name: "out" }], + name: 'tokenAddress', + outputs: [{ type: 'address', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 1413, }, { - name: "factoryAddress", - outputs: [{ type: "address", name: "out" }], + name: 'factoryAddress', + outputs: [{ type: 'address', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 1443, }, { - name: "balanceOf", - outputs: [{ type: "uint256", name: "out" }], - inputs: [{ type: "address", name: "_owner" }], + name: 'balanceOf', + outputs: [{ type: 'uint256', name: 'out' }], + inputs: [{ type: 'address', name: '_owner' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 1645, }, { - name: "transfer", - outputs: [{ type: "bool", name: "out" }], + name: 'transfer', + outputs: [{ type: 'bool', name: 'out' }], inputs: [ - { type: "address", name: "_to" }, - { type: "uint256", name: "_value" }, + { type: 'address', name: '_to' }, + { type: 'uint256', name: '_value' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 75034, }, { - name: "transferFrom", - outputs: [{ type: "bool", name: "out" }], + name: 'transferFrom', + outputs: [{ type: 'bool', name: 'out' }], inputs: [ - { type: "address", name: "_from" }, - { type: "address", name: "_to" }, - { type: "uint256", name: "_value" }, + { type: 'address', name: '_from' }, + { type: 'address', name: '_to' }, + { type: 'uint256', name: '_value' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 110907, }, { - name: "approve", - outputs: [{ type: "bool", name: "out" }], + name: 'approve', + outputs: [{ type: 'bool', name: 'out' }], inputs: [ - { type: "address", name: "_spender" }, - { type: "uint256", name: "_value" }, + { type: 'address', name: '_spender' }, + { type: 'uint256', name: '_value' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 38769, }, { - name: "allowance", - outputs: [{ type: "uint256", name: "out" }], + name: 'allowance', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "address", name: "_owner" }, - { type: "address", name: "_spender" }, + { type: 'address', name: '_owner' }, + { type: 'address', name: '_spender' }, ], constant: true, payable: false, - type: "function", + type: 'function', gas: 1925, }, { - name: "name", - outputs: [{ type: "bytes32", name: "out" }], + name: 'name', + outputs: [{ type: 'bytes32', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 1623, }, { - name: "symbol", - outputs: [{ type: "bytes32", name: "out" }], + name: 'symbol', + outputs: [{ type: 'bytes32', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 1653, }, { - name: "decimals", - outputs: [{ type: "uint256", name: "out" }], + name: 'decimals', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 1683, }, { - name: "totalSupply", - outputs: [{ type: "uint256", name: "out" }], + name: 'totalSupply', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 1713, }, -]; +] ``` ```javascript -const exchangeContract = new web3.eth.Contract(exchangeABI, exchangeAddress); +const exchangeContract = new web3.eth.Contract(exchangeABI, exchangeAddress) ``` # Token Contracts @@ -626,7 +626,7 @@ Some Uniswap interactions require making calls directly to ERC20 token contracts The `getToken` method in the factory contract can be used to find the ERC20 token address associated with an exchange contract. There is no barrier of entry for adding an ERC20 token to Uniswap or checks on the validity of the token contracts. Frontend interfaces should maintain a list of valid ERC20 tokens that users can safely trade or allow users to paste in arbitrary addresses. ```javascript -const tokenAddress = factoryContract.methods.getToken(exchangeAddress); +const tokenAddress = factoryContract.methods.getToken(exchangeAddress) ``` If the return value is `0x0000000000000000000000000000000000000000` the input address is not a Uniswap exchange. @@ -638,153 +638,153 @@ Creating a token interface in web3 requires the **token address** and the **toke ```javascript const tokenABI = [ { - name: "Transfer", + name: 'Transfer', inputs: [ - { type: "address", name: "_from", indexed: true }, - { type: "address", name: "_to", indexed: true }, - { type: "uint256", name: "_value", indexed: false }, + { type: 'address', name: '_from', indexed: true }, + { type: 'address', name: '_to', indexed: true }, + { type: 'uint256', name: '_value', indexed: false }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "Approval", + name: 'Approval', inputs: [ - { type: "address", name: "_owner", indexed: true }, - { type: "address", name: "_spender", indexed: true }, - { type: "uint256", name: "_value", indexed: false }, + { type: 'address', name: '_owner', indexed: true }, + { type: 'address', name: '_spender', indexed: true }, + { type: 'uint256', name: '_value', indexed: false }, ], anonymous: false, - type: "event", + type: 'event', }, { - name: "__init__", + name: '__init__', outputs: [], inputs: [ - { type: "bytes32", name: "_name" }, - { type: "bytes32", name: "_symbol" }, - { type: "uint256", name: "_decimals" }, - { type: "uint256", name: "_supply" }, + { type: 'bytes32', name: '_name' }, + { type: 'bytes32', name: '_symbol' }, + { type: 'uint256', name: '_decimals' }, + { type: 'uint256', name: '_supply' }, ], constant: false, payable: false, - type: "constructor", + type: 'constructor', }, { - name: "deposit", + name: 'deposit', outputs: [], inputs: [], constant: false, payable: true, - type: "function", + type: 'function', gas: 74279, }, { - name: "withdraw", - outputs: [{ type: "bool", name: "out" }], - inputs: [{ type: "uint256", name: "_value" }], + name: 'withdraw', + outputs: [{ type: 'bool', name: 'out' }], + inputs: [{ type: 'uint256', name: '_value' }], constant: false, payable: false, - type: "function", + type: 'function', gas: 108706, }, { - name: "totalSupply", - outputs: [{ type: "uint256", name: "out" }], + name: 'totalSupply', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 543, }, { - name: "balanceOf", - outputs: [{ type: "uint256", name: "out" }], - inputs: [{ type: "address", name: "_owner" }], + name: 'balanceOf', + outputs: [{ type: 'uint256', name: 'out' }], + inputs: [{ type: 'address', name: '_owner' }], constant: true, payable: false, - type: "function", + type: 'function', gas: 745, }, { - name: "transfer", - outputs: [{ type: "bool", name: "out" }], + name: 'transfer', + outputs: [{ type: 'bool', name: 'out' }], inputs: [ - { type: "address", name: "_to" }, - { type: "uint256", name: "_value" }, + { type: 'address', name: '_to' }, + { type: 'uint256', name: '_value' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 74698, }, { - name: "transferFrom", - outputs: [{ type: "bool", name: "out" }], + name: 'transferFrom', + outputs: [{ type: 'bool', name: 'out' }], inputs: [ - { type: "address", name: "_from" }, - { type: "address", name: "_to" }, - { type: "uint256", name: "_value" }, + { type: 'address', name: '_from' }, + { type: 'address', name: '_to' }, + { type: 'uint256', name: '_value' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 110600, }, { - name: "approve", - outputs: [{ type: "bool", name: "out" }], + name: 'approve', + outputs: [{ type: 'bool', name: 'out' }], inputs: [ - { type: "address", name: "_spender" }, - { type: "uint256", name: "_value" }, + { type: 'address', name: '_spender' }, + { type: 'uint256', name: '_value' }, ], constant: false, payable: false, - type: "function", + type: 'function', gas: 37888, }, { - name: "allowance", - outputs: [{ type: "uint256", name: "out" }], + name: 'allowance', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [ - { type: "address", name: "_owner" }, - { type: "address", name: "_spender" }, + { type: 'address', name: '_owner' }, + { type: 'address', name: '_spender' }, ], constant: true, payable: false, - type: "function", + type: 'function', gas: 1025, }, { - name: "name", - outputs: [{ type: "bytes32", name: "out" }], + name: 'name', + outputs: [{ type: 'bytes32', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 723, }, { - name: "symbol", - outputs: [{ type: "bytes32", name: "out" }], + name: 'symbol', + outputs: [{ type: 'bytes32', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 753, }, { - name: "decimals", - outputs: [{ type: "uint256", name: "out" }], + name: 'decimals', + outputs: [{ type: 'uint256', name: 'out' }], inputs: [], constant: true, payable: false, - type: "function", + type: 'function', gas: 783, }, -]; +] ``` ```javascript -const tokenContract = new web3.eth.Contract(tokenABI, tokenAddress); +const tokenContract = new web3.eth.Contract(tokenABI, tokenAddress) ``` diff --git a/versioned_docs/version-V1/guides/02-pool-liquidity.md b/versioned_docs/version-V1/guides/02-pool-liquidity.md index cb30173913..944d51f39f 100644 --- a/versioned_docs/version-V1/guides/02-pool-liquidity.md +++ b/versioned_docs/version-V1/guides/02-pool-liquidity.md @@ -15,7 +15,7 @@ Uniswap liquidity pools are autonomous and use the Constant Product Market Maker The `createExchange` function is used to deploy exchange contracts for ERC20 tokens that do not yet have one. ```javascript -factory.methods.createExchange(tokenAddress).send(); +factory.methods.createExchange(tokenAddress).send() ``` Once an exchange is created the address can be retrieved with [`getExchange`](connect-to-uniswap/#get-exchange-address). @@ -29,7 +29,7 @@ Each exchange contract holds a liquidity reserve of ETH and its associated ERC20 The ETH reserve associated with an ERC20 token exchange is the ETH balance of the exchange smart contract. ```javascript -const ethReserve = web3.eth.getBalance(exchangeAddress); +const ethReserve = web3.eth.getBalance(exchangeAddress) ``` ### ERC20 Reserve @@ -37,7 +37,7 @@ const ethReserve = web3.eth.getBalance(exchangeAddress); The ERC20 reserve associated with an ERC20 token exchange is the ERC20 balance of the exchange smart contract. ```javascript -const tokenReserve = tokenContract.methods.balanceOf(exchangeAddress); +const tokenReserve = tokenContract.methods.balanceOf(exchangeAddress) ``` ## Add Liquidity @@ -45,9 +45,7 @@ const tokenReserve = tokenContract.methods.balanceOf(exchangeAddress); Anyone who wants can join a Uniswap liquidity pool by calling the `addLiquidity` function. ```javascript -exchange.methods - .addLiquidity(min_liquidity, max_tokens, deadline) - .send({ value: ethAmount }); +exchange.methods.addLiquidity(min_liquidity, max_tokens, deadline).send({ value: ethAmount }) ``` Adding liquidity requires depositing an equivalent **value** of ETH and ERC20 tokens into the ERC20 token's associated exchange contract. @@ -71,7 +69,7 @@ Transaction `deadline` is used to set a time after which a transaction can no lo Liquidity providers use the `removeLiquidity` function to withdraw their portion of the reserves. ```javascript -exchange.methods.removeLiquidity(amount, min_eth, min_tokens, deadline).send(); +exchange.methods.removeLiquidity(amount, min_eth, min_tokens, deadline).send() ``` Liquidity is withdrawn at the same ratio as the reserves at the time of withdrawal. If the exchange rate is bad there is a profitable arbitrage opportunity that will correct the price. diff --git a/versioned_docs/version-V1/guides/03-trade-tokens.md b/versioned_docs/version-V1/guides/03-trade-tokens.md index c9ea2093a8..6eeacd8035 100644 --- a/versioned_docs/version-V1/guides/03-trade-tokens.md +++ b/versioned_docs/version-V1/guides/03-trade-tokens.md @@ -21,19 +21,19 @@ For sell orders \(exact input\), the amount bought \(output\) is calculated: ```javascript // Sell ETH for ERC20 -const inputAmount = userInputEthValue; -const inputReserve = web3.eth.getBalance(exchangeAddress); -const outputReserve = tokenContract.methods.balanceOf(exchangeAddress).call(); +const inputAmount = userInputEthValue +const inputReserve = web3.eth.getBalance(exchangeAddress) +const outputReserve = tokenContract.methods.balanceOf(exchangeAddress).call() // Sell ERC20 for ETH -const inputAmount = userInputTokenValue; -const inputReserve = tokenContract.methods.balanceOf(exchangeAddress).call(); -const outputReserve = web3.eth.getBalance(exchangeAddress); +const inputAmount = userInputTokenValue +const inputReserve = tokenContract.methods.balanceOf(exchangeAddress).call() +const outputReserve = web3.eth.getBalance(exchangeAddress) // Output amount bought -const numerator = inputAmount * outputReserve * 997; -const denominator = inputReserve * 1000 + inputAmount * 997; -const outputAmount = numerator / denominator; +const numerator = inputAmount * outputReserve * 997 +const denominator = inputReserve * 1000 + inputAmount * 997 +const outputAmount = numerator / denominator ``` ### Amount Sold \(buy order\) @@ -42,19 +42,19 @@ For buy orders \(exact output\), the cost \(input\) is calculated: ```javascript // Buy ERC20 with ETH -const outputAmount = userInputTokenValue; -const inputReserve = web3.eth.getBalance(exchangeAddress); -const outputReserve = tokenContract.methods.balanceOf(exchangeAddress).call(); +const outputAmount = userInputTokenValue +const inputReserve = web3.eth.getBalance(exchangeAddress) +const outputReserve = tokenContract.methods.balanceOf(exchangeAddress).call() // Buy ETH with ERC20 -const outputAmount = userInputEthValue; -const inputReserve = tokenContract.methods.balanceOf(exchangeAddress).call(); -const outputReserve = web3.eth.getBalance(exchangeAddress); +const outputAmount = userInputEthValue +const inputReserve = tokenContract.methods.balanceOf(exchangeAddress).call() +const outputReserve = web3.eth.getBalance(exchangeAddress) // Cost -const numerator = outputAmount * inputReserve * 1000; -const denominator = (outputReserve - outputAmount) * 997; -const inputAmount = numerator / denominator + 1; +const numerator = outputAmount * inputReserve * 1000 +const denominator = (outputReserve - outputAmount) * 997 +const inputAmount = numerator / denominator + 1 ``` ### Liquidity Provider Fee @@ -62,7 +62,7 @@ const inputAmount = numerator / denominator + 1; There is a 0.3% liquidity provider fee built into the price formula. This can be calculated: ```javascript -fee = inputAmount * 0.003; +fee = inputAmount * 0.003 ``` ### Exchange Rate @@ -70,7 +70,7 @@ fee = inputAmount * 0.003; The exchange rate is simply the output amount divided by the input amount. ```javascript -const rate = outputAmount / inputAmount; +const rate = outputAmount / inputAmount ``` ## ERC20 ā‡„ ERC20 Calculations @@ -89,22 +89,22 @@ For sell orders \(exact input\), the amount bought \(output\) is calculated: ```javascript // TokenA (ERC20) to ETH conversion -const inputAmountA = userInputTokenAValue; -const inputReserveA = tokenContractA.methods.balanceOf(exchangeAddressA).call(); -const outputReserveA = web3.eth.getBalance(exchangeAddressA); +const inputAmountA = userInputTokenAValue +const inputReserveA = tokenContractA.methods.balanceOf(exchangeAddressA).call() +const outputReserveA = web3.eth.getBalance(exchangeAddressA) -const numeratorA = inputAmountA * outputReserveA * 997; -const denominatorA = inputReserveA * 1000 + inputAmountA * 997; -const outputAmountA = numeratorA / denominatorA; +const numeratorA = inputAmountA * outputReserveA * 997 +const denominatorA = inputReserveA * 1000 + inputAmountA * 997 +const outputAmountA = numeratorA / denominatorA // ETH to TokenB conversion -const inputAmountB = outputAmountA; -const inputReserveB = web3.eth.getBalance(exchangeAddressB); -const outputReserveB = tokenContract.methods.balanceOf(exchangeAddressB).call(); +const inputAmountB = outputAmountA +const inputReserveB = web3.eth.getBalance(exchangeAddressB) +const outputReserveB = tokenContract.methods.balanceOf(exchangeAddressB).call() -const numeratorB = inputAmountB * outputReserveB * 997; -const denominatorB = inputReserveB * 1000 + inputAmountB * 997; -const outputAmountB = numeratorB / denominatorB; +const numeratorB = inputAmountB * outputReserveB * 997 +const denominatorB = inputReserveB * 1000 + inputAmountB * 997 +const outputAmountB = numeratorB / denominatorB ``` ### Amount Sold \(buy order\) @@ -113,26 +113,24 @@ For buy orders \(exact output\), the cost \(input\) is calculated: ```javascript // Buy TokenB with ETH -const outputAmountB = userInputEthValue; -const inputReserveB = web3.eth.getBalance(exchangeAddressB); -const outputReserveB = tokenContractB.methods - .balanceOf(exchangeAddressB) - .call(); +const outputAmountB = userInputEthValue +const inputReserveB = web3.eth.getBalance(exchangeAddressB) +const outputReserveB = tokenContractB.methods.balanceOf(exchangeAddressB).call() // Cost -const numeratorB = outputAmountB * inputReserveB * 1000; -const denominatorB = (outputReserveB - outputAmountB) * 997; -const inputAmountB = numeratorB / denominatorB + 1; +const numeratorB = outputAmountB * inputReserveB * 1000 +const denominatorB = (outputReserveB - outputAmountB) * 997 +const inputAmountB = numeratorB / denominatorB + 1 // Buy ETH with TokenA -const outputAmountA = userInputEthValue; -const inputReserveA = tokenContractA.methods.balanceOf(exchangeAddressA).call(); -const outputReserveA = web3.eth.getBalance(exchangeAddressA); +const outputAmountA = userInputEthValue +const inputReserveA = tokenContractA.methods.balanceOf(exchangeAddressA).call() +const outputReserveA = web3.eth.getBalance(exchangeAddressA) // Cost -const numeratorA = outputAmountA * inputReserveA * 1000; -const denominatorA = (outputReserveA - outputAmountA) * 997; -const inputAmountA = numeratorA / denominatorA + 1; +const numeratorA = outputAmountA * inputReserveA * 1000 +const denominatorA = (outputReserveA - outputAmountA) * 997 +const inputAmountA = numeratorA / denominatorA + 1 ``` ### Liquidity Provider Fee @@ -140,14 +138,14 @@ const inputAmountA = numeratorA / denominatorA + 1; There is a 0.30% liquidity provider fee to swap from TokenA to ETH on the input exchange. There is another 0.3% liquidity provider fee to swap the remaining ETH to TokenB. ```javascript -const exchangeAFee = inputAmountA * 0.003; -const exchangeBFee = inputAmountB * 0.003; +const exchangeAFee = inputAmountA * 0.003 +const exchangeBFee = inputAmountB * 0.003 ``` Since users only inputs Token A, it can be represented to them as: ```javascript -const combinedFee = inputAmountA * 0.00591; +const combinedFee = inputAmountA * 0.00591 ``` ### Exchange Rate @@ -155,7 +153,7 @@ const combinedFee = inputAmountA * 0.00591; The exchange rate is simply the output amount divided by the input amount. ```javascript -const rate = outputAmountB / inputAmountA; +const rate = outputAmountB / inputAmountA ``` ## Deadlines @@ -165,9 +163,9 @@ Many Uniswap functions include a transaction `deadline` that sets a time after w Deadlines are calculated by adding the desired amount of time \(in seconds\) to the latest Ethereum block timestamp. ```javascript -web3.eth.getBlock("latest", (error, block) => { - deadline = block.timestamp + 300; // transaction expires in 300 seconds (5 minutes) -}); +web3.eth.getBlock('latest', (error, block) => { + deadline = block.timestamp + 300 // transaction expires in 300 seconds (5 minutes) +}) ``` ## Recipients diff --git a/versioned_docs/version-V1/guides/_category_.json b/versioned_docs/version-V1/guides/_category_.json index 3d0cc8b7d4..c694eb5b29 100644 --- a/versioned_docs/version-V1/guides/_category_.json +++ b/versioned_docs/version-V1/guides/_category_.json @@ -1,5 +1,5 @@ { - "label": "Guides", - "position": 2, - "collapsed": false - } \ No newline at end of file + "label": "Guides", + "position": 2, + "collapsed": false +} diff --git a/versioned_docs/version-V1/introduction.md b/versioned_docs/version-V1/introduction.md index fa3241f1ea..57a6c03273 100644 --- a/versioned_docs/version-V1/introduction.md +++ b/versioned_docs/version-V1/introduction.md @@ -2,10 +2,9 @@ id: introduction title: The Uniswap V1 Protocol sidebar_position: 1 - --- -Uniswap V1 is the first version of the protocol, [launched in November 2018](https://twitter.com/haydenzadams/status/1058376395108376577) at Devcon 4. Because of its permissionless nature, it will exist for as long as Ethereum does. +Uniswap V1 is the first version of the protocol, [launched in November 2018](https://twitter.com/haydenzadams/status/1058376395108376577) at Devcon 4. Because of its permissionless nature, it will exist for as long as Ethereum does. Designed with simplicity in mind, the Uniswap protocol provides an interface for seamless exchange of ERC20 tokens on Ethereum. By eliminating unnecessary forms of rent extraction and middlemen it allows faster, more efficient exchange. Where it makes tradeoffs, decentralization, censorship resistance, and security are prioritized. diff --git a/versioned_docs/version-V1/reference/01-factory.md b/versioned_docs/version-V1/reference/01-factory.md index 10ca3cdcd0..8b359bf556 100644 --- a/versioned_docs/version-V1/reference/01-factory.md +++ b/versioned_docs/version-V1/reference/01-factory.md @@ -18,7 +18,7 @@ initializeFactory(template: address) ## Web3 ```javascript -factoryContract.methods.initializeFactory(template).send(); +factoryContract.methods.initializeFactory(template).send() ``` # createExchange @@ -40,7 +40,7 @@ createExchange(token: address): address ## Web3 ```javascript -factoryContract.methods.createExchange(token).send(); +factoryContract.methods.createExchange(token).send() ``` # getExchange @@ -61,7 +61,7 @@ getExchange(token: address): address ``` ```javascript -factoryContract.methods.getExchange(token).call(); +factoryContract.methods.getExchange(token).call() ``` # getToken @@ -84,7 +84,7 @@ getToken(exchange: address): address ## Web3 ```javascript -factoryContract.methods.getToken(exchange).call(); +factoryContract.methods.getToken(exchange).call() ``` # getTokenWithId @@ -107,5 +107,5 @@ getTokenWithId(token_id: uint256): address ## Web3 ```javascript -factoryContract.methods.getTokenWithId(token_id).call(); +factoryContract.methods.getTokenWithId(token_id).call() ``` diff --git a/versioned_docs/version-V1/reference/02-exchange.md b/versioned_docs/version-V1/reference/02-exchange.md index 6db46ca94f..4d82ce0613 100644 --- a/versioned_docs/version-V1/reference/02-exchange.md +++ b/versioned_docs/version-V1/reference/02-exchange.md @@ -20,7 +20,7 @@ setup(token_addr: address): ```javascript // Can only be called by factory contract during createExchange() -exchangeContract.methods.setup((token: String)).send(); +exchangeContract.methods.setup((token: String)).send() ``` # addLiquidity @@ -50,9 +50,7 @@ addLiquidity( ## Web3 ```javascript -exchangeContract.methods - .addLiquidity(min_liquidity, max_tokens, deadline) - .send({ value: ethValue }); +exchangeContract.methods.addLiquidity(min_liquidity, max_tokens, deadline).send({ value: ethValue }) ``` # removeLiquidity @@ -83,9 +81,7 @@ removeLiquidity( ## Web3 ```javascript -exchangeContract.methods - .removeLiquidity(amount, min_eth, min_tokens, deadline) - .send(); +exchangeContract.methods.removeLiquidity(amount, min_eth, min_tokens, deadline).send() ``` # default @@ -105,7 +101,7 @@ __default__(): ## Web3 ```javascript -web3.eth.sendTransaction({ value: ethAmount }); +web3.eth.sendTransaction({ value: ethAmount }) ``` # ethToTokenSwapInput @@ -133,9 +129,7 @@ ethToTokenSwapInput( ## Web3 ```javascript -exchangeContract.methods - .ethToTokenSwapInput(min_liquidity, max_tokens, deadline) - .send({ value: ethValue }); +exchangeContract.methods.ethToTokenSwapInput(min_liquidity, max_tokens, deadline).send({ value: ethValue }) ``` # ethToTokenTransferInput @@ -167,7 +161,7 @@ ethToTokenTransferInput( ```javascript exchangeContract.methods .ethToTokenTransferInput(min_liquidity, max_tokens, deadline, recipient) - .send({ value: ethValue }); + .send({ value: ethValue }) ``` # ethToTokenSwapOutput @@ -195,9 +189,7 @@ ethToTokenSwapOutput( ## Web3 ```javascript -exchangeContract.methods - .ethToTokenSwapOutput(tokens_bought, deadline) - .send({ value: ethValue }); +exchangeContract.methods.ethToTokenSwapOutput(tokens_bought, deadline).send({ value: ethValue }) ``` # ethToTokenTransferOutput @@ -229,7 +221,7 @@ ethToTokenTransferOutput( ```javascript exchangeContract.methods .ethToTokenTransferOutput(tokens_bought, deadline, (recipient: String)) - .send({ value: ethValue }); + .send({ value: ethValue }) ``` # tokenToEthSwapInput @@ -257,9 +249,7 @@ tokenToEthSwapInput( ## Web3 ```javascript -exchangeContract.methods - .tokenToEthSwapInput(tokens_sold, min_eth, deadline) - .send(); +exchangeContract.methods.tokenToEthSwapInput(tokens_sold, min_eth, deadline).send() ``` # tokenToEthTransferInput @@ -289,9 +279,7 @@ tokenToEthTransferInput( ## Web3 ```javascript -exchangeContract.methods - .tokenToEthTransferInput(tokens_sold, min_eth, deadline, recipient) - .send(); +exchangeContract.methods.tokenToEthTransferInput(tokens_sold, min_eth, deadline, recipient).send() ``` # tokenToEthSwapOutput @@ -319,9 +307,7 @@ tokenToEthSwapOutput( ## Web3 ```javascript -exchangeContract.methods - .tokenToEthSwapOutput(eth_bought, max_tokens, (deadline: Integer)) - .send(); +exchangeContract.methods.tokenToEthSwapOutput(eth_bought, max_tokens, (deadline: Integer)).send() ``` # tokenToEthTransferOutput @@ -352,13 +338,8 @@ tokenToEthTransferOutput( ```javascript exchangeContract.methods - .tokenToEthTransferOutput( - eth_bought, - max_tokens, - (deadline: Integer), - (recipient: String) - ) - .send(); + .tokenToEthTransferOutput(eth_bought, max_tokens, (deadline: Integer), (recipient: String)) + .send() ``` # tokenToTokenSwapInput @@ -391,14 +372,8 @@ tokenToTokenSwapInput( ```javascript exchangeContract.methods - .tokenToTokenSwapInput( - tokens_sold, - min_tokens_bought, - min_eth_bought, - deadline, - token_addr - ) - .send(); + .tokenToTokenSwapInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, token_addr) + .send() ``` # tokenToTokenTransferInput @@ -433,15 +408,8 @@ tokenToTokenTransferInput( ```javascript exchangeContract.methods - .tokenToTokenTransferInput( - tokens_sold, - min_tokens_bought, - min_eth_bought, - deadline, - recipient, - token_addr - ) - .send(); + .tokenToTokenTransferInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, recipient, token_addr) + .send() ``` # tokenToTokenSwapOutput @@ -474,14 +442,8 @@ tokenToTokenSwapOutput( ```javascript exchangeContract.methods - .tokenToTokenSwapOutput( - tokens_bought, - max_tokens_sold, - max_eth_sold, - deadline, - token_addr - ) - .send(); + .tokenToTokenSwapOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, token_addr) + .send() ``` # tokenToTokenTransferOutput @@ -516,15 +478,8 @@ tokenToTokenTransferOutput( ```javascript exchangeContract.methods - .tokenToTokenTransferOutput( - tokens_bought, - max_tokens_sold, - max_eth_sold, - deadline, - recipient, - token_addr - ) - .send(); + .tokenToTokenTransferOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, recipient, token_addr) + .send() ``` # tokenToExchangeSwapInput @@ -557,14 +512,8 @@ tokenToTokenSwapInput( ```javascript exchangeContract.methods - .tokenToTokenSwapInput( - tokens_sold, - min_tokens_bought, - min_eth_bought, - deadline, - exchange_addr - ) - .send(); + .tokenToTokenSwapInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, exchange_addr) + .send() ``` # tokenToExchangeTransferInput @@ -599,15 +548,8 @@ tokenToExchangeTransferInput( ```javascript exchangeContract.methods - .tokenToExchangeTransferInput( - tokens_sold, - min_tokens_bought, - min_eth_bought, - deadline, - recipient, - exchange_addr - ) - .send(); + .tokenToExchangeTransferInput(tokens_sold, min_tokens_bought, min_eth_bought, deadline, recipient, exchange_addr) + .send() ``` # tokenToExchangeSwapOutput @@ -640,14 +582,8 @@ tokenToExchangeSwapOutput( ```javascript exchangeContract.methods - .tokenToExchangeSwapOutput( - tokens_bought, - max_tokens_sold, - max_eth_sold, - deadline, - exchange_addr - ) - .send(); + .tokenToExchangeSwapOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, exchange_addr) + .send() ``` # tokenToExchangeTransferOutput @@ -682,15 +618,8 @@ tokenToExchangeTransferOutput( ```javascript exchangeContract.methods - .tokenToExchangeTransferOutput( - tokens_bought, - max_tokens_sold, - max_eth_sold, - deadline, - recipient, - exchange_addr - ) - .send(); + .tokenToExchangeTransferOutput(tokens_bought, max_tokens_sold, max_eth_sold, deadline, recipient, exchange_addr) + .send() ``` # getEthToTokenInputPrice @@ -713,7 +642,7 @@ getEthToTokenInputPrice(eth_sold: uint256): uint256 ## Web3 ```javascript -exchangeContract.methods.getEthToTokenInputPrice(eth_sold).call(); +exchangeContract.methods.getEthToTokenInputPrice(eth_sold).call() ``` # getEthToTokenOutputPrice @@ -736,7 +665,7 @@ getEthToTokenOutputPrice(tokens_bought: uint256): uint256 ## Web3 ```javascript -exchangeContract.methods.getEthToTokenOutputPrice(tokens_bought).call(); +exchangeContract.methods.getEthToTokenOutputPrice(tokens_bought).call() ``` # getTokenToEthInputPrice @@ -759,7 +688,7 @@ getTokenToEthInputPrice(tokens_sold: uint256): uint256 ## Web3 ```javascript -exchangeContract.methods.getTokenToEthInputPrice(tokens_sold).call(); +exchangeContract.methods.getTokenToEthInputPrice(tokens_sold).call() ``` # getTokenToEthOutputPrice @@ -782,7 +711,7 @@ getTokenToEthOutputPrice(eth_bought: uint256): uint256 ## Web3 ```javascript -exchangeContract.methods.getTokenToEthOutputPrice(eth_bought).call(); +exchangeContract.methods.getTokenToEthOutputPrice(eth_bought).call() ``` # tokenAddress @@ -801,7 +730,7 @@ tokenAddress(): address ## Web3 ```javascript -exchangeContract.methods.tokenAddress().call(); +exchangeContract.methods.tokenAddress().call() ``` # factoryAddress @@ -820,7 +749,7 @@ factoryAddress(): address ## Web3 ```javascript -exchangeContract.methods.factoryAddress().call(); +exchangeContract.methods.factoryAddress().call() ``` # name @@ -840,7 +769,7 @@ name(): bytes32 // Uniswap V1 ## Web3 ```javascript -exchangeContract.methods.tokenAddress().call(); +exchangeContract.methods.tokenAddress().call() ``` # symbol @@ -860,7 +789,7 @@ symbol(): bytes32 // UNI-V1 ## Web3 ```javascript -exchangeContract.methods.tokenAddress().call(); +exchangeContract.methods.tokenAddress().call() ``` # decimals @@ -880,7 +809,7 @@ decimals(): uint256 // 18 ## Web3 ```javascript -exchangeContract.methods.decimals().call(); +exchangeContract.methods.decimals().call() ``` # balanceOf @@ -903,7 +832,7 @@ balanceOf(_owner: address): uint256 ## Web3 ```javascript -exchangeContract.methods.balanceOf(_owner).call(); +exchangeContract.methods.balanceOf(_owner).call() ``` # transfer @@ -929,7 +858,7 @@ transfer( ## Web3 ```javascript -exchangeContract.methods.transfer(_to, _value).send(); +exchangeContract.methods.transfer(_to, _value).send() ``` # transferFrom @@ -957,7 +886,7 @@ transferFrom( ## Web3 ```javascript -exchangeContract.methods.transferFrom(_from, _to, _value).send(); +exchangeContract.methods.transferFrom(_from, _to, _value).send() ``` # approve @@ -983,7 +912,7 @@ approve( ## Web3 ```javascript -exchangeContract.methods.approve(_spender, _value).send(); +exchangeContract.methods.approve(_spender, _value).send() ``` # allowance @@ -1009,5 +938,5 @@ allowance( ## Web3 ```javascript -exchangeContract.methods.allowance(_owner, _spender).call(); +exchangeContract.methods.allowance(_owner, _spender).call() ``` diff --git a/versioned_docs/version-V1/reference/_category_.json b/versioned_docs/version-V1/reference/_category_.json index 8ba984d3d8..d580e42255 100644 --- a/versioned_docs/version-V1/reference/_category_.json +++ b/versioned_docs/version-V1/reference/_category_.json @@ -1,6 +1,5 @@ { - "label": "Reference", - "position": 3, - "collapsed": false - - } \ No newline at end of file + "label": "Reference", + "position": 3, + "collapsed": false +} diff --git a/versioned_docs/version-V2/concepts/01-protocol-overview/_category_.json b/versioned_docs/version-V2/concepts/01-protocol-overview/_category_.json index 500865adae..a97597e120 100644 --- a/versioned_docs/version-V2/concepts/01-protocol-overview/_category_.json +++ b/versioned_docs/version-V2/concepts/01-protocol-overview/_category_.json @@ -1,4 +1,4 @@ { - "label": "Protocol Overview", - "position": 1 - } \ No newline at end of file + "label": "Protocol Overview", + "position": 1 +} diff --git a/versioned_docs/version-V2/concepts/02-core-concepts/_category_.json b/versioned_docs/version-V2/concepts/02-core-concepts/_category_.json index 7c4f400868..3a49cbeeb1 100644 --- a/versioned_docs/version-V2/concepts/02-core-concepts/_category_.json +++ b/versioned_docs/version-V2/concepts/02-core-concepts/_category_.json @@ -1,4 +1,4 @@ { - "label": "Core Concepts", - "position": 2 - } \ No newline at end of file + "label": "Core Concepts", + "position": 2 +} diff --git a/versioned_docs/version-V2/concepts/03-advanced-topics/_category_.json b/versioned_docs/version-V2/concepts/03-advanced-topics/_category_.json index 3778076ab0..321360c5fb 100644 --- a/versioned_docs/version-V2/concepts/03-advanced-topics/_category_.json +++ b/versioned_docs/version-V2/concepts/03-advanced-topics/_category_.json @@ -1,4 +1,4 @@ { - "label": "Advanced Topics", - "position": 3 - } \ No newline at end of file + "label": "Advanced Topics", + "position": 3 +} diff --git a/versioned_docs/version-V2/concepts/_category_.json b/versioned_docs/version-V2/concepts/_category_.json index 90ac9852be..74051d2113 100644 --- a/versioned_docs/version-V2/concepts/_category_.json +++ b/versioned_docs/version-V2/concepts/_category_.json @@ -1,6 +1,5 @@ { - "label": "Concepts", - "position": 1, - "collapsed": false - - } \ No newline at end of file + "label": "Concepts", + "position": 1, + "collapsed": false +} diff --git a/versioned_docs/version-V2/guides/_category_.json b/versioned_docs/version-V2/guides/_category_.json index 92fca5fc3e..bb10c2893b 100644 --- a/versioned_docs/version-V2/guides/_category_.json +++ b/versioned_docs/version-V2/guides/_category_.json @@ -1,6 +1,5 @@ { - "label": "Guides", - "position": 1, - "collapsed": false - - } \ No newline at end of file + "label": "Guides", + "position": 1, + "collapsed": false +} diff --git a/versioned_docs/version-V2/guides/interface-integration/01-using-the-api.md b/versioned_docs/version-V2/guides/interface-integration/01-using-the-api.md index 5d558de4e7..9657db4182 100644 --- a/versioned_docs/version-V2/guides/interface-integration/01-using-the-api.md +++ b/versioned_docs/version-V2/guides/interface-integration/01-using-the-api.md @@ -1,6 +1,6 @@ --- id: using-the-api -title: "Using the API" +title: 'Using the API' --- In this guide we will create a web interface that consumes and displays data from the Uniswap Subgraph. The goal is to provide a quick overview of a setup that you can extend to create your own UIs and analytics around Uniswap data. @@ -21,14 +21,14 @@ yarn start In your browser you should see the default React app running. In a text editor open `App.js` within `src` and replace the contents with this stripped down boilerplate. We'll add to this as we go. ```javascript -import React from "react"; -import "./App.css"; +import React from 'react' +import './App.css' function App() { - return
; + return
} -export default App; +export default App ``` ### Graphql Client @@ -38,44 +38,44 @@ We need to set up some middleware in order to make requests to the Uniswap subgr 1. Add the imports shown below and instantiate a new client instance. Notice how we use the link to the Uniswap subgraph here. ```javascript -import React from "react"; -import "./App.css"; -import { ApolloClient } from "apollo-client"; -import { InMemoryCache } from "apollo-cache-inmemory"; -import { HttpLink } from "apollo-link-http"; +import React from 'react' +import './App.css' +import { ApolloClient } from 'apollo-client' +import { InMemoryCache } from 'apollo-cache-inmemory' +import { HttpLink } from 'apollo-link-http' export const client = new ApolloClient({ link: new HttpLink({ - uri: "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2", + uri: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', }), cache: new InMemoryCache(), -}); +}) function App() { - return
; + return
} -export default App; +export default App ``` 2. We also need to add a context so that Apollo can handle requests properly. In your `index.js` file import the proper provider and wrap the root in it like this: ```javascript -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import registerServiceWorker from "./registerServiceWorker"; -import "./index.css"; -import { ApolloProvider } from "react-apollo"; -import { client } from "./App"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import registerServiceWorker from './registerServiceWorker' +import './index.css' +import { ApolloProvider } from 'react-apollo' +import { client } from './App' ReactDOM.render( , - document.getElementById("root") -); -registerServiceWorker(); + document.getElementById('root') +) +registerServiceWorker() ``` ### Writing the queries @@ -85,7 +85,7 @@ Next we'll construct our query and fetch data. For this example we will fetch so 1. First we need to define the query itself. We'll use `gql` to parse a query string into the GraphQL AST standard. Import the `gql` helper into the app and use it to create the query. Add the following to your `App.js` file: ```javascript -import gql from "graphql-tag"; +import gql from 'graphql-tag' const DAI_QUERY = gql` query tokens($tokenAddress: Bytes!) { @@ -94,7 +94,7 @@ const DAI_QUERY = gql` totalLiquidity } } -`; +` const ETH_PRICE_QUERY = gql` query ethPrice { @@ -102,7 +102,7 @@ const ETH_PRICE_QUERY = gql` ethPrice } } -`; +` ``` We use an id of `1` for the bundle because there is only one hardcoded bundle in the subgraph. @@ -112,18 +112,18 @@ We use an id of `1` for the bundle because there is only one hardcoded bundle in Now we're ready to use these queries to fetch data from the Uniswap V2 subgraph. To do this we can use the `useQuery` hook which uses our client instance to fetch data, and gives us live info about the status of the request. To do this add the following to your `App.js` file: ```javascript -import { useQuery } from "@apollo/react-hooks"; +import { useQuery } from '@apollo/react-hooks' -const { loading, error, data: ethPriceData } = useQuery(ETH_PRICE_QUERY); +const { loading, error, data: ethPriceData } = useQuery(ETH_PRICE_QUERY) const { loading: daiLoading, error: daiError, data: daiData, } = useQuery(DAI_QUERY, { variables: { - tokenAddress: "0x6b175474e89094c44da98b954eedeac495271d0f", + tokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f', }, -}); +}) ``` Notice we're using the Dai token address to fetch data about Dai. @@ -137,9 +137,9 @@ These queries will return a response object for each query. Within each one we'r Add the following lines to your `App.js` file to parse the responses: ```javascript -const daiPriceInEth = daiData && daiData.tokens[0].derivedETH; -const daiTotalLiquidity = daiData && daiData.tokens[0].totalLiquidity; -const ethPriceInUSD = ethPriceData && ethPriceData.bundles[0].ethPrice; +const daiPriceInEth = daiData && daiData.tokens[0].derivedETH +const daiTotalLiquidity = daiData && daiData.tokens[0].totalLiquidity +const ethPriceInUSD = ethPriceData && ethPriceData.bundles[0].ethPrice ``` ### Displaying in the UI @@ -156,22 +156,22 @@ To do this add the following lines in the return function of your `App.js` file: return (
- Dai price:{" "} + Dai price:{' '} {ethLoading || daiLoading - ? "Loading token data..." - : "$" + + ? 'Loading token data...' + : '$' + // parse responses as floats and fix to 2 decimals (parseFloat(daiPriceInEth) * parseFloat(ethPriceInUSD)).toFixed(2)}
- Dai total liquidity:{" "} + Dai total liquidity:{' '} {daiLoading - ? "Loading token data..." + ? 'Loading token data...' : // display the total amount of DAI spread across all pools parseFloat(daiTotalLiquidity).toFixed(0)}
-); +) ``` ### Next steps @@ -185,23 +185,23 @@ You can visit our [analytics site](https://uniswap.info/) to see a more advanced In the end your `App.js` file should look like this: ```javascript -import React, { useEffect } from "react"; -import "./App.css"; -import { ApolloClient } from "apollo-client"; -import { InMemoryCache } from "apollo-cache-inmemory"; -import { HttpLink } from "apollo-link-http"; -import { useQuery } from "@apollo/react-hooks"; -import gql from "graphql-tag"; +import React, { useEffect } from 'react' +import './App.css' +import { ApolloClient } from 'apollo-client' +import { InMemoryCache } from 'apollo-cache-inmemory' +import { HttpLink } from 'apollo-link-http' +import { useQuery } from '@apollo/react-hooks' +import gql from 'graphql-tag' export const client = new ApolloClient({ link: new HttpLink({ - uri: "https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2", + uri: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', }), fetchOptions: { - mode: "no-cors", + mode: 'no-cors', }, cache: new InMemoryCache(), -}); +}) const DAI_QUERY = gql` query tokens($tokenAddress: Bytes!) { @@ -210,7 +210,7 @@ const DAI_QUERY = gql` totalLiquidity } } -`; +` const ETH_PRICE_QUERY = gql` query bundles { @@ -218,40 +218,40 @@ const ETH_PRICE_QUERY = gql` ethPrice } } -`; +` function App() { - const { loading: ethLoading, data: ethPriceData } = useQuery(ETH_PRICE_QUERY); + const { loading: ethLoading, data: ethPriceData } = useQuery(ETH_PRICE_QUERY) const { loading: daiLoading, data: daiData } = useQuery(DAI_QUERY, { variables: { - tokenAddress: "0x6b175474e89094c44da98b954eedeac495271d0f", + tokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f', }, - }); + }) - const daiPriceInEth = daiData && daiData.tokens[0].derivedETH; - const daiTotalLiquidity = daiData && daiData.tokens[0].totalLiquidity; - const ethPriceInUSD = ethPriceData && ethPriceData.bundles[0].ethPrice; + const daiPriceInEth = daiData && daiData.tokens[0].derivedETH + const daiTotalLiquidity = daiData && daiData.tokens[0].totalLiquidity + const ethPriceInUSD = ethPriceData && ethPriceData.bundles[0].ethPrice return (
- Dai price:{" "} + Dai price:{' '} {ethLoading || daiLoading - ? "Loading token data..." - : "$" + + ? 'Loading token data...' + : '$' + // parse responses as floats and fix to 2 decimals (parseFloat(daiPriceInEth) * parseFloat(ethPriceInUSD)).toFixed(2)}
- Dai total liquidity:{" "} + Dai total liquidity:{' '} {daiLoading - ? "Loading token data..." + ? 'Loading token data...' : // display the total amount of DAI spread across all pools parseFloat(daiTotalLiquidity).toFixed(0)}
- ); + ) } -export default App; +export default App ``` diff --git a/versioned_docs/version-V2/guides/interface-integration/_category_.json b/versioned_docs/version-V2/guides/interface-integration/_category_.json index 0e128e94c0..9c58146207 100644 --- a/versioned_docs/version-V2/guides/interface-integration/_category_.json +++ b/versioned_docs/version-V2/guides/interface-integration/_category_.json @@ -1,4 +1,4 @@ { - "label": "Interface Integration", - "position": 1 - } \ No newline at end of file + "label": "Interface Integration", + "position": 1 +} diff --git a/versioned_docs/version-V2/guides/smart-contract-integration/01-quick-start.md b/versioned_docs/version-V2/guides/smart-contract-integration/01-quick-start.md index 90071c8302..b101105333 100644 --- a/versioned_docs/version-V2/guides/smart-contract-integration/01-quick-start.md +++ b/versioned_docs/version-V2/guides/smart-contract-integration/01-quick-start.md @@ -186,8 +186,7 @@ to compute the pair address. To get the bytecode for deploying UniswapV2Factory, you can import the file via: ```javascript -const UniswapV2FactoryBytecode = - require("@uniswap/v2-core/build/UniswapV2Factory.json").bytecode; +const UniswapV2FactoryBytecode = require('@uniswap/v2-core/build/UniswapV2Factory.json').bytecode ``` We recommend using a standard ERC20 from `@openzeppelin/contracts` for deploying an ERC20. diff --git a/versioned_docs/version-V2/guides/smart-contract-integration/_category_.json b/versioned_docs/version-V2/guides/smart-contract-integration/_category_.json index 5202e2f056..534f3828fb 100644 --- a/versioned_docs/version-V2/guides/smart-contract-integration/_category_.json +++ b/versioned_docs/version-V2/guides/smart-contract-integration/_category_.json @@ -1,4 +1,4 @@ { - "label": "Smart Contract Integration", - "position": 3 - } \ No newline at end of file + "label": "Smart Contract Integration", + "position": 3 +} diff --git a/versioned_docs/version-V2/reference/API/_category_.json b/versioned_docs/version-V2/reference/API/_category_.json index eebb9f5779..a1e3abeaca 100644 --- a/versioned_docs/version-V2/reference/API/_category_.json +++ b/versioned_docs/version-V2/reference/API/_category_.json @@ -1,4 +1,4 @@ { - "label": "API", - "position": 1 - } \ No newline at end of file + "label": "API", + "position": 1 +} diff --git a/versioned_docs/version-V2/reference/Governance/_category_.json b/versioned_docs/version-V2/reference/Governance/_category_.json index 394002fe20..717c67daf3 100644 --- a/versioned_docs/version-V2/reference/Governance/_category_.json +++ b/versioned_docs/version-V2/reference/Governance/_category_.json @@ -1,4 +1,4 @@ { - "label": "Governance", - "position": 2 - } \ No newline at end of file + "label": "Governance", + "position": 2 +} diff --git a/versioned_docs/version-V2/reference/_category_.json b/versioned_docs/version-V2/reference/_category_.json index 911142b753..f9ee8b198e 100644 --- a/versioned_docs/version-V2/reference/_category_.json +++ b/versioned_docs/version-V2/reference/_category_.json @@ -1,6 +1,5 @@ { - "label": "Technical Reference", - "position": 4, - "collapsed": false - - } \ No newline at end of file + "label": "Technical Reference", + "position": 4, + "collapsed": false +} diff --git a/versioned_docs/version-V2/reference/smart-contracts/01-factory.md b/versioned_docs/version-V2/reference/smart-contracts/01-factory.md index 1523f8f11c..39cfbe672c 100644 --- a/versioned_docs/version-V2/reference/smart-contracts/01-factory.md +++ b/versioned_docs/version-V2/reference/smart-contracts/01-factory.md @@ -112,7 +112,7 @@ interface IUniswapV2Factory { # ABI ```typescript -import IUniswapV2Factory from "@uniswap/v2-core/build/IUniswapV2Factory.json"; +import IUniswapV2Factory from '@uniswap/v2-core/build/IUniswapV2Factory.json' ``` [https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2Factory.json](https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2Factory.json) diff --git a/versioned_docs/version-V2/reference/smart-contracts/02-pair.md b/versioned_docs/version-V2/reference/smart-contracts/02-pair.md index 3684fe1566..472c08a995 100644 --- a/versioned_docs/version-V2/reference/smart-contracts/02-pair.md +++ b/versioned_docs/version-V2/reference/smart-contracts/02-pair.md @@ -232,7 +232,7 @@ interface IUniswapV2Pair { # ABI ```typescript -import IUniswapV2Pair from "@uniswap/v2-core/build/IUniswapV2Pair.json"; +import IUniswapV2Pair from '@uniswap/v2-core/build/IUniswapV2Pair.json' ``` [https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2Pair.json](https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2Pair.json) diff --git a/versioned_docs/version-V2/reference/smart-contracts/03-pair-erc-20.md b/versioned_docs/version-V2/reference/smart-contracts/03-pair-erc-20.md index 31103c7268..af7fbd04bd 100644 --- a/versioned_docs/version-V2/reference/smart-contracts/03-pair-erc-20.md +++ b/versioned_docs/version-V2/reference/smart-contracts/03-pair-erc-20.md @@ -180,7 +180,7 @@ interface IUniswapV2ERC20 { # ABI ```typescript -import IUniswapV2ERC20 from "@uniswap/v2-core/build/IUniswapV2ERC20.json"; +import IUniswapV2ERC20 from '@uniswap/v2-core/build/IUniswapV2ERC20.json' ``` [https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2ERC20.json](https://unpkg.com/@uniswap/v2-core@1.0.0/build/IUniswapV2ERC20.json) diff --git a/versioned_docs/version-V2/reference/smart-contracts/05-router01.md b/versioned_docs/version-V2/reference/smart-contracts/05-router01.md index 2ec69cbcc4..9ed402c9ac 100644 --- a/versioned_docs/version-V2/reference/smart-contracts/05-router01.md +++ b/versioned_docs/version-V2/reference/smart-contracts/05-router01.md @@ -506,7 +506,7 @@ interface IUniswapV2Router01 { # ABI ```typescript -import IUniswapV2Router01 from "@uniswap/v2-periphery/build/IUniswapV2Router01.json"; +import IUniswapV2Router01 from '@uniswap/v2-periphery/build/IUniswapV2Router01.json' ``` [https://unpkg.com/@uniswap/v2-periphery@1.0.0-beta.0/build/IUniswapV2Router01.json](https://unpkg.com/@uniswap/v2-periphery@1.0.0-beta.0/build/IUniswapV2Router01.json) diff --git a/versioned_docs/version-V2/reference/smart-contracts/06-router02.md b/versioned_docs/version-V2/reference/smart-contracts/06-router02.md index f8b36ce182..5c07b7b886 100644 --- a/versioned_docs/version-V2/reference/smart-contracts/06-router02.md +++ b/versioned_docs/version-V2/reference/smart-contracts/06-router02.md @@ -675,7 +675,7 @@ interface IUniswapV2Router02 is IUniswapV2Router01 { # ABI ```typescript -import IUniswapV2Router02 from "@uniswap/v2-periphery/build/IUniswapV2Router02.json"; +import IUniswapV2Router02 from '@uniswap/v2-periphery/build/IUniswapV2Router02.json' ``` [https://unpkg.com/@uniswap/v2-periphery@1.1.0-beta.0/build/IUniswapV2Router02.json](https://unpkg.com/@uniswap/v2-periphery@1.1.0-beta.0/build/IUniswapV2Router02.json) diff --git a/versioned_docs/version-V2/reference/smart-contracts/_category_.json b/versioned_docs/version-V2/reference/smart-contracts/_category_.json index d675350d59..f7e489705d 100644 --- a/versioned_docs/version-V2/reference/smart-contracts/_category_.json +++ b/versioned_docs/version-V2/reference/smart-contracts/_category_.json @@ -1,4 +1,4 @@ { - "label": "Smart Contracts", - "position": 4 - } \ No newline at end of file + "label": "Smart Contracts", + "position": 4 +} diff --git a/versioned_docs/version-V3/concepts/V3-overview/_category_.json b/versioned_docs/version-V3/concepts/V3-overview/_category_.json index cc8216e2ce..e224ed81cd 100644 --- a/versioned_docs/version-V3/concepts/V3-overview/_category_.json +++ b/versioned_docs/version-V3/concepts/V3-overview/_category_.json @@ -1,4 +1,4 @@ { - "label": "Overview", - "position": 1 - } \ No newline at end of file + "label": "Overview", + "position": 1 +} diff --git a/versioned_docs/version-V3/concepts/_category_.json b/versioned_docs/version-V3/concepts/_category_.json index 97186a4a8a..74b831d116 100644 --- a/versioned_docs/version-V3/concepts/_category_.json +++ b/versioned_docs/version-V3/concepts/_category_.json @@ -1,6 +1,5 @@ { - "label": "Concepts", - "position": 2, - "collapsed": false - - } \ No newline at end of file + "label": "Concepts", + "position": 2, + "collapsed": false +} diff --git a/versioned_docs/version-V3/concepts/advanced/_category_.json b/versioned_docs/version-V3/concepts/advanced/_category_.json index 635fc9c068..dd1c52f2ee 100644 --- a/versioned_docs/version-V3/concepts/advanced/_category_.json +++ b/versioned_docs/version-V3/concepts/advanced/_category_.json @@ -1,4 +1,4 @@ { - "label": "Advanced", - "position": 3 - } \ No newline at end of file + "label": "Advanced", + "position": 3 +} diff --git a/versioned_docs/version-V3/concepts/advanced/integration-issues.md b/versioned_docs/version-V3/concepts/advanced/integration-issues.md index 67c90e7a5b..edc09d1556 100644 --- a/versioned_docs/version-V3/concepts/advanced/integration-issues.md +++ b/versioned_docs/version-V3/concepts/advanced/integration-issues.md @@ -5,10 +5,10 @@ title: Token Integration Issues Fee-on-transfer and rebasing tokens will not function correctly on v3. -## Fee-on-transfer Tokens +## 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. +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. ## 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. \ No newline at end of file +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. diff --git a/versioned_docs/version-V3/concepts/governance/01-overview.md b/versioned_docs/version-V3/concepts/governance/01-overview.md index 5d47cdd353..33b0c24a6c 100644 --- a/versioned_docs/version-V3/concepts/governance/01-overview.md +++ b/versioned_docs/version-V3/concepts/governance/01-overview.md @@ -18,7 +18,7 @@ For reference material on the Uniswap Governance system please see [Governance R ### ABI ```typescript -import Uni from "@uniswap/governance/build/Uni.json"; +import Uni from '@uniswap/governance/build/Uni.json' ``` [https://unpkg.com/@uniswap/governance@1.0.2/build/Uni.json](https://unpkg.com/@uniswap/governance@1.0.2/build/Uni.json) @@ -30,7 +30,7 @@ import Uni from "@uniswap/governance/build/Uni.json"; ### ABI ```typescript -import Timelock from "@uniswap/governance/build/Timelock.json"; +import Timelock from '@uniswap/governance/build/Timelock.json' ``` [https://unpkg.com/@uniswap/governance@1.0.2/build/Timelock.json](https://unpkg.com/@uniswap/governance@1.0.2/build/Timelock.json) @@ -46,7 +46,7 @@ The `GovernorAlpha` ABI is viewable on [Etherscan](https://etherscan.io/address/ [https://unpkg.com/@uniswap/governance@1.0.2/build/GovernorAlpha.json](https://unpkg.com/@uniswap/governance@1.0.2/build/GovernorAlpha.json) ```typescript -import GovernorAlpha from "@uniswap/governance/build/GovernorAlpha.json"; +import GovernorAlpha from '@uniswap/governance/build/GovernorAlpha.json' ``` ## GovernorAlpha v2 (Deprecated) @@ -76,19 +76,19 @@ The staking rewards factory address is `0x3032Ab3Fa8C01d786D29dAdE018d7f2017918e The four staking rewards addresses are: ```js -0x6c3e4cb2e96b01f4b866965a91ed4437839a121a; -0x7fba4b8dc5e7616e59622806932dbea72537a56b; -0xa1484c3aa22a66c62b77e0ae78e15258bd0cb711; -0xca35e32e7926b96a9988f61d510e038108d8068e; +0x6c3e4cb2e96b01f4b866965a91ed4437839a121a +0x7fba4b8dc5e7616e59622806932dbea72537a56b +0xa1484c3aa22a66c62b77e0ae78e15258bd0cb711 +0xca35e32e7926b96a9988f61d510e038108d8068e ``` The four year-long vesting contract addresses are: ```js -0x4750c43867ef5f89869132eccf19b9b6c4286e1a; -0xe3953d9d317b834592ab58ab2c7a6ad22b54075d; -0x4b4e140d1f131fdad6fb59c13af796fd194e4135; -0x3d30b1ab88d487b0f3061f40de76845bec3f1e94; +0x4750c43867ef5f89869132eccf19b9b6c4286e1a +0xe3953d9d317b834592ab58ab2c7a6ad22b54075d +0x4b4e140d1f131fdad6fb59c13af796fd194e4135 +0x3d30b1ab88d487b0f3061f40de76845bec3f1e94 ``` The `feeToSetterVester` address is `0x18e433c7Bf8A2E1d0197CE5d8f9AFAda1A771360`. diff --git a/versioned_docs/version-V3/concepts/governance/07-changelog.md b/versioned_docs/version-V3/concepts/governance/07-changelog.md index 0d49fa00fa..b7438578e3 100644 --- a/versioned_docs/version-V3/concepts/governance/07-changelog.md +++ b/versioned_docs/version-V3/concepts/governance/07-changelog.md @@ -3,7 +3,7 @@ id: changelog title: Changelog --- -| Date | Abstract | Transaction | Sybil Reference | -|-----------------|----------------------------------------------------------|--------------------------------------------------------------------|-----------------------------------------| +| Date | Abstract | Transaction | Sybil Reference | +| --------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------- | | June 12, 2021 | Reduce the UNI proposal submission threshold to 2.5M | [Etherscan](https://etherscan.io/tx/0xacda6ebe63dfc2b34a8b3e3f6297a424e4cf25cd68add6613f902099bd7432e4) | https://sybil.org/#/proposals/uniswap/4 | -| August 26, 2021 | Upgrade Governance Contract to Compound's Governor Bravo | [Etherscan](https://etherscan.io/tx/0x505870232ebd6cefd2a59c760924664212f72759e58fd2df82d61b67ffe0dd75) | https://sybil.org/#/proposals/uniswap/8 | \ No newline at end of file +| August 26, 2021 | Upgrade Governance Contract to Compound's Governor Bravo | [Etherscan](https://etherscan.io/tx/0x505870232ebd6cefd2a59c760924664212f72759e58fd2df82d61b67ffe0dd75) | https://sybil.org/#/proposals/uniswap/8 | diff --git a/versioned_docs/version-V3/concepts/governance/_category_.json b/versioned_docs/version-V3/concepts/governance/_category_.json index ca9dd4b3b7..1b5253115c 100644 --- a/versioned_docs/version-V3/concepts/governance/_category_.json +++ b/versioned_docs/version-V3/concepts/governance/_category_.json @@ -1,4 +1,4 @@ { - "label": "Governance", - "position": 4 - } \ No newline at end of file + "label": "Governance", + "position": 4 +} diff --git a/versioned_docs/version-V3/guides/_category_.json b/versioned_docs/version-V3/guides/_category_.json index 7ff44c4ec8..680904649f 100644 --- a/versioned_docs/version-V3/guides/_category_.json +++ b/versioned_docs/version-V3/guides/_category_.json @@ -1,5 +1,5 @@ { - "label": "Guides", - "position": 3, - "collapsed": false - } \ No newline at end of file + "label": "Guides", + "position": 3, + "collapsed": false +} diff --git a/versioned_docs/version-V3/guides/flash-integrations/_category_.json b/versioned_docs/version-V3/guides/flash-integrations/_category_.json index 2310955b98..2232324309 100644 --- a/versioned_docs/version-V3/guides/flash-integrations/_category_.json +++ b/versioned_docs/version-V3/guides/flash-integrations/_category_.json @@ -1,4 +1,4 @@ { - "label": "Implement Flash Swaps", - "position": 3 - } + "label": "Implement Flash Swaps", + "position": 3 +} diff --git a/versioned_docs/version-V3/guides/liquidity-mining/_category_.json b/versioned_docs/version-V3/guides/liquidity-mining/_category_.json index bab8b298e9..e61434ae7f 100644 --- a/versioned_docs/version-V3/guides/liquidity-mining/_category_.json +++ b/versioned_docs/version-V3/guides/liquidity-mining/_category_.json @@ -1,5 +1,5 @@ { - "label": "Liquidity Mining", - "position": 1, - "collapsed": true - } \ No newline at end of file + "label": "Liquidity Mining", + "position": 1, + "collapsed": true +} diff --git a/versioned_docs/version-V3/guides/local-environment.md b/versioned_docs/version-V3/guides/local-environment.md index 91607ef70c..d383f6f2d5 100644 --- a/versioned_docs/version-V3/guides/local-environment.md +++ b/versioned_docs/version-V3/guides/local-environment.md @@ -8,7 +8,6 @@ This guide describes how to set up your environment using a specific toolset: `N Once you have set up your environment, read the guides on liquidity mining, implementing swaps, and so on, which provide example contracts for those interactions. - ## Create a Node.js Project 1. Download and install [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). @@ -50,8 +49,8 @@ For this example, we'll need to change ./hardhat.config.js to include the approp * @type import('hardhat/config').HardhatUserConfig */ module.exports = { - solidity: "0.7.6", -}; + solidity: '0.7.6', +} ``` ## Compile a Contract diff --git a/versioned_docs/version-V3/guides/providing-liquidity/_category_.json b/versioned_docs/version-V3/guides/providing-liquidity/_category_.json index 2fea11062a..9bff5d8e4a 100644 --- a/versioned_docs/version-V3/guides/providing-liquidity/_category_.json +++ b/versioned_docs/version-V3/guides/providing-liquidity/_category_.json @@ -1,4 +1,4 @@ { - "label": "Providing Liquidity", - "position": 2 - } + "label": "Providing Liquidity", + "position": 2 +} diff --git a/versioned_docs/version-V3/guides/providing-liquidity/decrease-liquidity.md b/versioned_docs/version-V3/guides/providing-liquidity/decrease-liquidity.md index 2ee62d9009..9696f43e1f 100644 --- a/versioned_docs/version-V3/guides/providing-liquidity/decrease-liquidity.md +++ b/versioned_docs/version-V3/guides/providing-liquidity/decrease-liquidity.md @@ -7,8 +7,8 @@ sidebar_position: 4 Make sure to go through the [Setting Up Your Contract](./setting-up-your-contract.md) before continuing to this section Here we decrease the liquidity of our position without withdrawing all of it. - -- This example assumes the contract already has possession of the position NFT, and requires the calling address to be the same address that deposited the position NFT to our contract. + +- This example assumes the contract already has possession of the position NFT, and requires the calling address to be the same address that deposited the position NFT to our contract. - In production, `amount0Min` and `amount1Min` should be adjusted to create slippage protections. diff --git a/versioned_docs/version-V3/guides/providing-liquidity/increase-liquidity.md b/versioned_docs/version-V3/guides/providing-liquidity/increase-liquidity.md index 8b1c816791..b3e358c5ea 100644 --- a/versioned_docs/version-V3/guides/providing-liquidity/increase-liquidity.md +++ b/versioned_docs/version-V3/guides/providing-liquidity/increase-liquidity.md @@ -11,7 +11,6 @@ Make sure to go through the [first guide](./setting-up-your-contract.md) before - This example assumes the contract already has custody of the NFT. - We cannot change the boundaries of a given liquidity position using the Uniswap v3 protocol; `increaseLiquidity` can only increase the liquidity of a position. - - In production, `amount0Min` and `amount1Min` should be adjusted to create slippage protections. ```solidity diff --git a/versioned_docs/version-V3/guides/providing-liquidity/the-full-contract.md b/versioned_docs/version-V3/guides/providing-liquidity/the-full-contract.md index 31dcd851de..db448a8df3 100644 --- a/versioned_docs/version-V3/guides/providing-liquidity/the-full-contract.md +++ b/versioned_docs/version-V3/guides/providing-liquidity/the-full-contract.md @@ -6,7 +6,6 @@ sidebar_position: 6 Below we have the complete functioning code example: a contract that can custody Uniswap V3 position NFT's and manipulate the positions and liquidity therein by collecting fees, increasing or decreasing liquidity, and minting new positions. View on github [here](https://github.com/Uniswap/uniswap-docs/blob/main/smart_contract_examples/LiquidityExamples.sol). - ```solidity // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; @@ -67,7 +66,7 @@ contract LiquidityExamples is IERC721Receiver { deposits[tokenId] = Deposit({owner: owner, liquidity: liquidity, token0: token0, token1: token1}); } - /// @notice Calls the mint function defined in periphery, mints the same amount of each token. + /// @notice Calls the mint function defined in periphery, mints the same amount of each token. /// For this example we are providing 1000 DAI and 1000 USDC in liquidity /// @return tokenId The id of the newly minted ERC721 /// @return liquidity The amount of liquidity for the position @@ -198,7 +197,7 @@ contract LiquidityExamples is IERC721Receiver { uint256 amount0, uint256 amount1 ) { - + TransferHelper.safeTransferFrom(deposits[tokenId].token0, msg.sender, address(this), amountAdd0); TransferHelper.safeTransferFrom(deposits[tokenId].token1, msg.sender, address(this), amountAdd1); diff --git a/versioned_docs/version-V3/guides/swaps/_category_.json b/versioned_docs/version-V3/guides/swaps/_category_.json index 87b5f7614c..bae2cd5c4d 100644 --- a/versioned_docs/version-V3/guides/swaps/_category_.json +++ b/versioned_docs/version-V3/guides/swaps/_category_.json @@ -1,5 +1,5 @@ { - "label": "Implement A Swap", - "position": 1, - "collapsed": true - } \ No newline at end of file + "label": "Implement A Swap", + "position": 1, + "collapsed": true +} diff --git a/versioned_docs/version-V3/guides/swaps/multihop-swaps.md b/versioned_docs/version-V3/guides/swaps/multihop-swaps.md index 5dc249d609..35e4dad76d 100644 --- a/versioned_docs/version-V3/guides/swaps/multihop-swaps.md +++ b/versioned_docs/version-V3/guides/swaps/multihop-swaps.md @@ -108,7 +108,7 @@ An exact output swap will swap a variable amount of the input token for a fixed - `path`: The path is a sequence of `tokenAddress` `Fee` `tokenAddress`, _encoded in reverse order_, which are the variables needed to compute each pool contract address in our sequence of swaps. The multihop swap router code will automatically find the correct pool with these variables, and execute the swap needed within each pool in our sequence. - `recipient`: the destination address of the outbound asset. - `deadline`: the unix time after which a transaction will be reverted, to protect against long delays and the increased chance of large price swings therein. -- `amountOut`: The desired amount of WETH9. +- `amountOut`: The desired amount of WETH9. - `amountInMaximum`: The maximum amount of DAI willing to be swapped for the specified amountOut of WETH9. ### Calling the function diff --git a/versioned_docs/version-V3/guides/swaps/single-swaps.md b/versioned_docs/version-V3/guides/swaps/single-swaps.md index aa8c272143..8b6f1aa7b8 100644 --- a/versioned_docs/version-V3/guides/swaps/single-swaps.md +++ b/versioned_docs/version-V3/guides/swaps/single-swaps.md @@ -17,7 +17,7 @@ For simplification, the example hardcodes the token contract addresses, but as e When trading from a smart contract, the most important thing to keep in mind is that access to an external price source is required. Without this, trades can be frontrun for considerable loss. -**Note:** The swap examples are not production ready code, and are implemented in a simplistic manner for the purpose of learning. +**Note:** The swap examples are not production ready code, and are implemented in a simplistic manner for the purpose of learning. ## Set Up the Contract diff --git a/versioned_docs/version-V3/reference/Deployments.md b/versioned_docs/version-V3/reference/Deployments.md index d86b3623c0..9da1fae90c 100644 --- a/versioned_docs/version-V3/reference/Deployments.md +++ b/versioned_docs/version-V3/reference/Deployments.md @@ -5,7 +5,7 @@ title: Deployment Addresses # Uniswap Contract Deployments -The latest version of `@uniswap/v3-core`, `@uniswap/v3-periphery`, `@uniswap/swap-router-contracts`, and `@uniswap/v3-staker` are deployed at the addresses listed below. They are deployed at the same address on Ethereum mainnet, Optimism, Arbitrum, Polygon, and all testnets. +The latest version of `@uniswap/v3-core`, `@uniswap/v3-periphery`, `@uniswap/swap-router-contracts`, and `@uniswap/v3-staker` are deployed at the addresses listed below. They are deployed at the same address on Ethereum mainnet, Optimism, Arbitrum, Polygon, and all testnets. These addresses are final and were deployed from these npm package versions: @@ -22,13 +22,13 @@ These addresses are final and were deployed from these npm package versions: | TickLens | `0xbfd8137f7d1516D3ea5cA83523914859ec47F573` | https://github.com/Uniswap/uniswap-v3-periphery/blob/v1.0.0/contracts/lens/TickLens.sol | | Quoter | `0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6` | https://github.com/Uniswap/uniswap-v3-periphery/blob/v1.0.0/contracts/lens/Quoter.sol | | SwapRouter | `0xE592427A0AEce92De3Edee1F18E0157C05861564` | https://github.com/Uniswap/uniswap-v3-periphery/blob/v1.0.0/contracts/SwapRouter.sol | -| SwapRouter02 (1.1.0) | `0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45` | https://github.com/Uniswap/swap-router-contracts/blob/v1.1.0/contracts/SwapRouter02.sol | +| SwapRouter02 (1.1.0) | `0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45` | https://github.com/Uniswap/swap-router-contracts/blob/v1.1.0/contracts/SwapRouter02.sol | | NFTDescriptor | `0x42B24A95702b9986e82d421cC3568932790A48Ec` | https://github.com/Uniswap/uniswap-v3-periphery/blob/v1.0.0/contracts/libraries/NFTDescriptor.sol | | NonfungibleTokenPositionDescriptor | `0x91ae842A5Ffd8d12023116943e72A606179294f3` | https://github.com/Uniswap/uniswap-v3-periphery/blob/v1.0.0/contracts/NonfungibleTokenPositionDescriptor.sol | | TransparentUpgradeableProxy | `0xEe6A57eC80ea46401049E92587E52f5Ec1c24785` | https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.1-solc-0.7-2/contracts/proxy/TransparentUpgradeableProxy.sol | | NonfungiblePositionManager | `0xC36442b4a4522E871399CD717aBDD847Ab11FE88` | https://github.com/Uniswap/uniswap-v3-periphery/blob/v1.0.0/contracts/NonfungiblePositionManager.sol | | V3Migrator | `0xA5644E29708357803b5A882D272c41cC0dF92B34` | https://github.com/Uniswap/uniswap-v3-periphery/blob/v1.0.0/contracts/V3Migrator.sol | -| UniswapV3Staker (1.0.2) | `0xe34139463bA50bD61336E0c446Bd8C0867c6fE65` | https://github.com/Uniswap/v3-staker/blob/v1.0.2/contracts/UniswapV3Staker.sol | +| UniswapV3Staker (1.0.2) | `0xe34139463bA50bD61336E0c446Bd8C0867c6fE65` | https://github.com/Uniswap/v3-staker/blob/v1.0.2/contracts/UniswapV3Staker.sol | # Uniswap Pool Deployments @@ -44,16 +44,16 @@ getPool("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0xc02aaa39b223fe8d0a0e5c4 The Uniswap Protocol supports trading of ERC20 tokens. In order to swap a native asset like ETH (or MATIC on Polygon), the Uniswap protocol wraps these assets in an ERC20 wrapped native token contract. The protocol uses the following WETH9 addresses on Ethereum and WMATIC addresses on Polygon. -| Network | ChainId | Wrapped Native Token | Address | -|------------------|-----------|----------------------|----------------------------------------------| -| Ethereum | `1` | WETH | `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2` | -| Ropsten | `3` | WETH | `0xc778417E063141139Fce010982780140Aa0cD5Ab` | -| Rinkeby | `4` | WETH | `0xc778417E063141139Fce010982780140Aa0cD5Ab` | -| Goerli | `5` | WETH | `0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6` | -| Kovan | `42` | WETH | `0xd0A1E359811322d97991E03f863a0C30C2cF029C` | -| Optimism | `10` | WETH | `0x4200000000000000000000000000000000000006` | -| Optimistic Kovan | `69` | WETH | `0x4200000000000000000000000000000000000006` | -| Arbitrum One | `42161` | WETH | `0x82aF49447D8a07e3bd95BD0d56f35241523fBab1` | -| Arbitrum Rinkeby | `421611` | WETH | `0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681` | -| Polygon | `137` | WMATIC | `0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270` | -| Polygon Mumbai | `80001` | WMATIC | `0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889` | +| Network | ChainId | Wrapped Native Token | Address | +| ---------------- | -------- | -------------------- | -------------------------------------------- | +| Ethereum | `1` | WETH | `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2` | +| Ropsten | `3` | WETH | `0xc778417E063141139Fce010982780140Aa0cD5Ab` | +| Rinkeby | `4` | WETH | `0xc778417E063141139Fce010982780140Aa0cD5Ab` | +| Goerli | `5` | WETH | `0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6` | +| Kovan | `42` | WETH | `0xd0A1E359811322d97991E03f863a0C30C2cF029C` | +| Optimism | `10` | WETH | `0x4200000000000000000000000000000000000006` | +| Optimistic Kovan | `69` | WETH | `0x4200000000000000000000000000000000000006` | +| Arbitrum One | `42161` | WETH | `0x82aF49447D8a07e3bd95BD0d56f35241523fBab1` | +| Arbitrum Rinkeby | `421611` | WETH | `0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681` | +| Polygon | `137` | WMATIC | `0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270` | +| Polygon Mumbai | `80001` | WMATIC | `0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889` | diff --git a/versioned_docs/version-V3/reference/Governance/_category_.json b/versioned_docs/version-V3/reference/Governance/_category_.json index 394002fe20..717c67daf3 100644 --- a/versioned_docs/version-V3/reference/Governance/_category_.json +++ b/versioned_docs/version-V3/reference/Governance/_category_.json @@ -1,4 +1,4 @@ { - "label": "Governance", - "position": 2 - } \ No newline at end of file + "label": "Governance", + "position": 2 +} diff --git a/versioned_docs/version-V3/reference/_category_.json b/versioned_docs/version-V3/reference/_category_.json index bf05024cf4..f9ee8b198e 100644 --- a/versioned_docs/version-V3/reference/_category_.json +++ b/versioned_docs/version-V3/reference/_category_.json @@ -1,5 +1,5 @@ { - "label": "Technical Reference", - "position": 4, - "collapsed": false - } \ No newline at end of file + "label": "Technical Reference", + "position": 4, + "collapsed": false +} diff --git a/versioned_docs/version-V3/reference/core/UniswapV3Pool.md b/versioned_docs/version-V3/reference/core/UniswapV3Pool.md index 241d61b17f..41b051e6e3 100644 --- a/versioned_docs/version-V3/reference/core/UniswapV3Pool.md +++ b/versioned_docs/version-V3/reference/core/UniswapV3Pool.md @@ -223,15 +223,13 @@ The caller of this method receives a callback in the form of IUniswapV3SwapCallb #### Parameters: -| 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 | - - +| 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: diff --git a/versioned_docs/version-V3/reference/core/UniswapV3PoolDeployer.md b/versioned_docs/version-V3/reference/core/UniswapV3PoolDeployer.md index 39292aad3e..1fbc3535c4 100644 --- a/versioned_docs/version-V3/reference/core/UniswapV3PoolDeployer.md +++ b/versioned_docs/version-V3/reference/core/UniswapV3PoolDeployer.md @@ -1,8 +1,7 @@ - - - ## Functions + ### deploy + ```solidity function deploy( address factory, @@ -17,11 +16,11 @@ Deploys a pool with the given parameters by transiently setting the parameters s clearing it after deploying the pool. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`factory` | address | The contract address of the Uniswap 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 +| Name | Type | Description | +| :------------ | :------ | :-------------------------------------------------------------------------------- | +| `factory` | address | The contract address of the Uniswap 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 | diff --git a/versioned_docs/version-V3/reference/core/_category_.json b/versioned_docs/version-V3/reference/core/_category_.json index 3259dc0a86..bae4c68460 100644 --- a/versioned_docs/version-V3/reference/core/_category_.json +++ b/versioned_docs/version-V3/reference/core/_category_.json @@ -1,4 +1,4 @@ { - "label": "Core", - "position": 2 - } \ No newline at end of file + "label": "Core", + "position": 2 +} diff --git a/versioned_docs/version-V3/reference/core/interfaces/IERC20Minimal.md b/versioned_docs/version-V3/reference/core/interfaces/IERC20Minimal.md index faed216756..4564ac4f61 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/IERC20Minimal.md +++ b/versioned_docs/version-V3/reference/core/interfaces/IERC20Minimal.md @@ -1,87 +1,103 @@ Contains a subset of the full ERC20 interface that is used in Uniswap V3 - ## Functions + ### balanceOf + ```solidity function balanceOf( address account ) external view returns (uint256) ``` -Returns the balance of a token +Returns the balance of a token #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`account` | address | The account for which to look up the number of tokens it has, i.e. its balance + +| Name | Type | Description | +| :-------- | :------ | :----------------------------------------------------------------------------- | +| `account` | address | The account for which to look up the number of tokens it has, i.e. its balance | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint256 | number of tokens held by the account + +| Type | Description | +| :------ | :----------------------------------- | +| uint256 | number of tokens held by the account | ### transfer + ```solidity function transfer( address recipient, uint256 amount ) external returns (bool) ``` -Transfers the amount of token from the `msg.sender` to the recipient +Transfers the amount of token from the `msg.sender` to the recipient #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`recipient` | address | The account that will receive the amount transferred -|`amount` | uint256 | The number of tokens to send from the sender to the recipient + +| Name | Type | Description | +| :---------- | :------ | :------------------------------------------------------------ | +| `recipient` | address | The account that will receive the amount transferred | +| `amount` | uint256 | The number of tokens to send from the sender to the recipient | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bool | true for a successful transfer, false for an unsuccessful transfer + +| Type | Description | +| :--- | :----------------------------------------------------------------- | +| bool | true for a successful transfer, false for an unsuccessful transfer | + ### allowance + ```solidity function allowance( address owner, address spender ) external view returns (uint256) ``` -Returns the current allowance given to a spender by an owner +Returns the current allowance given to a spender by an owner #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`owner` | address | The account of the token owner -|`spender` | address | The account of the token spender + +| Name | Type | Description | +| :-------- | :------ | :------------------------------- | +| `owner` | address | The account of the token owner | +| `spender` | address | The account of the token spender | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint256 | current allowance granted by `owner` to `spender` + +| Type | Description | +| :------ | :------------------------------------------------ | +| uint256 | current allowance granted by `owner` to `spender` | + ### approve + ```solidity function approve( address spender, uint256 amount ) external returns (bool) ``` -Sets the allowance of a spender from the `msg.sender` to the value `amount` +Sets the allowance of a spender from the `msg.sender` to the value `amount` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`spender` | address | The account which will be allowed to spend a given amount of the owners tokens -|`amount` | uint256 | The amount of tokens allowed to be used by `spender` + +| Name | Type | Description | +| :-------- | :------ | :----------------------------------------------------------------------------- | +| `spender` | address | The account which will be allowed to spend a given amount of the owners tokens | +| `amount` | uint256 | The amount of tokens allowed to be used by `spender` | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bool | true for a successful approval, false for unsuccessful + +| Type | Description | +| :--- | :----------------------------------------------------- | +| bool | true for a successful approval, false for unsuccessful | + ### transferFrom + ```solidity function transferFrom( address sender, @@ -89,22 +105,27 @@ Sets the allowance of a spender from the `msg.sender` to the value `amount` uint256 amount ) external returns (bool) ``` -Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender` +Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sender` | address | The account from which the transfer will be initiated -|`recipient` | address | The recipient of the transfer -|`amount` | uint256 | The amount of the transfer + +| Name | Type | Description | +| :---------- | :------ | :---------------------------------------------------- | +| `sender` | address | The account from which the transfer will be initiated | +| `recipient` | address | The recipient of the transfer | +| `amount` | uint256 | The amount of the transfer | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bool | true for a successful transfer, false for unsuccessful + +| Type | Description | +| :--- | :----------------------------------------------------- | +| bool | true for a successful transfer, false for unsuccessful | + ## Events + ### Transfer + ```solidity event Transfer( address from, @@ -112,16 +133,19 @@ Transfers `amount` tokens from `sender` to `recipient` up to the allowance given uint256 value ) ``` -Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`. +Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`. #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`from`| address | The account from which the tokens were sent, i.e. the balance decreased -|`to`| address | The account to which the tokens were sent, i.e. the balance increased -|`value`| uint256 | The amount of tokens that were transferred + +| Name | Type | Description | +| :------ | :------ | :---------------------------------------------------------------------- | +| `from` | address | The account from which the tokens were sent, i.e. the balance decreased | +| `to` | address | The account to which the tokens were sent, i.e. the balance increased | +| `value` | uint256 | The amount of tokens that were transferred | + ### Approval + ```solidity event Approval( address owner, @@ -129,12 +153,13 @@ Event emitted when tokens are transferred from one address to another, either vi uint256 value ) ``` -Event emitted when the approval amount for the spender of a given owner's tokens changes. +Event emitted when the approval amount for the spender of a given owner's tokens changes. #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`owner`| address | The account that approved spending of its tokens -|`spender`| address | The account for which the spending allowance was modified -|`value`| uint256 | The new allowance from the owner to the spender + +| Name | Type | Description | +| :-------- | :------ | :-------------------------------------------------------- | +| `owner` | address | The account that approved spending of its tokens | +| `spender` | address | The account for which the spending allowance was modified | +| `value` | uint256 | The new allowance from the owner to the spender | diff --git a/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Factory.md b/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Factory.md index 568476d34a..3c79a82e61 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Factory.md +++ b/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Factory.md @@ -1,41 +1,50 @@ The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees - ## Functions + ### owner + ```solidity function owner( ) external view returns (address) ``` + Returns the current owner of the factory Can be changed by the current owner via setOwner - #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| address | address of the factory owner + +| Type | Description | +| :------ | :--------------------------- | +| address | address of the factory owner | + ### feeAmountTickSpacing + ```solidity function feeAmountTickSpacing( uint24 fee ) external view returns (int24) ``` + Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled A fee amount can never be removed, so this value should be hard coded or cached in the calling context #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`fee` | uint24 | The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee + +| Name | Type | Description | +| :---- | :----- | :-------------------------------------------------------------------------------------- | +| `fee` | uint24 | The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| int24 | tick spacing + +| Type | Description | +| :---- | :----------- | +| int24 | tick spacing | + ### getPool + ```solidity function getPool( address tokenA, @@ -43,22 +52,27 @@ A fee amount can never be removed, so this value should be hard coded or cached uint24 fee ) external view returns (address pool) ``` + Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist tokenA and tokenB may be passed in either token0/token1 or token1/token0 order #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenA` | address | The contract address of either token0 or token1 -|`tokenB` | address | The contract address of the other token -|`fee` | uint24 | The fee collected upon every swap in the pool, denominated in hundredths of a bip + +| Name | Type | Description | +| :------- | :------ | :-------------------------------------------------------------------------------- | +| `tokenA` | address | The contract address of either token0 or token1 | +| `tokenB` | address | The contract address of the other token | +| `fee` | uint24 | The fee collected upon every swap in the pool, denominated in hundredths of a bip | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| address | The pool address + +| Name | Type | Description | +| :----- | :------ | :--------------- | +| `pool` | address | The pool address | + ### createPool + ```solidity function createPool( address tokenA, @@ -66,6 +80,7 @@ tokenA and tokenB may be passed in either token0/token1 or token1/token0 order 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 @@ -73,65 +88,79 @@ from the fee. The call will revert if the pool already exists, the fee is invali are invalid. #### 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 + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| address | The address of the newly created pool + +| Name | Type | Description | +| :----- | :------ | :------------------------------------ | +| `pool` | address | The address of the newly created pool | + ### setOwner + ```solidity function setOwner( address _owner ) external ``` + Updates the owner of the factory Must be called by the current owner #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`_owner` | address | The new owner of the factory + +| Name | Type | Description | +| :------- | :------ | :--------------------------- | +| `_owner` | address | The new owner of the factory | ### enableFeeAmount + ```solidity function enableFeeAmount( uint24 fee, int24 tickSpacing ) external ``` + Enables a fee amount with the given tickSpacing Fee amounts may never be removed once enabled #### Parameters: -| 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 + +| 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 | ## Events + ### OwnerChanged + ```solidity event OwnerChanged( address oldOwner, address newOwner ) ``` -Emitted when the owner of the factory is changed +Emitted when the owner of the factory is changed #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`oldOwner`| address | The owner before the owner was changed -|`newOwner`| address | The owner after the owner was changed + +| Name | Type | Description | +| :--------- | :------ | :------------------------------------- | +| `oldOwner` | address | The owner before the owner was changed | +| `newOwner` | address | The owner after the owner was changed | + ### PoolCreated + ```solidity event PoolCreated( address token0, @@ -141,29 +170,33 @@ Emitted when the owner of the factory is changed address pool ) ``` -Emitted when a pool is created +Emitted when a pool is created #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`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 minimum number of ticks between initialized ticks -|`pool`| address | The address of the created pool + +| Name | Type | Description | +| :------------ | :------ | :-------------------------------------------------------------------------------- | +| `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 minimum number of ticks between initialized ticks | +| `pool` | address | The address of the created pool | + ### FeeAmountEnabled + ```solidity event FeeAmountEnabled( uint24 fee, int24 tickSpacing ) ``` -Emitted when a new fee amount is enabled for pool creation via the factory +Emitted when a new fee amount is enabled for pool creation via the factory #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`fee`| uint24 | The enabled fee, denominated in hundredths of a bip -|`tickSpacing`| int24 | The minimum number of ticks between initialized ticks for pools created with the given fee + +| Name | Type | Description | +| :------------ | :----- | :----------------------------------------------------------------------------------------- | +| `fee` | uint24 | The enabled fee, denominated in hundredths of a bip | +| `tickSpacing` | int24 | The minimum number of ticks between initialized ticks for pools created with the given fee | diff --git a/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Pool.md b/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Pool.md index b38c2a79f7..b751044273 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Pool.md +++ b/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3Pool.md @@ -2,4 +2,3 @@ A Uniswap pool facilitates swapping and automated market making between any two to the ERC20 specification The pool interface is broken up into many smaller pieces - diff --git a/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3PoolDeployer.md b/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3PoolDeployer.md index 8ee2c9d505..5e62649649 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3PoolDeployer.md +++ b/versioned_docs/version-V3/reference/core/interfaces/IUniswapV3PoolDeployer.md @@ -4,20 +4,22 @@ This is used to avoid having constructor arguments in the pool contract, which r of the pool being constant allowing the CREATE2 address of the pool to be cheaply computed on-chain ## Functions + ### parameters + ```solidity function parameters( ) external view returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing) ``` + Get the parameters to be used in constructing the pool, set transiently during pool creation. #### Return Values : -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -| `factory `| address | The factory address -| `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 minimum number of ticks between initialized ticks - +| Name | Type | Description | +| :------------ | :------ | :-------------------------------------------------------------------------------- | +| `factory ` | address | The factory address | +| `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 minimum number of ticks between initialized ticks | diff --git a/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3FlashCallback.md b/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3FlashCallback.md index 41ca2dc943..480d5306d0 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3FlashCallback.md +++ b/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3FlashCallback.md @@ -1,8 +1,9 @@ Any contract that calls IUniswapV3PoolActions#flash must implement this interface - ## Functions + ### uniswapV3FlashCallback + ```solidity function uniswapV3FlashCallback( uint256 fee0, @@ -10,15 +11,16 @@ Any contract that calls IUniswapV3PoolActions#flash must implement this interfac bytes data ) external ``` + Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash. In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts. The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`fee0` | uint256 | The fee amount in token0 due to the pool by the end of the flash -|`fee1` | uint256 | The fee amount in token1 due to the pool by the end of the flash -|`data` | bytes | Any data passed through by the caller via the IUniswapV3PoolActions#flash call +| Name | Type | Description | +| :----- | :------ | :----------------------------------------------------------------------------- | +| `fee0` | uint256 | The fee amount in token0 due to the pool by the end of the flash | +| `fee1` | uint256 | The fee amount in token1 due to the pool by the end of the flash | +| `data` | bytes | Any data passed through by the caller via the IUniswapV3PoolActions#flash call | diff --git a/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3MintCallback.md b/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3MintCallback.md index a93a2e7022..ff03dbfa76 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3MintCallback.md +++ b/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3MintCallback.md @@ -1,8 +1,9 @@ Any contract that calls IUniswapV3PoolActions#mint must implement this interface - ## Functions + ### uniswapV3MintCallback + ```solidity function uniswapV3MintCallback( uint256 amount0Owed, @@ -10,15 +11,16 @@ Any contract that calls IUniswapV3PoolActions#mint must implement this interface bytes data ) external ``` + Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint. In the implementation you must pay the pool tokens owed for the minted liquidity. The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`amount0Owed` | uint256 | The amount of token0 due to the pool for the minted liquidity -|`amount1Owed` | uint256 | The amount of token1 due to the pool for the minted liquidity -|`data` | bytes | Any data passed through by the caller via the IUniswapV3PoolActions#mint call +| Name | Type | Description | +| :------------ | :------ | :---------------------------------------------------------------------------- | +| `amount0Owed` | uint256 | The amount of token0 due to the pool for the minted liquidity | +| `amount1Owed` | uint256 | The amount of token1 due to the pool for the minted liquidity | +| `data` | bytes | Any data passed through by the caller via the IUniswapV3PoolActions#mint call | diff --git a/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3SwapCallback.md b/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3SwapCallback.md index dc2fa8708e..894aff79b7 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3SwapCallback.md +++ b/versioned_docs/version-V3/reference/core/interfaces/callback/IUniswapV3SwapCallback.md @@ -1,8 +1,9 @@ Any contract that calls IUniswapV3PoolActions#swap must implement this interface - ## Functions + ### uniswapV3SwapCallback + ```solidity function uniswapV3SwapCallback( int256 amount0Delta, @@ -10,6 +11,7 @@ Any contract that calls IUniswapV3PoolActions#swap must implement this interface bytes data ) external ``` + Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. In the implementation you must pay the pool tokens owed for the swap. @@ -17,9 +19,9 @@ The caller of this method must be checked to be a UniswapV3Pool deployed by the amount0Delta and amount1Delta can both be 0 if no tokens were swapped. #### 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 IUniswapV3PoolActions#swap call. +| 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 IUniswapV3PoolActions#swap call. | diff --git a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolActions.md b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolActions.md index 34ea17c60f..603bf4834c 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolActions.md +++ b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolActions.md @@ -1,23 +1,27 @@ Contains pool methods that can be called by anyone - ## Functions + ### initialize + ```solidity function initialize( uint160 sqrtPriceX96 ) external ``` + Sets the initial price for the pool Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtPriceX96` | uint160 | the initial sqrt price of the pool as a Q64.96 + +| Name | Type | Description | +| :------------- | :------ | :--------------------------------------------- | +| `sqrtPriceX96` | uint160 | the initial sqrt price of the pool as a Q64.96 | ### mint + ```solidity function mint( address recipient, @@ -27,6 +31,7 @@ Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value bytes data ) external returns (uint256 amount0, uint256 amount1) ``` + Adds liquidity for the given recipient/tickLower/tickUpper position The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback @@ -34,20 +39,24 @@ in which they must pay any token0 or token1 owed for the liquidity. The amount o on tickLower, tickUpper, the amount of liquidity, and the current price. #### Parameters: -| 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 + +| 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: -| 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 + +| 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 | + ### collect + ```solidity function collect( address recipient, @@ -57,6 +66,7 @@ on tickLower, tickUpper, the amount of liquidity, and the current price. uint128 amount1Requested ) external 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. @@ -65,20 +75,24 @@ amount1Requested may be set to zero. To withdraw all tokens owed, caller may pas actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. #### Parameters: -| 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 + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| uint128 | The amount of fees collected in token0 -|`amount1`| uint128 | The amount of fees collected in token1 + +| Name | Type | Description | +| :-------- | :------ | :------------------------------------- | +| `amount0` | uint128 | The amount of fees collected in token0 | +| `amount1` | uint128 | The amount of fees collected in token1 | + ### burn + ```solidity function burn( int24 tickLower, @@ -86,24 +100,29 @@ actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated uint128 amount ) external returns (uint256 amount0, uint256 amount1) ``` + Burn liquidity from the sender and account tokens owed for the liquidity to the position Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 Fees must be collected separately via a call to #collect #### Parameters: -| 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 + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| uint256 | The amount of token0 sent to the recipient -|`amount1`| uint256 | The amount of token1 sent to the recipient + +| Name | Type | Description | +| :-------- | :------ | :----------------------------------------- | +| `amount0` | uint256 | The amount of token0 sent to the recipient | +| `amount1` | uint256 | The amount of token1 sent to the recipient | + ### swap + ```solidity function swap( address recipient, @@ -113,26 +132,32 @@ Fees must be collected separately via a call to #collect bytes data ) external 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 IUniswapV3SwapCallback#uniswapV3SwapCallback #### Parameters: -| 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 + +| 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: -| 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 + +| 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 | + ### flash + ```solidity function flash( address recipient, @@ -141,6 +166,7 @@ value after the swap. If one for zero, the price cannot be greater than this val bytes data ) external ``` + 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 IUniswapV3FlashCallback#uniswapV3FlashCallback @@ -148,26 +174,29 @@ Can be used to donate underlying tokens pro-rata to currently in-range liquidity with 0 amount{0,1} and sending the donation amount(s) from the callback #### Parameters: -| 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 + +| 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 | ### increaseObservationCardinalityNext + ```solidity function increaseObservationCardinalityNext( uint16 observationCardinalityNext ) external ``` + 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: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`observationCardinalityNext` | uint16 | The desired minimum number of observations for the pool to store +| Name | Type | Description | +| :--------------------------- | :----- | :--------------------------------------------------------------- | +| `observationCardinalityNext` | uint16 | The desired minimum number of observations for the pool to store | diff --git a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolDerivedState.md b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolDerivedState.md index 79d5c12ac2..d3963a28ed 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolDerivedState.md +++ b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolDerivedState.md @@ -1,14 +1,16 @@ Contains view functions to provide information about the pool that is computed rather than stored on the blockchain. The functions here may have variable gas costs. - ## Functions + ### observe + ```solidity function observe( uint32[] secondsAgos ) external view 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 @@ -18,23 +20,29 @@ The time weighted average tick represents the geometric time weighted average pr log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`secondsAgos` | uint32[] | From how long ago each cumulative tick and liquidity value should be returned + +| Name | Type | Description | +| :------------ | :------- | :---------------------------------------------------------------------------- | +| `secondsAgos` | uint32[] | From how long ago each cumulative tick and liquidity value should be returned | #### Return Values: -| 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 + +| 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 + ### snapshotCumulativesInside + ```solidity function snapshotCumulativesInside( int24 tickLower, int24 tickUpper ) external 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. @@ -42,14 +50,16 @@ I.e., snapshots cannot be compared if a position is not held for the entire peri snapshot is taken and the second snapshot is taken. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tickLower` | int24 | The lower tick of the range -|`tickUpper` | int24 | The upper tick of the range + +| Name | Type | Description | +| :---------- | :---- | :-------------------------- | +| `tickLower` | int24 | The lower tick of the range | +| `tickUpper` | int24 | The upper tick of the range | #### 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 + +| 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 | diff --git a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolEvents.md b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolEvents.md index ed44e355be..6744cb3e5d 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolEvents.md +++ b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolEvents.md @@ -1,24 +1,29 @@ Contains all events emitted by the pool - ## Events + ### Initialize + ```solidity event Initialize( uint160 sqrtPriceX96, int24 tick ) ``` + Emitted exactly once by a pool when #initialize is first called on the pool Mint/Burn/Swap cannot be emitted by the pool before Initialize #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`sqrtPriceX96`| uint160 | The initial sqrt price of the pool, as a Q64.96 -|`tick`| int24 | The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool + +| Name | Type | Description | +| :------------- | :------ | :----------------------------------------------------------------------------------- | +| `sqrtPriceX96` | uint160 | The initial sqrt price of the pool, as a Q64.96 | +| `tick` | int24 | The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool | + ### Mint + ```solidity event Mint( address sender, @@ -30,20 +35,23 @@ Mint/Burn/Swap cannot be emitted by the pool before Initialize uint256 amount1 ) ``` -Emitted when liquidity is minted for a given position +Emitted when liquidity is minted for a given position #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`sender`| address | The address that minted the liquidity -|`owner`| address | The owner of the position and recipient of any minted liquidity -|`tickLower`| int24 | The lower tick of the position -|`tickUpper`| int24 | The upper tick of the position -|`amount`| uint128 | The amount of liquidity minted to the position range -|`amount0`| uint256 | How much token0 was required for the minted liquidity -|`amount1`| uint256 | How much token1 was required for the minted liquidity + +| Name | Type | Description | +| :---------- | :------ | :-------------------------------------------------------------- | +| `sender` | address | The address that minted the liquidity | +| `owner` | address | The owner of the position and recipient of any minted liquidity | +| `tickLower` | int24 | The lower tick of the position | +| `tickUpper` | int24 | The upper tick of the position | +| `amount` | uint128 | The amount of liquidity minted to the position range | +| `amount0` | uint256 | How much token0 was required for the minted liquidity | +| `amount1` | uint256 | How much token1 was required for the minted liquidity | + ### Collect + ```solidity event Collect( address owner, @@ -53,19 +61,23 @@ Emitted when liquidity is minted for a given position uint128 amount1 ) ``` + Emitted when fees are collected by the owner of a position Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`owner`| address | The owner of the position for which fees are collected -|`tickLower`| int24 | The lower tick of the position -|`tickUpper`| int24 | The upper tick of the position -|`amount0`| uint128 | The amount of token0 fees collected -|`amount1`| uint128 | The amount of token1 fees collected + +| Name | Type | Description | +| :---------- | :------ | :----------------------------------------------------- | +| `owner` | address | The owner of the position for which fees are collected | +| `tickLower` | int24 | The lower tick of the position | +| `tickUpper` | int24 | The upper tick of the position | +| `amount0` | uint128 | The amount of token0 fees collected | +| `amount1` | uint128 | The amount of token1 fees collected | + ### Burn + ```solidity event Burn( address owner, @@ -76,20 +88,24 @@ Collect events may be emitted with zero amount0 and amount1 when the caller choo uint256 amount1 ) ``` + Emitted when a position's liquidity is removed Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`owner`| address | The owner of the position for which liquidity is removed -|`tickLower`| int24 | The lower tick of the position -|`tickUpper`| int24 | The upper tick of the position -|`amount`| uint128 | The amount of liquidity to remove -|`amount0`| uint256 | The amount of token0 withdrawn -|`amount1`| uint256 | The amount of token1 withdrawn + +| Name | Type | Description | +| :---------- | :------ | :------------------------------------------------------- | +| `owner` | address | The owner of the position for which liquidity is removed | +| `tickLower` | int24 | The lower tick of the position | +| `tickUpper` | int24 | The upper tick of the position | +| `amount` | uint128 | The amount of liquidity to remove | +| `amount0` | uint256 | The amount of token0 withdrawn | +| `amount1` | uint256 | The amount of token1 withdrawn | + ### Swap + ```solidity event Swap( address sender, @@ -101,20 +117,23 @@ Does not withdraw any fees earned by the liquidity position, which must be withd int24 tick ) ``` -Emitted by the pool for any swaps between token0 and token1 +Emitted by the pool for any swaps between token0 and token1 #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`sender`| address | The address that initiated the swap call, and that received the callback -|`recipient`| address | The address that received the output of the swap -|`amount0`| int256 | The delta of the token0 balance of the pool -|`amount1`| int256 | The delta of the token1 balance of the pool -|`sqrtPriceX96`| uint160 | The sqrt(price) of the pool after the swap, as a Q64.96 -|`liquidity`| uint128 | The liquidity of the pool after the swap -|`tick`| int24 | The log base 1.0001 of price of the pool after the swap + +| Name | Type | Description | +| :------------- | :------ | :----------------------------------------------------------------------- | +| `sender` | address | The address that initiated the swap call, and that received the callback | +| `recipient` | address | The address that received the output of the swap | +| `amount0` | int256 | The delta of the token0 balance of the pool | +| `amount1` | int256 | The delta of the token1 balance of the pool | +| `sqrtPriceX96` | uint160 | The sqrt(price) of the pool after the swap, as a Q64.96 | +| `liquidity` | uint128 | The liquidity of the pool after the swap | +| `tick` | int24 | The log base 1.0001 of price of the pool after the swap | + ### Flash + ```solidity event Flash( address sender, @@ -125,36 +144,43 @@ Emitted by the pool for any swaps between token0 and token1 uint256 paid1 ) ``` -Emitted by the pool for any flashes of token0/token1 +Emitted by the pool for any flashes of token0/token1 #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`sender`| address | The address that initiated the swap call, and that received the callback -|`recipient`| address | The address that received the tokens from flash -|`amount0`| uint256 | The amount of token0 that was flashed -|`amount1`| uint256 | The amount of token1 that was flashed -|`paid0`| uint256 | The amount of token0 paid for the flash, which can exceed the amount0 plus the fee -|`paid1`| uint256 | The amount of token1 paid for the flash, which can exceed the amount1 plus the fee + +| Name | Type | Description | +| :---------- | :------ | :--------------------------------------------------------------------------------- | +| `sender` | address | The address that initiated the swap call, and that received the callback | +| `recipient` | address | The address that received the tokens from flash | +| `amount0` | uint256 | The amount of token0 that was flashed | +| `amount1` | uint256 | The amount of token1 that was flashed | +| `paid0` | uint256 | The amount of token0 paid for the flash, which can exceed the amount0 plus the fee | +| `paid1` | uint256 | The amount of token1 paid for the flash, which can exceed the amount1 plus the fee | + ### IncreaseObservationCardinalityNext + ```solidity event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ) ``` + Emitted by the pool for increases to the number of observations that can be stored observationCardinalityNext is not the observation cardinality until an observation is written at the index just before a mint/swap/burn. #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`observationCardinalityNextOld`| uint16 | The previous value of the next observation cardinality -|`observationCardinalityNextNew`| uint16 | The updated value of the next observation cardinality + +| Name | Type | Description | +| :------------------------------ | :----- | :----------------------------------------------------- | +| `observationCardinalityNextOld` | uint16 | The previous value of the next observation cardinality | +| `observationCardinalityNextNew` | uint16 | The updated value of the next observation cardinality | + ### SetFeeProtocol + ```solidity event SetFeeProtocol( uint8 feeProtocol0Old, @@ -163,17 +189,20 @@ just before a mint/swap/burn. uint8 feeProtocol1New ) ``` -Emitted when the protocol fee is changed by the pool +Emitted when the protocol fee is changed by the pool #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`feeProtocol0Old`| uint8 | The previous value of the token0 protocol fee -|`feeProtocol1Old`| uint8 | The previous value of the token1 protocol fee -|`feeProtocol0New`| uint8 | The updated value of the token0 protocol fee -|`feeProtocol1New`| uint8 | The updated value of the token1 protocol fee + +| Name | Type | Description | +| :---------------- | :---- | :-------------------------------------------- | +| `feeProtocol0Old` | uint8 | The previous value of the token0 protocol fee | +| `feeProtocol1Old` | uint8 | The previous value of the token1 protocol fee | +| `feeProtocol0New` | uint8 | The updated value of the token0 protocol fee | +| `feeProtocol1New` | uint8 | The updated value of the token1 protocol fee | + ### CollectProtocol + ```solidity event CollectProtocol( address sender, @@ -182,13 +211,14 @@ Emitted when the protocol fee is changed by the pool uint128 amount1 ) ``` -Emitted when the collected protocol fees are withdrawn by the factory owner +Emitted when the collected protocol fees are withdrawn by the factory owner #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`sender`| address | The address that collects the protocol fees -|`recipient`| address | The address that receives the collected protocol fees -|`amount0`| uint128 | The amount of token0 protocol fees that is withdrawn -|`amount1`| uint128 | The amount of token1 protocol fees that is withdrawn + +| Name | Type | Description | +| :---------- | :------ | :---------------------------------------------------- | +| `sender` | address | The address that collects the protocol fees | +| `recipient` | address | The address that receives the collected protocol fees | +| `amount0` | uint128 | The amount of token0 protocol fees that is withdrawn | +| `amount1` | uint128 | The amount of token1 protocol fees that is withdrawn | diff --git a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolImmutables.md b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolImmutables.md index a478e013ce..19b313e888 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolImmutables.md +++ b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolImmutables.md @@ -1,87 +1,100 @@ These parameters are fixed for a pool forever, i.e., the methods will always return the same values - ## Functions + ### factory + ```solidity function factory( ) external view returns (address) ``` + The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface +#### Return Values: +| Type | Description | +| :------ | :--------------- | +| address | contract address | -#### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| address | contract address ### token0 + ```solidity function token0( ) external view returns (address) ``` + The first of the two tokens of the pool, sorted by address +#### Return Values: +| Type | Description | +| :------ | :--------------------- | +| address | token contract address | -#### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| address | token contract address ### token1 + ```solidity function token1( ) external view returns (address) ``` + The second of the two tokens of the pool, sorted by address +#### Return Values: +| Type | Description | +| :------ | :--------------------- | +| address | token contract address | -#### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| address | token contract address ### fee + ```solidity function fee( ) external view returns (uint24) ``` + The pool's fee in hundredths of a bip, i.e. 1e-6 +#### Return Values: +| Type | Description | +| :----- | :---------- | +| uint24 | fee | -#### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint24 | fee ### tickSpacing + ```solidity function tickSpacing( ) external view returns (int24) ``` + The pool tick spacing Ticks can only be used at multiples of this value, minimum of 1 and always positive e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... This value is an int24 to avoid casting even though it is always positive. - #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| int24 | tick spacing + +| Type | Description | +| :---- | :----------- | +| int24 | tick spacing | + ### maxLiquidityPerTick + ```solidity function maxLiquidityPerTick( ) external view returns (uint128) ``` + The maximum amount of position liquidity that can use any tick in the range This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool - #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint128 | max amount of liquidity per tick + +| Type | Description | +| :------ | :------------------------------- | +| uint128 | max amount of liquidity per tick | diff --git a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolOwnerActions.md b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolOwnerActions.md index 47ffb1ab53..23ca6fe8aa 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolOwnerActions.md +++ b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolOwnerActions.md @@ -1,24 +1,27 @@ Contains pool methods that may only be called by the factory owner - ## Functions + ### setFeeProtocol + ```solidity function setFeeProtocol( uint8 feeProtocol0, uint8 feeProtocol1 ) external ``` -Set the denominator of the protocol's % share of the fees +Set the denominator of the protocol's % share of the fees #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`feeProtocol0` | uint8 | new protocol fee for token0 of the pool -|`feeProtocol1` | uint8 | new protocol fee for token1 of the pool + +| Name | Type | Description | +| :------------- | :---- | :-------------------------------------- | +| `feeProtocol0` | uint8 | new protocol fee for token0 of the pool | +| `feeProtocol1` | uint8 | new protocol fee for token1 of the pool | ### collectProtocol + ```solidity function collectProtocol( address recipient, @@ -26,18 +29,20 @@ Set the denominator of the protocol's % share of the fees uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1) ``` -Collect the protocol fee accrued to the pool +Collect the protocol fee accrued to the pool #### Parameters: -| 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 + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| uint128 | The protocol fee collected in token0 -|`amount1`| uint128 | The protocol fee collected in token1 + +| Name | Type | Description | +| :-------- | :------ | :----------------------------------- | +| `amount0` | uint128 | The protocol fee collected in token0 | +| `amount1` | uint128 | The protocol fee collected in token1 | diff --git a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolState.md b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolState.md index 012dd7d4af..42c61cf4be 100644 --- a/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolState.md +++ b/versioned_docs/version-V3/reference/core/interfaces/pool/IUniswapV3PoolState.md @@ -1,146 +1,165 @@ These methods compose the pool's state, and can change with any frequency including multiple times per transaction - ## Functions + ### slot0 + ```solidity function slot0( ) external view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked) ``` + The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas when accessed externally. +#### Return Values: +| Name | Type | Description | +| :--------------------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `sqrtPriceX96` | uint160 | The current price of the pool as a sqrt(token1/token0) Q64.96 value | +| `tick` | int24 | The current tick of the pool, i.e. according to the last tick transition that was run. This value may not always be equal to SqrtTickMath getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick boundary. | +| `observationIndex` | uint16 | The index of the last oracle observation that was written, | +| `observationCardinality` | uint16 | The current maximum number of observations stored in the pool, | +| `observationCardinalityNext` | uint16 | The next maximum number of observations, to be updated when the observation. | +| `feeProtocol` | uint8 | The protocol fee for both tokens of the pool. Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0is the lower 4 bits.Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. | +| `unlocked` | bool | Whether the pool is currently locked to reentrancy | -#### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`sqrtPriceX96`| uint160 | The current price of the pool as a sqrt(token1/token0) Q64.96 value| -|`tick`| int24 | The current tick of the pool, i.e. according to the last tick transition that was run. This value may not always be equal to SqrtTickMath getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick boundary. -| `observationIndex` | uint16 | The index of the last oracle observation that was written, -| `observationCardinality`| uint16 | The current maximum number of observations stored in the pool, -| `observationCardinalityNext` | uint16 | The next maximum number of observations, to be updated when the observation. -| `feeProtocol` | uint8 | The protocol fee for both tokens of the pool. Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0is the lower 4 bits.Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. -| `unlocked` | bool | Whether the pool is currently locked to reentrancy ### feeGrowthGlobal0X128 + ```solidity function feeGrowthGlobal0X128( ) external view returns (uint256) ``` + The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool This value can overflow the uint256 - ### feeGrowthGlobal1X128 + ```solidity function feeGrowthGlobal1X128( ) external view returns (uint256) ``` + The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool This value can overflow the uint256 - ### protocolFees + ```solidity function protocolFees( ) external view returns (uint128 token0, uint128 token1) ``` + The amounts of token0 and token1 that are owed to the protocol Protocol fees will never exceed uint128 max in either token - ### liquidity + ```solidity function liquidity( ) external view returns (uint128) ``` + The currently in range liquidity available to the pool This value has no relationship to the total liquidity across all ticks - ### ticks + ```solidity function ticks( int24 tick ) external view returns (uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized) ``` -Look up information about a specific tick in the pool +Look up information about a specific tick in the pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tick` | int24 | The tick to look up + +| Name | Type | Description | +| :----- | :---- | :------------------ | +| `tick` | int24 | The tick to look up | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`liquidityGross`| uint128 | the total amount of position liquidity that uses the pool either as tick lower or tick upper, -| `liquidityNet` | int128 | how much liquidity changes when the pool price crosses the tick, -| `feeGrowthOutside0X128` | uint256 | the fee growth on the other side of the tick from the current tick in token0, -| `feeGrowthOutside1X128` | uint256 | the fee growth on the other side of the tick from the current tick in token1, feeGrowthOutsideX128 values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. In addition, these values are only relative and are used to compute snapshots.| -| `tickCumulativeOutside` | int56 | | -| `secondsPerLiquidityOutsideX128` | uint160| | -| `secondsOutside` | uint32 | | -| `initialized` | bool | | + +| Name | Type | Description | +| :------------------------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `liquidityGross` | uint128 | the total amount of position liquidity that uses the pool either as tick lower or tick upper, | +| `liquidityNet` | int128 | how much liquidity changes when the pool price crosses the tick, | +| `feeGrowthOutside0X128` | uint256 | the fee growth on the other side of the tick from the current tick in token0, | +| `feeGrowthOutside1X128` | uint256 | the fee growth on the other side of the tick from the current tick in token1, feeGrowthOutsideX128 values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. In addition, these values are only relative and are used to compute snapshots. | +| `tickCumulativeOutside` | int56 | | +| `secondsPerLiquidityOutsideX128` | uint160 | | +| `secondsOutside` | uint32 | | +| `initialized` | bool | | + a specific position. + ### tickBitmap + ```solidity function tickBitmap( int16 wordPosition ) external view returns (uint256) ``` -Returns 256 packed tick initialized boolean values. See TickBitmap for more information - +Returns 256 packed tick initialized boolean values. See TickBitmap for more information ### positions + ```solidity function positions( bytes32 key ) external view returns (uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1) ``` -Returns the information about a position by the position's key +Returns the information about a position by the position's key #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | bytes32 | The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper + +| Name | Type | Description | +| :---- | :------ | :---------------------------------------------------------------------------------------- | +| `key` | bytes32 | The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`_liquidity`| bytes32 | The amount of liquidity in the position, -| `feeGrowthInside0LastX128`| uint256 | fee growth of token0 inside the tick range as of the last mint/burn/poke, -| `feeGrowthInside1LastX128`| uint256 | fee growth of token1 inside the tick range as of the last mint/burn/poke, -| `tokensOwed0` | uint128 | the computed amount of token0 owed to the position as of the last mint/burn/poke, -| `tokensOwed1` | uint128 | the computed amount of token1 owed to the position as of the last mint/burn/poke + +| Name | Type | Description | +| :------------------------- | :------ | :-------------------------------------------------------------------------------- | +| `_liquidity` | bytes32 | The amount of liquidity in the position, | +| `feeGrowthInside0LastX128` | uint256 | fee growth of token0 inside the tick range as of the last mint/burn/poke, | +| `feeGrowthInside1LastX128` | uint256 | fee growth of token1 inside the tick range as of the last mint/burn/poke, | +| `tokensOwed0` | uint128 | the computed amount of token0 owed to the position as of the last mint/burn/poke, | +| `tokensOwed1` | uint128 | the computed amount of token1 owed to the position as of the last mint/burn/poke | + ### observations + ```solidity function observations( uint256 index ) external view returns (uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized) ``` + Returns data about a specific observation index You most likely want to use #observe() instead of this method to get an observation as of some amount of time ago, rather than at a specific index in the array. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`index` | uint256 | The element of the observations array to fetch + +| Name | Type | Description | +| :------ | :------ | :--------------------------------------------- | +| `index` | uint256 | The element of the observations array to fetch | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`blockTimestamp`| uint256 | The timestamp of the observation, -| `tickCumulative`| int56 | the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, -| `secondsPerLiquidityCumulativeX128` | uint160 | the seconds per in range liquidity for the life of the pool as of the observation timestamp -| `initialized` | bool | whether the observation has been initialized and the values are safe to use + +| Name | Type | Description | +| :---------------------------------- | :------ | :----------------------------------------------------------------------------------------------- | +| `blockTimestamp` | uint256 | The timestamp of the observation, | +| `tickCumulative` | int56 | the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, | +| `secondsPerLiquidityCumulativeX128` | uint160 | the seconds per in range liquidity for the life of the pool as of the observation timestamp | +| `initialized` | bool | whether the observation has been initialized and the values are safe to use | diff --git a/versioned_docs/version-V3/reference/core/libraries/BitMath.md b/versioned_docs/version-V3/reference/core/libraries/BitMath.md index 4412987be0..600db8ad84 100644 --- a/versioned_docs/version-V3/reference/core/libraries/BitMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/BitMath.md @@ -1,46 +1,55 @@ - This library provides functionality for computing bit properties of an unsigned integer ## Functions + ### mostSignificantBit + ```solidity function mostSignificantBit( uint256 x ) internal pure returns (uint8 r) ``` + Returns the index of the most significant bit of the number, - where the least significant bit is at index 0 and the most significant bit is at index 255 +where the least significant bit is at index 0 and the most significant bit is at index 255 The function satisfies the property: - x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1) +x >= 2**mostSignificantBit(x) and x < 2**(mostSignificantBit(x)+1) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | uint256 | the value for which to compute the most significant bit, must be greater than 0 + +| Name | Type | Description | +| :--- | :------ | :------------------------------------------------------------------------------ | +| `x` | uint256 | the value for which to compute the most significant bit, must be greater than 0 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`r`| unit8 | the index of the most significant bit + +| Name | Type | Description | +| :--- | :---- | :------------------------------------ | +| `r` | unit8 | the index of the most significant bit | + ### leastSignificantBit + ```solidity function leastSignificantBit( uint256 x ) internal pure returns (uint8 r) ``` + Returns the index of the least significant bit of the number, - where the least significant bit is at index 0 and the most significant bit is at index 255 +where the least significant bit is at index 0 and the most significant bit is at index 255 The function satisfies the property: - (x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0) +(x & 2**leastSignificantBit(x)) != 0 and (x & (2**(leastSignificantBit(x)) - 1)) == 0) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | uint256 | the value for which to compute the least significant bit, must be greater than 0 + +| Name | Type | Description | +| :--- | :------ | :------------------------------------------------------------------------------- | +| `x` | uint256 | the value for which to compute the least significant bit, must be greater than 0 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`r`| unit8 | the index of the least significant bit + +| Name | Type | Description | +| :--- | :---- | :------------------------------------- | +| `r` | unit8 | the index of the least significant bit | diff --git a/versioned_docs/version-V3/reference/core/libraries/FixedPoint128.md b/versioned_docs/version-V3/reference/core/libraries/FixedPoint128.md index c9f3deaf53..3fadaba61c 100644 --- a/versioned_docs/version-V3/reference/core/libraries/FixedPoint128.md +++ b/versioned_docs/version-V3/reference/core/libraries/FixedPoint128.md @@ -1,3 +1 @@ A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) - - diff --git a/versioned_docs/version-V3/reference/core/libraries/FixedPoint96.md b/versioned_docs/version-V3/reference/core/libraries/FixedPoint96.md index 82eb8d1a69..fdaa3b8114 100644 --- a/versioned_docs/version-V3/reference/core/libraries/FixedPoint96.md +++ b/versioned_docs/version-V3/reference/core/libraries/FixedPoint96.md @@ -1,4 +1,3 @@ A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) Used in SqrtPriceMath.sol - diff --git a/versioned_docs/version-V3/reference/core/libraries/FullMath.md b/versioned_docs/version-V3/reference/core/libraries/FullMath.md index f35a476f49..bd98f577ab 100644 --- a/versioned_docs/version-V3/reference/core/libraries/FullMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/FullMath.md @@ -3,7 +3,9 @@ Facilitates multiplication and division that can have overflow of an intermediat Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits ## Functions + ### mulDiv + ```solidity function mulDiv( uint256 a, @@ -11,22 +13,27 @@ Handles "phantom overflow" i.e., allows multiplication and division where an int uint256 denominator ) internal pure returns (uint256 result) ``` + Calculates floor(aƗbĆ·denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv + #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`a` | uint256 | The multiplicand -|`b` | uint256 | The multiplier -|`denominator` | uint256 | The divisor + +| Name | Type | Description | +| :------------ | :------ | :--------------- | +| `a` | uint256 | The multiplicand | +| `b` | uint256 | The multiplier | +| `denominator` | uint256 | The divisor | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`result`| uint256 | The 256-bit result + +| Name | Type | Description | +| :------- | :------ | :----------------- | +| `result` | uint256 | The 256-bit result | ### mulDivRoundingUp + ```solidity function mulDivRoundingUp( uint256 a, @@ -34,17 +41,19 @@ Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv uint256 denominator ) internal pure returns (uint256 result) ``` -Calculates ceil(aƗbĆ·denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 +Calculates ceil(aƗbĆ·denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`a` | uint256 | The multiplicand -|`b` | uint256 | The multiplier -|`denominator` | uint256 | The divisor + +| Name | Type | Description | +| :------------ | :------ | :--------------- | +| `a` | uint256 | The multiplicand | +| `b` | uint256 | The multiplier | +| `denominator` | uint256 | The divisor | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`result`| uint256 | The 256-bit result + +| Name | Type | Description | +| :------- | :------ | :----------------- | +| `result` | uint256 | The 256-bit result | diff --git a/versioned_docs/version-V3/reference/core/libraries/LiquidityMath.md b/versioned_docs/version-V3/reference/core/libraries/LiquidityMath.md index eedf88e7c3..a77db5120c 100644 --- a/versioned_docs/version-V3/reference/core/libraries/LiquidityMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/LiquidityMath.md @@ -1,24 +1,25 @@ - - - ## Functions + ### addDelta + ```solidity function addDelta( uint128 x, int128 y ) internal pure returns (uint128 z) ``` -Add a signed liquidity delta to liquidity and revert if it overflows or underflows +Add a signed liquidity delta to liquidity and revert if it overflows or underflows #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | uint128 | The liquidity before change -|`y` | int128 | The delta by which liquidity should be changed + +| Name | Type | Description | +| :--- | :------ | :--------------------------------------------- | +| `x` | uint128 | The liquidity before change | +| `y` | int128 | The delta by which liquidity should be changed | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| uint128 | The liquidity delta + +| Name | Type | Description | +| :--- | :------ | :------------------ | +| `z` | uint128 | The liquidity delta | diff --git a/versioned_docs/version-V3/reference/core/libraries/LowGasSafeMath.md b/versioned_docs/version-V3/reference/core/libraries/LowGasSafeMath.md index 3a9b8eb738..3a722ed257 100644 --- a/versioned_docs/version-V3/reference/core/libraries/LowGasSafeMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/LowGasSafeMath.md @@ -1,104 +1,123 @@ Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost - ## Functions + ### add + ```solidity function add( uint256 x, uint256 y ) internal pure returns (uint256 z) ``` -Returns x + y, reverts if sum overflows uint256 +Returns x + y, reverts if sum overflows uint256 #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | uint256 | The augend -|`y` | uint256 | The addend + +| Name | Type | Description | +| :--- | :------ | :---------- | +| `x` | uint256 | The augend | +| `y` | uint256 | The addend | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| uint256 | The sum of x and y + +| Name | Type | Description | +| :--- | :------ | :----------------- | +| `z` | uint256 | The sum of x and y | + ### sub + ```solidity function sub( uint256 x, uint256 y ) internal pure returns (uint256 z) ``` -Returns x - y, reverts if underflows +Returns x - y, reverts if underflows #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | uint256 | The minuend -|`y` | uint256 | The subtrahend + +| Name | Type | Description | +| :--- | :------ | :------------- | +| `x` | uint256 | The minuend | +| `y` | uint256 | The subtrahend | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| uint256 | The difference of x and y + +| Name | Type | Description | +| :--- | :------ | :------------------------ | +| `z` | uint256 | The difference of x and y | + ### mul + ```solidity function mul( uint256 x, uint256 y ) internal pure returns (uint256 z) ``` -Returns x * y, reverts if overflows +Returns x \* y, reverts if overflows #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | uint256 | The multiplicand -|`y` | uint256 | The multiplier + +| Name | Type | Description | +| :--- | :------ | :--------------- | +| `x` | uint256 | The multiplicand | +| `y` | uint256 | The multiplier | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| uint256 | The product of x and y + +| Name | Type | Description | +| :--- | :------ | :--------------------- | +| `z` | uint256 | The product of x and y | + ### add + ```solidity function add( int256 x, int256 y ) internal pure returns (int256 z) ``` -Returns x + y, reverts if overflows or underflows +Returns x + y, reverts if overflows or underflows #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | int256 | The augend -|`y` | int256 | The addend + +| Name | Type | Description | +| :--- | :----- | :---------- | +| `x` | int256 | The augend | +| `y` | int256 | The addend | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| int256 | The sum of x and y + +| Name | Type | Description | +| :--- | :----- | :----------------- | +| `z` | int256 | The sum of x and y | + ### sub + ```solidity function sub( int256 x, int256 y ) internal pure returns (int256 z) ``` -Returns x - y, reverts if overflows or underflows +Returns x - y, reverts if overflows or underflows #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | int256 | The minuend -|`y` | int256 | The subtrahend + +| Name | Type | Description | +| :--- | :----- | :------------- | +| `x` | int256 | The minuend | +| `y` | int256 | The subtrahend | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| int256 | The difference of x and y + +| Name | Type | Description | +| :--- | :----- | :------------------------ | +| `z` | int256 | The difference of x and y | diff --git a/versioned_docs/version-V3/reference/core/libraries/Oracle.md b/versioned_docs/version-V3/reference/core/libraries/Oracle.md index f7445ef2e4..9a8503b7f1 100644 --- a/versioned_docs/version-V3/reference/core/libraries/Oracle.md +++ b/versioned_docs/version-V3/reference/core/libraries/Oracle.md @@ -7,28 +7,34 @@ Observations are overwritten when the full length of the oracle array is populat The most recent observation is available, independent of the length of the oracle array, by passing 0 to observe() ## Functions + ### initialize + ```solidity function initialize( struct Oracle.Observation[65535] self, uint32 time ) internal returns (uint16 cardinality, uint16 cardinalityNext) ``` -Initialize the oracle array by writing the first slot. Called once for the lifecycle of the observations array +Initialize the oracle array by writing the first slot. Called once for the lifecycle of the observations array #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | struct Oracle.Observation[65535] | The stored oracle array -|`time` | uint32 | The time of the oracle initialization, via block.timestamp truncated to uint32 + +| Name | Type | Description | +| :----- | :------------------------------- | :----------------------------------------------------------------------------- | +| `self` | struct Oracle.Observation[65535] | The stored oracle array | +| `time` | uint32 | The time of the oracle initialization, via block.timestamp truncated to uint32 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`cardinality`| uint16 | The number of populated elements in the oracle array -|`cardinalityNext`| uint16 | The new length of the oracle array, independent of population + +| Name | Type | Description | +| :---------------- | :----- | :------------------------------------------------------------ | +| `cardinality` | uint16 | The number of populated elements in the oracle array | +| `cardinalityNext` | uint16 | The new length of the oracle array, independent of population | + ### write + ```solidity function write( struct Oracle.Observation[65535] self, @@ -40,6 +46,7 @@ Initialize the oracle array by writing the first slot. Called once for the lifec uint16 cardinalityNext ) internal returns (uint16 indexUpdated, uint16 cardinalityUpdated) ``` + Writes an oracle observation to the array Writable at most once per block. Index represents the most recently written element. cardinality and index must be tracked externally. @@ -47,22 +54,26 @@ If the index is at the end of the allowable array length (according to cardinali is greater than the current one, cardinality may be increased. This restriction is created to preserve ordering. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | struct Oracle.Observation[65535] | The stored oracle array -|`index` | uint16 | The location of the most recently updated observation -|`blockTimestamp` | uint32 | The timestamp of the new observation -|`tick` | int24 | The active tick at the time of the new observation -|`liquidity` | uint128 | The total in-range liquidity at the time of the new observation -|`cardinality` | uint16 | The number of populated elements in the oracle array -|`cardinalityNext` | uint16 | The new length of the oracle array, independent of population + +| Name | Type | Description | +| :---------------- | :------------------------------- | :-------------------------------------------------------------- | +| `self` | struct Oracle.Observation[65535] | The stored oracle array | +| `index` | uint16 | The location of the most recently updated observation | +| `blockTimestamp` | uint32 | The timestamp of the new observation | +| `tick` | int24 | The active tick at the time of the new observation | +| `liquidity` | uint128 | The total in-range liquidity at the time of the new observation | +| `cardinality` | uint16 | The number of populated elements in the oracle array | +| `cardinalityNext` | uint16 | The new length of the oracle array, independent of population | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`indexUpdated`| uint16 | The new index of the most recently written element in the oracle array -|`cardinalityUpdated`| uint16 | The new cardinality of the oracle array + +| Name | Type | Description | +| :------------------- | :----- | :--------------------------------------------------------------------- | +| `indexUpdated` | uint16 | The new index of the most recently written element in the oracle array | +| `cardinalityUpdated` | uint16 | The new cardinality of the oracle array | + ### grow + ```solidity function grow( struct Oracle.Observation[65535] self, @@ -70,21 +81,25 @@ is greater than the current one, cardinality may be increased. This restriction uint16 next ) internal returns (uint16) ``` -Prepares the oracle array to store up to `next` observations +Prepares the oracle array to store up to `next` observations #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | struct Oracle.Observation[65535] | The stored oracle array -|`current` | uint16 | The current next cardinality of the oracle array -|`next` | uint16 | The proposed next cardinality which will be populated in the oracle array + +| Name | Type | Description | +| :-------- | :------------------------------- | :------------------------------------------------------------------------ | +| `self` | struct Oracle.Observation[65535] | The stored oracle array | +| `current` | uint16 | The current next cardinality of the oracle array | +| `next` | uint16 | The proposed next cardinality which will be populated in the oracle array | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`next`| uint16 | The next cardinality which will be populated in the oracle array + +| Name | Type | Description | +| :----- | :----- | :--------------------------------------------------------------- | +| `next` | uint16 | The next cardinality which will be populated in the oracle array | + ### observe + ```solidity function observe( struct Oracle.Observation[65535] self, @@ -96,23 +111,26 @@ Prepares the oracle array to store up to `next` observations uint16 cardinality ) internal view returns (int56[] tickCumulatives, uint160[] liquidityCumulatives) ``` + Returns the accumulator values as of each time seconds ago from the given time in the array of `secondsAgos` Reverts if `secondsAgos` > oldest observation #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | struct Oracle.Observation[65535] | The stored oracle array -|`time` | uint32 | The current block.timestamp -|`secondsAgos` | uint32[] | Each amount of time to look back, in seconds, at which point to return an observation -|`tick` | int24 | The current tick -|`index` | uint16 | The location of a given observation within the oracle array -|`liquidity` | uint128 | The current in-range pool liquidity -|`cardinality` | uint16 | The number of populated elements in the oracle array + +| Name | Type | Description | +| :------------ | :------------------------------- | :------------------------------------------------------------------------------------ | +| `self` | struct Oracle.Observation[65535] | The stored oracle array | +| `time` | uint32 | The current block.timestamp | +| `secondsAgos` | uint32[] | Each amount of time to look back, in seconds, at which point to return an observation | +| `tick` | int24 | The current tick | +| `index` | uint16 | The location of a given observation within the oracle array | +| `liquidity` | uint128 | The current in-range pool liquidity | +| `cardinality` | uint16 | The number of populated elements in the oracle array | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`tickCumulatives`| int56[] | The tick * time elapsed since the pool was first initialized, as of each `secondsAgo` -|`liquidityCumulatives`| uint160[] | The liquidity * time elapsed since the pool was first initialized, as of each `secondsAgo` + +| Name | Type | Description | +| :--------------------- | :-------- | :------------------------------------------------------------------------------------------ | +| `tickCumulatives` | int56[] | The tick \* time elapsed since the pool was first initialized, as of each `secondsAgo` | +| `liquidityCumulatives` | uint160[] | The liquidity \* time elapsed since the pool was first initialized, as of each `secondsAgo` | diff --git a/versioned_docs/version-V3/reference/core/libraries/Position.md b/versioned_docs/version-V3/reference/core/libraries/Position.md index c12cee15cb..b324e13dc7 100644 --- a/versioned_docs/version-V3/reference/core/libraries/Position.md +++ b/versioned_docs/version-V3/reference/core/libraries/Position.md @@ -3,7 +3,9 @@ Positions represent an owner address' liquidity between a lower and upper tick b Positions store additional state for tracking fees owed to the position ## Functions + ### get + ```solidity function get( mapping(bytes32 => struct Position.Info) self, @@ -12,22 +14,26 @@ Positions store additional state for tracking fees owed to the position int24 tickUpper ) internal view returns (struct Position.Info position) ``` -Returns the Info struct of a position, given an owner and position boundaries +Returns the Info struct of a position, given an owner and position boundaries #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(bytes32 => struct Position.Info) | The mapping containing all user positions -|`owner` | address | The address of the position owner -|`tickLower` | int24 | The lower tick boundary of the position -|`tickUpper` | int24 | The upper tick boundary of the position + +| Name | Type | Description | +| :---------- | :--------------------------------------- | :---------------------------------------- | +| `self` | mapping(bytes32 => struct Position.Info) | The mapping containing all user positions | +| `owner` | address | The address of the position owner | +| `tickLower` | int24 | The lower tick boundary of the position | +| `tickUpper` | int24 | The upper tick boundary of the position | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`position`| struct Position.Info | The position info struct of the given owners' position + +| Name | Type | Description | +| :--------- | :------------------- | :----------------------------------------------------- | +| `position` | struct Position.Info | The position info struct of the given owners' position | + ### update + ```solidity function update( struct Position.Info self, @@ -36,14 +42,14 @@ Returns the Info struct of a position, given an owner and position boundaries uint256 feeGrowthInside1X128 ) internal ``` -Credits accumulated fees to a user's position +Credits accumulated fees to a user's position #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | struct Position.Info | The mapping containing all user positions -|`liquidityDelta` | int128 | The change in pool liquidity as a result of the position update -|`feeGrowthInside0X128` | uint256 | The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries -|`feeGrowthInside1X128` | uint256 | The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries +| Name | Type | Description | +| :--------------------- | :------------------- | :---------------------------------------------------------------------------------------------- | +| `self` | struct Position.Info | The mapping containing all user positions | +| `liquidityDelta` | int128 | The change in pool liquidity as a result of the position update | +| `feeGrowthInside0X128` | uint256 | The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries | +| `feeGrowthInside1X128` | uint256 | The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries | diff --git a/versioned_docs/version-V3/reference/core/libraries/SafeCast.md b/versioned_docs/version-V3/reference/core/libraries/SafeCast.md index 80f046c9b9..dbc9fb5a86 100644 --- a/versioned_docs/version-V3/reference/core/libraries/SafeCast.md +++ b/versioned_docs/version-V3/reference/core/libraries/SafeCast.md @@ -1,58 +1,69 @@ Contains methods for safely casting between types - ## Functions + ### toUint160 + ```solidity function toUint160( uint256 y ) internal pure returns (uint160 z) ``` -Cast a uint256 to a uint160, revert on overflow +Cast a uint256 to a uint160, revert on overflow #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`y` | uint256 | The uint256 to be downcasted + +| Name | Type | Description | +| :--- | :------ | :--------------------------- | +| `y` | uint256 | The uint256 to be downcasted | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| uint160 | The downcasted integer, now type uint160 + +| Name | Type | Description | +| :--- | :------ | :--------------------------------------- | +| `z` | uint160 | The downcasted integer, now type uint160 | + ### toInt128 + ```solidity function toInt128( int256 y ) internal pure returns (int128 z) ``` -Cast a int256 to a int128, revert on overflow or underflow +Cast a int256 to a int128, revert on overflow or underflow #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`y` | int256 | The int256 to be downcasted + +| Name | Type | Description | +| :--- | :----- | :-------------------------- | +| `y` | int256 | The int256 to be downcasted | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| int128 | The downcasted integer, now type int128 + +| Name | Type | Description | +| :--- | :----- | :-------------------------------------- | +| `z` | int128 | The downcasted integer, now type int128 | + ### toInt256 + ```solidity function toInt256( uint256 y ) internal pure returns (int256 z) ``` -Cast a uint256 to a int256, revert on overflow +Cast a uint256 to a int256, revert on overflow #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`y` | uint256 | The uint256 to be casted + +| Name | Type | Description | +| :--- | :------ | :----------------------- | +| `y` | uint256 | The uint256 to be casted | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| int256 | The casted integer, now type int256 + +| Name | Type | Description | +| :--- | :----- | :---------------------------------- | +| `z` | int256 | The casted integer, now type int256 | diff --git a/versioned_docs/version-V3/reference/core/libraries/SecondsOutside.md b/versioned_docs/version-V3/reference/core/libraries/SecondsOutside.md index 61603b7dc6..9c850f82a0 100644 --- a/versioned_docs/version-V3/reference/core/libraries/SecondsOutside.md +++ b/versioned_docs/version-V3/reference/core/libraries/SecondsOutside.md @@ -6,7 +6,9 @@ Note "seconds outside" is always a relative measurement, only consistent for as have gross liquidity greater than 0. ## Functions + ### initialize + ```solidity function initialize( mapping(int24 => uint256) self, @@ -16,20 +18,22 @@ have gross liquidity greater than 0. uint32 time ) internal ``` + Called the first time a tick is used to set the seconds outside value. Assumes the tick is not initialized. - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside -|`tick` | int24 | the tick to be initialized -|`tickCurrent` | int24 | the current tick -|`tickSpacing` | int24 | the spacing between usable ticks -|`time` | uint32 | the current timestamp + +| Name | Type | Description | +| :------------ | :------------------------ | :-------------------------------------------- | +| `self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside | +| `tick` | int24 | the tick to be initialized | +| `tickCurrent` | int24 | the current tick | +| `tickSpacing` | int24 | the spacing between usable ticks | +| `time` | uint32 | the current timestamp | ### clear + ```solidity function clear( mapping(int24 => uint256) self, @@ -37,17 +41,19 @@ initialized. int24 tickSpacing ) internal ``` -Called when a tick is no longer used, to clear the seconds outside value of the tick +Called when a tick is no longer used, to clear the seconds outside value of the tick #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside -|`tick` | int24 | the tick to be cleared -|`tickSpacing` | int24 | the spacing between usable ticks + +| Name | Type | Description | +| :------------ | :------------------------ | :-------------------------------------------- | +| `self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside | +| `tick` | int24 | the tick to be cleared | +| `tickSpacing` | int24 | the spacing between usable ticks | ### cross + ```solidity function cross( mapping(int24 => uint256) self, @@ -56,19 +62,21 @@ Called when a tick is no longer used, to clear the seconds outside value of the uint32 time ) internal ``` + Called when an initialized tick is crossed to update the seconds outside for that tick. Must be called every time an initialized tick is crossed - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside -|`tick` | int24 | the tick to be crossed -|`tickSpacing` | int24 | the spacing between usable ticks -|`time` | uint32 | the current block timestamp truncated to 32 bits + +| Name | Type | Description | +| :------------ | :------------------------ | :----------------------------------------------- | +| `self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside | +| `tick` | int24 | the tick to be crossed | +| `tickSpacing` | int24 | the spacing between usable ticks | +| `time` | uint32 | the current block timestamp truncated to 32 bits | ### get + ```solidity function get( mapping(int24 => uint256) self, @@ -76,21 +84,25 @@ every time an initialized tick is crossed int24 tickSpacing ) internal view returns (uint32) ``` -Get the seconds outside for an initialized tick. Should be called only on initialized ticks. +Get the seconds outside for an initialized tick. Should be called only on initialized ticks. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside -|`tick` | int24 | the tick to get the seconds outside value for -|`tickSpacing` | int24 | the spacing between usable ticks + +| Name | Type | Description | +| :------------ | :------------------------ | :-------------------------------------------- | +| `self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside | +| `tick` | int24 | the tick to get the seconds outside value for | +| `tickSpacing` | int24 | the spacing between usable ticks | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint32 | seconds outside value for that tick + +| Type | Description | +| :----- | :---------------------------------- | +| uint32 | seconds outside value for that tick | + ### secondsInside + ```solidity function secondsInside( mapping(int24 => uint256) self, @@ -100,20 +112,23 @@ Get the seconds outside for an initialized tick. Should be called only on initia int24 tickSpacing ) internal view returns (uint32) ``` -Get the seconds inside a tick range, assuming both tickLower and tickUpper are initialized +Get the seconds inside a tick range, assuming both tickLower and tickUpper are initialized #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside -|`tickLower` | int24 | the lower tick for which to get seconds inside -|`tickUpper` | int24 | the upper tick for which to get seconds inside -|`tickCurrent` | int24 | the current tick -|`tickSpacing` | int24 | the spacing between usable ticks + +| Name | Type | Description | +| :------------ | :------------------------ | :--------------------------------------------- | +| `self` | mapping(int24 => uint256) | the packed mapping of tick to seconds outside | +| `tickLower` | int24 | the lower tick for which to get seconds inside | +| `tickUpper` | int24 | the upper tick for which to get seconds inside | +| `tickCurrent` | int24 | the current tick | +| `tickSpacing` | int24 | the spacing between usable ticks | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`a`| uint32 | relative seconds inside value that can be snapshotted and compared to a later snapshot to compute + +| Name | Type | Description | +| :--- | :----- | :------------------------------------------------------------------------------------------------ | +| `a` | uint32 | relative seconds inside value that can be snapshotted and compared to a later snapshot to compute | + time spent between tickLower and tickUpper, i.e. time that a position's liquidity was in use. diff --git a/versioned_docs/version-V3/reference/core/libraries/SqrtPriceMath.md b/versioned_docs/version-V3/reference/core/libraries/SqrtPriceMath.md index 000fbd7a87..75e54e22ae 100644 --- a/versioned_docs/version-V3/reference/core/libraries/SqrtPriceMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/SqrtPriceMath.md @@ -1,8 +1,9 @@ Contains the math that uses square root of price as a Q64.96 and liquidity to compute deltas - ## Functions + ### getNextSqrtPriceFromAmount0RoundingUp + ```solidity function getNextSqrtPriceFromAmount0RoundingUp( uint160 sqrtPX96, @@ -11,27 +12,32 @@ Contains the math that uses square root of price as a Q64.96 and liquidity to co bool add ) internal pure returns (uint160) ``` + Gets the next sqrt price given a delta of token0 Always rounds up, because in the exact output case (increasing price) we need to move the price at least far enough to get the desired output amount, and in the exact input case (decreasing price) we need to move the price less in order to not send too much output. -The most precise formula for this is liquidity * sqrtPX96 / (liquidity +- amount * sqrtPX96), +The most precise formula for this is liquidity _ sqrtPX96 / (liquidity +- amount _ sqrtPX96), if this is impossible because of overflow, we calculate liquidity / (liquidity / sqrtPX96 +- amount). #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtPX96` | uint160 | The starting price, i.e. before accounting for the token0 delta -|`liquidity` | uint128 | The amount of usable liquidity -|`amount` | uint256 | How much of token0 to add or remove from virtual reserves -|`add` | bool | Whether to add or remove the amount of token0 + +| Name | Type | Description | +| :---------- | :------ | :-------------------------------------------------------------- | +| `sqrtPX96` | uint160 | The starting price, i.e. before accounting for the token0 delta | +| `liquidity` | uint128 | The amount of usable liquidity | +| `amount` | uint256 | How much of token0 to add or remove from virtual reserves | +| `add` | bool | Whether to add or remove the amount of token0 | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint160 | price after adding or removing amount, depending on add + +| Type | Description | +| :------ | :------------------------------------------------------ | +| uint160 | price after adding or removing amount, depending on add | + ### getNextSqrtPriceFromAmount1RoundingDown + ```solidity function getNextSqrtPriceFromAmount1RoundingDown( uint160 sqrtPX96, @@ -40,6 +46,7 @@ if this is impossible because of overflow, we calculate liquidity / (liquidity / bool add ) internal pure returns (uint160) ``` + Gets the next sqrt price given a delta of token1 Always rounds down, because in the exact output case (decreasing price) we need to move the price at least @@ -48,18 +55,22 @@ price less in order to not send too much output. The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amount / liquidity #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtPX96` | uint160 | The starting price, i.e., before accounting for the token1 delta -|`liquidity` | uint128 | The amount of usable liquidity -|`amount` | uint256 | How much of token1 to add, or remove, from virtual reserves -|`add` | bool | Whether to add, or remove, the amount of token1 + +| Name | Type | Description | +| :---------- | :------ | :--------------------------------------------------------------- | +| `sqrtPX96` | uint160 | The starting price, i.e., before accounting for the token1 delta | +| `liquidity` | uint128 | The amount of usable liquidity | +| `amount` | uint256 | How much of token1 to add, or remove, from virtual reserves | +| `add` | bool | Whether to add, or remove, the amount of token1 | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint160 | price after adding or removing `amount` + +| Type | Description | +| :------ | :-------------------------------------- | +| uint160 | price after adding or removing `amount` | + ### getNextSqrtPriceFromInput + ```solidity function getNextSqrtPriceFromInput( uint160 sqrtPX96, @@ -68,23 +79,28 @@ The formula we compute is within <1 wei of the lossless version: sqrtPX96 +- amo bool zeroForOne ) internal pure returns (uint160 sqrtQX96) ``` + Gets the next sqrt price given an input amount of token0 or token1 Throws if price or liquidity are 0, or if the next price is out of bounds #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtPX96` | uint160 | The starting price, i.e., before accounting for the input amount -|`liquidity` | uint128 | The amount of usable liquidity -|`amountIn` | uint256 | How much of token0, or token1, is being swapped in -|`zeroForOne` | bool | Whether the amount in is token0 or token1 + +| Name | Type | Description | +| :----------- | :------ | :--------------------------------------------------------------- | +| `sqrtPX96` | uint160 | The starting price, i.e., before accounting for the input amount | +| `liquidity` | uint128 | The amount of usable liquidity | +| `amountIn` | uint256 | How much of token0, or token1, is being swapped in | +| `zeroForOne` | bool | Whether the amount in is token0 or token1 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`sqrtQX96`| uint160 | The price after adding the input amount to token0 or token1 + +| Name | Type | Description | +| :--------- | :------ | :---------------------------------------------------------- | +| `sqrtQX96` | uint160 | The price after adding the input amount to token0 or token1 | + ### getNextSqrtPriceFromOutput + ```solidity function getNextSqrtPriceFromOutput( uint160 sqrtPX96, @@ -93,23 +109,28 @@ Throws if price or liquidity are 0, or if the next price is out of bounds bool zeroForOne ) internal pure returns (uint160 sqrtQX96) ``` + Gets the next sqrt price given an output amount of token0 or token1 Throws if price or liquidity are 0 or the next price is out of bounds #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtPX96` | uint160 | The starting price before accounting for the output amount -|`liquidity` | uint128 | The amount of usable liquidity -|`amountOut` | uint256 | How much of token0, or token1, is being swapped out -|`zeroForOne` | bool | Whether the amount out is token0 or token1 + +| Name | Type | Description | +| :----------- | :------ | :--------------------------------------------------------- | +| `sqrtPX96` | uint160 | The starting price before accounting for the output amount | +| `liquidity` | uint128 | The amount of usable liquidity | +| `amountOut` | uint256 | How much of token0, or token1, is being swapped out | +| `zeroForOne` | bool | Whether the amount out is token0 or token1 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`sqrtQX96`| uint160 | The price after removing the output amount of token0 or token1 + +| Name | Type | Description | +| :--------- | :------ | :------------------------------------------------------------- | +| `sqrtQX96` | uint160 | The price after removing the output amount of token0 or token1 | + ### getAmount0Delta + ```solidity function getAmount0Delta( uint160 sqrtRatioAX96, @@ -118,24 +139,29 @@ Throws if price or liquidity are 0 or the next price is out of bounds bool roundUp ) internal pure returns (uint256 amount0) ``` + Gets the amount0 delta between two prices Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper), -i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower)) +i.e. liquidity _ (sqrt(upper) - sqrt(lower)) / (sqrt(upper) _ sqrt(lower)) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price -|`sqrtRatioBX96` | uint160 | Another sqrt price -|`liquidity` | uint128 | The amount of usable liquidity -|`roundUp` | bool | Whether to round the amount up or down + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price | +| `sqrtRatioBX96` | uint160 | Another sqrt price | +| `liquidity` | uint128 | The amount of usable liquidity | +| `roundUp` | bool | Whether to round the amount up or down | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| uint256 | Amount of token0 required to cover a position of size liquidity between the two passed prices + +| Name | Type | Description | +| :-------- | :------ | :-------------------------------------------------------------------------------------------- | +| `amount0` | uint256 | Amount of token0 required to cover a position of size liquidity between the two passed prices | + ### getAmount1Delta + ```solidity function getAmount1Delta( uint160 sqrtRatioAX96, @@ -144,23 +170,28 @@ i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower)) bool roundUp ) internal pure returns (uint256 amount1) ``` + Gets the amount1 delta between two prices -Calculates liquidity * (sqrt(upper) - sqrt(lower)) +Calculates liquidity \* (sqrt(upper) - sqrt(lower)) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price -|`sqrtRatioBX96` | uint160 | Another sqrt price -|`liquidity` | uint128 | The amount of usable liquidity -|`roundUp` | bool | Whether to round the amount up, or down + +| Name | Type | Description | +| :-------------- | :------ | :-------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price | +| `sqrtRatioBX96` | uint160 | Another sqrt price | +| `liquidity` | uint128 | The amount of usable liquidity | +| `roundUp` | bool | Whether to round the amount up, or down | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount1`| uint256 | Amount of token1 required to cover a position of size liquidity between the two passed prices + +| Name | Type | Description | +| :-------- | :------ | :-------------------------------------------------------------------------------------------- | +| `amount1` | uint256 | Amount of token1 required to cover a position of size liquidity between the two passed prices | + ### getAmount0Delta + ```solidity function getAmount0Delta( uint160 sqrtRatioAX96, @@ -168,21 +199,25 @@ Calculates liquidity * (sqrt(upper) - sqrt(lower)) int128 liquidity ) internal pure returns (int256 amount0) ``` -Helper that gets signed token0 delta +Helper that gets signed token0 delta #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price -|`sqrtRatioBX96` | uint160 | Another sqrt price -|`liquidity` | int128 | The change in liquidity for which to compute the amount0 delta + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price | +| `sqrtRatioBX96` | uint160 | Another sqrt price | +| `liquidity` | int128 | The change in liquidity for which to compute the amount0 delta | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| int256 | Amount of token0 corresponding to the passed liquidityDelta between the two prices + +| Name | Type | Description | +| :-------- | :----- | :--------------------------------------------------------------------------------- | +| `amount0` | int256 | Amount of token0 corresponding to the passed liquidityDelta between the two prices | + ### getAmount1Delta + ```solidity function getAmount1Delta( uint160 sqrtRatioAX96, @@ -190,17 +225,19 @@ Helper that gets signed token0 delta int128 liquidity ) internal pure returns (int256 amount1) ``` -Helper that gets signed token1 delta +Helper that gets signed token1 delta #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price -|`sqrtRatioBX96` | uint160 | Another sqrt price -|`liquidity` | int128 | The change in liquidity for which to compute the amount1 delta + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price | +| `sqrtRatioBX96` | uint160 | Another sqrt price | +| `liquidity` | int128 | The change in liquidity for which to compute the amount1 delta | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount1`| int256 | Amount of token1 corresponding to the passed liquidityDelta between the two prices + +| Name | Type | Description | +| :-------- | :----- | :--------------------------------------------------------------------------------- | +| `amount1` | int256 | Amount of token1 corresponding to the passed liquidityDelta between the two prices | diff --git a/versioned_docs/version-V3/reference/core/libraries/SwapMath.md b/versioned_docs/version-V3/reference/core/libraries/SwapMath.md index 653e8a8948..36d97ba0b8 100644 --- a/versioned_docs/version-V3/reference/core/libraries/SwapMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/SwapMath.md @@ -1,8 +1,9 @@ Contains methods for computing the result of a swap within a single tick price range, i.e., a single tick. - ## Functions + ### computeSwapStep + ```solidity function computeSwapStep( uint160 sqrtRatioCurrentX96, @@ -12,23 +13,26 @@ Contains methods for computing the result of a swap within a single tick price r uint24 feePips ) internal pure returns (uint160 sqrtRatioNextX96, uint256 amountIn, uint256 amountOut, uint256 feeAmount) ``` + Computes the result of swapping some amount in, or amount out, given the parameters of the swap The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioCurrentX96` | uint160 | The current sqrt price of the pool -|`sqrtRatioTargetX96` | uint160 | The price that cannot be exceeded, from which the direction of the swap is inferred -|`liquidity` | uint128 | The usable liquidity -|`amountRemaining` | int256 | How much input or output amount is remaining to be swapped in/out -|`feePips` | uint24 | The fee taken from the input amount, expressed in hundredths of a bip + +| Name | Type | Description | +| :-------------------- | :------ | :---------------------------------------------------------------------------------- | +| `sqrtRatioCurrentX96` | uint160 | The current sqrt price of the pool | +| `sqrtRatioTargetX96` | uint160 | The price that cannot be exceeded, from which the direction of the swap is inferred | +| `liquidity` | uint128 | The usable liquidity | +| `amountRemaining` | int256 | How much input or output amount is remaining to be swapped in/out | +| `feePips` | uint24 | The fee taken from the input amount, expressed in hundredths of a bip | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`sqrtRatioNextX96`| uint160 | The price after swapping the amount in/out, not to exceed the price target -|`amountIn`| uint256 | The amount to be swapped in, of either token0 or token1, based on the direction of the swap -|`amountOut`| uint256 | The amount to be received, of either token0 or token1, based on the direction of the swap -|`feeAmount`| uint256 | The amount of input that will be taken as a fee + +| Name | Type | Description | +| :----------------- | :------ | :------------------------------------------------------------------------------------------ | +| `sqrtRatioNextX96` | uint160 | The price after swapping the amount in/out, not to exceed the price target | +| `amountIn` | uint256 | The amount to be swapped in, of either token0 or token1, based on the direction of the swap | +| `amountOut` | uint256 | The amount to be received, of either token0 or token1, based on the direction of the swap | +| `feeAmount` | uint256 | The amount of input that will be taken as a fee | diff --git a/versioned_docs/version-V3/reference/core/libraries/Tick.md b/versioned_docs/version-V3/reference/core/libraries/Tick.md index 3f2a4d8f2d..1f38a37d74 100644 --- a/versioned_docs/version-V3/reference/core/libraries/Tick.md +++ b/versioned_docs/version-V3/reference/core/libraries/Tick.md @@ -1,27 +1,33 @@ Contains functions for managing tick processes and relevant calculations - ## Functions + ### tickSpacingToMaxLiquidityPerTick + ```solidity function tickSpacingToMaxLiquidityPerTick( int24 tickSpacing ) internal pure returns (uint128) ``` + Derives max liquidity per tick from given tick spacing Executed within the pool constructor #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tickSpacing` | int24 | The amount of required tick separation, realized in multiples of `tickSpacing` e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ... | + +| Name | Type | Description | +| :------------ | :---- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `tickSpacing` | int24 | The amount of required tick separation, realized in multiples of `tickSpacing` e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ... | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint128 | max liquidity per tick + +| Type | Description | +| :------ | :--------------------- | +| uint128 | max liquidity per tick | + ### getFeeGrowthInside + ```solidity function getFeeGrowthInside( mapping(int24 => struct Tick.Info) self, @@ -32,25 +38,29 @@ Executed within the pool constructor uint256 feeGrowthGlobal1X128 ) internal view returns (uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) ``` -Retrieves fee growth data +Retrieves fee growth data #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks -|`tickLower` | int24 | The lower tick boundary of the position -|`tickUpper` | int24 | The upper tick boundary of the position -|`tickCurrent` | int24 | The current tick -|`feeGrowthGlobal0X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token0 -|`feeGrowthGlobal1X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token1 + +| Name | Type | Description | +| :--------------------- | :--------------------------------- | :---------------------------------------------------------------- | +| `self` | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks | +| `tickLower` | int24 | The lower tick boundary of the position | +| `tickUpper` | int24 | The upper tick boundary of the position | +| `tickCurrent` | int24 | The current tick | +| `feeGrowthGlobal0X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token0 | +| `feeGrowthGlobal1X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token1 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`feeGrowthInside0X128`| uint256 | The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries -|`feeGrowthInside1X128`| uint256 | The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries + +| Name | Type | Description | +| :--------------------- | :------ | :---------------------------------------------------------------------------------------------- | +| `feeGrowthInside0X128` | uint256 | The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries | +| `feeGrowthInside1X128` | uint256 | The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries | + ### update + ```solidity function update( mapping(int24 => struct Tick.Info) self, @@ -63,42 +73,48 @@ Retrieves fee growth data uint128 maxLiquidity ) internal returns (bool flipped) ``` -Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa +Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks -|`tick` | int24 | The tick that will be updated -|`tickCurrent` | int24 | The current tick -|`liquidityDelta` | int128 | A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left) -|`feeGrowthGlobal0X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token0 -|`feeGrowthGlobal1X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token1 -|`upper` | bool | true for updating a position's upper tick, or false for updating a position's lower tick -|`maxLiquidity` | uint128 | The maximum liquidity allocation for a single tick + +| Name | Type | Description | +| :--------------------- | :--------------------------------- | :--------------------------------------------------------------------------------------------------------- | +| `self` | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks | +| `tick` | int24 | The tick that will be updated | +| `tickCurrent` | int24 | The current tick | +| `liquidityDelta` | int128 | A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left) | +| `feeGrowthGlobal0X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token0 | +| `feeGrowthGlobal1X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token1 | +| `upper` | bool | true for updating a position's upper tick, or false for updating a position's lower tick | +| `maxLiquidity` | uint128 | The maximum liquidity allocation for a single tick | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`flipped`| bool | Whether the tick was flipped from initialized to uninitialized, or vice versa + +| Name | Type | Description | +| :-------- | :--- | :---------------------------------------------------------------------------- | +| `flipped` | bool | Whether the tick was flipped from initialized to uninitialized, or vice versa | + ### clear + ```solidity function clear( mapping(int24 => struct Tick.Info) self, int24 tick ) internal ``` -Clears tick data +Clears tick data #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => struct Tick.Info) | The mapping containing all initialized tick information for initialized ticks -|`tick` | int24 | The tick that will be cleared + +| Name | Type | Description | +| :----- | :--------------------------------- | :---------------------------------------------------------------------------- | +| `self` | mapping(int24 => struct Tick.Info) | The mapping containing all initialized tick information for initialized ticks | +| `tick` | int24 | The tick that will be cleared | ### cross + ```solidity function cross( mapping(int24 => struct Tick.Info) self, @@ -107,18 +123,20 @@ Clears tick data uint256 feeGrowthGlobal1X128 ) internal returns (int128 liquidityNet) ``` -Transitions to next tick as needed by price movement +Transitions to next tick as needed by price movement #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks -|`tick` | int24 | The destination tick of the transition -|`feeGrowthGlobal0X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token0 -|`feeGrowthGlobal1X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token1 + +| Name | Type | Description | +| :--------------------- | :--------------------------------- | :---------------------------------------------------------------- | +| `self` | mapping(int24 => struct Tick.Info) | The mapping containing all tick information for initialized ticks | +| `tick` | int24 | The destination tick of the transition | +| `feeGrowthGlobal0X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token0 | +| `feeGrowthGlobal1X128` | uint256 | The all-time global fee growth, per unit of liquidity, in token1 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`liquidityNet`| int128 | The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left) + +| Name | Type | Description | +| :------------- | :----- | :------------------------------------------------------------------------------------------------- | +| `liquidityNet` | int128 | The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left) | diff --git a/versioned_docs/version-V3/reference/core/libraries/TickBitmap.md b/versioned_docs/version-V3/reference/core/libraries/TickBitmap.md index bf6439193e..59fee28865 100644 --- a/versioned_docs/version-V3/reference/core/libraries/TickBitmap.md +++ b/versioned_docs/version-V3/reference/core/libraries/TickBitmap.md @@ -3,7 +3,9 @@ Stores a packed mapping of tick index to its initialized state The mapping uses int16 for keys since ticks are represented as int24 and there are 256 (2^8) values per word. ## Functions + ### flipTick + ```solidity function flipTick( mapping(int16 => uint256) self, @@ -11,17 +13,19 @@ The mapping uses int16 for keys since ticks are represented as int24 and there a int24 tickSpacing ) internal ``` -Flips the initialized state for a given tick from false to true, or vice versa +Flips the initialized state for a given tick from false to true, or vice versa #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int16 => uint256) | The mapping in which to flip the tick -|`tick` | int24 | The tick to flip -|`tickSpacing` | int24 | The spacing between usable ticks + +| Name | Type | Description | +| :------------ | :------------------------ | :------------------------------------ | +| `self` | mapping(int16 => uint256) | The mapping in which to flip the tick | +| `tick` | int24 | The tick to flip | +| `tickSpacing` | int24 | The spacing between usable ticks | ### nextInitializedTickWithinOneWord + ```solidity function nextInitializedTickWithinOneWord( mapping(int16 => uint256) self, @@ -30,20 +34,22 @@ Flips the initialized state for a given tick from false to true, or vice versa bool lte ) internal view returns (int24 next, bool initialized) ``` + Returns the next initialized tick contained in the same word (or adjacent word) as the tick that is either to the left (less than or equal to) or right (greater than) of the given tick - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`self` | mapping(int16 => uint256) | The mapping in which to compute the next initialized tick -|`tick` | int24 | The starting tick -|`tickSpacing` | int24 | The spacing between usable ticks -|`lte` | bool | Whether to search for the next initialized tick to the left (less than or equal to the starting tick) + +| Name | Type | Description | +| :------------ | :------------------------ | :---------------------------------------------------------------------------------------------------- | +| `self` | mapping(int16 => uint256) | The mapping in which to compute the next initialized tick | +| `tick` | int24 | The starting tick | +| `tickSpacing` | int24 | The spacing between usable ticks | +| `lte` | bool | Whether to search for the next initialized tick to the left (less than or equal to the starting tick) | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`next`| int24 | The next initialized or uninitialized tick up to 256 ticks away from the current tick -|`initialized`| bool | Whether the next tick is initialized, as the function only searches within up to 256 ticks + +| Name | Type | Description | +| :------------ | :---- | :----------------------------------------------------------------------------------------- | +| `next` | int24 | The next initialized or uninitialized tick up to 256 ticks away from the current tick | +| `initialized` | bool | Whether the next tick is initialized, as the function only searches within up to 256 ticks | diff --git a/versioned_docs/version-V3/reference/core/libraries/TickMath.md b/versioned_docs/version-V3/reference/core/libraries/TickMath.md index 021f2326ef..ec34f80f6e 100644 --- a/versioned_docs/version-V3/reference/core/libraries/TickMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/TickMath.md @@ -1,45 +1,55 @@ Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports prices between 2**-128 and 2**128 - ## Functions + ### getSqrtRatioAtTick + ```solidity function getSqrtRatioAtTick( int24 tick ) internal pure returns (uint160 sqrtPriceX96) ``` -Calculates sqrt(1.0001^tick) * 2^96 + +Calculates sqrt(1.0001^tick) \* 2^96 Throws if |tick| > max tick #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tick` | int24 | The input tick for the above formula + +| Name | Type | Description | +| :----- | :---- | :----------------------------------- | +| `tick` | int24 | The input tick for the above formula | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`sqrtPriceX96`| uint160 | A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) + +| Name | Type | Description | +| :------------- | :------ | :----------------------------------------------------------------------------------------------- | +| `sqrtPriceX96` | uint160 | A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) | + at the given tick + ### getTickAtSqrtRatio + ```solidity function getTickAtSqrtRatio( uint160 sqrtPriceX96 ) internal pure returns (int24 tick) ``` + Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may ever return. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtPriceX96` | uint160 | The sqrt ratio for which to compute the tick as a Q64.96 + +| Name | Type | Description | +| :------------- | :------ | :------------------------------------------------------- | +| `sqrtPriceX96` | uint160 | The sqrt ratio for which to compute the tick as a Q64.96 | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`tick`| int24 | The greatest tick for which the ratio is less than or equal to the input ratio + +| Name | Type | Description | +| :----- | :---- | :----------------------------------------------------------------------------- | +| `tick` | int24 | The greatest tick for which the ratio is less than or equal to the input ratio | diff --git a/versioned_docs/version-V3/reference/core/libraries/TransferHelper.md b/versioned_docs/version-V3/reference/core/libraries/TransferHelper.md index 4be90fa106..e83e1439eb 100644 --- a/versioned_docs/version-V3/reference/core/libraries/TransferHelper.md +++ b/versioned_docs/version-V3/reference/core/libraries/TransferHelper.md @@ -1,8 +1,9 @@ Contains helper methods for interacting with ERC20 tokens that do not consistently return true/false - ## Functions + ### safeTransfer + ```solidity function safeTransfer( address token, @@ -10,14 +11,15 @@ Contains helper methods for interacting with ERC20 tokens that do not consistent uint256 value ) internal ``` + Transfers tokens from msg.sender to a recipient Calls transfer on token contract, errors with TF if transfer fails #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The contract address of the token which will be transferred -|`to` | address | The recipient of the transfer -|`value` | uint256 | The value of the transfer +| Name | Type | Description | +| :------ | :------ | :---------------------------------------------------------- | +| `token` | address | The contract address of the token which will be transferred | +| `to` | address | The recipient of the transfer | +| `value` | uint256 | The value of the transfer | diff --git a/versioned_docs/version-V3/reference/core/libraries/UnsafeMath.md b/versioned_docs/version-V3/reference/core/libraries/UnsafeMath.md index a6c582476d..145e04a982 100644 --- a/versioned_docs/version-V3/reference/core/libraries/UnsafeMath.md +++ b/versioned_docs/version-V3/reference/core/libraries/UnsafeMath.md @@ -1,25 +1,29 @@ Contains methods that perform common math functions but do not do any overflow or underflow checks - ## Functions + ### divRoundingUp + ```solidity function divRoundingUp( uint256 x, uint256 y ) internal pure returns (uint256 z) ``` + Returns ceil(x / y) panics if y == 0 #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`x` | uint256 | The dividend -|`y` | uint256 | The divisor + +| Name | Type | Description | +| :--- | :------ | :----------- | +| `x` | uint256 | The dividend | +| `y` | uint256 | The divisor | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`z`| uint256 | The quotient, ceil(x / y) + +| Name | Type | Description | +| :--- | :------ | :------------------------ | +| `z` | uint256 | The quotient, ceil(x / y) | diff --git a/versioned_docs/version-V3/reference/error-codes.md b/versioned_docs/version-V3/reference/error-codes.md index b92367a07f..120132dcf8 100644 --- a/versioned_docs/version-V3/reference/error-codes.md +++ b/versioned_docs/version-V3/reference/error-codes.md @@ -3,49 +3,47 @@ id: error-codes title: Error Codes --- - LiquidityMath.sol -* `LS`: Liquidity Sub -* `LA`: Liquidity Add +- `LS`: Liquidity Sub +- `LA`: Liquidity Add Oracle.sol -* `OLD`: The target must be chronologically after the oldest observation +- `OLD`: The target must be chronologically after the oldest observation + +- `I`: The pool has not been initialized -* `I`: The pool has not been initialized - Position.sol -* `NP`: Burn cannot be called for a position with 0 liquidity +- `NP`: Burn cannot be called for a position with 0 liquidity Tick.sol -* `LO`: LiquidityGrossAfter must be less than MaxLiquidity +- `LO`: LiquidityGrossAfter must be less than MaxLiquidity -TickMath.sol +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 +- `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 - +- `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 +- `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 diff --git a/versioned_docs/version-V3/reference/periphery/NonfungiblePositionManager.md b/versioned_docs/version-V3/reference/periphery/NonfungiblePositionManager.md index ce304e25fd..3efc9a4bc7 100644 --- a/versioned_docs/version-V3/reference/periphery/NonfungiblePositionManager.md +++ b/versioned_docs/version-V3/reference/periphery/NonfungiblePositionManager.md @@ -1,174 +1,191 @@ Wraps Uniswap V3 positions in the ERC721 non-fungible token interface - ## Functions + ### constructor + ```solidity function constructor( ) public ``` - - - ### positions + ```solidity 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: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The ID of the token that represents the position + +| Name | Type | Description | +| :-------- | :------ | :----------------------------------------------- | +| `tokenId` | uint256 | The ID of the token that represents the position | #### 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 + +| 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 | + ### mint + ```solidity 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: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct INonfungiblePositionManager.MintParams | The params necessary to mint a position, encoded as `MintParams` in calldata + +| Name | Type | Description | +| :------- | :-------------------------------------------- | :--------------------------------------------------------------------------- | +| `params` | struct INonfungiblePositionManager.MintParams | The params necessary to mint a position, encoded as `MintParams` in calldata | #### Return Values: -| 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 + +| 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 | + ### tokenURI + ```solidity function tokenURI( ) public view returns (string) ``` - - - ### baseURI + ```solidity function baseURI( ) public returns (string) ``` - - - ### increaseLiquidity + ```solidity function increaseLiquidity( struct INonfungiblePositionManager.IncreaseLiquidityParams params ) external returns (uint128 liquidity, uint256 amount0, uint256 amount1) ``` -Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` +Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct INonfungiblePositionManager.IncreaseLiquidityParams | tokenId The ID of the token for which liquidity is being increased, +| Name | Type | Description | +| :------- | :--------------------------------------------------------- | :------------------------------------------------------------------ | +| `params` | struct INonfungiblePositionManager.IncreaseLiquidityParams | tokenId The ID of the token for which liquidity is being increased, | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`liquidity`| uint128 | The new liquidity amount as a result of the increase -|`amount0`| uint256 | The amount of token0 to acheive resulting liquidity -|`amount1`| uint256 | The amount of token1 to acheive resulting liquidity + +| Name | Type | Description | +| :---------- | :------ | :--------------------------------------------------- | +| `liquidity` | uint128 | The new liquidity amount as a result of the increase | +| `amount0` | uint256 | The amount of token0 to acheive resulting liquidity | +| `amount1` | uint256 | The amount of token1 to acheive resulting liquidity | + ### decreaseLiquidity + ```solidity 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 +Decreases the amount of liquidity in a position and accounts it to the position #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct INonfungiblePositionManager.DecreaseLiquidityParams | tokenId The ID of the token for which liquidity is being decreased, + +| Name | Type | Description | +| :------- | :--------------------------------------------------------- | :------------------------------------------------------------------ | +| `params` | struct INonfungiblePositionManager.DecreaseLiquidityParams | tokenId The ID of the token for which liquidity is being decreased, | #### Return Values: -| 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 + +| 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 | + ### collect + ```solidity 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 +Collects up to a maximum amount of fees owed to a specific position to the recipient #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct INonfungiblePositionManager.CollectParams | tokenId The ID of the NFT for which tokens are being collected, + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| uint256 | The amount of fees collected in token0 -|`amount1`| uint256 | The amount of fees collected in token1 + +| Name | Type | Description | +| :-------- | :------ | :------------------------------------- | +| `amount0` | uint256 | The amount of fees collected in token0 | +| `amount1` | uint256 | The amount of fees collected in token1 | + ### burn + ```solidity 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: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The ID of the token that is being burned -### _getAndIncrementNonce +| Name | Type | Description | +| :-------- | :------ | :--------------------------------------- | +| `tokenId` | uint256 | The ID of the token that is being burned | + +### \_getAndIncrementNonce + ```solidity function _getAndIncrementNonce( ) internal returns (uint256) ``` - - - ### getApproved + ```solidity function getApproved( ) public view returns (address) @@ -176,15 +193,14 @@ must be collected first. Returns the account approved for `tokenId` token. Requirements: + - `tokenId` must exist. +### \_approve -### _approve ```solidity function _approve( ) internal ``` -Overrides _approve to use the operator in the position, which is packed with the position permit nonce - - +Overrides \_approve to use the operator in the position, which is packed with the position permit nonce diff --git a/versioned_docs/version-V3/reference/periphery/NonfungibleTokenPositionDescriptor.md b/versioned_docs/version-V3/reference/periphery/NonfungibleTokenPositionDescriptor.md index 2634ad632f..65ee4b61a4 100644 --- a/versioned_docs/version-V3/reference/periphery/NonfungibleTokenPositionDescriptor.md +++ b/versioned_docs/version-V3/reference/periphery/NonfungibleTokenPositionDescriptor.md @@ -1,46 +1,50 @@ Produces a string containing the data URI for a JSON metadata string - ## Functions + ### constructor + ```solidity function constructor( ) public ``` ### tokenURI + ```solidity 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: -| 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 + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`The`| contract INonfungiblePositionManager | URI of the ERC721-compliant metadata + +| Name | Type | Description | +| :---- | :----------------------------------- | :----------------------------------- | +| `The` | contract INonfungiblePositionManager | URI of the ERC721-compliant metadata | + ### flipRatio + ```solidity function flipRatio( ) public returns (bool) ``` ### tokenRatioPriority + ```solidity function tokenRatioPriority( ) public returns (int256) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/SwapRouter.md b/versioned_docs/version-V3/reference/periphery/SwapRouter.md index c7bb61ba94..81570c7036 100644 --- a/versioned_docs/version-V3/reference/periphery/SwapRouter.md +++ b/versioned_docs/version-V3/reference/periphery/SwapRouter.md @@ -3,16 +3,16 @@ Router for stateless execution of swaps against Uniswap V3 > Input parameters are viewable on the [**Swap Router Interface**](https://docs.uniswap.org/protocol/reference/periphery/interfaces/ISwapRouter) ## Functions + ### constructor + ```solidity function constructor( ) public ``` - - - ### uniswapV3SwapCallback + ```solidity function uniswapV3SwapCallback( int256 amount0Delta, @@ -20,6 +20,7 @@ Router for stateless execution of swaps against Uniswap V3 bytes data ) external ``` + Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. In the implementation you must pay the pool tokens owed for the swap. @@ -27,81 +28,97 @@ The caller of this method must be checked to be a UniswapV3Pool deployed by the amount0Delta and amount1Delta can both be 0 if no tokens were swapped. #### 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 IUniswapV3PoolActions#swap call + +| 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 IUniswapV3PoolActions#swap call | ### exactInputSingle + ```solidity function exactInputSingle( struct ISwapRouter.ExactInputSingleParams params ) external returns (uint256 amountOut) ``` -Swaps `amountIn` of one token for as much as possible of another token +Swaps `amountIn` of one token for as much as possible of another token #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct ISwapRouter.ExactInputSingleParams | The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata + +| Name | Type | Description | +| :------- | :---------------------------------------- | :------------------------------------------------------------------------------------- | +| `params` | struct ISwapRouter.ExactInputSingleParams | The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountOut`| uint256 | The amount of the received token + +| Name | Type | Description | +| :---------- | :------ | :------------------------------- | +| `amountOut` | uint256 | The amount of the received token | + ### exactInput + ```solidity 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 +Swaps `amountIn` of one token for as much as possible of another along the specified path #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct ISwapRouter.ExactInputParams | The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata + +| Name | Type | Description | +| :------- | :---------------------------------- | :----------------------------------------------------------------------------------------- | +| `params` | struct ISwapRouter.ExactInputParams | The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountOut`| uint256 | The amount of the received token + +| Name | Type | Description | +| :---------- | :------ | :------------------------------- | +| `amountOut` | uint256 | The amount of the received token | + ### exactOutputSingle + ```solidity function exactOutputSingle( struct ISwapRouter.ExactOutputSingleParams params ) external returns (uint256 amountIn) ``` -Swaps as little as possible of one token for `amountOut` of another token +Swaps as little as possible of one token for `amountOut` of another token #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct ISwapRouter.ExactOutputSingleParams | The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata + +| Name | Type | Description | +| :------- | :----------------------------------------- | :-------------------------------------------------------------------------------------- | +| `params` | struct ISwapRouter.ExactOutputSingleParams | The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountIn`| uint256 | The amount of the input token + +| Name | Type | Description | +| :--------- | :------ | :---------------------------- | +| `amountIn` | uint256 | The amount of the input token | + ### exactOutput + ```solidity 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) +Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct ISwapRouter.ExactOutputParams | The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata + +| Name | Type | Description | +| :------- | :----------------------------------- | :------------------------------------------------------------------------------------------ | +| `params` | struct ISwapRouter.ExactOutputParams | The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountIn`| uint256 | The amount of the input token + +| Name | Type | Description | +| :--------- | :------ | :---------------------------- | +| `amountIn` | uint256 | The amount of the input token | diff --git a/versioned_docs/version-V3/reference/periphery/V3Migrator.md b/versioned_docs/version-V3/reference/periphery/V3Migrator.md index 6114308bbb..1f2cfcea48 100644 --- a/versioned_docs/version-V3/reference/periphery/V3Migrator.md +++ b/versioned_docs/version-V3/reference/periphery/V3Migrator.md @@ -1,31 +1,22 @@ - - - ## Functions + ### constructor + ```solidity function constructor( ) public ``` - - - ### receive + ```solidity function receive( ) external ``` - - - ### migrate + ```solidity function migrate( ) external ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/_category_.json b/versioned_docs/version-V3/reference/periphery/_category_.json index ce4b3802fc..1e6987c254 100644 --- a/versioned_docs/version-V3/reference/periphery/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/_category_.json @@ -1,4 +1,4 @@ { - "label": "Periphery", - "position": 2 - } \ No newline at end of file + "label": "Periphery", + "position": 2 +} diff --git a/versioned_docs/version-V3/reference/periphery/base/BlockTimestamp.md b/versioned_docs/version-V3/reference/periphery/base/BlockTimestamp.md index 5b854067cf..1c41700034 100644 --- a/versioned_docs/version-V3/reference/periphery/base/BlockTimestamp.md +++ b/versioned_docs/version-V3/reference/periphery/base/BlockTimestamp.md @@ -1,8 +1,9 @@ - Base contract that is overridden for tests ## Functions -### _blockTimestamp + +### \_blockTimestamp + ```solidity function _blockTimestamp( ) internal view returns (uint256) @@ -10,8 +11,8 @@ Base contract that is overridden for tests Method that exists purely to be overridden for tests - #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint256 | current block timestamp + +| Type | Description | +| :------ | :---------------------- | +| uint256 | current block timestamp | diff --git a/versioned_docs/version-V3/reference/periphery/base/ERC721Permit.md b/versioned_docs/version-V3/reference/periphery/base/ERC721Permit.md index 2f917bc82b..0df50b8d13 100644 --- a/versioned_docs/version-V3/reference/periphery/base/ERC721Permit.md +++ b/versioned_docs/version-V3/reference/periphery/base/ERC721Permit.md @@ -1,8 +1,9 @@ Nonfungible tokens that support an approve via signature, i.e. permit - ## Functions -### _getAndIncrementNonce + +### \_getAndIncrementNonce + ```solidity function _getAndIncrementNonce( uint256 tokenId @@ -11,8 +12,8 @@ Nonfungible tokens that support an approve via signature, i.e. permit Gets the current nonce for a token ID and then increments it, returning the original value - ### constructor + ```solidity function constructor( string memory name_, @@ -20,24 +21,26 @@ Gets the current nonce for a token ID and then increments it, returning the orig string memory version_ ) internal ``` -Computes the nameHash and versionHash - +Computes the nameHash and versionHash ### DOMAIN_SEPARATOR + ```solidity function DOMAIN_SEPARATOR( ) public view override returns (bytes32) ``` + The domain separator used in the permit signature +#### Return Values: +| Type | Description | +| :------ | :---------------------------------------------------- | +| bytes32 | domain seperator used in encoding of permit signature | -#### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bytes32 | domain seperator used in encoding of permit signature ### permit + ```solidity function permit( address spender, @@ -48,16 +51,16 @@ The domain separator used in the permit signature bytes32 s ) external ``` -Approve of a specific token ID for spending by spender via signature +Approve of a specific token ID for spending by spender via signature #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`spender` | address | The account that is being approved -|`tokenId` | uint256 | The ID of the token that is being approved for spending -|`deadline` | uint256 | The deadline timestamp by which the call must be mined for the approve to work -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` +| Name | Type | Description | +| :--------- | :------ | :----------------------------------------------------------------------------- | +| `spender` | address | The account that is being approved | +| `tokenId` | uint256 | The ID of the token that is being approved for spending | +| `deadline` | uint256 | The deadline timestamp by which the call must be mined for the approve to work | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | diff --git a/versioned_docs/version-V3/reference/periphery/base/LiquidityManagement.md b/versioned_docs/version-V3/reference/periphery/base/LiquidityManagement.md index 076eaa35c4..f987f0e258 100644 --- a/versioned_docs/version-V3/reference/periphery/base/LiquidityManagement.md +++ b/versioned_docs/version-V3/reference/periphery/base/LiquidityManagement.md @@ -3,6 +3,7 @@ Internal functions for safely managing liquidity in Uniswap V3 ## Parameter Structs ### AddLiquidityParams + ```solidity struct AddLiquidityParams { address token0; @@ -17,8 +18,11 @@ Internal functions for safely managing liquidity in Uniswap V3 uint256 amount1Min; } ``` + ## Functions + ### uniswapV3MintCallback + ```solidity function uniswapV3MintCallback( uint256 amount0Owed, @@ -26,25 +30,26 @@ Internal functions for safely managing liquidity in Uniswap V3 bytes data ) external ``` + Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint. In the implementation you must pay the pool tokens owed for the minted liquidity. The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`amount0Owed` | uint256 | The amount of token0 due to the pool for the minted liquidity -|`amount1Owed` | uint256 | The amount of token1 due to the pool for the minted liquidity -|`data` | bytes | Any data passed through by the caller via the IUniswapV3PoolActions#mint call + +| Name | Type | Description | +| :------------ | :------ | :---------------------------------------------------------------------------- | +| `amount0Owed` | uint256 | The amount of token0 due to the pool for the minted liquidity | +| `amount1Owed` | uint256 | The amount of token1 due to the pool for the minted liquidity | +| `data` | bytes | Any data passed through by the caller via the IUniswapV3PoolActions#mint call | ### addLiquidity + ```solidity function addLiquidity( AddLiquidityParams memory params ) internal returns (uint128 liquidity, uint256 amount0, uint256 amount1, contract IUniswapV3Pool pool) ``` -Add liquidity to an initialized pool - - +Add liquidity to an initialized pool diff --git a/versioned_docs/version-V3/reference/periphery/base/Multicall.md b/versioned_docs/version-V3/reference/periphery/base/Multicall.md index 8ce5db1103..0670ffdaff 100644 --- a/versioned_docs/version-V3/reference/periphery/base/Multicall.md +++ b/versioned_docs/version-V3/reference/periphery/base/Multicall.md @@ -1,23 +1,27 @@ Enables calling multiple methods in a single call to the contract - ## Functions + ### multicall + ```solidity function multicall( bytes[] data ) external payable override returns (bytes[] results) ``` + Call multiple functions in the current contract and return the data from all of them if they all succeed The `msg.value` should not be trusted for any method callable from multicall. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`data` | bytes[] | The encoded function data for each of the calls to make to this contract + +| Name | Type | Description | +| :----- | :------ | :----------------------------------------------------------------------- | +| `data` | bytes[] | The encoded function data for each of the calls to make to this contract | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`results`| bytes[] | The results from each of the calls passed in via data + +| Name | Type | Description | +| :-------- | :------ | :---------------------------------------------------- | +| `results` | bytes[] | The results from each of the calls passed in via data | diff --git a/versioned_docs/version-V3/reference/periphery/base/PeripheryImmutableState.md b/versioned_docs/version-V3/reference/periphery/base/PeripheryImmutableState.md index 8b124a9998..63347231dd 100644 --- a/versioned_docs/version-V3/reference/periphery/base/PeripheryImmutableState.md +++ b/versioned_docs/version-V3/reference/periphery/base/PeripheryImmutableState.md @@ -1,14 +1,11 @@ Immutable state used by periphery contracts - ## Functions + ### constructor + ```solidity function constructor( address _factory, address _WETH9 ) internal ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/base/PeripheryPayments.md b/versioned_docs/version-V3/reference/periphery/base/PeripheryPayments.md index 171ce2ada0..a140a56353 100644 --- a/versioned_docs/version-V3/reference/periphery/base/PeripheryPayments.md +++ b/versioned_docs/version-V3/reference/periphery/base/PeripheryPayments.md @@ -1,34 +1,34 @@ - - - ## Functions + ### receive + ```solidity function receive( ) external ``` - - - ### unwrapWETH9 + ```solidity function unwrapWETH9( uint256 amountMinimum, address recipient ) external ``` + Unwraps the contract's WETH9 balance and sends it to recipient as ETH. The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`amountMinimum` | uint256 | The minimum amount of WETH9 to unwrap -|`recipient` | address | The address receiving ETH + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------ | +| `amountMinimum` | uint256 | The minimum amount of WETH9 to unwrap | +| `recipient` | address | The address receiving ETH | ### sweepToken + ```solidity function sweepToken( address token, @@ -36,29 +36,33 @@ The amountMinimum parameter prevents malicious contracts from stealing WETH9 fro address recipient ) external ``` + Transfers the full amount of a token held by this contract to recipient The amountMinimum parameter prevents malicious contracts from stealing the token from users #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The contract address of the token which will be transferred to `recipient` -|`amountMinimum` | uint256 | The minimum amount of token required for a transfer -|`recipient` | address | The destination address of the token + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------------------------------- | +| `token` | address | The contract address of the token which will be transferred to `recipient` | +| `amountMinimum` | uint256 | The minimum amount of token required for a transfer | +| `recipient` | address | The destination address of the token | ### refundETH + ```solidity function refundETH( ) external ``` + Refunds any ETH balance held by this contract to the `msg.sender` Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps that use ether for the input amount - ### pay + ```solidity function pay( address token, @@ -68,12 +72,11 @@ that use ether for the input amount ) internal ``` - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The token to pay -|`payer` | address | The entity that must pay -|`recipient` | address | The entity that will receive payment -|`value` | uint256 | The amount to pay +| Name | Type | Description | +| :---------- | :------ | :----------------------------------- | +| `token` | address | The token to pay | +| `payer` | address | The entity that must pay | +| `recipient` | address | The entity that will receive payment | +| `value` | uint256 | The amount to pay | diff --git a/versioned_docs/version-V3/reference/periphery/base/PeripheryPaymentsWithFee.md b/versioned_docs/version-V3/reference/periphery/base/PeripheryPaymentsWithFee.md index 65315efca3..59152bd082 100644 --- a/versioned_docs/version-V3/reference/periphery/base/PeripheryPaymentsWithFee.md +++ b/versioned_docs/version-V3/reference/periphery/base/PeripheryPaymentsWithFee.md @@ -1,8 +1,7 @@ - - - ## Functions + ### unwrapWETH9WithFee + ```solidity function unwrapWETH9WithFee( uint256 amountMinimum, @@ -11,13 +10,14 @@ address feeRecipient ) public ``` + Unwraps the contract's WETH9 balance and sends it to recipient as ETH, with a percentage between 0 (exclusive), and 1 (inclusive) going to feeRecipient The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. - ### sweepTokenWithFee + ```solidity function sweepTokenWithFee( address token, @@ -27,9 +27,8 @@ The amountMinimum parameter prevents malicious contracts from stealing WETH9 fro address feeRecipient ) public ``` + Transfers the full amount of a token held by this contract to recipient, with a percentage between 0 (exclusive) and 1 (inclusive) going to feeRecipient The amountMinimum parameter prevents malicious contracts from stealing the token from users - - diff --git a/versioned_docs/version-V3/reference/periphery/base/PoolInitializer.md b/versioned_docs/version-V3/reference/periphery/base/PoolInitializer.md index 7c51aa0c1b..ebaf9b9a3e 100644 --- a/versioned_docs/version-V3/reference/periphery/base/PoolInitializer.md +++ b/versioned_docs/version-V3/reference/periphery/base/PoolInitializer.md @@ -1,8 +1,7 @@ - - - ## Functions + ### createAndInitializePoolIfNecessary + ```solidity function createAndInitializePoolIfNecessary( address token0, @@ -11,19 +10,22 @@ uint160 sqrtPriceX96 ) external returns (address pool) ``` + Creates a new pool if it does not exist, then initializes if not initialized This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token0` | address | The contract address of token0 of the pool -|`token1` | address | The contract address of token1 of the pool -|`fee` | uint24 | The fee amount of the v3 pool for the specified token pair -|`sqrtPriceX96` | uint160 | The initial square root price of the pool as a Q64.96 value + +| Name | Type | Description | +| :------------- | :------ | :---------------------------------------------------------- | +| `token0` | address | The contract address of token0 of the pool | +| `token1` | address | The contract address of token1 of the pool | +| `fee` | uint24 | The fee amount of the v3 pool for the specified token pair | +| `sqrtPriceX96` | uint160 | The initial square root price of the pool as a Q64.96 value | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| address | Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary + +| Name | Type | Description | +| :----- | :------ | :-------------------------------------------------------------------------------------------------------------------- | +| `pool` | address | Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary | diff --git a/versioned_docs/version-V3/reference/periphery/base/SelfPermit.md b/versioned_docs/version-V3/reference/periphery/base/SelfPermit.md index fa92ed3ccf..2aaec6499d 100644 --- a/versioned_docs/version-V3/reference/periphery/base/SelfPermit.md +++ b/versioned_docs/version-V3/reference/periphery/base/SelfPermit.md @@ -4,7 +4,9 @@ These functions are expected to be embedded in multicalls to allow EOAs to appro that requires an approval in a single transaction. ## Functions + ### selfPermit + ```solidity function selfPermit( address token, @@ -15,21 +17,24 @@ that requires an approval in a single transaction. bytes32 s ) public ``` + Permits this contract to spend a given token from `msg.sender` The `owner` is always msg.sender and the `spender` is always address(this). #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`value` | uint256 | The amount that can be spent of token -|`deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` + +| Name | Type | Description | +| :--------- | :------ | :------------------------------------------------------------------------------ | +| `token` | address | The address of the token spent | +| `value` | uint256 | The amount that can be spent of token | +| `deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | ### selfPermitIfNecessary + ```solidity function selfPermitIfNecessary( address token, @@ -40,22 +45,25 @@ The `owner` is always msg.sender and the `spender` is always address(this). bytes32 s ) external ``` + Permits this contract to spend a given token from `msg.sender` The `owner` is always msg.sender and the `spender` is always address(this). Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`value` | uint256 | The amount that can be spent of token -|`deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` + +| Name | Type | Description | +| :--------- | :------ | :------------------------------------------------------------------------------ | +| `token` | address | The address of the token spent | +| `value` | uint256 | The amount that can be spent of token | +| `deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | ### selfPermitAllowed + ```solidity function selfPermitAllowed( address token, @@ -66,21 +74,24 @@ Can be used instead of #selfPermit to prevent calls from failing due to a frontr bytes32 s ) public ``` + Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter The `owner` is always msg.sender and the `spender` is always address(this) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`nonce` | uint256 | The current nonce of the owner -|`expiry` | uint256 | The timestamp at which the permit is no longer valid -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` + +| Name | Type | Description | +| :------- | :------ | :---------------------------------------------------------------------------- | +| `token` | address | The address of the token spent | +| `nonce` | uint256 | The current nonce of the owner | +| `expiry` | uint256 | The timestamp at which the permit is no longer valid | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | ### selfPermitAllowedIfNecessary + ```solidity function selfPermitAllowedIfNecessary( address token, @@ -91,18 +102,19 @@ The `owner` is always msg.sender and the `spender` is always address(this) bytes32 s ) external ``` + Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter The `owner` is always msg.sender and the `spender` is always address(this) Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`nonce` | uint256 | The current nonce of the owner -|`expiry` | uint256 | The timestamp at which the permit is no longer valid -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` +| Name | Type | Description | +| :------- | :------ | :---------------------------------------------------------------------------- | +| `token` | address | The address of the token spent | +| `nonce` | uint256 | The current nonce of the owner | +| `expiry` | uint256 | The timestamp at which the permit is no longer valid | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | diff --git a/versioned_docs/version-V3/reference/periphery/base/_category_.json b/versioned_docs/version-V3/reference/periphery/base/_category_.json index d2dbf023f3..8e8631257c 100644 --- a/versioned_docs/version-V3/reference/periphery/base/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/base/_category_.json @@ -1,4 +1,4 @@ { - "label": "Base", - "position": 1 - } \ No newline at end of file + "label": "Base", + "position": 1 +} diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IERC20Metadata.md b/versioned_docs/version-V3/reference/periphery/interfaces/IERC20Metadata.md index db281e8f62..34a794e361 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IERC20Metadata.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IERC20Metadata.md @@ -1,34 +1,42 @@ Extension to IERC20 that includes token metadata - ## Functions + ### name + ```solidity function name( ) external returns (string) ``` #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| string | name of the token + +| Type | Description | +| :----- | :---------------- | +| string | name of the token | + ### symbol + ```solidity function symbol( ) external returns (string) ``` #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| string | symbol of the token + +| Type | Description | +| :----- | :------------------ | +| string | symbol of the token | + ### decimals + ```solidity function decimals( ) external returns (uint8) ``` #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| uint8 | number of decimal places the token has + +| Type | Description | +| :---- | :------------------------------------- | +| uint8 | number of decimal places the token has | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IERC721Permit.md b/versioned_docs/version-V3/reference/periphery/interfaces/IERC721Permit.md index 8765b90f45..f667800b76 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IERC721Permit.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IERC721Permit.md @@ -1,34 +1,39 @@ Extension to ERC721 that includes a permit function for signature based approvals - ## Functions + ### PERMIT_TYPEHASH + ```solidity function PERMIT_TYPEHASH( ) external returns (bytes32) ``` + The permit typehash used in the permit signature +#### Return Values: +| Type | Description | +| :------ | :---------------------- | +| bytes32 | typehash for the permit | -#### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bytes32 | typehash for the permit ### DOMAIN_SEPARATOR + ```solidity function DOMAIN_SEPARATOR( ) external returns (bytes32) ``` + The domain separator used in the permit signature +#### Return Values: +| Name | Type | Description | +| :---- | :--- | :---------------------------------------------------- | +| `The` | | domain seperator used in encoding of permit signature | -#### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`The`| | domain seperator used in encoding of permit signature ### permit + ```solidity function permit( address spender, @@ -39,16 +44,16 @@ The domain separator used in the permit signature bytes32 s ) external ``` -Approve of a specific token ID for spending by spender via signature +Approve of a specific token ID for spending by spender via signature #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`spender` | address | The account that is being approved -|`tokenId` | uint256 | The ID of the token that is being approved for spending -|`deadline` | uint256 | The deadline timestamp by which the call must be mined for the approve to work -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` +| Name | Type | Description | +| :--------- | :------ | :----------------------------------------------------------------------------- | +| `spender` | address | The account that is being approved | +| `tokenId` | uint256 | The ID of the token that is being approved for spending | +| `deadline` | uint256 | The deadline timestamp by which the call must be mined for the approve to work | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IMulticall.md b/versioned_docs/version-V3/reference/periphery/interfaces/IMulticall.md index 64a1d7c7c2..1c6be14010 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IMulticall.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IMulticall.md @@ -1,23 +1,27 @@ Enables calling multiple methods in a single call to the contract - ## Functions + ### multicall + ```solidity function multicall( bytes[] data ) external returns (bytes[] results) ``` + Call multiple functions in the current contract and return the data from all of them if they all succeed The `msg.value` should not be trusted for any method callable from multicall. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`data` | bytes[] | The encoded function data for each of the calls to make to this contract + +| Name | Type | Description | +| :----- | :------ | :----------------------------------------------------------------------- | +| `data` | bytes[] | The encoded function data for each of the calls to make to this contract | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`results`| bytes[] | The results from each of the calls passed in via data + +| Name | Type | Description | +| :-------- | :------ | :---------------------------------------------------- | +| `results` | bytes[] | The results from each of the calls passed in via data | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/INonfungiblePositionManager.md b/versioned_docs/version-V3/reference/periphery/interfaces/INonfungiblePositionManager.md index bea7af5388..fa063dee60 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/INonfungiblePositionManager.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/INonfungiblePositionManager.md @@ -111,11 +111,11 @@ This method can be bundled with mint for the first mint of a pool to create, ini #### Parameters: -| Name | Type | Description | -| :------- | :------ | :---------------------------------------------- | -| `tokenA` | address | The contract address of either token0 or token1 | -| `tokenB` | address | The contract address of the other token | -| `fee` | uint24 | The fee amount of the v3 pool for the specified token pair | +| Name | Type | Description | +| :------------- | :------ | :---------------------------------------------------------- | +| `tokenA` | address | The contract address of either token0 or token1 | +| `tokenB` | address | The contract address of the other token | +| `fee` | uint24 | The fee amount of the v3 pool for the specified token pair | | `sqrtPriceX96` | uint160 | The initial square root price of the pool as a Q64.96 value | We use tokenA and tokenB when we are referring to unsorted, or unordered tokens diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryImmutableState.md b/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryImmutableState.md index de96721472..2da71d5b2c 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryImmutableState.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryImmutableState.md @@ -1,24 +1,29 @@ Functions that return immutable state of the router - ## Functions + ### factory + ```solidity function factory( ) external returns (address) ``` #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| address | the address of the Uniswap V3 factory + +| Type | Description | +| :------ | :------------------------------------ | +| address | the address of the Uniswap V3 factory | + ### WETH9 + ```solidity function WETH9( ) external returns (address) ``` #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| address | the address of WETH9 + +| Type | Description | +| :------ | :------------------- | +| address | the address of WETH9 | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPayments.md b/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPayments.md index ebd81e3ded..444e4744f6 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPayments.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPayments.md @@ -1,36 +1,41 @@ Functions to ease deposits and withdrawals of ETH - ## Functions + ### unwrapWETH9 + ```solidity function unwrapWETH9( uint256 amountMinimum, address recipient ) external ``` + Unwraps the contract's WETH9 balance and sends it to recipient as ETH. The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`amountMinimum` | uint256 | The minimum amount of WETH9 to unwrap -|`recipient` | address | The address receiving ETH + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------ | +| `amountMinimum` | uint256 | The minimum amount of WETH9 to unwrap | +| `recipient` | address | The address receiving ETH | ### refundETH + ```solidity function refundETH( ) external ``` + Refunds any ETH balance held by this contract to the `msg.sender` Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps that use ether for the input amount - ### sweepToken + ```solidity function sweepToken( address token, @@ -38,14 +43,15 @@ that use ether for the input amount address recipient ) external ``` + Transfers the full amount of a token held by this contract to recipient The amountMinimum parameter prevents malicious contracts from stealing the token from users #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The contract address of the token which will be transferred to `recipient` -|`amountMinimum` | uint256 | The minimum amount of token required for a transfer -|`recipient` | address | The destination address of the token +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------------------------------- | +| `token` | address | The contract address of the token which will be transferred to `recipient` | +| `amountMinimum` | uint256 | The minimum amount of token required for a transfer | +| `recipient` | address | The destination address of the token | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPaymentsWithFee.md b/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPaymentsWithFee.md index daa34a58a7..a29bf68c47 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPaymentsWithFee.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IPeripheryPaymentsWithFee.md @@ -1,26 +1,27 @@ Functions to ease deposits and withdrawals of ETH - ## Functions + ### unwrapWETH9WithFee + ```solidity function unwrapWETH9WithFee( ) external ``` + Unwraps the contract's WETH9 balance and sends it to recipient as ETH, with a percentage between 0 (exclusive), and 1 (inclusive) going to feeRecipient The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. - ### sweepTokenWithFee + ```solidity function sweepTokenWithFee( ) external ``` + Transfers the full amount of a token held by this contract to recipient, with a percentage between 0 (exclusive) and 1 (inclusive) going to feeRecipient The amountMinimum parameter prevents malicious contracts from stealing the token from users - - diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IPoolInitializer.md b/versioned_docs/version-V3/reference/periphery/interfaces/IPoolInitializer.md index 828c7e0bc0..e1e309500f 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IPoolInitializer.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IPoolInitializer.md @@ -1,9 +1,10 @@ Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that require the pool to exist. - ## Functions + ### createAndInitializePoolIfNecessary + ```solidity function createAndInitializePoolIfNecessary( address token0, @@ -12,19 +13,22 @@ require the pool to exist. uint160 sqrtPriceX96 ) external returns (address pool) ``` + Creates a new pool if it does not exist, then initializes if not initialized This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token0` | address | The contract address of token0 of the pool -|`token1` | address | The contract address of token1 of the pool -|`fee` | uint24 | The fee amount of the v3 pool for the specified token pair -|`sqrtPriceX96` | uint160 | The initial square root price of the pool as a Q64.96 value + +| Name | Type | Description | +| :------------- | :------ | :---------------------------------------------------------- | +| `token0` | address | The contract address of token0 of the pool | +| `token1` | address | The contract address of token1 of the pool | +| `fee` | uint24 | The fee amount of the v3 pool for the specified token pair | +| `sqrtPriceX96` | uint160 | The initial square root price of the pool as a Q64.96 value | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| address | Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary + +| Name | Type | Description | +| :----- | :------ | :-------------------------------------------------------------------------------------------------------------------- | +| `pool` | address | Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IQuoter.md b/versioned_docs/version-V3/reference/periphery/interfaces/IQuoter.md index bf76e9821d..083df4e05a 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IQuoter.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IQuoter.md @@ -4,27 +4,33 @@ These functions are not marked view because they rely on calling non-view functi to compute the result. They are also not gas efficient and should not be called on-chain. ## Functions + ### quoteExactInput + ```solidity function quoteExactInput( bytes path, uint256 amountIn ) external returns (uint256 amountOut) ``` -Returns the amount out received for a given exact input swap without executing the swap +Returns the amount out received for a given exact input swap without executing the swap #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The path of the swap, i.e. each token pair and the pool fee -|`amountIn` | uint256 | The amount of the first token to swap + +| Name | Type | Description | +| :--------- | :------ | :---------------------------------------------------------- | +| `path` | bytes | The path of the swap, i.e. each token pair and the pool fee | +| `amountIn` | uint256 | The amount of the first token to swap | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountOut`| uint256 | The amount of the last token that would be received + +| Name | Type | Description | +| :---------- | :------ | :-------------------------------------------------- | +| `amountOut` | uint256 | The amount of the last token that would be received | + ### quoteExactInputSingle + ```solidity function quoteExactInputSingle( address tokenIn, @@ -34,43 +40,51 @@ Returns the amount out received for a given exact input swap without executing t uint160 sqrtPriceLimitX96 ) external returns (uint256 amountOut) ``` -Returns the amount out received for a given exact input but for a swap of a single pool +Returns the amount out received for a given exact input but for a swap of a single pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenIn` | address | The token being swapped in -|`tokenOut` | address | The token being swapped out -|`fee` | uint24 | The fee of the token pool to consider for the pair -|`amountIn` | uint256 | The desired input amount -|`sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap + +| Name | Type | Description | +| :------------------ | :------ | :-------------------------------------------------------------- | +| `tokenIn` | address | The token being swapped in | +| `tokenOut` | address | The token being swapped out | +| `fee` | uint24 | The fee of the token pool to consider for the pair | +| `amountIn` | uint256 | The desired input amount | +| `sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountOut`| uint256 | The amount of `tokenOut` that would be received + +| Name | Type | Description | +| :---------- | :------ | :---------------------------------------------- | +| `amountOut` | uint256 | The amount of `tokenOut` that would be received | + ### quoteExactOutput + ```solidity function quoteExactOutput( bytes path, uint256 amountOut ) external returns (uint256 amountIn) ``` -Returns the amount in required for a given exact output swap without executing the swap +Returns the amount in required for a given exact output swap without executing the swap #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The path of the swap, i.e. each token pair and the pool fee -|`amountOut` | uint256 | The amount of the last token to receive + +| Name | Type | Description | +| :---------- | :------ | :---------------------------------------------------------- | +| `path` | bytes | The path of the swap, i.e. each token pair and the pool fee | +| `amountOut` | uint256 | The amount of the last token to receive | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountIn`| uint256 | The amount of first token required to be paid + +| Name | Type | Description | +| :--------- | :------ | :-------------------------------------------- | +| `amountIn` | uint256 | The amount of first token required to be paid | + ### quoteExactOutputSingle + ```solidity function quoteExactOutputSingle( address tokenIn, @@ -80,19 +94,21 @@ Returns the amount in required for a given exact output swap without executing t uint160 sqrtPriceLimitX96 ) external returns (uint256 amountIn) ``` -Returns the amount in required to receive the given exact output amount but for a swap of a single pool +Returns the amount in required to receive the given exact output amount but for a swap of a single pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenIn` | address | The token being swapped in -|`tokenOut` | address | The token being swapped out -|`fee` | uint24 | The fee of the token pool to consider for the pair -|`amountOut` | uint256 | The desired output amount -|`sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap + +| Name | Type | Description | +| :------------------ | :------ | :-------------------------------------------------------------- | +| `tokenIn` | address | The token being swapped in | +| `tokenOut` | address | The token being swapped out | +| `fee` | uint24 | The fee of the token pool to consider for the pair | +| `amountOut` | uint256 | The desired output amount | +| `sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountIn`| uint256 | The amount required as the input for the swap in order to receive `amountOut` + +| Name | Type | Description | +| :--------- | :------ | :---------------------------------------------------------------------------- | +| `amountIn` | uint256 | The amount required as the input for the swap in order to receive `amountOut` | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/ISelfPermit.md b/versioned_docs/version-V3/reference/periphery/interfaces/ISelfPermit.md index 14c2232b76..cf37ea8ab5 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/ISelfPermit.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/ISelfPermit.md @@ -1,8 +1,9 @@ Functionality to call permit on any EIP-2612-compliant token for use in the route - ## Functions + ### selfPermit + ```solidity function selfPermit( address token, @@ -13,21 +14,24 @@ Functionality to call permit on any EIP-2612-compliant token for use in the rout bytes32 s ) external ``` + Permits this contract to spend a given token from `msg.sender` The `owner` is always msg.sender and the `spender` is always address(this). #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`value` | uint256 | The amount that can be spent of token -|`deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` + +| Name | Type | Description | +| :--------- | :------ | :------------------------------------------------------------------------------ | +| `token` | address | The address of the token spent | +| `value` | uint256 | The amount that can be spent of token | +| `deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | ### selfPermitIfNecessary + ```solidity function selfPermitIfNecessary( address token, @@ -38,22 +42,25 @@ The `owner` is always msg.sender and the `spender` is always address(this). bytes32 s ) external ``` + Permits this contract to spend a given token from `msg.sender` The `owner` is always msg.sender and the `spender` is always address(this). Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`value` | uint256 | The amount that can be spent of token -|`deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` + +| Name | Type | Description | +| :--------- | :------ | :------------------------------------------------------------------------------ | +| `token` | address | The address of the token spent | +| `value` | uint256 | The amount that can be spent of token | +| `deadline` | uint256 | A timestamp, the current blocktime must be less than or equal to this timestamp | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | ### selfPermitAllowed + ```solidity function selfPermitAllowed( address token, @@ -64,21 +71,24 @@ Can be used instead of #selfPermit to prevent calls from failing due to a frontr bytes32 s ) external ``` + Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter The `owner` is always msg.sender and the `spender` is always address(this) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`nonce` | uint256 | The current nonce of the owner -|`expiry` | uint256 | The timestamp at which the permit is no longer valid -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` + +| Name | Type | Description | +| :------- | :------ | :---------------------------------------------------------------------------- | +| `token` | address | The address of the token spent | +| `nonce` | uint256 | The current nonce of the owner | +| `expiry` | uint256 | The timestamp at which the permit is no longer valid | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | ### selfPermitAllowedIfNecessary + ```solidity function selfPermitAllowedIfNecessary( address token, @@ -89,18 +99,19 @@ The `owner` is always msg.sender and the `spender` is always address(this) bytes32 s ) external ``` + Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter The `owner` is always msg.sender and the `spender` is always address(this) Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The address of the token spent -|`nonce` | uint256 | The current nonce of the owner -|`expiry` | uint256 | The timestamp at which the permit is no longer valid -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` +| Name | Type | Description | +| :------- | :------ | :---------------------------------------------------------------------------- | +| `token` | address | The address of the token spent | +| `nonce` | uint256 | The current nonce of the owner | +| `expiry` | uint256 | The timestamp at which the permit is no longer valid | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/ITickLens.md b/versioned_docs/version-V3/reference/periphery/interfaces/ITickLens.md index de99ad999e..f041ebf4c5 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/ITickLens.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/ITickLens.md @@ -4,24 +4,29 @@ This avoids the waterfall of fetching the tick bitmap, parsing the bitmap to kno then sending additional multicalls to fetch the tick data ## Functions + ### getPopulatedTicksInWord + ```solidity function getPopulatedTicksInWord( address pool, int16 tickBitmapIndex ) external returns (struct ITickLens.PopulatedTick[] populatedTicks) ``` -Get all the tick data for the populated ticks from a word of the tick bitmap of a pool +Get all the tick data for the populated ticks from a word of the tick bitmap of a pool #### 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 + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`populatedTicks`| ITickLens.PopulatedTick[] | An array of tick data for the given word in the tick bitmap + +| Name | Type | Description | +| :--------------- | :------------------------ | :---------------------------------------------------------- | +| `populatedTicks` | ITickLens.PopulatedTick[] | An array of tick data for the given word in the tick bitmap | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/IV3Migrator.md b/versioned_docs/version-V3/reference/periphery/interfaces/IV3Migrator.md index eb8320e4cd..e7f6917a37 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/IV3Migrator.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/IV3Migrator.md @@ -1,13 +1,15 @@ Enables migration of liqudity from Uniswap v2-compatible pairs into Uniswap v3 pools - ## Functions + ### migrate + ```solidity function migrate( struct IV3Migrator.MigrateParams params ) external ``` + Migrates liquidity to v3 by burning v2 liquidity and minting a new position for v3 Slippage protection is enforced via `amount{0,1}Min`, which should be a discount of the expected values of @@ -15,7 +17,7 @@ the maximum amount of v3 liquidity that the v2 liquidity can get. For the specia out-of-range position, `amount{0,1}Min` may be set to 0, enforcing that the position remains out of range #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`params` | struct IV3Migrator.MigrateParams | The params necessary to migrate v2 liquidity, encoded as `MigrateParams` in calldata +| Name | Type | Description | +| :------- | :------------------------------- | :----------------------------------------------------------------------------------- | +| `params` | struct IV3Migrator.MigrateParams | The params necessary to migrate v2 liquidity, encoded as `MigrateParams` in calldata | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/_category_.json b/versioned_docs/version-V3/reference/periphery/interfaces/_category_.json index ff65ac2668..fabd7b53d5 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/interfaces/_category_.json @@ -1,4 +1,4 @@ { - "label": "Interfaces", - "position": 1 - } \ No newline at end of file + "label": "Interfaces", + "position": 1 +} diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC1271.md b/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC1271.md index 2fa7ac1561..7034cebdd0 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC1271.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC1271.md @@ -3,13 +3,16 @@ Interface that verifies provided signature for the data Interface defined by EIP-1271 ## Functions + ### isValidSignature + ```solidity function isValidSignature( bytes32 hash, bytes signature ) external returns (bytes4 magicValue) ``` + Returns whether the provided signature is valid for the provided data MUST return the bytes4 magic value 0x1626ba7e when function passes. @@ -17,12 +20,14 @@ MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > MUST allow external calls. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`hash` | bytes32 | Hash of the data to be signed -|`signature` | bytes | Signature byte array associated with _data + +| Name | Type | Description | +| :---------- | :------ | :------------------------------------------ | +| `hash` | bytes32 | Hash of the data to be signed | +| `signature` | bytes | Signature byte array associated with \_data | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`magicValue`| bytes32 | The bytes4 magic value 0x1626ba7e + +| Name | Type | Description | +| :----------- | :------ | :-------------------------------- | +| `magicValue` | bytes32 | The bytes4 magic value 0x1626ba7e | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC20PermitAllowed.md b/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC20PermitAllowed.md index af6ff75db7..1918a6a652 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC20PermitAllowed.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/external/IERC20PermitAllowed.md @@ -1,8 +1,9 @@ Interface used by DAI/CHAI for permit - ## Functions + ### permit + ```solidity function permit( address holder, @@ -15,19 +16,20 @@ Interface used by DAI/CHAI for permit bytes32 s ) external ``` + Approve the spender to spend some tokens via the holder signature This is the permit interface used by DAI and CHAI #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`holder` | address | The address of the token holder, the token owner -|`spender` | address | The address of the token spender -|`nonce` | uint256 | The holder's nonce, increases at each call to permit -|`expiry` | uint256 | The timestamp at which the permit is no longer valid -|`allowed` | bool | Boolean that sets approval amount, true for type(uint256).max and false for 0 -|`v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` -|`r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` -|`s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` +| Name | Type | Description | +| :-------- | :------ | :---------------------------------------------------------------------------- | +| `holder` | address | The address of the token holder, the token owner | +| `spender` | address | The address of the token spender | +| `nonce` | uint256 | The holder's nonce, increases at each call to permit | +| `expiry` | uint256 | The timestamp at which the permit is no longer valid | +| `allowed` | bool | Boolean that sets approval amount, true for type(uint256).max and false for 0 | +| `v` | uint8 | Must produce valid secp256k1 signature from the holder along with `r` and `s` | +| `r` | bytes32 | Must produce valid secp256k1 signature from the holder along with `v` and `s` | +| `s` | bytes32 | Must produce valid secp256k1 signature from the holder along with `r` and `v` | diff --git a/versioned_docs/version-V3/reference/periphery/interfaces/external/IWETH9.md b/versioned_docs/version-V3/reference/periphery/interfaces/external/IWETH9.md index 3f0c83e904..9c3304b828 100644 --- a/versioned_docs/version-V3/reference/periphery/interfaces/external/IWETH9.md +++ b/versioned_docs/version-V3/reference/periphery/interfaces/external/IWETH9.md @@ -1,22 +1,19 @@ - - - ## Functions + ### deposit + ```solidity function deposit( ) external ``` -Deposit ether to get wrapped ether - +Deposit ether to get wrapped ether ### withdraw + ```solidity function withdraw( ) external ``` -Withdraw wrapped ether to get ether - - +Withdraw wrapped ether to get ether diff --git a/versioned_docs/version-V3/reference/periphery/lens/Quoter.md b/versioned_docs/version-V3/reference/periphery/lens/Quoter.md index 7837680d32..72981243be 100644 --- a/versioned_docs/version-V3/reference/periphery/lens/Quoter.md +++ b/versioned_docs/version-V3/reference/periphery/lens/Quoter.md @@ -4,14 +4,16 @@ These functions are not gas efficient and should _not_ be called on chain. Inste the swap and check the amounts in the callback. ## Functions + ### constructor + ```solidity function constructor( ) public ``` - ### uniswapV3SwapCallback + ```solidity function uniswapV3SwapCallback( int256 amount0Delta, @@ -19,6 +21,7 @@ the swap and check the amounts in the callback. bytes data ) external ``` + Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. In the implementation you must pay the pool tokens owed for the swap. @@ -26,15 +29,18 @@ The caller of this method must be checked to be a UniswapV3Pool deployed by the amount0Delta and amount1Delta can both be 0 if no tokens were swapped. #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`amount0Delta` | int256 | The amount of token0 that was sent (negative) or must be received (positive) by the pool by + +| 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 IUniswapV3PoolActions#swap call ### quoteExactInputSingle + ```solidity function quoteExactInputSingle( address tokenIn, @@ -44,43 +50,51 @@ the end of the swap. If positive, the callback must send that amount of token1 t uint160 sqrtPriceLimitX96 ) public returns (uint256 amountOut) ``` -Returns the amount out received for a given exact input but for a swap of a single pool +Returns the amount out received for a given exact input but for a swap of a single pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenIn` | address | The token being swapped in -|`tokenOut` | address | The token being swapped out -|`fee` | uint24 | The fee of the token pool to consider for the pair -|`amountIn` | uint256 | The desired input amount -|`sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap + +| Name | Type | Description | +| :------------------ | :------ | :-------------------------------------------------------------- | +| `tokenIn` | address | The token being swapped in | +| `tokenOut` | address | The token being swapped out | +| `fee` | uint24 | The fee of the token pool to consider for the pair | +| `amountIn` | uint256 | The desired input amount | +| `sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountOut`| uint256 | The amount of `tokenOut` that would be received + +| Name | Type | Description | +| :---------- | :------ | :---------------------------------------------- | +| `amountOut` | uint256 | The amount of `tokenOut` that would be received | + ### quoteExactInput + ```solidity function quoteExactInput( bytes path, uint256 amountIn ) external returns (uint256 amountOut) ``` -Returns the amount out received for a given exact input swap without executing the swap +Returns the amount out received for a given exact input swap without executing the swap #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The path of the swap, i.e. each token pair and the pool fee -|`amountIn` | uint256 | The amount of the first token to swap + +| Name | Type | Description | +| :--------- | :------ | :---------------------------------------------------------- | +| `path` | bytes | The path of the swap, i.e. each token pair and the pool fee | +| `amountIn` | uint256 | The amount of the first token to swap | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountOut`| uint256 | The amount of the last token that would be received + +| Name | Type | Description | +| :---------- | :------ | :-------------------------------------------------- | +| `amountOut` | uint256 | The amount of the last token that would be received | + ### quoteExactOutputSingle + ```solidity function quoteExactOutputSingle( address tokenIn, @@ -90,39 +104,45 @@ Returns the amount out received for a given exact input swap without executing t uint160 sqrtPriceLimitX96 ) public returns (uint256 amountIn) ``` -Returns the amount in required to receive the given exact output amount but for a swap of a single pool +Returns the amount in required to receive the given exact output amount but for a swap of a single pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenIn` | address | The token being swapped in -|`tokenOut` | address | The token being swapped out -|`fee` | uint24 | The fee of the token pool to consider for the pair -|`amountOut` | uint256 | The desired output amount -|`sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap + +| Name | Type | Description | +| :------------------ | :------ | :-------------------------------------------------------------- | +| `tokenIn` | address | The token being swapped in | +| `tokenOut` | address | The token being swapped out | +| `fee` | uint24 | The fee of the token pool to consider for the pair | +| `amountOut` | uint256 | The desired output amount | +| `sqrtPriceLimitX96` | uint160 | The price limit of the pool that cannot be exceeded by the swap | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountIn`| uint256 | The amount required as the input for the swap in order to receive `amountOut` + +| Name | Type | Description | +| :--------- | :------ | :---------------------------------------------------------------------------- | +| `amountIn` | uint256 | The amount required as the input for the swap in order to receive `amountOut` | + ### quoteExactOutput + ```solidity function quoteExactOutput( bytes path, uint256 amountOut ) external returns (uint256 amountIn) ``` -Returns the amount in required for a given exact output swap without executing the swap +Returns the amount in required for a given exact output swap without executing the swap #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The path of the swap, i.e. each token pair and the pool fee -|`amountOut` | uint256 | The amount of the last token to receive + +| Name | Type | Description | +| :---------- | :------ | :---------------------------------------------------------- | +| `path` | bytes | The path of the swap, i.e. each token pair and the pool fee | +| `amountOut` | uint256 | The amount of the last token to receive | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amountIn`| uint256 | The amount of first token required to be paid + +| Name | Type | Description | +| :--------- | :------ | :-------------------------------------------- | +| `amountIn` | uint256 | The amount of first token required to be paid | diff --git a/versioned_docs/version-V3/reference/periphery/lens/TickLens.md b/versioned_docs/version-V3/reference/periphery/lens/TickLens.md index 809b96a1af..6d85368d19 100644 --- a/versioned_docs/version-V3/reference/periphery/lens/TickLens.md +++ b/versioned_docs/version-V3/reference/periphery/lens/TickLens.md @@ -1,25 +1,27 @@ - - - ## Functions + ### getPopulatedTicksInWord + ```solidity 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 +Get all the tick data for the populated ticks from a word of the tick bitmap of a pool #### 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 + +| 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: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`populatedTicks`| ITickLens.PopulatedTick[] | An array of tick data for the given word in the tick bitmap + +| Name | Type | Description | +| :--------------- | :------------------------ | :---------------------------------------------------------- | +| `populatedTicks` | ITickLens.PopulatedTick[] | An array of tick data for the given word in the tick bitmap | diff --git a/versioned_docs/version-V3/reference/periphery/lens/_category_.json b/versioned_docs/version-V3/reference/periphery/lens/_category_.json index 370b48499c..8a84b863db 100644 --- a/versioned_docs/version-V3/reference/periphery/lens/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/lens/_category_.json @@ -1,4 +1,4 @@ { - "label": "Lens", - "position": 3 - } \ No newline at end of file + "label": "Lens", + "position": 3 +} diff --git a/versioned_docs/version-V3/reference/periphery/libraries/Base64.md b/versioned_docs/version-V3/reference/periphery/libraries/Base64.md index a59eebec9e..531f48b958 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/Base64.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/Base64.md @@ -1,13 +1,12 @@ Provides a function for encoding some bytes in base64 - ## Functions + ### encode + ```solidity function encode( ) internal returns (string) ``` -Encodes some bytes to the base64 representation - - +Encodes some bytes to the base64 representation diff --git a/versioned_docs/version-V3/reference/periphery/libraries/BytesLib.md b/versioned_docs/version-V3/reference/periphery/libraries/BytesLib.md index f86de024d6..7115641a5c 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/BytesLib.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/BytesLib.md @@ -1,31 +1,22 @@ - - - ## Functions + ### slice + ```solidity function slice( ) internal returns (bytes) ``` - - - ### toAddress + ```solidity function toAddress( ) internal returns (address) ``` - - - ### toUint24 + ```solidity function toUint24( ) internal returns (uint24) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/libraries/CallbackValidation.md b/versioned_docs/version-V3/reference/periphery/libraries/CallbackValidation.md index 50768380c5..79ec4af050 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/CallbackValidation.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/CallbackValidation.md @@ -1,8 +1,9 @@ Provides validation for callbacks from Uniswap V3 Pools - ## Functions + ### verifyCallback + ```solidity function verifyCallback( address factory, @@ -11,38 +12,44 @@ Provides validation for callbacks from Uniswap V3 Pools uint24 fee ) internal returns (contract IUniswapV3Pool pool) ``` -Returns the address of a valid Uniswap V3 Pool +Returns the address of a valid Uniswap V3 Pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`factory` | address | The contract address of the Uniswap V3 factory -|`tokenA` | address | The contract address of either token0 or token1 -|`tokenB` | address | The contract address of the other token -|`fee` | uint24 | The fee collected upon every swap in the pool, denominated in hundredths of a bip + +| Name | Type | Description | +| :-------- | :------ | :-------------------------------------------------------------------------------- | +| `factory` | address | The contract address of the Uniswap V3 factory | +| `tokenA` | address | The contract address of either token0 or token1 | +| `tokenB` | address | The contract address of the other token | +| `fee` | uint24 | The fee collected upon every swap in the pool, denominated in hundredths of a bip | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| IUniswapV3Pool | The V3 pool contract address + +| Name | Type | Description | +| :----- | :------------- | :--------------------------- | +| `pool` | IUniswapV3Pool | The V3 pool contract address | + ### verifyCallback + ```solidity function verifyCallback( address factory, struct PoolAddress.PoolKey poolKey ) internal returns (contract IUniswapV3Pool pool) ``` -Returns the address of a valid Uniswap V3 Pool +Returns the address of a valid Uniswap V3 Pool #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`factory` | address | The contract address of the Uniswap V3 factory -|`poolKey` | struct PoolAddress.PoolKey | The identifying key of the V3 pool + +| Name | Type | Description | +| :-------- | :------------------------- | :--------------------------------------------- | +| `factory` | address | The contract address of the Uniswap V3 factory | +| `poolKey` | struct PoolAddress.PoolKey | The identifying key of the V3 pool | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| IUniswapV3Pool | The V3 pool contract address + +| Name | Type | Description | +| :----- | :------------- | :--------------------------- | +| `pool` | IUniswapV3Pool | The V3 pool contract address | diff --git a/versioned_docs/version-V3/reference/periphery/libraries/ChainId.md b/versioned_docs/version-V3/reference/periphery/libraries/ChainId.md index b4a27dd117..a3b508f0b7 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/ChainId.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/ChainId.md @@ -1,8 +1,7 @@ - - - ## Functions + ### get + ```solidity function get( ) internal returns (uint256 chainId) @@ -10,8 +9,8 @@ Gets the current chain ID - #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`chainId`| uint256 | The current chain ID + +| Name | Type | Description | +| :-------- | :------ | :------------------- | +| `chainId` | uint256 | The current chain ID | diff --git a/versioned_docs/version-V3/reference/periphery/libraries/HexStrings.md b/versioned_docs/version-V3/reference/periphery/libraries/HexStrings.md index d509d9d64b..2d692cbccc 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/HexStrings.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/HexStrings.md @@ -1,23 +1,19 @@ - - - ## Functions + ### toHexString + ```solidity function toHexString( ) internal returns (string) ``` + Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. Credit to Open Zeppelin under MIT license https://github.com/OpenZeppelin/openzeppelin-contracts/blob/243adff49ce1700e0ecb99fe522fb16cff1d1ddc/contracts/utils/Strings.sol#L55 - ### toHexStringNoPrefix + ```solidity function toHexStringNoPrefix( ) internal returns (string) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/libraries/LiquidityAmounts.md b/versioned_docs/version-V3/reference/periphery/libraries/LiquidityAmounts.md index 7c959c27c9..0ab79163ae 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/LiquidityAmounts.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/LiquidityAmounts.md @@ -1,8 +1,9 @@ Provides functions for computing liquidity amounts from token amounts and prices - ## Functions + ### getLiquidityForAmount0 + ```solidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, @@ -10,22 +11,27 @@ Provides functions for computing liquidity amounts from token amounts and prices uint256 amount0 ) internal returns (uint128 liquidity) ``` + Computes the amount of liquidity received for a given amount of token0 and price range -Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) +Calculates amount0 _ (sqrt(upper) _ sqrt(lower)) / (sqrt(upper) - sqrt(lower)) #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary -|`sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary -|`amount0` | uint256 | The amount0 being sent in + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary | +| `sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary | +| `amount0` | uint256 | The amount0 being sent in | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`liquidity`| uint128 | The amount of returned liquidity + +| Name | Type | Description | +| :---------- | :------ | :------------------------------- | +| `liquidity` | uint128 | The amount of returned liquidity | + ### getLiquidityForAmount1 + ```solidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, @@ -33,22 +39,27 @@ Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) uint256 amount1 ) internal returns (uint128 liquidity) ``` + Computes the amount of liquidity received for a given amount of token1 and price range Calculates amount1 / (sqrt(upper) - sqrt(lower)). #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary -|`sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary -|`amount1` | uint256 | The amount1 being sent in + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary | +| `sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary | +| `amount1` | uint256 | The amount1 being sent in | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`liquidity`| uint128 | The amount of returned liquidity + +| Name | Type | Description | +| :---------- | :------ | :------------------------------- | +| `liquidity` | uint128 | The amount of returned liquidity | + ### getLiquidityForAmounts + ```solidity function getLiquidityForAmounts( uint160 sqrtRatioX96, @@ -58,24 +69,28 @@ Calculates amount1 / (sqrt(upper) - sqrt(lower)). uint256 amount1 ) internal returns (uint128 liquidity) ``` + Computes the maximum amount of liquidity received for a given amount of token0, token1, the current pool prices and the prices at the tick boundaries - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioX96` | uint160 | A sqrt price representing the current pool prices -|`sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary -|`sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary -|`amount0` | uint256 | The amount of token0 being sent in -|`amount1` | uint256 | The amount of token1 being sent in + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------- | +| `sqrtRatioX96` | uint160 | A sqrt price representing the current pool prices | +| `sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary | +| `sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary | +| `amount0` | uint256 | The amount of token0 being sent in | +| `amount1` | uint256 | The amount of token1 being sent in | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`liquidity`| uint128 | The maximum amount of liquidity received + +| Name | Type | Description | +| :---------- | :------ | :--------------------------------------- | +| `liquidity` | uint128 | The maximum amount of liquidity received | + ### getAmount0ForLiquidity + ```solidity function getAmount0ForLiquidity( uint160 sqrtRatioAX96, @@ -83,21 +98,25 @@ pool prices and the prices at the tick boundaries uint128 liquidity ) internal returns (uint256 amount0) ``` -Computes the amount of token0 for a given amount of liquidity and a price range +Computes the amount of token0 for a given amount of liquidity and a price range #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary -|`sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary -|`liquidity` | uint128 | The liquidity being valued + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary | +| `sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary | +| `liquidity` | uint128 | The liquidity being valued | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| uint256 | The amount of token0 + +| Name | Type | Description | +| :-------- | :------ | :------------------- | +| `amount0` | uint256 | The amount of token0 | + ### getAmount1ForLiquidity + ```solidity function getAmount1ForLiquidity( uint160 sqrtRatioAX96, @@ -105,21 +124,25 @@ Computes the amount of token0 for a given amount of liquidity and a price range uint128 liquidity ) internal returns (uint256 amount1) ``` -Computes the amount of token1 for a given amount of liquidity and a price range +Computes the amount of token1 for a given amount of liquidity and a price range #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary -|`sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary -|`liquidity` | uint128 | The liquidity being valued + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------- | +| `sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary | +| `sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary | +| `liquidity` | uint128 | The liquidity being valued | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount1`| uint256 | The amount of token1 + +| Name | Type | Description | +| :-------- | :------ | :------------------- | +| `amount1` | uint256 | The amount of token1 | + ### getAmountsForLiquidity + ```solidity function getAmountsForLiquidity( uint160 sqrtRatioX96, @@ -128,20 +151,22 @@ Computes the amount of token1 for a given amount of liquidity and a price range uint128 liquidity ) internal returns (uint256 amount0, uint256 amount1) ``` + Computes the token0 and token1 value for a given amount of liquidity, the current pool prices and the prices at the tick boundaries - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`sqrtRatioX96` | uint160 | A sqrt price representing the current pool prices -|`sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary -|`sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary -|`liquidity` | uint128 | The liquidity being valued + +| Name | Type | Description | +| :-------------- | :------ | :------------------------------------------------- | +| `sqrtRatioX96` | uint160 | A sqrt price representing the current pool prices | +| `sqrtRatioAX96` | uint160 | A sqrt price representing the first tick boundary | +| `sqrtRatioBX96` | uint160 | A sqrt price representing the second tick boundary | +| `liquidity` | uint128 | The liquidity being valued | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`amount0`| uint256 | The amount of token0 -|`amount1`| uint256 | The amount of token1 + +| Name | Type | Description | +| :-------- | :------ | :------------------- | +| `amount0` | uint256 | The amount of token0 | +| `amount1` | uint256 | The amount of token1 | diff --git a/versioned_docs/version-V3/reference/periphery/libraries/NFTDescriptor.md b/versioned_docs/version-V3/reference/periphery/libraries/NFTDescriptor.md index 50afa74bb1..687a25c756 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/NFTDescriptor.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/NFTDescriptor.md @@ -1,94 +1,71 @@ - - - ## Functions + ### constructTokenURI + ```solidity function constructTokenURI( ) public returns (string) ``` - - - ### escapeQuotes + ```solidity function escapeQuotes( ) internal returns (string) ``` - - - ### tickToDecimalString + ```solidity function tickToDecimalString( ) internal returns (string) ``` - - - ### fixedPointToDecimalString + ```solidity function fixedPointToDecimalString( ) internal returns (string) ``` - - - ### feeToPercentString + ```solidity function feeToPercentString( ) internal returns (string) ``` - - - ### addressToString + ```solidity function addressToString( ) internal returns (string) ``` - - - ### generateSVGImage + ```solidity function generateSVGImage( ) internal returns (string svg) ``` - - - ### tokenToColorHex + ```solidity function tokenToColorHex( ) internal returns (string str) ``` - - - ### getCircleCoord + ```solidity function getCircleCoord( ) internal returns (uint256) ``` - - - ### sliceTokenHex + ```solidity function sliceTokenHex( ) internal returns (uint256) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/libraries/NFTSVG.md b/versioned_docs/version-V3/reference/periphery/libraries/NFTSVG.md index ab7a43a88e..d3069bcd83 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/NFTSVG.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/NFTSVG.md @@ -1,49 +1,38 @@ Provides a function for generating an SVG associated with a Uniswap NFT - ## Functions + ### generateSVG + ```solidity function generateSVG( ) internal returns (string svg) ``` - - - ### getCurve + ```solidity function getCurve( ) internal returns (string curve) ``` - - - ### generateSVGCurveCircle + ```solidity function generateSVGCurveCircle( ) internal returns (string svg) ``` - - - ### rangeLocation + ```solidity function rangeLocation( ) internal returns (string, string) ``` - - - ### isRare + ```solidity function isRare( ) internal returns (bool) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/libraries/OracleLibrary.md b/versioned_docs/version-V3/reference/periphery/libraries/OracleLibrary.md index 56a2df451d..1c7eb94f4f 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/OracleLibrary.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/OracleLibrary.md @@ -1,28 +1,33 @@ Provides functions to integrate with V3 pool oracle - ## Functions + ### consult + ```solidity function consult( address pool, uint32 period ) internal view returns (int24 timeWeightedAverageTick) ``` -Fetches time-weighted average tick using Uniswap V3 oracle +Fetches time-weighted average tick using Uniswap V3 oracle #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`pool` | address | Address of Uniswap V3 pool that we want to observe -|`period` | uint32 | Number of seconds in the past to start calculating time-weighted average + +| Name | Type | Description | +| :------- | :------ | :----------------------------------------------------------------------- | +| `pool` | address | Address of Uniswap V3 pool that we want to observe | +| `period` | uint32 | Number of seconds in the past to start calculating time-weighted average | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`timeWeightedAverageTick`| address | The time-weighted average tick from (block.timestamp - period) to block.timestamp + +| Name | Type | Description | +| :------------------------ | :------ | :-------------------------------------------------------------------------------- | +| `timeWeightedAverageTick` | address | The time-weighted average tick from (block.timestamp - period) to block.timestamp | + ### getQuoteAtTick + ```solidity function getQuoteAtTick( int24 tick, @@ -31,18 +36,20 @@ Fetches time-weighted average tick using Uniswap V3 oracle address quoteToken ) internal pure returns (uint256 quoteAmount) ``` -Given a tick and a token amount, calculates the amount of token received in exchange +Given a tick and a token amount, calculates the amount of token received in exchange #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tick` | int24 | Tick value used to calculate the quote -|`baseAmount` | uint128 | Amount of token to be converted -|`baseToken` | address | Address of an ERC20 token contract used as the baseAmount denomination -|`quoteToken` | address | Address of an ERC20 token contract used as the quoteAmount denomination + +| Name | Type | Description | +| :----------- | :------ | :---------------------------------------------------------------------- | +| `tick` | int24 | Tick value used to calculate the quote | +| `baseAmount` | uint128 | Amount of token to be converted | +| `baseToken` | address | Address of an ERC20 token contract used as the baseAmount denomination | +| `quoteToken` | address | Address of an ERC20 token contract used as the quoteAmount denomination | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`quoteAmount`| uint256 | Amount of quoteToken received for baseAmount of baseToken + +| Name | Type | Description | +| :------------ | :------ | :-------------------------------------------------------- | +| `quoteAmount` | uint256 | Amount of quoteToken received for baseAmount of baseToken | diff --git a/versioned_docs/version-V3/reference/periphery/libraries/Path.md b/versioned_docs/version-V3/reference/periphery/libraries/Path.md index f5e0def50b..598a440094 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/Path.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/Path.md @@ -1,78 +1,91 @@ - - - ## Functions + ### hasMultiplePools + ```solidity function hasMultiplePools( bytes path ) internal returns (bool) ``` -Returns true iff the path contains two or more pools +Returns true iff the path contains two or more pools #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The encoded swap path + +| Name | Type | Description | +| :----- | :---- | :-------------------- | +| `path` | bytes | The encoded swap path | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bool | if path contains two or more pools, otherwise false + +| Type | Description | +| :--- | :-------------------------------------------------- | +| bool | if path contains two or more pools, otherwise false | + ### decodeFirstPool + ```solidity function decodeFirstPool( bytes path ) internal returns (address tokenA, address tokenB, uint24 fee) ``` -Decodes the first pool in path +Decodes the first pool in path #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The bytes encoded swap path + +| Name | Type | Description | +| :----- | :---- | :-------------------------- | +| `path` | bytes | The bytes encoded swap path | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`tokenA`| address | The first token of the given pool -|`tokenB`| address | The second token of the given pool -|`fee`| uint24 | The fee level of the pool + +| Name | Type | Description | +| :------- | :------ | :--------------------------------- | +| `tokenA` | address | The first token of the given pool | +| `tokenB` | address | The second token of the given pool | +| `fee` | uint24 | The fee level of the pool | + ### getFirstPool + ```solidity function getFirstPool( bytes path ) internal returns (bytes) ``` -Gets the segment corresponding to the first pool in the path +Gets the segment corresponding to the first pool in the path #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The bytes encoded swap path + +| Name | Type | Description | +| :----- | :---- | :-------------------------- | +| `path` | bytes | The bytes encoded swap path | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bytes | segment containing all data necessary to target the first pool in the path + +| Type | Description | +| :---- | :------------------------------------------------------------------------- | +| bytes | segment containing all data necessary to target the first pool in the path | + ### skipToken + ```solidity function skipToken( bytes path ) internal returns (bytes) ``` -Skips a token + fee element from the buffer and returns the remainder +Skips a token + fee element from the buffer and returns the remainder #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`path` | bytes | The swap path + +| Name | Type | Description | +| :----- | :---- | :------------ | +| `path` | bytes | The swap path | #### Return Values: -| Type | Description | -| :------------ | :--------------------------------------------------------------------------- | -| bytes | remaining token + fee elements in the path + +| Type | Description | +| :---- | :----------------------------------------- | +| bytes | remaining token + fee elements in the path | diff --git a/versioned_docs/version-V3/reference/periphery/libraries/PoolAddress.md b/versioned_docs/version-V3/reference/periphery/libraries/PoolAddress.md index 28b50aacbd..9d809d908d 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/PoolAddress.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/PoolAddress.md @@ -1,8 +1,7 @@ - - - ## Functions + ### getPoolKey + ```solidity function getPoolKey( address tokenA, @@ -10,37 +9,43 @@ uint24 fee ) internal returns (struct PoolAddress.PoolKey) ``` -Returns PoolKey: the ordered tokens with the matched fee levels +Returns PoolKey: the ordered tokens with the matched fee levels #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenA` | address | The first token of a pool, unsorted -|`tokenB` | address | The second token of a pool, unsorted -|`fee` | uint24 | The fee level of the pool + +| Name | Type | Description | +| :------- | :------ | :----------------------------------- | +| `tokenA` | address | The first token of a pool, unsorted | +| `tokenB` | address | The second token of a pool, unsorted | +| `fee` | uint24 | The fee level of the pool | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`Poolkey`| PoolAddress.PoolKey | The pool details with ordered token0 and token1 assignments + +| Name | Type | Description | +| :-------- | :------------------ | :---------------------------------------------------------- | +| `Poolkey` | PoolAddress.PoolKey | The pool details with ordered token0 and token1 assignments | + ### computeAddress + ```solidity function computeAddress( address factory, struct PoolAddress.PoolKey key ) internal returns (address pool) ``` -Deterministically computes the pool address given the factory and PoolKey +Deterministically computes the pool address given the factory and PoolKey #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`factory` | address | The Uniswap V3 factory contract address -|`key` | struct PoolAddress.PoolKey | The PoolKey + +| Name | Type | Description | +| :-------- | :------------------------- | :-------------------------------------- | +| `factory` | address | The Uniswap V3 factory contract address | +| `key` | struct PoolAddress.PoolKey | The PoolKey | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| address | The contract address of the V3 pool + +| Name | Type | Description | +| :----- | :------ | :---------------------------------- | +| `pool` | address | The contract address of the V3 pool | diff --git a/versioned_docs/version-V3/reference/periphery/libraries/PositionKey.md b/versioned_docs/version-V3/reference/periphery/libraries/PositionKey.md index d4021399d7..4a58713250 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/PositionKey.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/PositionKey.md @@ -1,13 +1,10 @@ - - - ## Functions + ### compute + ```solidity function compute( ) internal returns (bytes32) ``` Returns the key of the position in the core library - - diff --git a/versioned_docs/version-V3/reference/periphery/libraries/TokenRatioSortOrder.md b/versioned_docs/version-V3/reference/periphery/libraries/TokenRatioSortOrder.md index 3385a8bea6..f42f174312 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/TokenRatioSortOrder.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/TokenRatioSortOrder.md @@ -9,4 +9,4 @@ library TokenRatioSortOrder { int256 constant DENOMINATOR_MORE = -200; int256 constant DENOMINATOR = -100; } -``` \ No newline at end of file +``` diff --git a/versioned_docs/version-V3/reference/periphery/libraries/TransferHelper.md b/versioned_docs/version-V3/reference/periphery/libraries/TransferHelper.md index 235210f394..22dbab69a9 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/TransferHelper.md +++ b/versioned_docs/version-V3/reference/periphery/libraries/TransferHelper.md @@ -1,8 +1,7 @@ - - - ## Functions + ### safeTransferFrom + ```solidity function safeTransferFrom( address token, @@ -11,19 +10,21 @@ uint256 value ) internal ``` + Transfers tokens from the targeted address to the given destination Errors with 'STF' if transfer fails - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The contract address of the token to be transferred -|`from` | address | The originating address from which the tokens will be transferred -|`to` | address | The destination address of the transfer -|`value` | uint256 | The amount to be transferred + +| Name | Type | Description | +| :------ | :------ | :---------------------------------------------------------------- | +| `token` | address | The contract address of the token to be transferred | +| `from` | address | The originating address from which the tokens will be transferred | +| `to` | address | The destination address of the transfer | +| `value` | uint256 | The amount to be transferred | ### safeTransfer + ```solidity function safeTransfer( address token, @@ -31,18 +32,21 @@ Errors with 'STF' if transfer fails uint256 value ) internal ``` + Transfers tokens from msg.sender to a recipient Errors with ST if transfer fails #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The contract address of the token which will be transferred -|`to` | address | The recipient of the transfer -|`value` | uint256 | The value of the transfer + +| Name | Type | Description | +| :------ | :------ | :---------------------------------------------------------- | +| `token` | address | The contract address of the token which will be transferred | +| `to` | address | The recipient of the transfer | +| `value` | uint256 | The value of the transfer | ### safeApprove + ```solidity function safeApprove( address token, @@ -50,31 +54,35 @@ Errors with ST if transfer fails uint256 value ) internal ``` + Approves the stipulated contract to spend the given allowance in the given token Errors with 'SA' if transfer fails #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`token` | address | The contract address of the token to be approved -|`to` | address | The target of the approval -|`value` | uint256 | The amount of the given token the target will be allowed to spend + +| Name | Type | Description | +| :------ | :------ | :---------------------------------------------------------------- | +| `token` | address | The contract address of the token to be approved | +| `to` | address | The target of the approval | +| `value` | uint256 | The amount of the given token the target will be allowed to spend | ### safeTransferETH + ```solidity function safeTransferETH( address to, uint256 value ) internal ``` + Transfers ETH to the recipient address Fails with `STE` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`to` | address | The destination of the transfer -|`value` | uint256 | The value to be transferred +| Name | Type | Description | +| :------ | :------ | :------------------------------ | +| `to` | address | The destination of the transfer | +| `value` | uint256 | The value to be transferred | diff --git a/versioned_docs/version-V3/reference/periphery/libraries/_category_.json b/versioned_docs/version-V3/reference/periphery/libraries/_category_.json index 3a8bc6547f..9528f74123 100644 --- a/versioned_docs/version-V3/reference/periphery/libraries/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/libraries/_category_.json @@ -1,4 +1,4 @@ { - "label": "Libraries", - "position": 4 - } \ No newline at end of file + "label": "Libraries", + "position": 4 +} diff --git a/versioned_docs/version-V3/reference/periphery/staker/Design.md b/versioned_docs/version-V3/reference/periphery/staker/Design.md index 8dae6e31a9..af03c88f78 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/Design.md +++ b/versioned_docs/version-V3/reference/periphery/staker/Design.md @@ -1,11 +1,11 @@ --- sidebar_label: Uniswap V3 Staker Design -sidebar_position: 1 +sidebar_position: 1 --- # Uniswap V3 Staker Design -The liquidity mining staker design is comprised of one canonical position staking contract, Staker. The technical reference for this contract is [here](https://docs.uniswap.org/protocol/reference/periphery/staker/UniswapV3Staker) and the source code is [here](https://github.com/Uniswap/uniswap-v3-staker). +The liquidity mining staker design is comprised of one canonical position staking contract, Staker. The technical reference for this contract is [here](https://docs.uniswap.org/protocol/reference/periphery/staker/UniswapV3Staker) and the source code is [here](https://github.com/Uniswap/uniswap-v3-staker). ## Data Structures diff --git a/versioned_docs/version-V3/reference/periphery/staker/UniswapV3Staker.md b/versioned_docs/version-V3/reference/periphery/staker/UniswapV3Staker.md index 4c3de54658..b34f15c8b4 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/UniswapV3Staker.md +++ b/versioned_docs/version-V3/reference/periphery/staker/UniswapV3Staker.md @@ -2,33 +2,40 @@ sidebar_label: Uniswap V3 Staker Contract sidebar_position: 2 --- + # Uniswap V3 Staker Contract Below is the technical reference for the staker contract, [`UniswapV3Staker.sol`](https://github.com/Uniswap/uniswap-v3-staker/blob/main/contracts/UniswapV3Staker.sol). A technical guide for interacting with this staking contract will be released soon. ## Functions + ### stakes + ```solidity function stakes( uint256 tokenId, bytes32 incentiveId ) public view override returns (uint160 secondsPerLiquidityInsideInitialX128, uint128 liquidity) ``` -Returns information about a staked liquidity NFT +Returns information about a staked liquidity NFT #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The ID of the staked token -|`incentiveId` | bytes32 | The ID of the incentive for which the token is staked + +| Name | Type | Description | +| :------------ | :------ | :---------------------------------------------------- | +| `tokenId` | uint256 | The ID of the staked token | +| `incentiveId` | bytes32 | The ID of the incentive for which the token is staked | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`secondsPerLiquidityInsideInitialX128`| uint160 | secondsPerLiquidity represented as a UQ32.128 -|`liquidity`| bytes32 | The amount of liquidity in the NFT as of the last time the rewards were computed + +| Name | Type | Description | +| :------------------------------------- | :------ | :------------------------------------------------------------------------------- | +| `secondsPerLiquidityInsideInitialX128` | uint160 | secondsPerLiquidity represented as a UQ32.128 | +| `liquidity` | bytes32 | The amount of liquidity in the NFT as of the last time the rewards were computed | + ### constructor + ```solidity function constructor( contract IUniswapV3Factory _factory, @@ -38,54 +45,62 @@ Returns information about a staked liquidity NFT ) public ``` - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`_factory` | contract IUniswapV3Factory | the Uniswap V3 factory -|`_nonfungiblePositionManager` | contract INonfungiblePositionManager | the NFT position manager contract address -|`_maxIncentiveStartLeadTime` | uint256 | the max duration of an incentive in seconds -|`_maxIncentiveDuration` | uint256 | the max amount of seconds into the future the incentive startTime can be set + +| Name | Type | Description | +| :---------------------------- | :----------------------------------- | :--------------------------------------------------------------------------- | +| `_factory` | contract IUniswapV3Factory | the Uniswap V3 factory | +| `_nonfungiblePositionManager` | contract INonfungiblePositionManager | the NFT position manager contract address | +| `_maxIncentiveStartLeadTime` | uint256 | the max duration of an incentive in seconds | +| `_maxIncentiveDuration` | uint256 | the max amount of seconds into the future the incentive startTime can be set | ### createIncentive + ```solidity function createIncentive( struct IUniswapV3Staker.IncentiveKey key, uint256 reward ) external ``` -Creates a new liquidity mining incentive program +Creates a new liquidity mining incentive program #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to create -|`reward` | uint256 | The amount of reward tokens to be distributed + +| Name | Type | Description | +| :------- | :----------------------------------- | :-------------------------------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to create | +| `reward` | uint256 | The amount of reward tokens to be distributed | ### endIncentive + ```solidity function endIncentive( struct IUniswapV3Staker.IncentiveKey key ) external returns (uint256 refund) ``` -Ends an incentive after the incentive end time has passed and all stakes have been withdrawn +Ends an incentive after the incentive end time has passed and all stakes have been withdrawn #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to end + +| Name | Type | Description | +| :---- | :----------------------------------- | :------------------------------ | +| `key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to end | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`refund`| uint256 | The remaining reward tokens when the incentive is ended + +| Name | Type | Description | +| :------- | :------ | :------------------------------------------------------ | +| `refund` | uint256 | The remaining reward tokens when the incentive is ended | + ### onERC721Received + ```solidity function onERC721Received( ) external returns (bytes4) ``` + Upon receiving a Uniswap V3 ERC721, creates the token deposit setting owner to `from`. Also stakes token in one or more incentives if properly formatted `data` has a length > 0. @@ -95,24 +110,26 @@ It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. - ### transferDeposit + ```solidity function transferDeposit( uint256 tokenId, address to ) external ``` -Transfers ownership of a deposit from the sender to the given recipient +Transfers ownership of a deposit from the sender to the given recipient #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The ID of the token (and the deposit) to transfer -|`to` | address | The new owner of the deposit + +| Name | Type | Description | +| :-------- | :------ | :------------------------------------------------ | +| `tokenId` | uint256 | The ID of the token (and the deposit) to transfer | +| `to` | address | The new owner of the deposit | ### withdrawToken + ```solidity function withdrawToken( uint256 tokenId, @@ -120,49 +137,55 @@ Transfers ownership of a deposit from the sender to the given recipient bytes data ) external ``` -Withdraws a Uniswap V3 LP token `tokenId` from this contract to the recipient `to` +Withdraws a Uniswap V3 LP token `tokenId` from this contract to the recipient `to` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token -|`to` | address | The address where the LP token will be sent -|`data` | bytes | An optional data array that will be passed along to the `to` address via the NFT safeTransferFrom + +| Name | Type | Description | +| :-------- | :------ | :------------------------------------------------------------------------------------------------ | +| `tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token | +| `to` | address | The address where the LP token will be sent | +| `data` | bytes | An optional data array that will be passed along to the `to` address via the NFT safeTransferFrom | ### stakeToken + ```solidity function stakeToken( struct IUniswapV3Staker.IncentiveKey key, uint256 tokenId ) external ``` -Stakes a Uniswap V3 LP token +Stakes a Uniswap V3 LP token #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to stake the NFT -|`tokenId` | uint256 | The ID of the token to stake + +| Name | Type | Description | +| :-------- | :----------------------------------- | :-------------------------------------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to stake the NFT | +| `tokenId` | uint256 | The ID of the token to stake | ### unstakeToken + ```solidity function unstakeToken( struct IUniswapV3Staker.IncentiveKey key, uint256 tokenId ) external ``` -Unstakes a Uniswap V3 LP token +Unstakes a Uniswap V3 LP token #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to unstake the NFT -|`tokenId` | uint256 | The ID of the token to unstake + +| Name | Type | Description | +| :-------- | :----------------------------------- | :---------------------------------------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to unstake the NFT | +| `tokenId` | uint256 | The ID of the token to unstake | ### claimReward + ```solidity function claimReward( contract IERC20Minimal rewardToken, @@ -170,38 +193,44 @@ Unstakes a Uniswap V3 LP token uint256 amountRequested ) external override returns (uint256 reward) ``` -Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to` +Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`rewardToken` | contract IERC20Minimal | The token being distributed as a reward -|`to` | address | The address where claimed rewards will be sent to -|`amountRequested` | uint256 | The amount of reward tokens to claim. Claims entire reward amount if set to 0. + +| Name | Type | Description | +| :---------------- | :--------------------- | :----------------------------------------------------------------------------- | +| `rewardToken` | contract IERC20Minimal | The token being distributed as a reward | +| `to` | address | The address where claimed rewards will be sent to | +| `amountRequested` | uint256 | The amount of reward tokens to claim. Claims entire reward amount if set to 0. | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`reward`| uint256 | The amount of reward tokens claimed + +| Name | Type | Description | +| :------- | :------ | :---------------------------------- | +| `reward` | uint256 | The amount of reward tokens claimed | + ### getRewardInfo + ```solidity function getRewardInfo( struct IUniswapV3Staker.IncentiveKey key, uint256 tokenId ) external view override returns (uint256 reward, uint160 secondsInsideX128) ``` -Calculates the reward amount that will be received for the given stake +Calculates the reward amount that will be received for the given stake #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive -|`tokenId` | uint256 | The ID of the token + +| Name | Type | Description | +| :-------- | :----------------------------------- | :----------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive | +| `tokenId` | uint256 | The ID of the token | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`reward`| uint256 | The reward accrued to the NFT for the given incentive thus far -|`secondsInsideX128` | uint160 | The seconds inside the tick range + +| Name | Type | Description | +| :------------------ | :------ | :------------------------------------------------------------- | +| `reward` | uint256 | The reward accrued to the NFT for the given incentive thus far | +| `secondsInsideX128` | uint160 | The seconds inside the tick range | diff --git a/versioned_docs/version-V3/reference/periphery/staker/_category_.json b/versioned_docs/version-V3/reference/periphery/staker/_category_.json index 398d188115..df99453323 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/staker/_category_.json @@ -1,4 +1,4 @@ { - "label": "Staker", - "position": 4 - } \ No newline at end of file + "label": "Staker", + "position": 4 +} diff --git a/versioned_docs/version-V3/reference/periphery/staker/interfaces/IUniswapV3Staker.md b/versioned_docs/version-V3/reference/periphery/staker/interfaces/IUniswapV3Staker.md index 85e6f000d3..47901ec127 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/interfaces/IUniswapV3Staker.md +++ b/versioned_docs/version-V3/reference/periphery/staker/interfaces/IUniswapV3Staker.md @@ -1,171 +1,194 @@ Allows staking nonfungible liquidity tokens in exchange for reward tokens - ## Functions + ### factory + ```solidity function factory( ) external view returns (contract IUniswapV3Factory) ``` -The Uniswap V3 Factory - +The Uniswap V3 Factory ### nonfungiblePositionManager + ```solidity function nonfungiblePositionManager( ) external view returns (contract INonfungiblePositionManager) ``` -The nonfungible position manager with which this staking contract is compatible - +The nonfungible position manager with which this staking contract is compatible ### maxIncentiveDuration + ```solidity function maxIncentiveDuration( ) external view returns (uint256) ``` -The max duration of an incentive in seconds - +The max duration of an incentive in seconds ### maxIncentiveStartLeadTime + ```solidity function maxIncentiveStartLeadTime( ) external view returns (uint256) ``` -The max amount of seconds into the future the incentive startTime can be set - +The max amount of seconds into the future the incentive startTime can be set ### incentives + ```solidity function incentives( bytes32 incentiveId ) external view returns (uint256 totalRewardUnclaimed, uint160 totalSecondsClaimedX128, uint96 numberOfStakes) ``` -Represents a staking incentive +Represents a staking incentive #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`incentiveId` | bytes32 | The ID of the incentive computed from its parameters + +| Name | Type | Description | +| :------------ | :------ | :--------------------------------------------------- | +| `incentiveId` | bytes32 | The ID of the incentive computed from its parameters | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`totalRewardUnclaimed`| uint256 | The amount of reward token not yet claimed by users -|`totalSecondsClaimedX128`| uint160 | Total liquidity-seconds claimed, represented as a UQ32.128 -|`numberOfStakes`| uint96 | The count of deposits that are currently staked for the incentive + +| Name | Type | Description | +| :------------------------ | :------ | :---------------------------------------------------------------- | +| `totalRewardUnclaimed` | uint256 | The amount of reward token not yet claimed by users | +| `totalSecondsClaimedX128` | uint160 | Total liquidity-seconds claimed, represented as a UQ32.128 | +| `numberOfStakes` | uint96 | The count of deposits that are currently staked for the incentive | + ### deposits + ```solidity function deposits( ) external view returns (address owner, uint48 numberOfStakes, int24 tickLower, int24 tickUpper) ``` + Returns information about a deposited NFT +#### Return Values: +| Name | Type | Description | +| :--------------- | :------ | :--------------------------------------------------------------- | +| `owner` | address | The owner of the deposited NFT | +| `numberOfStakes` | uint48 | Counter of how many incentives for which the liquidity is staked | +| `tickLower` | int24 | The lower tick of the range | +| `tickUpper` | int24 | The upper tick of the range | -#### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`owner`| address | The owner of the deposited NFT -|`numberOfStakes`| uint48 | Counter of how many incentives for which the liquidity is staked -|`tickLower`| int24 | The lower tick of the range -|`tickUpper`| int24 | The upper tick of the range ### stakes + ```solidity function stakes( uint256 tokenId, bytes32 incentiveId ) external view returns (uint160 secondsPerLiquidityInsideInitialX128, uint128 liquidity) ``` -Returns information about a staked liquidity NFT +Returns information about a staked liquidity NFT #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The ID of the staked token -|`incentiveId` | bytes32 | The ID of the incentive for which the token is staked + +| Name | Type | Description | +| :------------ | :------ | :---------------------------------------------------- | +| `tokenId` | uint256 | The ID of the staked token | +| `incentiveId` | bytes32 | The ID of the incentive for which the token is staked | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`secondsPerLiquidityInsideInitialX128`| uint160 | secondsPerLiquidity represented as a UQ32.128 -|`liquidity`| uint128 | The amount of liquidity in the NFT as of the last time the rewards were computed + +| Name | Type | Description | +| :------------------------------------- | :------ | :------------------------------------------------------------------------------- | +| `secondsPerLiquidityInsideInitialX128` | uint160 | secondsPerLiquidity represented as a UQ32.128 | +| `liquidity` | uint128 | The amount of liquidity in the NFT as of the last time the rewards were computed | + ### rewards + ```solidity function rewards( contract IERC20Minimal rewardToken, address owner ) external view returns (uint256 rewardsOwed) ``` -Returns amounts of reward tokens owed to a given address according to the last time all stakes were updated +Returns amounts of reward tokens owed to a given address according to the last time all stakes were updated #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`rewardToken` | contract IERC20Minimal | The token for which to check rewards -|`owner` | address | The owner for which the rewards owed are checked + +| Name | Type | Description | +| :------------ | :--------------------- | :----------------------------------------------- | +| `rewardToken` | contract IERC20Minimal | The token for which to check rewards | +| `owner` | address | The owner for which the rewards owed are checked | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`rewardsOwed`| uint256 | The amount of the reward token claimable by the owner + +| Name | Type | Description | +| :------------ | :------ | :---------------------------------------------------- | +| `rewardsOwed` | uint256 | The amount of the reward token claimable by the owner | + ### createIncentive + ```solidity function createIncentive( struct IUniswapV3Staker.IncentiveKey key, uint256 reward ) external ``` -Creates a new liquidity mining incentive program +Creates a new liquidity mining incentive program #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to create -|`reward` | uint256 | The amount of reward tokens to be distributed + +| Name | Type | Description | +| :------- | :----------------------------------- | :-------------------------------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to create | +| `reward` | uint256 | The amount of reward tokens to be distributed | ### endIncentive + ```solidity function endIncentive( struct IUniswapV3Staker.IncentiveKey key ) external returns (uint256 refund) ``` -Ends an incentive after the incentive end time has passed and all stakes have been withdrawn +Ends an incentive after the incentive end time has passed and all stakes have been withdrawn #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to end + +| Name | Type | Description | +| :---- | :----------------------------------- | :------------------------------ | +| `key` | struct IUniswapV3Staker.IncentiveKey | Details of the incentive to end | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`refund`| uint256 | The remaining reward tokens when the incentive is ended + +| Name | Type | Description | +| :------- | :------ | :------------------------------------------------------ | +| `refund` | uint256 | The remaining reward tokens when the incentive is ended | + ### transferDeposit + ```solidity function transferDeposit( uint256 tokenId, address to ) external ``` -Transfers ownership of a deposit from the sender to the given recipient +Transfers ownership of a deposit from the sender to the given recipient #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The ID of the token (and the deposit) to transfer -|`to` | address | The new owner of the deposit + +| Name | Type | Description | +| :-------- | :------ | :------------------------------------------------ | +| `tokenId` | uint256 | The ID of the token (and the deposit) to transfer | +| `to` | address | The new owner of the deposit | ### withdrawToken + ```solidity function withdrawToken( uint256 tokenId, @@ -173,49 +196,55 @@ Transfers ownership of a deposit from the sender to the given recipient bytes data ) external ``` -Withdraws a Uniswap V3 LP token `tokenId` from this contract to the recipient `to` +Withdraws a Uniswap V3 LP token `tokenId` from this contract to the recipient `to` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token -|`to` | address | The address where the LP token will be sent -|`data` | bytes | An optional data array that will be passed along to the `to` address via the NFT safeTransferFrom + +| Name | Type | Description | +| :-------- | :------ | :------------------------------------------------------------------------------------------------ | +| `tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token | +| `to` | address | The address where the LP token will be sent | +| `data` | bytes | An optional data array that will be passed along to the `to` address via the NFT safeTransferFrom | ### stakeToken + ```solidity function stakeToken( struct IUniswapV3Staker.IncentiveKey key, uint256 tokenId ) external ``` -Stakes a Uniswap V3 LP token +Stakes a Uniswap V3 LP token #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to stake the NFT -|`tokenId` | uint256 | The ID of the token to stake + +| Name | Type | Description | +| :-------- | :----------------------------------- | :-------------------------------------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to stake the NFT | +| `tokenId` | uint256 | The ID of the token to stake | ### unstakeToken + ```solidity function unstakeToken( struct IUniswapV3Staker.IncentiveKey key, uint256 tokenId ) external ``` -Unstakes a Uniswap V3 LP token +Unstakes a Uniswap V3 LP token #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to unstake the NFT -|`tokenId` | uint256 | The ID of the token to unstake + +| Name | Type | Description | +| :-------- | :----------------------------------- | :---------------------------------------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive for which to unstake the NFT | +| `tokenId` | uint256 | The ID of the token to unstake | ### claimReward + ```solidity function claimReward( contract IERC20Minimal rewardToken, @@ -223,43 +252,52 @@ Unstakes a Uniswap V3 LP token uint256 amountRequested ) external returns (uint256 reward) ``` -Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to` +Transfers `amountRequested` of accrued `rewardToken` rewards from the contract to the recipient `to` #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`rewardToken` | contract IERC20Minimal | The token being distributed as a reward -|`to` | address | The address where claimed rewards will be sent to -|`amountRequested` | uint256 | The amount of reward tokens to claim. Claims entire reward amount if set to 0. + +| Name | Type | Description | +| :---------------- | :--------------------- | :----------------------------------------------------------------------------- | +| `rewardToken` | contract IERC20Minimal | The token being distributed as a reward | +| `to` | address | The address where claimed rewards will be sent to | +| `amountRequested` | uint256 | The amount of reward tokens to claim. Claims entire reward amount if set to 0. | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`reward`| uint256 | The amount of reward tokens claimed + +| Name | Type | Description | +| :------- | :------ | :---------------------------------- | +| `reward` | uint256 | The amount of reward tokens claimed | + ### getRewardInfo + ```solidity function getRewardInfo( struct IUniswapV3Staker.IncentiveKey key, uint256 tokenId ) external returns (uint256 reward, uint160 secondsInsideX128) ``` -Calculates the reward amount that will be received for the given stake +Calculates the reward amount that will be received for the given stake #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive -|`tokenId` | uint256 | The ID of the token + +| Name | Type | Description | +| :-------- | :----------------------------------- | :----------------------- | +| `key` | struct IUniswapV3Staker.IncentiveKey | The key of the incentive | +| `tokenId` | uint256 | The ID of the token | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`reward`| uint256 | The reward accrued to the NFT for the given incentive thus far -| `secondsInsideX128` | uint160 | The seconds inside the tick range + +| Name | Type | Description | +| :------------------ | :------ | :------------------------------------------------------------- | +| `reward` | uint256 | The reward accrued to the NFT for the given incentive thus far | +| `secondsInsideX128` | uint160 | The seconds inside the tick range | + ## Events + ### IncentiveCreated + ```solidity event IncentiveCreated( contract IERC20Minimal rewardToken, @@ -270,34 +308,40 @@ Calculates the reward amount that will be received for the given stake uint256 reward ) ``` -Event emitted when a liquidity mining incentive has been created +Event emitted when a liquidity mining incentive has been created #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`rewardToken`| contract IERC20Minimal | The token being distributed as a reward -|`pool`| contract IUniswapV3Pool | The Uniswap V3 pool -|`startTime`| uint256 | The time when the incentive program begins -|`endTime`| uint256 | The time when rewards stop accruing -|`refundee`| address | The address which receives any remaining reward tokens after the end time -|`reward`| uint256 | The amount of reward tokens to be distributed + +| Name | Type | Description | +| :------------ | :---------------------- | :------------------------------------------------------------------------ | +| `rewardToken` | contract IERC20Minimal | The token being distributed as a reward | +| `pool` | contract IUniswapV3Pool | The Uniswap V3 pool | +| `startTime` | uint256 | The time when the incentive program begins | +| `endTime` | uint256 | The time when rewards stop accruing | +| `refundee` | address | The address which receives any remaining reward tokens after the end time | +| `reward` | uint256 | The amount of reward tokens to be distributed | + ### IncentiveEnded + ```solidity event IncentiveEnded( bytes32 incentiveId, uint256 refund ) ``` -Event that can be emitted when a liquidity mining incentive has ended +Event that can be emitted when a liquidity mining incentive has ended #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`incentiveId`| bytes32 | The incentive which is ending -|`refund`| uint256 | The amount of reward tokens refunded + +| Name | Type | Description | +| :------------ | :------ | :----------------------------------- | +| `incentiveId` | bytes32 | The incentive which is ending | +| `refund` | uint256 | The amount of reward tokens refunded | + ### DepositTransferred + ```solidity event DepositTransferred( uint256 tokenId, @@ -305,16 +349,19 @@ Event that can be emitted when a liquidity mining incentive has ended address newOwner ) ``` -Emitted when ownership of a deposit changes +Emitted when ownership of a deposit changes #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`tokenId`| uint256 | The ID of the deposit (and token) that is being transferred -|`oldOwner`| address | The owner before the deposit was transferred -|`newOwner`| address | The owner after the deposit was transferred + +| Name | Type | Description | +| :--------- | :------ | :---------------------------------------------------------- | +| `tokenId` | uint256 | The ID of the deposit (and token) that is being transferred | +| `oldOwner` | address | The owner before the deposit was transferred | +| `newOwner` | address | The owner after the deposit was transferred | + ### TokenStaked + ```solidity event TokenStaked( uint256 tokenId, @@ -322,42 +369,49 @@ Emitted when ownership of a deposit changes uint128 incentiveId ) ``` -Event emitted when a Uniswap V3 LP token has been staked +Event emitted when a Uniswap V3 LP token has been staked #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`tokenId`| uint256 | The unique identifier of an Uniswap V3 LP token -|`liquidity`| bytes32 | The amount of liquidity staked -|`incentiveId`| uint128 | The incentive in which the token is staking + +| Name | Type | Description | +| :------------ | :------ | :---------------------------------------------- | +| `tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token | +| `liquidity` | bytes32 | The amount of liquidity staked | +| `incentiveId` | uint128 | The incentive in which the token is staking | + ### TokenUnstaked + ```solidity event TokenUnstaked( uint256 tokenId, bytes32 incentiveId ) ``` -Event emitted when a Uniswap V3 LP token has been unstaked +Event emitted when a Uniswap V3 LP token has been unstaked #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`tokenId`| uint256 | The unique identifier of an Uniswap V3 LP token -|`incentiveId`| bytes32 | The incentive in which the token is staking + +| Name | Type | Description | +| :------------ | :------ | :---------------------------------------------- | +| `tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token | +| `incentiveId` | bytes32 | The incentive in which the token is staking | + ### RewardClaimed + ```solidity event RewardClaimed( address to, uint256 reward ) ``` -Event emitted when a reward token has been claimed +Event emitted when a reward token has been claimed #### Parameters: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------- | -|`to`| address | The address where claimed rewards were sent to -|`reward`| uint256 | The amount of reward tokens claimed + +| Name | Type | Description | +| :------- | :------ | :--------------------------------------------- | +| `to` | address | The address where claimed rewards were sent to | +| `reward` | uint256 | The amount of reward tokens claimed | diff --git a/versioned_docs/version-V3/reference/periphery/staker/interfaces/_category_.json b/versioned_docs/version-V3/reference/periphery/staker/interfaces/_category_.json index 1b4ae7ea2d..be0ed47cef 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/interfaces/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/staker/interfaces/_category_.json @@ -1,4 +1,4 @@ { - "label": "Interfaces", - "position": 3 - } \ No newline at end of file + "label": "Interfaces", + "position": 3 +} diff --git a/versioned_docs/version-V3/reference/periphery/staker/libraries/IncentiveId.md b/versioned_docs/version-V3/reference/periphery/staker/libraries/IncentiveId.md index 86ae7a1bda..4dbb37b406 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/libraries/IncentiveId.md +++ b/versioned_docs/version-V3/reference/periphery/staker/libraries/IncentiveId.md @@ -1,22 +1,23 @@ - - - ## Functions + ### compute + ```solidity function compute( struct IUniswapV3Staker.IncentiveKey key ) internal pure returns (bytes32 incentiveId) ``` -Calculate the key for a staking incentive +Calculate the key for a staking incentive #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`key` | struct IUniswapV3Staker.IncentiveKey | The components used to compute the incentive identifier + +| Name | Type | Description | +| :---- | :----------------------------------- | :------------------------------------------------------ | +| `key` | struct IUniswapV3Staker.IncentiveKey | The components used to compute the incentive identifier | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`incentiveId`| bytes32 | The identifier for the incentive + +| Name | Type | Description | +| :------------ | :------ | :------------------------------- | +| `incentiveId` | bytes32 | The identifier for the incentive | diff --git a/versioned_docs/version-V3/reference/periphery/staker/libraries/NFTPositionInfo.md b/versioned_docs/version-V3/reference/periphery/staker/libraries/NFTPositionInfo.md index c2ae3e352b..b1ccf09f12 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/libraries/NFTPositionInfo.md +++ b/versioned_docs/version-V3/reference/periphery/staker/libraries/NFTPositionInfo.md @@ -1,8 +1,9 @@ Encapsulates the logic for getting info about a NFT token ID - ## Functions + ### getPositionInfo + ```solidity function getPositionInfo( contract IUniswapV3Factory factory, @@ -11,18 +12,19 @@ Encapsulates the logic for getting info about a NFT token ID ) internal view returns (contract IUniswapV3Pool pool, int24 tickLower, int24 tickUpper, uint128 liquidity) ``` - #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`factory` | contract IUniswapV3Factory | The address of the Uniswap V3 Factory used in computing the pool address -|`nonfungiblePositionManager` | contract INonfungiblePositionManager | The address of the nonfungible position manager to query -|`tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token + +| Name | Type | Description | +| :--------------------------- | :----------------------------------- | :----------------------------------------------------------------------- | +| `factory` | contract IUniswapV3Factory | The address of the Uniswap V3 Factory used in computing the pool address | +| `nonfungiblePositionManager` | contract INonfungiblePositionManager | The address of the nonfungible position manager to query | +| `tokenId` | uint256 | The unique identifier of an Uniswap V3 LP token | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`pool`| IUniswapV3Pool | The address of the Uniswap V3 pool -|`tickLower`| int24 | The lower tick of the Uniswap V3 position -|`tickUpper`| int24 | The upper tick of the Uniswap V3 position -|`liquidity`| uint128 | The amount of liquidity staked + +| Name | Type | Description | +| :---------- | :------------- | :---------------------------------------- | +| `pool` | IUniswapV3Pool | The address of the Uniswap V3 pool | +| `tickLower` | int24 | The lower tick of the Uniswap V3 position | +| `tickUpper` | int24 | The upper tick of the Uniswap V3 position | +| `liquidity` | uint128 | The amount of liquidity staked | diff --git a/versioned_docs/version-V3/reference/periphery/staker/libraries/RewardMath.md b/versioned_docs/version-V3/reference/periphery/staker/libraries/RewardMath.md index 68f21d416a..3c5b386385 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/libraries/RewardMath.md +++ b/versioned_docs/version-V3/reference/periphery/staker/libraries/RewardMath.md @@ -1,8 +1,9 @@ Allows computing rewards given some parameters of stakes and incentives - ## Functions + ### computeRewardAmount + ```solidity function computeRewardAmount( uint256 totalRewardUnclaimed, @@ -15,23 +16,25 @@ Allows computing rewards given some parameters of stakes and incentives uint256 currentTime ) internal pure returns (uint256 reward, uint160 secondsInsideX128) ``` -Compute the amount of rewards owed given parameters of the incentive and stake +Compute the amount of rewards owed given parameters of the incentive and stake #### Parameters: -| Name | Type | Description | -| :--- | :--- | :------------------------------------------------------------------- | -|`totalRewardUnclaimed` | uint256 | The total amount of unclaimed rewards left for an incentive -|`totalSecondsClaimedX128` | uint160 | How many full liquidity-seconds have been already claimed for the incentive -|`startTime` | uint256 | When the incentive rewards began in epoch seconds -|`endTime` | uint256 | When rewards are no longer being dripped out in epoch seconds -|`liquidity` | uint128 | The amount of liquidity, assumed to be constant over the period over which the snapshots are measured -|`secondsPerLiquidityInsideInitialX128` | uint160 | The seconds per liquidity of the liquidity tick range as of the beginning of the period -|`secondsPerLiquidityInsideX128` | uint160 | The seconds per liquidity of the liquidity tick range as of the current block timestamp -|`currentTime` | uint256 | The current block timestamp, which must be greater than or equal to the start time + +| Name | Type | Description | +| :------------------------------------- | :------ | :---------------------------------------------------------------------------------------------------- | +| `totalRewardUnclaimed` | uint256 | The total amount of unclaimed rewards left for an incentive | +| `totalSecondsClaimedX128` | uint160 | How many full liquidity-seconds have been already claimed for the incentive | +| `startTime` | uint256 | When the incentive rewards began in epoch seconds | +| `endTime` | uint256 | When rewards are no longer being dripped out in epoch seconds | +| `liquidity` | uint128 | The amount of liquidity, assumed to be constant over the period over which the snapshots are measured | +| `secondsPerLiquidityInsideInitialX128` | uint160 | The seconds per liquidity of the liquidity tick range as of the beginning of the period | +| `secondsPerLiquidityInsideX128` | uint160 | The seconds per liquidity of the liquidity tick range as of the current block timestamp | +| `currentTime` | uint256 | The current block timestamp, which must be greater than or equal to the start time | #### Return Values: -| Name | Type | Description | -| :----------------------------- | :------------ | :--------------------------------------------------------------------------- | -|`reward`| uint256 | The amount of rewards owed -|`secondsInsideX128`| uint160 | The total liquidity seconds inside the position's range for the duration of the stake + +| Name | Type | Description | +| :------------------ | :------ | :------------------------------------------------------------------------------------ | +| `reward` | uint256 | The amount of rewards owed | +| `secondsInsideX128` | uint160 | The total liquidity seconds inside the position's range for the duration of the stake | diff --git a/versioned_docs/version-V3/reference/periphery/staker/libraries/_category_.json b/versioned_docs/version-V3/reference/periphery/staker/libraries/_category_.json index 3a8bc6547f..9528f74123 100644 --- a/versioned_docs/version-V3/reference/periphery/staker/libraries/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/staker/libraries/_category_.json @@ -1,4 +1,4 @@ { - "label": "Libraries", - "position": 4 - } \ No newline at end of file + "label": "Libraries", + "position": 4 +} diff --git a/versioned_docs/version-V3/reference/periphery/test/Base64Test.md b/versioned_docs/version-V3/reference/periphery/test/Base64Test.md index 46754ecbaf..b87e8e37e9 100644 --- a/versioned_docs/version-V3/reference/periphery/test/Base64Test.md +++ b/versioned_docs/version-V3/reference/periphery/test/Base64Test.md @@ -1,22 +1,15 @@ - - - ## Functions + ### encode + ```solidity function encode( ) external returns (string) ``` - - - ### getGasCostOfEncode + ```solidity function getGasCostOfEncode( ) external returns (uint256) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/LiquidityAmountsTest.md b/versioned_docs/version-V3/reference/periphery/test/LiquidityAmountsTest.md index 0f1030aa29..a72bbd9577 100644 --- a/versioned_docs/version-V3/reference/periphery/test/LiquidityAmountsTest.md +++ b/versioned_docs/version-V3/reference/periphery/test/LiquidityAmountsTest.md @@ -1,112 +1,85 @@ - - - ## Functions + ### getLiquidityForAmount0 + ```solidity function getLiquidityForAmount0( ) external returns (uint128 liquidity) ``` - - - ### getGasCostOfGetLiquidityForAmount0 + ```solidity function getGasCostOfGetLiquidityForAmount0( ) external returns (uint256) ``` - - - ### getLiquidityForAmount1 + ```solidity function getLiquidityForAmount1( ) external returns (uint128 liquidity) ``` - - - ### getGasCostOfGetLiquidityForAmount1 + ```solidity function getGasCostOfGetLiquidityForAmount1( ) external returns (uint256) ``` - - - ### getLiquidityForAmounts + ```solidity function getLiquidityForAmounts( ) external returns (uint128 liquidity) ``` - - - ### getGasCostOfGetLiquidityForAmounts + ```solidity function getGasCostOfGetLiquidityForAmounts( ) external returns (uint256) ``` - - - ### getAmount0ForLiquidity + ```solidity function getAmount0ForLiquidity( ) external returns (uint256 amount0) ``` - - - ### getGasCostOfGetAmount0ForLiquidity + ```solidity function getGasCostOfGetAmount0ForLiquidity( ) external returns (uint256) ``` - - - ### getAmount1ForLiquidity + ```solidity function getAmount1ForLiquidity( ) external returns (uint256 amount1) ``` - - - ### getGasCostOfGetAmount1ForLiquidity + ```solidity function getGasCostOfGetAmount1ForLiquidity( ) external returns (uint256) ``` - - - ### getAmountsForLiquidity + ```solidity function getAmountsForLiquidity( ) external returns (uint256 amount0, uint256 amount1) ``` - - - ### getGasCostOfGetAmountsForLiquidity + ```solidity function getGasCostOfGetAmountsForLiquidity( ) external returns (uint256) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/MockTimeNonfungiblePositionManager.md b/versioned_docs/version-V3/reference/periphery/test/MockTimeNonfungiblePositionManager.md index 7651c775b8..c99ffb9cc9 100644 --- a/versioned_docs/version-V3/reference/periphery/test/MockTimeNonfungiblePositionManager.md +++ b/versioned_docs/version-V3/reference/periphery/test/MockTimeNonfungiblePositionManager.md @@ -1,31 +1,22 @@ - - - ## Functions + ### constructor + ```solidity function constructor( ) public ``` +### \_blockTimestamp - - -### _blockTimestamp ```solidity function _blockTimestamp( ) internal returns (uint256) ``` - - - ### setTime + ```solidity function setTime( ) external ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/MockTimeSwapRouter.md b/versioned_docs/version-V3/reference/periphery/test/MockTimeSwapRouter.md index 7651c775b8..c99ffb9cc9 100644 --- a/versioned_docs/version-V3/reference/periphery/test/MockTimeSwapRouter.md +++ b/versioned_docs/version-V3/reference/periphery/test/MockTimeSwapRouter.md @@ -1,31 +1,22 @@ - - - ## Functions + ### constructor + ```solidity function constructor( ) public ``` +### \_blockTimestamp - - -### _blockTimestamp ```solidity function _blockTimestamp( ) internal returns (uint256) ``` - - - ### setTime + ```solidity function setTime( ) external ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/NFTDescriptorTest.md b/versioned_docs/version-V3/reference/periphery/test/NFTDescriptorTest.md index 20543f9be8..0d3c4a5239 100644 --- a/versioned_docs/version-V3/reference/periphery/test/NFTDescriptorTest.md +++ b/versioned_docs/version-V3/reference/periphery/test/NFTDescriptorTest.md @@ -1,103 +1,78 @@ - - - ## Functions + ### constructTokenURI + ```solidity function constructTokenURI( ) public returns (string) ``` - - - ### getGasCostOfConstructTokenURI + ```solidity function getGasCostOfConstructTokenURI( ) public returns (uint256) ``` - - - ### tickToDecimalString + ```solidity function tickToDecimalString( ) public returns (string) ``` - - - ### fixedPointToDecimalString + ```solidity function fixedPointToDecimalString( ) public returns (string) ``` - - - ### feeToPercentString + ```solidity function feeToPercentString( ) public returns (string) ``` - - - ### addressToString + ```solidity function addressToString( ) public returns (string) ``` - - - ### generateSVGImage + ```solidity function generateSVGImage( ) public returns (string) ``` - - - ### tokenToColorHex + ```solidity function tokenToColorHex( ) public returns (string) ``` - - - ### sliceTokenHex + ```solidity function sliceTokenHex( ) public returns (uint256) ``` - - - ### rangeLocation + ```solidity function rangeLocation( ) public returns (string, string) ``` - - - ### isRare + ```solidity function isRare( ) public returns (bool) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/PathTest.md b/versioned_docs/version-V3/reference/periphery/test/PathTest.md index dfbffcd587..9b8a419755 100644 --- a/versioned_docs/version-V3/reference/periphery/test/PathTest.md +++ b/versioned_docs/version-V3/reference/periphery/test/PathTest.md @@ -1,49 +1,36 @@ - - - ## Functions + ### hasMultiplePools + ```solidity function hasMultiplePools( ) public returns (bool) ``` - - - ### decodeFirstPool + ```solidity function decodeFirstPool( ) public returns (address tokenA, address tokenB, uint24 fee) ``` - - - ### getFirstPool + ```solidity function getFirstPool( ) public returns (bytes) ``` - - - ### skipToken + ```solidity function skipToken( ) public returns (bytes) ``` - - - ### getGasCostOfDecodeFirstPool + ```solidity function getGasCostOfDecodeFirstPool( ) public returns (uint256) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/PeripheryImmutableStateTest.md b/versioned_docs/version-V3/reference/periphery/test/PeripheryImmutableStateTest.md index 5d1f04d396..f13713d422 100644 --- a/versioned_docs/version-V3/reference/periphery/test/PeripheryImmutableStateTest.md +++ b/versioned_docs/version-V3/reference/periphery/test/PeripheryImmutableStateTest.md @@ -1,13 +1,8 @@ - - - ## Functions + ### constructor + ```solidity function constructor( ) public ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/PoolAddressTest.md b/versioned_docs/version-V3/reference/periphery/test/PoolAddressTest.md index 95524500f7..6f3849cd2c 100644 --- a/versioned_docs/version-V3/reference/periphery/test/PoolAddressTest.md +++ b/versioned_docs/version-V3/reference/periphery/test/PoolAddressTest.md @@ -1,31 +1,22 @@ - - - ## Functions + ### POOL_INIT_CODE_HASH + ```solidity function POOL_INIT_CODE_HASH( ) external returns (bytes32) ``` - - - ### computeAddress + ```solidity function computeAddress( ) external returns (address) ``` - - - ### getGasCostOfComputeAddress + ```solidity function getGasCostOfComputeAddress( ) external returns (uint256) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/SelfPermitTest.md b/versioned_docs/version-V3/reference/periphery/test/SelfPermitTest.md index e1f7d76d64..c7032bc090 100644 --- a/versioned_docs/version-V3/reference/periphery/test/SelfPermitTest.md +++ b/versioned_docs/version-V3/reference/periphery/test/SelfPermitTest.md @@ -1,3 +1 @@ - Same as SelfPermit but not abstract - diff --git a/versioned_docs/version-V3/reference/periphery/test/TestCallbackValidation.md b/versioned_docs/version-V3/reference/periphery/test/TestCallbackValidation.md index 5f34d035c9..86a95722a6 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TestCallbackValidation.md +++ b/versioned_docs/version-V3/reference/periphery/test/TestCallbackValidation.md @@ -1,13 +1,8 @@ - - - ## Functions + ### verifyCallback + ```solidity function verifyCallback( ) external returns (contract IUniswapV3Pool pool) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/TestERC20.md b/versioned_docs/version-V3/reference/periphery/test/TestERC20.md index 5d1f04d396..f13713d422 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TestERC20.md +++ b/versioned_docs/version-V3/reference/periphery/test/TestERC20.md @@ -1,13 +1,8 @@ - - - ## Functions + ### constructor + ```solidity function constructor( ) public ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/TestERC20Metadata.md b/versioned_docs/version-V3/reference/periphery/test/TestERC20Metadata.md index 5d1f04d396..f13713d422 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TestERC20Metadata.md +++ b/versioned_docs/version-V3/reference/periphery/test/TestERC20Metadata.md @@ -1,13 +1,8 @@ - - - ## Functions + ### constructor + ```solidity function constructor( ) public ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/TestERC20PermitAllowed.md b/versioned_docs/version-V3/reference/periphery/test/TestERC20PermitAllowed.md index bf58a3e8d4..740ae6369d 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TestERC20PermitAllowed.md +++ b/versioned_docs/version-V3/reference/periphery/test/TestERC20PermitAllowed.md @@ -1,22 +1,15 @@ - - - ## Functions + ### constructor + ```solidity function constructor( ) public ``` - - - ### permit + ```solidity function permit( ) external ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/TestMulticall.md b/versioned_docs/version-V3/reference/periphery/test/TestMulticall.md index 3e067e047a..4edbc466f4 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TestMulticall.md +++ b/versioned_docs/version-V3/reference/periphery/test/TestMulticall.md @@ -1,40 +1,29 @@ - - - ## Functions + ### functionThatRevertsWithError + ```solidity function functionThatRevertsWithError( ) external ``` - - - ### functionThatReturnsTuple + ```solidity function functionThatReturnsTuple( ) external returns (struct TestMulticall.Tuple tuple) ``` - - - ### pays + ```solidity function pays( ) external ``` - - - ### returnSender + ```solidity function returnSender( ) external returns (address) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/TestPositionNFTOwner.md b/versioned_docs/version-V3/reference/periphery/test/TestPositionNFTOwner.md index 1c679808e0..673a5704d9 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TestPositionNFTOwner.md +++ b/versioned_docs/version-V3/reference/periphery/test/TestPositionNFTOwner.md @@ -1,22 +1,15 @@ - - - ## Functions + ### setOwner + ```solidity function setOwner( ) external ``` - - - ### isValidSignature + ```solidity function isValidSignature( ) external returns (bytes4 magicValue) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/TestUniswapV3Callee.md b/versioned_docs/version-V3/reference/periphery/test/TestUniswapV3Callee.md index 452060f932..efdc0d2405 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TestUniswapV3Callee.md +++ b/versioned_docs/version-V3/reference/periphery/test/TestUniswapV3Callee.md @@ -1,49 +1,36 @@ - - - ## Functions + ### swapExact0For1 + ```solidity function swapExact0For1( ) external ``` - - - ### swap0ForExact1 + ```solidity function swap0ForExact1( ) external ``` - - - ### swapExact1For0 + ```solidity function swapExact1For0( ) external ``` - - - ### swap1ForExact0 + ```solidity function swap1ForExact0( ) external ``` - - - ### uniswapV3SwapCallback + ```solidity function uniswapV3SwapCallback( ) external ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/TickLensTest.md b/versioned_docs/version-V3/reference/periphery/test/TickLensTest.md index 9f3a0578be..8d71124d64 100644 --- a/versioned_docs/version-V3/reference/periphery/test/TickLensTest.md +++ b/versioned_docs/version-V3/reference/periphery/test/TickLensTest.md @@ -1,13 +1,8 @@ - - - ## Functions + ### getGasCostOfGetPopulatedTicksInWord + ```solidity function getGasCostOfGetPopulatedTicksInWord( ) external returns (uint256) ``` - - - - diff --git a/versioned_docs/version-V3/reference/periphery/test/_category_.json b/versioned_docs/version-V3/reference/periphery/test/_category_.json index 56202206f1..8312720c4b 100644 --- a/versioned_docs/version-V3/reference/periphery/test/_category_.json +++ b/versioned_docs/version-V3/reference/periphery/test/_category_.json @@ -1,4 +1,4 @@ { - "label": "Test", - "position": 4 - } \ No newline at end of file + "label": "Test", + "position": 4 +} diff --git a/versions.json b/versions.json index 7681f2efad..b2bc2bf5bb 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1 @@ -[ - "V3", - "V2", - "V1" -] +["V3", "V2", "V1"]