From 0f3e4db953a23e65573ff6d80027e53e91e3b0a1 Mon Sep 17 00:00:00 2001 From: 0xLightt <0xlightt@protonmail.com> Date: Tue, 18 Apr 2023 22:23:55 +0100 Subject: [PATCH] Fix broken paths --- .../version-Maia/guides/01-quick-start.md | 27 -- .../version-Maia/guides/02-using-ethers.md | 198 --------- .../version-Maia/guides/03-creating-a-pool.md | 256 ----------- .../version-Maia/guides/04-fetching-prices.md | 151 ------- .../guides/05-creating-a-trade.md | 241 ---------- .../version-Maia/guides/06-auto-router.md | 176 -------- .../version-Maia/guides/_category_.json | 5 - .../guides/liquidity/04-minting-positions.md | 119 ----- .../guides/liquidity/05-adding-liquidity.md | 56 --- .../guides/liquidity/06-removing-liquidity.md | 105 ----- .../guides/liquidity/07-swap-and-add.md | 167 ------- .../guides/liquidity/_category_.json | 5 - .../version-Maia/introduction.md | 26 -- .../version-Maia/subgraph/_category_.json | 5 - .../version-Maia/subgraph/subgraph-example.md | 311 ------------- .../subgraph/subgraph-introduction.md | 40 -- .../version-Maia/widgets/_category_.json | 5 - .../widgets/swap-widget-api-v1.md | 58 --- .../version-Maia/widgets/swap-widget-api.md | 66 --- .../widgets/swap-widget-examples.mdx | 210 --------- .../version-Maia/widgets/swap-widget.mdx | 411 ------------------ .../version-Maia-sidebars.json | 8 - docusaurus.config.js | 30 +- sdk-examples/AddAndRemoveLiquidity.tsx | 126 ------ .../overview/gauges/01-introduction.md | 2 +- .../overview/tokenomics/02-boost.md | 2 +- .../overview/tokenomics/03-supply.md | 2 +- .../overview/vaults/01-strategies.md | 2 +- versioned_docs/version-Maia/what-is-maia.md | 8 +- .../version-Ulysses/what-is-Ulysses.md | 4 +- 30 files changed, 16 insertions(+), 2806 deletions(-) delete mode 100644 SDK_versioned_docs/version-Maia/guides/01-quick-start.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/02-using-ethers.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/03-creating-a-pool.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/04-fetching-prices.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/05-creating-a-trade.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/06-auto-router.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/_category_.json delete mode 100644 SDK_versioned_docs/version-Maia/guides/liquidity/04-minting-positions.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/liquidity/05-adding-liquidity.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/liquidity/06-removing-liquidity.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/liquidity/07-swap-and-add.md delete mode 100644 SDK_versioned_docs/version-Maia/guides/liquidity/_category_.json delete mode 100644 SDK_versioned_docs/version-Maia/introduction.md delete mode 100644 SDK_versioned_docs/version-Maia/subgraph/_category_.json delete mode 100644 SDK_versioned_docs/version-Maia/subgraph/subgraph-example.md delete mode 100644 SDK_versioned_docs/version-Maia/subgraph/subgraph-introduction.md delete mode 100644 SDK_versioned_docs/version-Maia/widgets/_category_.json delete mode 100644 SDK_versioned_docs/version-Maia/widgets/swap-widget-api-v1.md delete mode 100644 SDK_versioned_docs/version-Maia/widgets/swap-widget-api.md delete mode 100644 SDK_versioned_docs/version-Maia/widgets/swap-widget-examples.mdx delete mode 100644 SDK_versioned_docs/version-Maia/widgets/swap-widget.mdx delete mode 100644 SDK_versioned_sidebars/version-Maia-sidebars.json delete mode 100644 sdk-examples/AddAndRemoveLiquidity.tsx diff --git a/SDK_versioned_docs/version-Maia/guides/01-quick-start.md b/SDK_versioned_docs/version-Maia/guides/01-quick-start.md deleted file mode 100644 index e5be28f..0000000 --- a/SDK_versioned_docs/version-Maia/guides/01-quick-start.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -id: quick-start -title: Quick Start ---- - -The Uniswap SDK is separate from the Uniswap protocol. It is designed to assist developers when interacting with the protocol in any environment that can execute JavaScript, such as websites or node scripts. With the SDK, you can manipulate data that has been queried from the EVM using libraries that assist with several needs, such as data modeling and protection from rounding errors. - -The following guides will help you use [ethers.js](https://docs.ethers.io/v5/) to return state data from the EVM, and the Uniswap V3 SDK to manipulate it once it has been retrieved. - -# Installation - -To interact with the V3 SDK - we recommend installing though the npm package - -```javascript -npm i --save-dev @uniswap/v3-sdk -npm i --save-dev @uniswap/sdk-core -``` - -# Usage - -```javascript -import { Pool } from '@uniswap/v3-sdk' -``` - -# Next Steps - -To use `Ethers.js` for the first time, or would like a more beginner friendly starting place, check out [**Using Ethers.js**](./02-using-ethers.md). If you are already familiar with ethers.js and general dev setup, you can move to [**Creating a Pool Instance**](./03-creating-a-pool.md). diff --git a/SDK_versioned_docs/version-Maia/guides/02-using-ethers.md b/SDK_versioned_docs/version-Maia/guides/02-using-ethers.md deleted file mode 100644 index b8a483f..0000000 --- a/SDK_versioned_docs/version-Maia/guides/02-using-ethers.md +++ /dev/null @@ -1,198 +0,0 @@ ---- -id: using-ethers -title: Using Ethers.js ---- - -This guide will help you install the V3 SDK and [ethers.js](https://docs.ethers.io/v5/) to query state data from Ethereum. -While this tutorial doesn't use the V3 SDK - it will set us up to use it after we get the on-chain data we need. - -## First Steps - -For our first step, we're going to use `ethers.js` to return immutable variables from a Uniswap V3 pool contract, and assign those to an interface in our script that can be repeatedly referenced without continually reading state data directly from the EVM. - -We'll need to make a new directory called `example`: - -```typescript -mkdir example -cd example -``` - -Then we'll make a new project using Node's `npm`: - -```typescript -npm init -``` - -```typescript -npm i typescript --save -npm i ts-node --save -npm i @uniswap/v3-sdk --save -npm i @uniswap/sdk-core --save -npm i ethers --save -``` - -Depending on your machine configuration, you may also need this: - -```typescript -npm install -D tslib @types/node -``` - -## Importing Ethers and the V3 SDK - -We'll need to import ethers, and set up our environment variables so we can query chain data. -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' - -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' -``` - -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)', -] -``` - -## Using ethers.js "Contract" - -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) -``` - -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 -} -``` - -## Returning Chain Data - -Now we're ready to query the EVM using `ethers.js` and assign the returned values to the variables inside of our `Immutables` interface. - -```typescript -async function getPoolImmutables() { - const PoolImmutables: Immutables = { - factory: await poolContract.factory(), - token0: await poolContract.token0(), - token1: await poolContract.token1(), - fee: await poolContract.fee(), - tickSpacing: await poolContract.tickSpacing(), - maxLiquidityPerTick: await poolContract.maxLiquidityPerTick(), - } - return PoolImmutables -} -``` - -Finally, we can call our function, and print out the returned data in our console: - -## Calling Our Function - -```typescript -getPoolImmutables().then((result) => { - console.log(result) -}) -``` - -To call our function, we'll navigate to our project directory within our console, and use the following command: - -``` -npx ts-node example.ts -``` - -If everything worked correctly, you should see something like this: - -```typescript -➜ example npx ts-node example.ts -{ - factory: '0x1F98431c8aD98523631AE4a59f267346ea31F984', - token0: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', - token1: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - fee: 3000, - tickSpacing: 60, - maxLiquidityPerTick: BigNumber { - _hex: '0x023746e6a58dcb13d4af821b93f062', - _isBigNumber: true - } -} -``` - -## The Final Script - -```typescript -import { ethers } from 'ethers' -import { Address } from 'cluster' - -const provider = new ethers.providers.JsonRpcProvider('') - -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) - -interface Immutables { - 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 immutables: Immutables = { - factory, - token0, - token1, - fee, - tickSpacing, - maxLiquidityPerTick, - } - return immutables -} - -getPoolImmutables().then((result) => { - console.log(result) -}) -``` diff --git a/SDK_versioned_docs/version-Maia/guides/03-creating-a-pool.md b/SDK_versioned_docs/version-Maia/guides/03-creating-a-pool.md deleted file mode 100644 index 1052c5b..0000000 --- a/SDK_versioned_docs/version-Maia/guides/03-creating-a-pool.md +++ /dev/null @@ -1,256 +0,0 @@ ---- -id: creating-a-pool -title: Creating a Pool Instance ---- - -This guide extends the previous [Using Ethers.js](./using-ethers) guide by using the fetched data from the EVM to create a `Pool` instance using the V3 SDK. A "Pool" as we refer to it here does not mean an actual V3 pool, but a model of one created with the SDK. This model will help us interact with the protocol, or manipulate data relevant to the protocol, in a way that does not require continually fetching pool data from the EVM - which can be time intensive and computationally costly. - -## Importing the ABI - -First we will replace the abi that we previously wrote out manually with a library that contains the total V3 pool abi for us to easily interact with. Note the abi is imported from the `v3-core` npm package, rather than the `v3-sdk` npm package, as it is a part of the protocol rather than the SDK. - -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' -``` - -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) -``` - -## Creating The Interfaces - -Create two interfaces with types that are appropriate for the data we need. We won't be using all of this data, but some extra data is fetched for context. - -```typescript -interface Immutables { - 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 -} -``` - -## Fetching Immutable Data - -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 immutables: Immutables = { - factory, - token0, - token1, - fee, - tickSpacing, - maxLiquidityPerTick, - } - return immutables -} -``` - -Fetch the state data in with the same `Promise.all` style. This approach queries state data concurrently, rather than sequentially, to avoid out of sync data that may be returned if sequential queries are executed over the span of two blocks. - -> `sqrtPriceX96` and `sqrtRatioX96`, despite being named differently, are interchangeable values. - -## Fetching State Data - -```typescript -async function getPoolState() { - const [liquidity, slot] = await Promise.all([poolContract.liquidity(), poolContract.slot0()]) - - const PoolState: State = { - liquidity, - sqrtPriceX96: slot[0], - tick: slot[1], - observationIndex: slot[2], - observationCardinality: slot[3], - observationCardinalityNext: slot[4], - feeProtocol: slot[5], - unlocked: slot[6], - } - - return PoolState -} -``` - -## Creating the Pool Instance - -Create a function called `main`, which calls previously written functions, and uses the returned data to construct two `Ethers.js` `Token` instances and a V3 SDK `Pool` instance. - -> The final constructor argument when creating a Pool, `ticks`, is optional. `ticks` takes all tick data, including the liquidity within, which can be used to model the result of a swap. Because this can add up to a lot of data fetched from the EVM, it is optional and may be left out when not needed. In this example, we have left it out. - -```typescript -async function main() { - const [immutables, state] = await Promise.all([getPoolImmutables(), getPoolState()]) - - const TokenA = new Token(3, immutables.token0, 6, 'USDC', 'USD Coin') - - const TokenB = new Token(3, immutables.token1, 18, 'WETH', 'Wrapped Ether') - - const poolExample = new Pool( - TokenA, - TokenB, - immutables.fee, - state.sqrtPriceX96.toString(), - state.liquidity.toString(), - state.tick - ) - console.log(poolExample) -} - -main() -``` - -If everything is working, the script should return something like this: - -```typescript -Pool { - token0: Token { - chainId: 1, - decimals: 6, - symbol: 'USDC', - name: 'USD Coin', - isNative: false, - isToken: true, - address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' - }, - token1: Token { - chainId: 1, - decimals: 18, - symbol: 'WETH', - name: 'Wrapped Ether', - isNative: false, - isToken: true, - address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' - }, - fee: 3000, - sqrtRatioX96: JSBI(4) [ 1389262056, -1079304777, -1721588872, 19633, sign: false ], - liquidity: JSBI(3) [ 988036789, -62655684, 1, sign: false ], - tickCurrent: 197709, - tickDataProvider: NoTickDataProvider {} -} -``` - -## 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' - -const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/') - -const poolAddress = '0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8' - -const poolContract = new ethers.Contract(poolAddress, IUniswapV3PoolABI, provider) - -interface Immutables { - 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 -} - -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 immutables: Immutables = { - factory, - token0, - token1, - fee, - tickSpacing, - maxLiquidityPerTick, - } - return immutables -} - -async function getPoolState() { - const [liquidity, slot] = await Promise.all([poolContract.liquidity(), poolContract.slot0()]) - - const PoolState: State = { - liquidity, - sqrtPriceX96: slot[0], - tick: slot[1], - observationIndex: slot[2], - observationCardinality: slot[3], - observationCardinalityNext: slot[4], - feeProtocol: slot[5], - unlocked: slot[6], - } - - return PoolState -} - -async function main() { - const [immutables, state] = await Promise.all([getPoolImmutables(), getPoolState()]) - - const TokenA = new Token(3, immutables.token0, 6, 'USDC', 'USD Coin') - - const TokenB = new Token(3, immutables.token1, 18, 'WETH', 'Wrapped Ether') - - const poolExample = new Pool( - TokenA, - TokenB, - immutables.fee, - state.sqrtPriceX96.toString(), - state.liquidity.toString(), - state.tick - ) - console.log(poolExample) -} - -main() -``` diff --git a/SDK_versioned_docs/version-Maia/guides/04-fetching-prices.md b/SDK_versioned_docs/version-Maia/guides/04-fetching-prices.md deleted file mode 100644 index a322a7f..0000000 --- a/SDK_versioned_docs/version-Maia/guides/04-fetching-prices.md +++ /dev/null @@ -1,151 +0,0 @@ ---- -id: fetching-prices -title: Fetching Spot Prices ---- - -## Fetching Token Prices with the SDK - -This guide will teach you how to fetch the current market price of any token on Uniswap. First, you will learn how to call the getter methods `token0Price` and `token1Price` exposed on `Pool` instances. Then you will peek under the hood and learn how the SDK calculates these quantities from the `sqrtPriceX96` value. Going through these calculations will hopefully provide the necessary context behind fixed-point numbers, square roots, and difficult-to-understand variable names like `sqrtPriceX96`. - -### Calling the functions - -Similar to other examples, you first must set up your pool. If you’re unsure how to collect all the parameters necessary in creating a `Pool` instance see [Creating a Pool Instance](https://docs.uniswap.org/sdk/guides/creating-a-pool) or look at this typescript [example](https://github.com/Uniswap/uniswap-docs/blob/main/sdk-examples/AddAndRemoveLiquidity.tsx). The `Pool` class contains two getter methods `token0Price` and `token1Price` which will return the prices of each token respectively as a `Price`. - -After constructing the pool, you can save the token prices as constants: - -```typescript -const DAI_USDC_POOL = new Pool( - DAI, - USDC, - immutables.fee, - state.sqrtPriceX96.toString(), - state.liquidity.toString(), - state.tick -) - -const token0Price = DAI_USDC_POOL.token0Price -const token1Price = DAI_USDC_POOL.token1Price -``` - -### Understanding sqrtPrice - -What is `sqrtPriceX96`? - -In Uniswap V3, prices of tokens are stored in the [0th slot](https://docs.uniswap.org/protocol/reference/core/interfaces/pool/IUniswapV3PoolState#slot0) of the pool state. Storing the price values instead of deriving them allows pools to perform higher precision operations. In the actual implementation, prices are stored as square roots, hence the `sqrt` prefix. The price is stored as a square root because of the geometric nature of the core AMM algorithm, x\*y=k. Essentially, the [math](https://uniswap.org/whitepaper-v3.pdf) works out well when working with the square root of the price. - -In addition, you'll notice the `X96` suffix at the end of the variable name. This `X*` naming convention is used throughout the Uniswap V3 codebase to indicate values that are encoded as binary [fixed-point numbers](https://en.wikipedia.org/wiki/Fixed-point_arithmetic). Fixed-point is excellent at representing fractions while maintaining consistent fidelity and high precision in integer-only environments like the EVM, making it a perfect fit for representing prices, which of course are ultimately fractions. The number after `X` indicates the number of _fraction bits_ - 96 in this case - reserved for encoding the value after the decimal point. The number of integer bits can be trivially derived from the size of the variable and the number of fraction bits. In this case, `sqrtPriceX96` is stored as a `uint160`, meaning that there are `160 - 96 = 64` integer bits. - -:::note -`sqrtPriceX96` and `sqrtRatioX96` represent the same value, and are interchangeable. -::: - -Consider the following derivation, which formalizes the definitions above: - -```python -sqrtPriceX96 = sqrt(price) * 2 ** 96 -``` - -Thus, to get a `price` from a `sqrtPriceX96` value, you can execute the following operations: - -```python -sqrtPriceX96 = sqrt(price) * 2 ** 96 -# divide both sides by 2 ** 96 -sqrtPriceX96 / (2 ** 96) = sqrt(price) -# square both sides -(sqrtPriceX96 / (2 ** 96)) ** 2 = price -# expand the squared fraction -(sqrtPriceX96 ** 2) / ((2 ** 96) ** 2) = price -# multiply the exponents in the denominator to get the final expression -sqrtRatioX96 ** 2 / 2 ** 192 = price -``` - -You will see that the formula in the last step is how the SDK calculates the prices with the functions [`token0Price`](#token0price) and [`token1Price`](#token1price). - -### token0Price - -Let's apply the math derived above to the functions `token0Price` and `token1Price`. Note that `sqrtRatioX96` is interchangeable with `sqrtPriceX96`. - -```typescript - /** - * Returns the current mid-price of the pool in terms of token0, i.e. the ratio of token1 over token0 - */ - public get token0Price(): Price { - return ( - this._token0Price ?? - (this._token0Price = new Price( - this.token0, - this.token1, - Q192, - JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96) - )) - ) - } -``` - -`token0Price` returns a new `Price` as the ratio of token1 over token0. Note that a `Price` is constructed by: - -```typescript -constructor( - baseToken: Token, - quoteToken: Token, - denominator: BigintIsh, - numerator: BigintIsh) -``` - -Let's break down the denominator and the numerator of the returned price and prove that it matches the math derived above. Recall that the expression achieved above is - -```python -price = sqrtRatioX96 ** 2 / 2 ** 192 -``` - -#### The numerator - -It's worth noting that the numerator is misleadingly listed _below_ the denominator in the constructor for a `Price`. In any case, you will see that the numerator of the fraction is `JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96)` which nicely follows the math above: `sqrtPriceX96 ** 2`. - -#### The denominator - -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)) -``` - -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)`. - -### token1Price - -Recall that `token0Price` is the ratio of token1 over token0 and that `token1Price` is the ratio of token0 over token1. This means that the derivation for `token1Price` follows the same math except the numerator and denominator are flipped, implying the inverse. - -So instead of - -```python -price = sqrtRatioX96 ** 2 / 2 ** 192 -``` - -you have - -```python - price = 2 ** 192 / sqrtRatioX96 ** 2 -``` - -which is simply shown below in the function definition of `token1Price` : - -```typescript - /** - * Returns the current mid-price of the pool in terms of token1, i.e. the ratio of token0 over token1 - */ - public get token1Price(): Price { - return ( - this._token1Price ?? - (this._token1Price = new Price( - this.token1, - this.token0, - JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96), - Q192 - )) - ) - } -``` - -You can see that in the function definition the numerator is now `Q192` and the denominator is now `JSBI.multiply(this.sqrtRatioX96, this.sqrtRatioX96)`, matching the expression above. diff --git a/SDK_versioned_docs/version-Maia/guides/05-creating-a-trade.md b/SDK_versioned_docs/version-Maia/guides/05-creating-a-trade.md deleted file mode 100644 index b663829..0000000 --- a/SDK_versioned_docs/version-Maia/guides/05-creating-a-trade.md +++ /dev/null @@ -1,241 +0,0 @@ ---- -id: creating-a-trade -title: Creating a Trade ---- - -This guide extends the previous [Creating a Pool Instance](03-creating-a-pool.md) and [Using Ethers.js](./using-ethers) guides by using the `pool` object to quote an estimated amount out for a trade, then creates a trade object that can be used to execute a swap. - -## Creating a Quoter Contract Object - -In order to retrieve a quote, create a [Contract](https://docs.ethers.io/v5/api/contract/contract/) object using ethers.js - -The quoter is a smart contract that retrieves estimated output or input amounts for a given swap type. This example creates an object in our javascript environment that models the [quoter interface](https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/interfaces/IQuoter.sol), which can be called to return a swap quote. - -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' -``` - -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('') -``` - -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) -``` - -## Using callStatic To Return A Quote - -To get a quote for a swap, we will call the Quoter contract's `quoteExactInputSingle` function, the interface of which looks like this: - -```solidity - function quoteExactInputSingle( - address tokenIn, - address tokenOut, - uint24 fee, - uint256 amountIn, - uint160 sqrtPriceLimitX96 - ) external returns (uint256 amountOut); -``` - -In an ideal world, these quoter functions would be `view` functions, which would make them very easy to query on-chain with minimal gas costs. Instead, the V3 quoter contracts rely on state-changing calls designed to be reverted to return the desired data. This means calling the quoter will be very expensive and should not be called on-chain. - -To get around this difficulty, we can use the [callStatic](https://docs.ethers.io/v5/api/contract/contract/#contract-callStatic) method provided by `ethers.js`. `callStatic` is a useful method that submits a state-changing transaction to an Ethereum node, but asks the node to simulate the state change, rather than to execute it. Our script can then return the result of the simulated state change. - -To simulate a transaction without actually broadcasting it to the EVM, use the `callStatic` to call the `ExactInputSingle` function in the `Quoter` contract, which will tell us how much an of output token we will receive given a certain amount of input token when using a single hop swap. - -Note this function uses the `Immutables` interface defined in the earlier guides. - -```ts -async function main() { - const amountIn = 1500 - - const quotedAmountOut = await quoterContract.callStatic.quoteExactInputSingle( - immutables.token0, - immutables.token1, - immutables.fee, - amountIn.toString(), - 0 - ) -} -``` - -## Construct a Trade - -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) -``` - -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. - -```ts -const uncheckedTradeExample = await Trade.createUncheckedTrade({ - route: swapRoute, - inputAmount: CurrencyAmount.fromRawAmount(TokenA, amountIn.toString()), - outputAmount: CurrencyAmount.fromRawAmount(TokenB, quotedAmountOut.toString()), - tradeType: TradeType.EXACT_INPUT, -}) -``` - -## Print The Quote And Trade To Your Console - -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) -``` - -If everything is working, you should see something similar to this returned in your console. - -```console -The quoted amount out is 661497830963 -The unchecked trade object is Trade { - swaps: [ - { - inputAmount: [CurrencyAmount], - outputAmount: [CurrencyAmount], - route: [Route] - } - ], - tradeType: 0 -} -``` - -## 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' - -const provider = new ethers.providers.JsonRpcProvider('') - -// USDC-WETH pool address on mainnet for fee tier 0.05% -const poolAddress = '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640' - -const poolContract = new ethers.Contract(poolAddress, IUniswapV3PoolABI, provider) - -const quoterAddress = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6' - -const quoterContract = new ethers.Contract(quoterAddress, QuoterABI, provider) - -interface Immutables { - 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 -} - -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 immutables: Immutables = { - factory, - token0, - token1, - fee, - tickSpacing, - maxLiquidityPerTick, - } - 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 PoolState: State = { - liquidity, - sqrtPriceX96: slot[0], - tick: slot[1], - observationIndex: slot[2], - observationCardinality: slot[3], - observationCardinalityNext: slot[4], - feeProtocol: slot[5], - unlocked: slot[6], - } - - return PoolState -} - -async function main() { - // query the state and immutable variables of the pool - 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 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( - TokenA, - TokenB, - immutables.fee, - 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 - - // call the quoter contract to determine the amount out of a swap, given an amount in - const quotedAmountOut = await quoterContract.callStatic.quoteExactInputSingle( - immutables.token0, - immutables.token1, - 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) - - // create an unchecked trade instance - const uncheckedTradeExample = await Trade.createUncheckedTrade({ - route: swapRoute, - inputAmount: CurrencyAmount.fromRawAmount(TokenA, amountIn.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) -} - -main() -``` diff --git a/SDK_versioned_docs/version-Maia/guides/06-auto-router.md b/SDK_versioned_docs/version-Maia/guides/06-auto-router.md deleted file mode 100644 index 4f31c43..0000000 --- a/SDK_versioned_docs/version-Maia/guides/06-auto-router.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -id: auto-router -title: Integrating the Auto Router ---- - -# Integrating the Auto Router - -You can use the Auto Router to fetch optimized trade routes for swapping on Uniswap. To use the Auto Router, you will create an `AlphaRouter` instance and use the method `route` to get quotes, gas information, and calldata for an optimized swap. - -In this quick start you will: - -1. Import necessary packages -2. Initialize the `AlphaRouter` -3. Set up the parameters for the `route` method -4. Call `route` to retrieve calldata -5. Submit a route transaction - -## Importing the Package - -To integrate with the Auto Router, you will use the [smart-order-router](https://www.npmjs.com/package/@uniswap/smart-order-router) package. The smart-order-router package allows you to use the Auto Router through the `AlphaRouter` class. - -Import `AlphaRouter` from the smart-order-router package to get started. - -```typescript -import { AlphaRouter } from '@uniswap/smart-order-router' -``` - -## Initializing the AlphaRouter - -The `AlphaRouter` class contains methods for generating optimized routes. To create an instance of the AlphaRouter, configure the `chainId` and `provider` parameters. - -#### Parameters - -| Name | Requirement | Description | -| -------- | ----------- | ---------------------------------------------------------------------------------------------- | -| chainId | [required] | The id of the chain you want to route swaps on. e.g., The chainId for Ethereum mainnet is `1`. | -| provider | [required] | A JSON RPC endpoint, e.g., Infura. | - -```typescript -const router = new AlphaRouter({ chainId: 1, provider: web3Provider }) -``` - -## Calling `route` - -The `route` method returns all the swap calldata and gas information needed for submitting an optimal swap to the chain. - -Once you instantiate `AlphaRouter` call `route` with the following parameters: - -```typescript - { - amount: CurrencyAmount, - quoteCurrency: Currency, - tradeType: TradeType, - swapConfig?: SwapConfig, - partialRoutingConfig?: Partial = {} - } -``` - -#### Parameters - -| Name | Requirement | Description | -| ------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| amount | [required] | The amount specified by the user. For EXACT_INPUT swaps, this is the input token amount. For EXACT_OUTPUT swaps, this is the output token. | -| quoteCurrency | [required] | The currency of the token we are returning a quote for. For EXACT_INPUT swaps, this is the output token. For EXACT_OUTPUT, this is the input token | -| swapType | [required] | Either an exactInput swap or an exactOutput swap. | -| swapConfig | [optional] | Configure to set a recipient, slippageTolerance, deadline, and inputTokenPermit. If provided, calldata for executing the swap will also be returned. | -| routingConfig | [optional] | Optional config for tuning the performance of the routing algorithm. | - -This example gets a route for a WETH-USDC swap. - -```typescript -const WETH = new Token(1, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether') - -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 - -The object returned from calling `route` is a `SwapRoute` object with the following fields: - -```typescript -export type SwapRoute = { - 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: - -```typescript -const V3_SWAP_ROUTER_ADDRESS = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45"; -const MY_ADDRESS = /*YOUR ADDRESS HERE*/; - -const transaction = { - data: route.methodParameters.calldata, - to: V3_SWAP_ROUTER_ADDRESS, - value: BigNumber.from(route.methodParameters.value), - from: MY_ADDRESS, - gasPrice: BigNumber.from(route.gasPriceWei), -}; - -await web3Provider.sendTransaction(transaction); -``` - -## The Full Example - -This full example compiles all of the steps above and also prints the route quote and gas quotes returned from the `SwapRoute` data. - -```typescript -import { AlphaRouter } from '@uniswap/smart-order-router' -import { Token, CurrencyAmount } from '@uniswap/sdk-core' - -const V3_SWAP_ROUTER_ADDRESS = '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'; -const MY_ADDRESS = /*YOUR ADDRESS HERE*/; -const web3Provider = /*YOUR PROVIDER HERE*/ - -const router = new AlphaRouter({ chainId: 1, provider: web3Provider }); - -const WETH = new Token( - 1, - '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - 18, - 'WETH', - 'Wrapped Ether' -); - -const USDC = new Token( - ChainId.MAINNET, - '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', - 6, - 'USDC', - 'USD//C' -); - -const typedValueParsed = '100000000000000000000' -const wethAmount = CurrencyAmount.fromRawAmount(currency, JSBI.BigInt(typedValueParsed)); - -const route = await router.route( - wethAmount, - USDC, - TradeType.EXACT_INPUT, - { - recipient: myAddress, - slippageTolerance: new Percent(5, 100), - deadline: Math.floor(Date.now()/1000 +1800) - } -); - -console.log(`Quote Exact In: ${route.quote.toFixed(2)}`); -console.log(`Gas Adjusted Quote In: ${route.quoteGasAdjusted.toFixed(2)}`); -console.log(`Gas Used USD: ${route.estimatedGasUsedUSD.toFixed(6)}`); - -const transaction = { - data: route.methodParameters.calldata, - to: V3_SWAP_ROUTER_ADDRESS, - value: BigNumber.from(route.methodParameters.value), - from: MY_ADDRESS, - gasPrice: BigNumber.from(route.gasPriceWei), -}; - -await web3Provider.sendTransaction(transaction); -``` diff --git a/SDK_versioned_docs/version-Maia/guides/_category_.json b/SDK_versioned_docs/version-Maia/guides/_category_.json deleted file mode 100644 index c694eb5..0000000 --- a/SDK_versioned_docs/version-Maia/guides/_category_.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "Guides", - "position": 2, - "collapsed": false -} diff --git a/SDK_versioned_docs/version-Maia/guides/liquidity/04-minting-positions.md b/SDK_versioned_docs/version-Maia/guides/liquidity/04-minting-positions.md deleted file mode 100644 index 5354dea..0000000 --- a/SDK_versioned_docs/version-Maia/guides/liquidity/04-minting-positions.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -id: minting -title: Minting a new Position ---- - -## Overview - -In this guide, you will learn how to mint a new liquidity position, add liquidity, and then remove liquidity. You will learn how to invoke each function with the required parameters necessary in returning the calldata. Because any liquidity related action relies on setting up pool and position instances, you will also need to know [How to Create A Pool](https://docs.uniswap.org/sdk/guides/creating-a-pool) and how to set up a position instance. - -In summary, the following is what you will learn in this guide: - -1. Set up the pool instance. This follows the same structure as the previous guide. Refer to [Creating a Pool Instance](https://docs.uniswap.org/sdk/guides/creating-a-pool) for more detail. -2. Create a position. -3. Construct the calldata for minting a position. -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 -) -``` - -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 - -A position represents the price range for a specific pool that LPs choose to provide in. After constructing a pool, set up the position instance: - -```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, -}) -``` - -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. - -## 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`. - -`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): - -```typescript -export interface CommonAddLiquidityOptions { - /** - * How much the pool price is allowed to move. - */ - slippageTolerance: Percent - - /** - * When the transaction expires, in epoch seconds. - */ - deadline: BigintIsh - - /** - * Whether to spend ether. If true, one of the pool tokens must be WETH, by default false - */ - useNative?: NativeCurrency - - /** - * The optional permit parameters for spending token0 - */ - token0Permit?: PermitOptions - - /** - * The optional permit parameters for spending token1 - */ - token1Permit?: PermitOptions -} -``` - -and here is the reference for [`MintSpecificOptions`](https://docs.uniswap.org/sdk/reference/interfaces/MintSpecificOptions): - -```typescript -export interface MintSpecificOptions { - /** - * The account that should receive the minted NFT. - */ - recipient: string - - /** - * Creates pool if not initialized before mint. - */ - createPool?: boolean -} -``` - -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 { 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. diff --git a/SDK_versioned_docs/version-Maia/guides/liquidity/05-adding-liquidity.md b/SDK_versioned_docs/version-Maia/guides/liquidity/05-adding-liquidity.md deleted file mode 100644 index 953e39d..0000000 --- a/SDK_versioned_docs/version-Maia/guides/liquidity/05-adding-liquidity.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -id: adding -title: Adding Liquidity ---- - -## Adding Liquidity to the Position - -Constructing the calldata for adding liquidity uses the same function call to `addCallParameters`, which takes in a `Position` and an options field of type `AddLiquidityOptions`. Since the goal of this example is to add liquidity to an already existing position, construct `IncreaseOptions` instead of `MintOptions`. `IncreaseOptions` types are defined by the interfaces [`CommonAddLiquidityOptions`](https://docs.uniswap.org/sdk/reference/interfaces/CommonAddLiquidityOptions) and [`IncreaseSpecificOptions`](https://docs.uniswap.org/sdk/reference/interfaces/IncreaseSpecificOptions). - -```typescript -export interface CommonAddLiquidityOptions { - /** - * How much the pool price is allowed to move. - */ - slippageTolerance: Percent - - /** - * When the transaction expires, in epoch seconds. - */ - deadline: BigintIsh - - /** - * Whether to spend ether. If true, one of the pool tokens must be WETH, by default false - */ - useNative?: NativeCurrency - - /** - * The optional permit parameters for spending token0 - */ - token0Permit?: PermitOptions - - /** - * The optional permit parameters for spending token1 - */ - token1Permit?: PermitOptions -} - -export interface IncreaseSpecificOptions { - /** - * Indicates the ID of the position to increase liquidity for. - */ - tokenId: BigintIsh -} -``` - -To construct the `IncreaseOptions` struct, specify `slippageTolerance`, `deadline`, and `tokenId`. The `tokenId` is the unique identifier of the position (or more specifically, the ERC721 that represents a position). In this example, the `tokenId` is naively set to 1, but in production, each `tokenId` is unique and can be fetched on chain. - -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, -}) -``` diff --git a/SDK_versioned_docs/version-Maia/guides/liquidity/06-removing-liquidity.md b/SDK_versioned_docs/version-Maia/guides/liquidity/06-removing-liquidity.md deleted file mode 100644 index 9836bec..0000000 --- a/SDK_versioned_docs/version-Maia/guides/liquidity/06-removing-liquidity.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -id: removing -title: Removing Liquidity ---- - -## Removing Liquidity from a Position - -Use the function `removeCallParameters` with the `position` instantiated earlier and a `RemoveLiquidityOptions` interface. The reference for [`RemoveLiquidityOptions`](https://docs.uniswap.org/sdk/reference/interfaces/RemoveLiquidityOptions) is: - -```typescript -/** - * Options for producing the calldata to exit a position. - */ -export interface RemoveLiquidityOptions { - /** - * The ID of the token to exit - */ - tokenId: BigintIsh - - /** - * The percentage of position liquidity to exit. - */ - liquidityPercentage: Percent - - /** - * How much the pool price is allowed to move. - */ - slippageTolerance: Percent - - /** - * When the transaction expires, in epoch seconds. - */ - deadline: BigintIsh - - /** - * Whether the NFT should be burned if the entire position is being exited, by default false. - */ - burnToken?: boolean - - /** - * The optional permit of the token ID being exited, in case the exit transaction is being sent by an account that does not own the NFT - */ - permit?: NFTPermitOptions - - /** - * Parameters to be passed on to collect - */ - collectOptions: Omit -} -``` - -To remove liquidity from a position, set the parameters for `tokenId`, `liquidityPercentage`, `slippageTolerance`, `deadline`, and `collectOptions`. - -The reference for `CollectOptions` is - -```typescript -export interface CollectOptions { - /** - * Indicates the ID of the position to collect for. - */ - tokenId: BigintIsh - - /** - * Expected value of tokensOwed0, including as-of-yet-unaccounted-for fees/liquidity value to be burned - */ - expectedCurrencyOwed0: CurrencyAmount - - /** - * Expected value of tokensOwed1, including as-of-yet-unaccounted-for fees/liquidity value to be burned - */ - expectedCurrencyOwed1: CurrencyAmount - - /** - * The account that should receive the tokens. - */ - recipient: string -} -``` - -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). - -```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, - }, -}) -``` - -## 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. diff --git a/SDK_versioned_docs/version-Maia/guides/liquidity/07-swap-and-add.md b/SDK_versioned_docs/version-Maia/guides/liquidity/07-swap-and-add.md deleted file mode 100644 index 84d2ed7..0000000 --- a/SDK_versioned_docs/version-Maia/guides/liquidity/07-swap-and-add.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -id: swap-and-add -title: Swap and Add Liquidity Atomically ---- - -# Swap and Add Liquidity Atomically - -When adding liquidity to a Uniswap v3 pool, you must provide two assets in a particular ratio. In many cases, your contract or the user's wallet hold a different ratio of those two assets. In order to deposit 100% of your assets, you must first **swap** your assets to the optimal ratio and then **add liquidity**. However, the swap may shift the balance of the pool and thus change the optimal ratio! - -This guide will teach you how to execute this swap-and-add operation in a single atomic transaction. First, you will use the Auto Router to fetch calldata to swap to the optimal ratio and add liquidity. Then you will submit the transaction to the on-chain router contract `SwapRouter02.sol`. - -## Initializing the Alpha Router - -First, [import](https://docs.uniswap.org/sdk/guides/auto-router/quick-start#importing-the-package) and [initialize](https://docs.uniswap.org/sdk/guides/auto-router/quick-start#initializing-the-alpharouter) an instance of the Alpha Router. If you are using a different network, be sure to specify the right `chainId` parameter. - -```bash -npm install @uniswap/smart-order-router -``` - -```typescript -import { AlphaRouter } from '@uniswap/smart-order-router' -const router = new AlphaRouter({ chainId: 1, provider: web3Provider }) -``` - -## Fetching calldata from `routeToRatio` - -Now call the `routeToRatio` method on the Auto Router. This function will return all the calldata you need to submit an atomic swap-and-add transaction. - -#### Parameters - -| Name | Requirement | Description | -| ------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `token0Balance` | required | The initial balance of `token0` that you wish to swap-and-add, where `token0` is the `token0` in your target liquidity pool. | -| `token1Balance` | required | The initial balance of `token1` that you wish to swap-and-add, where `token1` is the `token1` in your target liquidity pool. | -| `position` | required | A [Position](https://docs.uniswap.org/sdk/guides/liquidity/minting#creating-a-position-instance) object that contains the details of the position for which to add liquidity. The position liquidity can be set to `1`, since liquidity is still unknown and will be set inside the call to `routeToRatio`. | -| `swapAndAddConfig` | required | A [swapAndAddConfig](https://github.com/Uniswap/smart-order-router/blob/b26ffdc978ab1076c817392ab20ed2df325daf7a/src/routers/router.ts#L123) sets configurations for the `routeToRatio` algorithm. `ratioErrorTolerance` determines the margin of error the resulting ratio can have from the optimal ratio. `maxIterations` determines the maximum times the algorithm will iterate to find a ratio within error tolerance. If `maxIterations` is exceeded, an error is returned. | -| `swapAndAddOptions` | optional | If [swapAndAddOptions](https://github.com/Uniswap/smart-order-router/blob/b26ffdc978ab1076c817392ab20ed2df325daf7a/src/routers/router.ts#L130) is included, `routeToRatio` will return the calldata for executing the atomic swap-and-add. These options contain `swapConfig` and `addLiquidityOptions`. `swapConfig` configures to set a recipient of leftover dust from swap, slippageTolerance, deadline, inputTokenPermit and outputTokenPermit. `addLiquidityOptions` must contain a `tokenId` to add to an existing position, or `recipient` to mint a new one. It also includes a slippage tolerance and deadline for adding liquidity. | -| `routingConfig` | optional | Optional advanced config for tuning the performance of the routing algorithm. View the [AlphaRouterConfig](https://github.com/Uniswap/smart-order-router/blob/b26ffdc978ab1076c817392ab20ed2df325daf7a/src/routers/alpha-router/alpha-router.ts#L222) object for these optional configuration parameters. | - -`token0Balance` [required] - -- The initial balance of token0 that you wish to swap-and-add, where token0 is the token0 in your target liquidity pool. - -`token1Balance` [required] - -- The initial balance of token1 that you wish to swap-and-add, where token1 is the token1 in your target liquidity pool. - -`position` [required] - -- A [position object](https://docs.uniswap.org/sdk/guides/liquidity/minting#creating-a-position-instance) that contains the details of the position for which to add liquidity. The position liquidity can be set to 1, since liquidity is still unknown and will be set inside the call to `routeToRatio`. - -`swapAndAddConfig` [required] - -- A [swapAndAddConfig](https://github.com/Uniswap/smart-order-router/blob/b26ffdc978ab1076c817392ab20ed2df325daf7a/src/routers/router.ts#L123) sets configurations for the routeToRatio algorithm. `ratioErrorTolerance` determines the margin of error the resulting ratio can have from the optimal ratio. `maxIterations` determines the maximum times the algorithm will iterate to find a ratio within error tolerance. If max iterations is exceeded, an error is returned. - -`swapAndAddOptions` [optional] - -- If [swapAndAddOptions](https://github.com/Uniswap/smart-order-router/blob/b26ffdc978ab1076c817392ab20ed2df325daf7a/src/routers/router.ts#L130) is included, routeToRatio will return the calldata for executing the atomic swap-and-add. These options contain `swapConfig` and `addLiquidityOptions`. `swapConfig` configures to set a recipient of leftover dust from swap, slippageTolerance, deadline, inputTokenPermit and outputTokenPermit. `addLiquidityOptions` must contain a `tokenId` to add to an existing position, or `recipient` to mint a new one. It also includes a slippage tolerance and deadline for adding liquidity. - -`routingConfig` [optional] - -- Optional config for tuning the performance of the routing algorithm. View the [AlphaRouterConfig object](https://github.com/Uniswap/smart-order-router/blob/b26ffdc978ab1076c817392ab20ed2df325daf7a/src/routers/alpha-router/alpha-router.ts#L222) for these optional configuration parameters. - -Here is a complete example that initializes these parameters and then calls `routeToRatio` - -```typescript -const USDC = new Token( - ChainId.MAINNET, - '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', - 6, - 'USDC', - 'USD//C' -); - -const WETH = new Token( - 1, - '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - 18, - 'WETH', - 'Wrapped Ether' -); - -const token0Balance = CurrencyAmount.fromRawAmount(USDC, '5000000000') -const token1Balance = CurrencyAmount.fromRawAmount(WETH, '0') -const pool = new Pool( - USDC, - WETH, - 3000, - '1283723400872544054280619964098219', - '8390320113764730804' , - '193868' -); - - -const routeToRatioResponse = await router.routeToRatio( - token0Balance, - token1Balance, - position: new Position({ - pool, - tickLower: -60, - tickUpper: 60, - liquidity: 1, - }), - swapAndAddConfig: { - ratioErrorTolerance: new Fraction(1, 100), - maxIterations: 6, - }, - swapAndAddOptions: { - swapConfig: { - recipient: , - slippage: new Percent(5, 100), - deadline: 100 - }, - addLiquidityOptions: { - tokenId: 10, - } - } -); -``` - -## Submitting a Transaction - -The `routeToRatio` function returns a `SwapToRatioResponse` object. If a route was found successfully, this object will have two fields: - -- `status` will be set to `success` -- `result` will contain the `SwapToRatioRoute` object - -The `SwapToRatioRoute` object will have the properties listed out in the type below: - -```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 -} -``` - -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: - -```typescript -import { SwapToRatioStatus } from "@uniswap/smart-order-router"; - -const V3_SWAP_ROUTER_ADDRESS = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45"; -const MY_ADDRESS = "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"; - -if (routeToRatioResponse.status == SwapToRatioStatus.success) { - const route = routeToRatioResponse.result - const transaction = { - data: route.methodParameters.calldata, - to: V3_SWAP_ROUTER_ADDRESS, - value: BigNumber.from(route.methodParameters.value), - from: MY_ADDRESS, - gasPrice: BigNumber.from(route.gasPriceWei), - }; -) - -await web3Provider.sendTransaction(transaction); -``` diff --git a/SDK_versioned_docs/version-Maia/guides/liquidity/_category_.json b/SDK_versioned_docs/version-Maia/guides/liquidity/_category_.json deleted file mode 100644 index f9a4a1c..0000000 --- a/SDK_versioned_docs/version-Maia/guides/liquidity/_category_.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "Interacting with Pool Liquidity", - "position": 6, - "collapsed": true -} diff --git a/SDK_versioned_docs/version-Maia/introduction.md b/SDK_versioned_docs/version-Maia/introduction.md deleted file mode 100644 index 6822b78..0000000 --- a/SDK_versioned_docs/version-Maia/introduction.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -id: introduction -sidebar_position: 1 ---- - -# The Maia Ecosystem SDK - -Welcome to the Maia Ecosystem SDK. To begin, we recommend looking at the [**Guides**](./guides/01-quick-start.md), for deeper reference see the [**SDK Github**](https://github.com/Maia-DAO/maia-ecosystem-sdk) repo. - -# Alpha software - -The latest version of the SDK is used in production in Maia Ecosystem Protocols, -but it is considered Alpha software and may contain bugs or change significantly between patch versions. -If you have questions about how to use the SDK, please reach out in the `#dev-chat` channel of the Discord. -Pull requests welcome! - -# Maia Ecosystem SDK - -- [**V3 SDK Github Repo**](https://github.com/Maia-DAO/maia-ecosystem-sdk) -- [**SDK Core Github Repo**](https://github.com/Maia-DAO/maia-ecosystem-core) -- [**SDK NPM Package**](https://www.npmjs.com/Maia-dAO/@maia/ecosystem-sdk) - -[![Unit Tests](https://github.com/Maia-DAO/maia-ecosystem-sdk/workflows/Unit%20Tests/badge.svg)](https://github.com/Maia-DAO/maia-ecosystem-sdk/actions?query=workflow%3A%22Unit+Tests%22) -[![Lint](https://github.com/Maia-DAO/maia-ecosystem-sdk/workflows/Lint/badge.svg)](https://github.com/Maia-DAO/maia-ecosystem-sdk/actions?query=workflow%3ALint) -[![npm version](https://img.shields.io/npm/v/@maia/ecosystem-sdk/latest.svg)](https://www.npmjs.com/package/@maia/ecosystem-sdk/v/latest) -[![npm bundle size (scoped version)](https://img.shields.io/bundlephobia/minzip/@maia/ecosystem-sdk/latest.svg)](https://bundlephobia.com/result?p=@maia/ecosystem-sdk@latest) diff --git a/SDK_versioned_docs/version-Maia/subgraph/_category_.json b/SDK_versioned_docs/version-Maia/subgraph/_category_.json deleted file mode 100644 index 6830c30..0000000 --- a/SDK_versioned_docs/version-Maia/subgraph/_category_.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "The Uniswap Subgraph", - "position": 4, - "collapsed": true -} diff --git a/SDK_versioned_docs/version-Maia/subgraph/subgraph-example.md b/SDK_versioned_docs/version-Maia/subgraph/subgraph-example.md deleted file mode 100644 index 9d12aa2..0000000 --- a/SDK_versioned_docs/version-Maia/subgraph/subgraph-example.md +++ /dev/null @@ -1,311 +0,0 @@ ---- -id: subgraph-examples -title: Subgraph Query Examples -sidebar_position: 3 ---- - -:::caution -This page needs updates. -::: - -# Subgraph Query Examples - -This doc will teach you how to query Uniswap V3 analytics by writing GraphQL queries on the subgraph. You can fetch data points like : - -- [collected fees for a position](#general-position-data) -- [current liquidity](#pool-data) of a pool -- [volume on a certain day](#historical-global-data) - -and much more. Below are some example queries. To run a query copy and paste it into the [v3 explorer](https://thegraph.com/hosted-service/subgraph/uniswap/uniswap-v3) to get fresh data. - -## Global Data - -Global data refers to data points about the Uniswap v3 protocol as a whole. Some examples of global data points are total value locked in the protocol, total pools deployed, or total transaction counts. Thus, to query global data you must pass in the Uniswap V3 Factory address `0x1F98431c8aD98523631AE4a59f267346ea31F984` and select the desired fields. Reference the full [factory schema](https://github.com/Uniswap/v3-subgraph/blob/main/schema.graphql#L1) to see all possible fields. - -### Current Global Data - -An example querying total pool count, transaction count, and total volume in USD and ETH: - -``` -{ - factory(id: "0x1F98431c8aD98523631AE4a59f267346ea31F984" ) { - poolCount - txCount - totalVolumeUSD - totalVolumeETH - } -} -``` - -### Historical Global Data - -You can also query historical data by specifying a block number. - -``` -{ - factory(id: "0x1F98431c8aD98523631AE4a59f267346ea31F984", block: {number: 13380584}){ - poolCount - txCount - totalVolumeUSD - totalVolumeETH - } -} -``` - -## Pool Data - -To get data about a certain pool, pass in the pool address. Reference the full [pool schema](https://github.com/Uniswap/v3-subgraph/blob/main/schema.graphql#L75) and adjust the query fields to retrieve the data points you want. - -### General Pool Query - -The query below returns the feeTier, spot price, and liquidity for the ETH-USDC pool. - -``` -{ - pool(id: "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8") { - tick - token0 { - symbol - id - decimals - } - token1 { - symbol - id - decimals - } - feeTier - sqrtPrice - liquidity - } -} -``` - -### All Possible Pools - -The maxiumum items you can query at once is 1000. Thus to get all possible pools, you can interate using the skip variable. To get pools beyond the first 1000 you can also set the skip as shown below. - -### Skipping First 1000 Pools - -This query sets the skip value and returns the first 10 responses after the first 1000. - -``` -{ - pools(first:10, skip:1000){ - id - token0 { - id - symbol - } - token1 { - id - symbol - } - } -} -``` - -### Creating a Skip Variable - -This next query sets a skip variable. In your language and environment of choice you can then iterate through a loop, query to get 1000 pools each time, and continually adjust skip by 1000 until all pool responses are returned. - -Check out [this example](https://github.com/Uniswap/v3-info/blob/770a05dc1a191cf229432ebc43c1f2ceb3666e3b/src/data/pools/chartData.ts#L14) from our interface for poolDayData that does something similar. - -Note: This query will not work in the graph explorer and more resembles the structure of a query you'd pass to some graphql middleware like Apollo. - -``` -query pools( $skip: Int!) { - pools( - first: 1000 - skip: $skip - orderDirection: asc - ) { - id - sqrtPrice - token0 { - id - } - token1{ - id - } - } - } - -``` - -### Most Liquid Pools - -Retrieve the top 1000 most liquid pools. You can use this similar set up to orderBy other variables like number of swaps or volume. - -``` -{ - pools(first: 1000, orderBy: liquidity, orderDirection: desc) { - id - } -} -``` - -### Pool Daily Aggregated - -This query returns daily aggregated data for the first 10 days since the given timestamp for the UNI-ETH pool. - -``` -{ - poolDayDatas(first: 10, orderBy: date, where: { - pool: "0x1d42064fc4beb5f8aaf85f4617ae8b3b5b8bd801", - date_gt: 1633642435 - } ) { - date - liquidity - sqrtPrice - token0Price - token1Price - volumeToken0 - volumeToken1 - } -} -``` - -## Swap Data - -### General Swap Data - -To query data about a particular swap, input the transaction hash + "#" + the index in the swaps the transaction array.R -This is the reference for the full [swap schema](https://github.com/Uniswap/v3-subgraph/blob/main/schema.graphql#L353). - -This query fetches data about the sender, receiver, amounts, transaction data, and timestamp for a particular swap. - -``` -{ - swap(id: "0x000007e1111cbd97f74cfc6eea2879a5b02020f26960ac06f4af0f9395372b64#66785") { - sender - recipient - amount0 - amount1 - transaction { - id - blockNumber - gasUsed - gasPrice - } - timestamp - token0 { - id - symbol - } - token1 { - id - symbol - } - } - } -``` - -### Recent Swaps Within a Pool - -You can set the `where` field to filter swap data by pool address. This example fetches data about multiple swaps for the USDC-USDT pool, ordered by timestamp. - -``` -{ -swaps(orderBy: timestamp, orderDirection: desc, where: - { pool: "0x7858e59e0c01ea06df3af3d20ac7b0003275d4bf" } -) { - pool { - token0 { - id - symbol - } - token1 { - id - symbol - } - } - sender - recipient - amount0 - amount1 - } -} -``` - -## Token Data - -Input the the token contract address to fetch token data. Any token that exists in at least one Uniswap V3 pool can be queried. The output will aggregate data across all v3 pools that include the token. - -### General Token Data - -This queries the decimals, symbol, name, pool count, and volume in USD for the UNI token. Reference the full [token schema](https://github.com/Uniswap/v3-subgraph/blob/main/schema.graphql#L38) for all possible fields you can query. - -``` -{ - token(id:"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984") { - symbol - name - decimals - volumeUSD - poolCount - } -} -``` - -### Token Daily Aggregated - -You can fetch aggregate data about a specific token over a 24-hour period. This query gets 10-days of the 24-hour volume data for the UNI token ordered from oldest to newest. - -``` -{ - tokenDayDatas(first: 10, where: {token: "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"}, orderBy: date, orderDirection: asc) { - date - token { - id - symbol - } - volumeUSD - } -} -``` - -### All Tokens - -Similar to retrieving all pools, you can fetch all tokens by using skip. -Note: This query will not work in the graph sandbox and more resembles the structure of a query you'd pass to some graphql middleware like Apollo. - -``` -query tokens($skip: Int!) { - tokens(first: 1000, skip: $skip) { - id - symbol - name - } -} -``` - -## Position Data - -### General Position Data - -To get data about a specific position, input the NFT tokenId. This queries the collected fees for token0 and token1 and current liquidity for the position with tokedId 3. Reference the full [position schema](https://github.com/Uniswap/v3-subgraph/blob/main/schema.graphql#L192) to see all fields. - -``` -{ - position(id:3) { - id - collectedFeesToken0 - collectedFeesToken1 - liquidity - token0 { - id - symbol - } - token1 - { - id - symbol - } - } -} -``` - -## Contribute - -There are many more queries you can do with the Uniswap v3 subgraph including data related to ticks, mints, positions, and burns. Once again you can reference the full schema [here](https://github.com/Uniswap/v3-subgraph/blob/main/schema.graphql). If you'd like to suggest more example queries to showcase, feel free to drop some suggestions in [discord](https://discord.gg/UZvfWwwvwa) under #dev-chat or [contribute](https://github.com/Uniswap/docs/blob/main/README.md) your own queries by submitting a pull request to the docs repo. diff --git a/SDK_versioned_docs/version-Maia/subgraph/subgraph-introduction.md b/SDK_versioned_docs/version-Maia/subgraph/subgraph-introduction.md deleted file mode 100644 index 920efa6..0000000 --- a/SDK_versioned_docs/version-Maia/subgraph/subgraph-introduction.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -id: subgraph-data -sidebar_position: 2 -title: Subgraph Data Introduction ---- - -# Uniswap Subgraph Introduction - -Uniswap uses multiple [subgraphs](https://thegraph.com/docs/about/introduction#what-the-graph-is) for indexing and organizing data from the Uniswap smart contracts. -These subgraphs are hosted on The Graph hosted service and can be used to query Uniswap data. - -## Versions and Production Endpoints - -Each version of Uniswap has its own dedicated subgraph, and governance contracts have a dedicated subgraph as well. - -Each subgraph has a dedicated endpoint for querying data, as well as a page on [The Graph explorer](https://thegraph.com/explorer/) the exposes the schema and available fields to query. - -##### V3 - -- Explorer Page: https://thegraph.com/explorer/subgraph/uniswap/uniswap-v3 -- Graphql Endpoint: https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3 -- Code: https://github.com/Uniswap/uniswap-v3-subgraph - -##### Governance - -- Explorer Page: https://thegraph.com/explorer/subgraph/ianlapham/governance-tracking -- Graphql Endpoint: https://api.thegraph.com/subgraphs/name/ianlapham/governance-tracking -- Code: https://github.com/ianlapham/uniswap-governance-subgraph - -##### V2 - -- Explorer Page: https://thegraph.com/explorer/subgraph/ianlapham/uniswapv2 -- Graphql Endpoint: https://api.thegraph.com/subgraphs/name/ianlapham/uniswapv2 -- Code: https://github.com/Uniswap/uniswap-v2-subgraph - -##### V1 - -- Explorer Page: https://thegraph.com/explorer/subgraph/ianlapham/uniswap -- Graphql Endpoint: https://api.thegraph.com/subgraphs/name/ianlapham/uniswap -- Code: https://github.com/graphprotocol/uniswap-subgraph diff --git a/SDK_versioned_docs/version-Maia/widgets/_category_.json b/SDK_versioned_docs/version-Maia/widgets/_category_.json deleted file mode 100644 index 539e131..0000000 --- a/SDK_versioned_docs/version-Maia/widgets/_category_.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "Swap Widget", - "position": 3, - "collapsed": true -} diff --git a/SDK_versioned_docs/version-Maia/widgets/swap-widget-api-v1.md b/SDK_versioned_docs/version-Maia/widgets/swap-widget-api-v1.md deleted file mode 100644 index 85dd535..0000000 --- a/SDK_versioned_docs/version-Maia/widgets/swap-widget-api-v1.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -id: swap-widget-api-v1 -slug: swap-widget/api/v1 -title: Swap Widget API V1 Reference -sidebar_label: (Deprecated) V1 API Reference -sidebar_position: 4 ---- - -# Swap Widget API V1 Reference (Deprecated) - -
- -## 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](/sdk/widgets/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`. | -| `defaultInputAmount` | `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 `defaultOutputAmount`, so you may set only one of `defaultInputAmount` and `defaultOutputAmount`. | -| `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`. | -| `defaultOutputAmount` | `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 `defaultInputAmount`, so you may set only one of `defaultInputAmount` and `defaultOutputAmount`. | -| `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/widgets/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](/sdk/widgets/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](/sdk/widgets/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](/sdk/widgets/swap-widget#customizing-width). | - -## Subscribing to Events - -During the lifecycle of the swap widget, most of the events you will need are available on the web3 provider. For example, the below snippet shows how to listen for events when the wallet account changes or a new wallet connects. You can see more event examples in the [MetaMask](https://docs.metamask.io/guide/ethereum-provider.html) docs. - -```js -// Subscribe to messages -interface ProviderMessage { - type: string; - data: unknown; -} - -ethereum.on( - 'message', - handler: (message: ProviderMessage) => void -); -``` - -
- -:::note Questions? -Join the [Discord channel](https://discord.com/channels/597638925346930701/941447445844463676) to ask questions and get support from the Uniswap community. -::: diff --git a/SDK_versioned_docs/version-Maia/widgets/swap-widget-api.md b/SDK_versioned_docs/version-Maia/widgets/swap-widget-api.md deleted file mode 100644 index a3085e8..0000000 --- a/SDK_versioned_docs/version-Maia/widgets/swap-widget-api.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -id: swap-widget-api -slug: swap-widget/api -title: Swap Widget API V2 Reference -sidebar_label: API Reference -sidebar_position: 3 ---- - -# Swap Widget API V2 Reference - -
- -## Recommended Parameters {#recommended-parameters} - -| Prop Name | Prop Type | Default Value | Description | -| --------------- | -------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `jsonRpcUrlMap` | `{ [chainId: number]: string[] }` | `JSON_RPC_FALLBACK_ENDPOINTS` | Mapping of your JSON-RPC endpoint URLs indexed by chainId, used to provide trade quotes prior to the user connecting a wallet. If none is provided for a chain, the widget will fallback to public JSON-RPC endpoints, which are unreliable and rate-limited. See [JSON-RPC Endpoints](../swap-widget#json-rpc-endpoint). | -| `provider` | `JsonRpcProvider` or `Eip1193Provider` | `undefined` | An [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider. See [Web3 provider](../swap-widget#web3-provider). | - -## 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. | -| `defaultChainId` | `number` | `1` | You may specify which chainId you want to prompt a user to connect their wallet to. [See a list of all chains supported on widget.](https://github.com/Uniswap/widgets/blob/main/src/constants/chains.ts#L4) | -| `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`. | -| `defaultInputAmount` | `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`. | -| `defaultOutputAmount` | `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`. | -| `hideConnectionUI` | `boolean` | `false` | Hide the widget's built-in wallet connection UI, including the connected account chip & 'Connect wallet to swap' button. | -| `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/widgets/blob/main/src/constants/locales.ts). | -| `onConnectWalletClick` | `() => void` or `() => Promise` | `undefined` | If passed, allows you to add custom behavior when the user clicks on the 'Connect your wallet to swap' button. To manage displaying the widget's built-in wallet connection modal, return a resolved promise with `resolve(true/false)`. | -| `onError` | `ErrorHandler` | `undefined` | An error handler which receives any Javascript errors that occur in the widget. This can be used for collecting error metrics. | -| `onReviewSwapClick` | `() => void` or `() => Promise` | `undefined` | If passed, allows you to add custom behavior when the user clicks on the 'review swap' button. To manage progression to the review screen (i.e. to add a pre-swap warning speedbump), return a resolved promise with `resolve(true/false)`. | -| `onTokenSelectorClick` | `(f: Field) => void \| (f: Field) => Promise` | `undefined` | A click handler fired with the selected `Field` (`'INPUT'\|'OUTPUT'`) when the user clicks on a token selector dropdown. To manage progression to the native token selector view (i.e. to utilize your own external token selector UI), return a resolved promise with resolve(true/false). | -| `onTxFail` | `(error: Error, data: any) => void` | `undefined` | An error handler which receives error data for on-chain transaction failures. Does not include when user cancels a transaction or if a transaction isn't able to be submitted. | -| `onTxSubmit` | `(txHash: string, data: any) => void` | `undefined` | A handler that receives the transaction hash and related data when a user submits a transaction. | -| `onTxSuccess` | `(txHash: string, data: any) => void` | `undefined` | A handler that receives the transaction hash and related data when a transaction succeeds on-chain. | -| `routerUrl` | `string` | `undefined` | Optionally provide a base URL to your own hosted instance of the Uniswap Router API. If none is provided, the optimal trade route is computed by running the @uniswap/smart-order-router package locally in the browser; this can take a few seconds to load & is slower. You also may be able to find more optimal routes using the Router API! See more about [deploying the Router API](https://github.com/Uniswap/routing-api#deploying-the-api). | -| `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 300px. See [Customizing the Width](../swap-widget#customizing-width). | - -## Subscribing to Events - -During the lifecycle of the swap widget, most of the events you will need are available on the web3 provider. For example, the below snippet shows how to listen for events when the wallet account changes or a new wallet connects. You can see more event examples in the [MetaMask](https://docs.metamask.io/guide/ethereum-provider.html) docs. - -```js -// Subscribe to messages -interface ProviderMessage { - type: string; - data: unknown; -} - -ethereum.on( - 'message', - handler: (message: ProviderMessage) => void -); -``` - -
- -:::note Questions? -Join the [Discord channel](https://discord.com/channels/597638925346930701/941447445844463676) to ask questions and get support from the Uniswap community. -::: diff --git a/SDK_versioned_docs/version-Maia/widgets/swap-widget-examples.mdx b/SDK_versioned_docs/version-Maia/widgets/swap-widget-examples.mdx deleted file mode 100644 index 8378118..0000000 --- a/SDK_versioned_docs/version-Maia/widgets/swap-widget-examples.mdx +++ /dev/null @@ -1,210 +0,0 @@ ---- -id: swap-widget-examples -slug: swap-widget/examples -title: Swap Widget Example Themes -sidebar_label: Example Themes -sidebar_position: 2 ---- - -import useBaseUrl from '@docusaurus/useBaseUrl'; - -# Swap Widget Example Themes - -The [Getting Started guide](../swap-widget) showed how to embed the swap widget and let your users trade tokens on the Uniswap Protocol without leaving your dApp. - -Below you’ll find a few examples showing how you can [customize the widget theme](../swap-widget#customizing-theme) to match the look and feel of your dApp. All of them can be integrated using the following code snippet where you can set your `theme`: - -```tsx -import { Theme, SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/dist/fonts.css' - -const theme: Theme = { - // Check out the theme examples below -} - -function App() { -
- -
-} -``` - -## Theme Examples - -Copy any of the `theme` object below to start making your own custom appearance for the swap widget. You might also need the right CSS import for any custom fonts. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Swap Widget Theme Example 1 - - -```tsx -const theme: Theme = { - primary: '#1F4A05', - secondary: '#5F7D52', - interactive: '#CBD6BA', - container: '#D9ECD9', - module: '#E9F7DF', - accent: '#8E8B78', - outline: '#CADDC2', - dialog: '#FFF', - fontFamily: 'Nunito', - borderRadius: 0.8, -} -``` - -
- Swap Widget Theme Example 2 - - -```tsx -const theme: Theme = { - primary: '#000', - secondary: '#666', - interactive: '#0089EC', - container: '#FFF', - module: '#E7E7E7', - accent: '#3D3B31', - outline: '#343D3A', - dialog: '#FFF', - fontFamily: 'Verdana', - borderRadius: 0.8, -} -``` - -
- Swap Widget Theme Example 3 - - -```tsx -const theme: Theme = { - primary: '#FFF', - secondary: '#A9A9A9', - interactive: '#000', - container: '#4E4E5A', - module: '#222633', - accent: '#71FF98', - outline: '#CC1', - dialog: '#000', - fontFamily: 'Josefin Sans', - borderRadius: 0.5, -} -``` - -
- Swap Widget Theme Example 4 - - -```tsx -const theme: Theme = { - primary: '#000', - secondary: '#A9A9A9', - interactive: '#1E4D3C', - container: '#98D747', - module: '#FFF', - accent: '#FD5B00', - outline: '#1E4D3C', - dialog: '#000', - fontFamily: 'Inter', - borderRadius: 0.2, -} -``` - -
- Swap Widget Theme Example 5 - - -```tsx -const theme: Theme = { - primary: '#001D82', - secondary: '#6677C1', - interactive: '#005BAE', - container: '#ABD6FE', - module: '#FFF7FB', - accent: '#FF7BC2', - outline: '#ABD6FE', - dialog: '#FFF', - fontFamily: 'Arvo', - borderRadius: 1, -} -``` - -
- Swap Widget Theme Example 6 - - -```tsx -const theme: Theme = { - primary: '#000', - secondary: '#666', - interactive: '#AFAFAF', - container: '#DADADA', - module: '#FFF', - accent: '#0018F4', - outline: '#000', - dialog: '#FFF', - fontFamily: 'Comic Sans MS', - borderRadius: 0.2, -} -``` - -
- -:::note Questions? -Join the [Discord channel](https://discord.com/channels/597638925346930701/941447445844463676) to ask questions and get support from the Uniswap community. -::: diff --git a/SDK_versioned_docs/version-Maia/widgets/swap-widget.mdx b/SDK_versioned_docs/version-Maia/widgets/swap-widget.mdx deleted file mode 100644 index e3c5d21..0000000 --- a/SDK_versioned_docs/version-Maia/widgets/swap-widget.mdx +++ /dev/null @@ -1,411 +0,0 @@ ---- -id: swap-widget -slug: swap-widget -title: Getting Started with the Swap Widget -sidebar_label: Getting Started -sidebar_position: 1 ---- - -import ThemedImage from '@theme/ThemedImage' -import useBaseUrl from '@docusaurus/useBaseUrl' - -# Getting Started with the Swap Widget - -This guide walks you through the steps to embed the swap widget in your website in 2 minutes — whether your site is already a decentralized application (dApp) or not. With the swap widget, your users can trade ERC-20 tokens on the Uniswap Protocol without leaving your site! - -Here’s a live preview of the swap widget. - - - -Example use cases include: - -- Building a custom frontend for the Uniswap Protocol -- Swapping assets in a DeFi application -- Acquiring a token to participate in your web3 community (e.g. FWB or a gaming token) -- Converting to the required currency for an NFT purchase (e.g. WETH) - -You can make the widget feel like a native part of your app by customizing the colors, font, and token list to match your app theme. This guide will teach you how. - -## Installing the Widgets Library {#installing-library} - -To get started, install the widgets library using npm or Yarn. If you don’t already use it, you’ll need to install `react-redux` as well. - -```bash npm2yarn -npm install --save @uniswap/widgets react-redux -``` - -## Adding the Swap Widget to Your App {#adding-the-widget} - -Next, embed the React component in your application. - -```jsx -import { SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -function App() { -
- -
-} -``` - -That’s it! You should now see a fully functional swap widget on your site. The widget is self-contained and gracefully handles all interactions with the Uniswap Protocol. It leverages the [Auto Router](https://docs.uniswap.org/sdk/guides/auto-router) to compute the best price across all Uniswap v2 and v3 pools. - -See a full implementation of the swap widget in the `/cra` and `/nextjs` branches of the [widgets-demo](https://github.com/Uniswap/widgets-demo) repo. - -:::note Create React App V4 -All code snippets will work seamlessly if you use [Next.js](https://nextjs.org/) or [Create React App](https://create-react-app.dev/) V5. However, if you’re using Create React App V4, you’ll need to use the following `import` statements instead: - -```jsx -import { SwapWidget } from '@uniswap/widgets/dist/index.js' -import '@uniswap/widgets/dist/fonts.css' -``` - -::: - -# Recommended Parameters {#recommended-parameters} - -The swap widget is a React component that can be easily imported into any React project. It's designed to work out-of-the-box, with no required parameters or web3 integration necessary. Trading is supported on all networks where the Uniswap Protocol is deployed. - -Although the widget will work out-of-the-box with no parameters, we highly recommend integrators provide [JSON-RPC endpoints](#json-rpc-endpoint), like from Infura or Alchemy. Existing dApps can also provide their existing [web3 provider](#web3-provider) to integrate the widget seamlessly into their dApp. - -Additional [optional parameters](/sdk/widgets/swap-widget/api#optional-parameters) are available to customize the appearance and performance of the swap widget to fit your unique use case. - -## JSON-RPC Endpoints {#json-rpc-endpoint} - -We strongly recommend you provide JSON-RPC endpoint URLs in the widget’s `jsonRpcUrlMap` prop. The widget will use these endpoints to fetch on-chain data and submit transactions for signature. If the user connects a MetaMask wallet, the widget will use the JSON-RPC provided by MetaMask when possible. [(See a list of all chains supported on widget.)](https://github.com/Uniswap/widgets/blob/main/src/constants/chains.ts#L4) - -If you don’t yet have JSON-RPC endpoints, you can easily create them with services like [Infura](https://infura.io/product/ethereum) or [Alchemy](https://www.alchemy.com/supernode). - -If you choose not to provide a `jsonRpcUrlMap` prop or are missing endpoints for some chains, the widget uses free public JSON-RPC endpoints to still allow users to interact with the widget and fetch price quotes. However, these public endpoints are NOT recommended for production environment usage, are severely rate-limited, and aren't necessarily as reliable. When possible, we'd recommend providing your own endpoints! - -## Web3 Provider {#web3-provider} - -The swap widget uses a web3 `provider` prop to allow users to connect their wallets, fetch balances, and submit transactions through the user’s connected wallet. - -If you already have a web3 provider, you can pass your provider object directly into the `provider` prop. Both the [ethers](https://docs.ethers.io/v5/api/providers/provider/) and [web3.js](https://web3js.readthedocs.io/en/v1.5.2/index.html) provider objects are compatible with the widget, as is any [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider. - -If you don't have a web3 provider yet, the widget has built-in wallet connection functionality that supports [WalletConnect](https://walletconnect.com/) and [MetaMask](https://metamask.io/) wallets, making it super simple for you to integrate web3 in your app! - -Otherwise, you can also add your own custom wallet connection flow in the [`onConnectWalletClick` handler](../swap-widget/api), which is triggered when the widget's 'Connect your wallet to swap' button is clicked. Check out libraries such as [web3-react](https://github.com/Uniswap/web3-react), BlockNative’s [Onboard](https://www.blocknative.com/onboard), or Aragon’s [useWallet()](https://github.com/aragon/use-wallet) to build your own flow. To hide the widget's native wallet connection flow, set the `hideConnectionUI` prop to true. - -The widget will match the network currently selected by the user. If the user switches networks in your app or in their wallet, that change will propagate to the widget as well. If the user connects to a network that is not supported by the swap widget, the widget will gracefully disable itself. - -```tsx -import { SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -// Recommended to provide a Web3 provider -import { provider } from './your/provider' -// Recommended to provide your own JSON-RPC endpoints -const jsonRpcUrlMap = { - 1: ['https://mainnet.infura.io/v3/'], - 3: ['https://ropsten.infura.io/v3/'] -} - -function App() { -
- -
-} -``` - -# Customizing the Swap Widget {#customizing-widget} - -You can set [optional parameters](/sdk/widgets/swap-widget-reference#optional-parameters) to tailor the appearance and functionality of the swap widget to fit your dApp. - -## Customizing the Width {#customizing-width} - -The swap widget has a fixed height of 360px and a default width of 360px. You cannot modify the height of the widget. You can modify the width up to a minimum width of 300px. - -You can customize the width by passing a number (of pixels) or a valid CSS width to the `width` prop of the widget. - -```tsx -import { SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -function App() { -
- -
-} -``` - -For example: - -- `width={360}` sets the width to 360 pixels -- `width="100%"` sets the width to dynamically fill 100% of the parent container -- `width="20em"` sets the width to 20 * 16 = 320 pixels because 16px is the base font-size of the widget - -The recommended and default width is 360 pixels. - -## Customizing the Theme {#customizing-theme} - -You can customize the colors, font, and border radius of the swap widget to match the look and feel of your dApp. You can also toggle between light and dark modes. This section explains how to customize each attribute of the widget with your own `theme`. - -All attributes below are color codes, except `fontFamily` (string), `borderRadius` (number between 0 and 1), and `tokenColorExtraction`(boolean). The next two sections show code examples using these attributes. - -Check out [examples](/sdk/widgets/swap-widget/examples) of the swap widget, and the [Figma file](https://www.figma.com/file/m0pVMlgAgSoaIrXlM3VRUG/Widgets-(External)?node-id=4302%3A18261) if you want to mock it up first! - - - - - -### Overriding Attributes {#overriding-attributes} - -You can override specific attributes of the widget by creating a `Theme` object and defining the properties you wish to override. Any properties left undefined will fallback to the default theme. For example, here is a simple `Theme` that removes the border radius and sets a custom font family. - -```tsx -import { Theme, SwapWidget } from '@uniswap/widgets' - -// Define a custom theme to override default attributes -const theme: Theme = { - borderRadius: 0, - fontFamily: '"Helvetica"', -} - -function App() { -
- -
-} -``` - -Please note that the `borderRadius` attribute is a multiplier from 0 to 1 of how much radius to apply. Since the widget uses different values of border radius (e.g. internal edges have tighter radii than external edges), `borderRadius` will apply your multiplier value on all instances so that the border radii still look proportionally correct. - -:::note Importing Fonts -The swap widget fonts must be imported explicitly with `import '@uniswap/widgets/fonts.css'`. However, if you’re overriding the swap widget fonts with your own, or with a default font such as Helvetica in the example above, you can remove this `import` statement. -::: - -### Enabling Token Color Extraction {#enabling-color-extraction} - -By default, the background color of the output module will be set by the `module` attribute. You can optionally enable color extraction to flood the output module with the color of the selected output token. In the above example, DAI is the output token so the output module is flooded with DAI yellow. - -To enable color extraction, set the `tokenColorExtraction` property to `true` in your `Theme` object. - -```tsx -import { Theme, SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -const enableColorExtractionTheme: Theme = { - tokenColorExtraction: true, // Enable color extraction of the output token -} - -function App() { -
- -
-} -``` - -### Toggling Light and Dark Mode {#toggling-light-dark-mode} - -The swap widget provides a default light theme and dark theme as a starting point. You can import each one and extend it to create your own theme. If your app can toggle between light and dark mode, you can propagate that state down to the widget by following the example below. - -```tsx -import { darkTheme, lightTheme, Theme, SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -let darkMode = true // Dynamically toggle dark mode on and off -function App() { -
- -
-} -``` - -### Matching System Preference for Light and Dark Mode {#matching-system-light-dark-mode} - -You can match the user’s system preference for light/dark mode by using the `useSystemTheme` hook. This will return the default widget light or dark theme according to the user’s system configuration. You can extend this base theme with further customizations, as you will see in the next section. - -```tsx -import { SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -function useSystemTheme() { - // Access -} - -function App() { - const theme = useSystemTheme() // Get a theme that matches the user system preference -
- -
-} -``` - -### Extending Themes {#extending-themes} - -You can extend any theme with custom attributes. The below example extends the base light and dark themes with custom colors. - -```tsx -import { darkTheme, lightTheme, Theme, SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -const myLightTheme: Theme = { - ...lightTheme, // Extend the lightTheme - accent: '#FF007A', - primary: '#000000', - secondary: '#565A69', -} - -const myDarkTheme: Theme = { - ...darkTheme, // Extend the darkTheme - accent: '#2172E5', - primary: '#FFFFFF', - secondary: '#888D9B', -} - -let darkMode = true -function App() { -
- -
-} -``` - -## Customizing the Token Lists {#customizing-token-lists} - -By default, the widget will use the [Uniswap Labs default token list](https://tokenlists.org/token-list?url=https://gateway.ipfs.io/ipns/tokens.uniswap.org) in the selector. - -### Customizing the Default Token List {#customizing-default-token-list} - -If you want to offer a different set of tokens in the widget, you can provide a custom `tokenList` parameter. You can [browse popular token lists](https://tokenlists.org/) to find one that suits your needs and then pass the URL as a parameter. - -```jsx -import { SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -const CMC_TOKEN_LIST = 'https://api.coinmarketcap.com/data-api/v3/uniswap/all.json' - -function App() { -
- -
-} -``` - -Alternatively, you can create your own token list. There are two ways to provide your own token list for the widget. - -The first option is to [create a full token list](https://github.com/Uniswap/token-lists#authoring-token-lists), host it at your own URI, and pass the URI as a parameter as in the above example. This option is recommended if you want to use the same token list in multiple places throughout your application or community. - -The second and easiest option is to construct a custom token list inline as an array of tokens. The schema is equivalent to the `tokens` array from the [tokenlist JSON schema](https://github.com/Uniswap/token-lists/blob/main/src/tokenlist.schema.json). This option lets you skip deployment, hosting, and versioning of a full URI token list. Here is an example of an inline token list containing only the DAI, USDT, and USDC tokens (in addition to ETH which is always available, regardless of token list). - -```jsx -import { SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -// You can also pass a token list as JSON, as long as it matches the schema -const MY_TOKEN_LIST = [ - { - "name": "Dai Stablecoin", - "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F", - "symbol": "DAI", - "decimals": 18, - "chainId": 1, - "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png" - }, - { - "name": "Tether USD", - "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", - "symbol": "USDT", - "decimals": 6, - "chainId": 1, - "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png" - }, - { - "name": "USD Coin", - "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", - "symbol": "USDC", - "decimals": 6, - "chainId": 1, - "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png" - }, -] - -function App() { -
- -
-} -``` - -Please note that the swap widget only enforces metadata validation on remotely hosted token lists, not on token list data passed as a literal value to the widget like in this example. - -If you want to add Layer 2 tokens to the token list, you can add an extension field. See this [GitHub issue](https://github.com/Uniswap/token-lists/issues/51#issuecomment-952268629) for details. - -## Customizing the Default Input and Output Tokens {#customizing-default-input-output-tokens} - -You can set the `defaultInputTokenAddress`, `defaultInputAmount`, `defaultOutputTokenAddress`, and `defaultOutputAmount` to pre-populate the input and output token fields respectively. This is useful when the widget appears in a context where you know which tokens the user is evaluating to trade. For example, if the widget appears on a page that displays the WBTC price chart, it would be helpful to pre-select WBTC as the output token in the widget. - -If your page does not need any particular defaults, then the recommended default input token is the native asset of the active network (e.g. ETH) and no default output token is recommended. Since ETH does not have an address, you can pass `'NATIVE'` as the parameter to set it as the default input or output token. - -The following example sets the default input to 2 ETH and the default output token to WBTC. - -```tsx -import { SwapWidget } from '@uniswap/widgets' -import '@uniswap/widgets/fonts.css' - -// Default token list from Uniswap -const UNISWAP_TOKEN_LIST = 'https://gateway.ipfs.io/ipns/tokens.uniswap.org' - -// Use the native token of the connected chain as the default input token -const NATIVE = 'NATIVE' // Special address for native token - -// WBTC as the default output token -const WBTC = '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599' - -function App() { -
- -
-} -``` - -## Understanding the Swap Widget States {#understanding-widget-states} - -The widget has two main connectivity states depending on if the user has connected a wallet. - - - -1. **Before wallet connection**, the widget will use the JSON-RPC endpoint to fetch token price data and provide trade quotes, but submitting transactions will be disabled. -2. **After wallet connection**, the widget will be fully functional. The user will be able to fetch trade quotes and submit swap transactions using the JSON-RPC endpoint and web3 provider from their connected wallet. - -:::note Questions? -Join the [Discord channel](https://discord.com/channels/597638925346930701/941447445844463676) to ask questions and get support from the Uniswap community. -::: diff --git a/SDK_versioned_sidebars/version-Maia-sidebars.json b/SDK_versioned_sidebars/version-Maia-sidebars.json deleted file mode 100644 index 574f8ad..0000000 --- a/SDK_versioned_sidebars/version-Maia-sidebars.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "version-Maia/sdksidebar": [ - { - "type": "autogenerated", - "dirName": "." - } - ] -} diff --git a/docusaurus.config.js b/docusaurus.config.js index e8049fa..ab0edf2 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -19,9 +19,9 @@ module.exports = { additionalLanguages: ['solidity'], }, algolia: { - apiKey: '215a980d267cf35cc81fa49332092a8b', + apiKey: 'feec8d3ebb219a69c27e6e675015127f', indexName: 'ecosystem-docs', - appId: 'HUFIQABVG5', + appId: 'KP5MH8H1FE', }, navbar: { title: 'Maia Ecosystem Docs', @@ -131,25 +131,25 @@ module.exports = { // className: 'persistent', // }, { - to: '/protocols/concepts/governance/overview', + to: '/protocols/governance/overview', label: 'Governance', position: 'left', className: 'Maia_active', }, { - to: '/protocols/Hermes/concepts/governance/overview', + to: '/protocols/Hermes/governance/overview', label: 'Governance', position: 'left', className: 'Hermes_active', }, { - to: '/protocols/Talos/concepts/governance/overview', + to: '/protocols/Talos/governance/overview', label: 'Governance', position: 'left', className: 'Talos_active', }, { - to: '/protocols/Ulysses/concepts/governance/overview', + to: '/protocols/Ulysses/governance/overview', label: 'Governance', position: 'left', className: 'Ulysses_active', @@ -347,22 +347,4 @@ module.exports = { crossorigin: 'anonymous', }, ], - plugins: [ - [ - '@docusaurus/plugin-content-docs', - { - id: 'SDK', - path: 'sdk', - routeBasePath: 'sdk/', - sidebarPath: require.resolve('./sdkSidebars.js'), - remarkPlugins: [[require('@docusaurus/remark-plugin-npm2yarn'), { sync: true }]], - includeCurrentVersion: false, - versions: { - 'Maia': { - banner: 'none', - } - }, - }, - ], - ], } diff --git a/sdk-examples/AddAndRemoveLiquidity.tsx b/sdk-examples/AddAndRemoveLiquidity.tsx deleted file mode 100644 index 19196c3..0000000 --- a/sdk-examples/AddAndRemoveLiquidity.tsx +++ /dev/null @@ -1,126 +0,0 @@ -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' - -// 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() - -// pool address for DAI/USDC 0.05% -const poolAddress = '0x6c6bc977e13df9b0de53b251522280bb72383700' - -const poolContract = new ethers.Contract(poolAddress, IUniswapV3PoolABI, provider) - -interface Immutables { - 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 -} - -async function getPoolImmutables() { - const immutables: Immutables = { - factory: await poolContract.factory(), - token0: await poolContract.token0(), - token1: await poolContract.token1(), - fee: await poolContract.fee(), - tickSpacing: await poolContract.tickSpacing(), - maxLiquidityPerTick: await poolContract.maxLiquidityPerTick(), - } - return immutables -} - -async function getPoolState() { - const slot = await poolContract.slot0() - const PoolState: State = { - liquidity: await poolContract.liquidity(), - sqrtPriceX96: slot[0], - tick: slot[1], - observationIndex: slot[2], - observationCardinality: slot[3], - observationCardinalityNext: slot[4], - feeProtocol: slot[5], - unlocked: slot[6], - } - 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 - - //create a pool - const DAI_USDC_POOL = new Pool( - DAI, - USDC, - immutables.fee, - 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 - // in this example, we will set the liquidity parameter to a small percentage of the current liquidity - 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, - }) - - // 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, - }) - } - - // 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, - }) - } - - // 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, - }, - }) - } -} - -// call the example function by passing the sender, e.g.: -// liquidityExamples("0xDA9dfA130Df4dE4673b89022EE50ff26f6EA73Cf", 0) diff --git a/versioned_docs/version-Hermes/overview/gauges/01-introduction.md b/versioned_docs/version-Hermes/overview/gauges/01-introduction.md index 5ece573..4897d7f 100644 --- a/versioned_docs/version-Hermes/overview/gauges/01-introduction.md +++ b/versioned_docs/version-Hermes/overview/gauges/01-introduction.md @@ -30,7 +30,7 @@ Direct emissions to different Gauges to earn a share of the Gauge's revenue. ### Partners Bribe voters to attract TVL. -Gauges will receive as bribes the [protocol fees](../../../../Ulysses/concepts/overview/unified-liquidity/fees#protocol-fees) of their underlying asset's Ulysses [Unified Liquidity Pools](../../../../Ulysses/concepts/overview/unified-liquidity/pools). +Gauges will receive as bribes the [protocol fees](/protocols/Ulysses/overview/unified-liquidity/fees#protocol-fees) of their underlying asset's Ulysses [Unified Liquidity Pools](/protocols/Ulysses/overview/unified-liquidity/pools). ## Practical Example diff --git a/versioned_docs/version-Maia/overview/tokenomics/02-boost.md b/versioned_docs/version-Maia/overview/tokenomics/02-boost.md index d1d5cfa..85e10b3 100644 --- a/versioned_docs/version-Maia/overview/tokenomics/02-boost.md +++ b/versioned_docs/version-Maia/overview/tokenomics/02-boost.md @@ -5,7 +5,7 @@ title: Boost ## How does vMAIA boost yields? -One of the core incentives for vMAIA adoption is the ability to maximize your bHERMES voting power and boost your rewards on deployed capital. But where does this boost come from? This is possible due to the fact Maia DAO has around 50% of the bHermes supply, as such, for each MAIA in circulation there is a basket of bHERMES in the Maian Treasury. [**Learn about boosting **](../../../Hermes/concepts/overview/tokenomics/boost) and [**how it is applied to gauges.**](../../../Hermes/concepts/overview/gauges/uni-v3#calculating-boost) +One of the core incentives for vMAIA adoption is the ability to maximize your bHERMES voting power and boost your rewards on deployed capital. But where does this boost come from? This is possible due to the fact Maia DAO has around 50% of the bHermes supply, as such, for each MAIA in circulation there is a basket of bHERMES in the Maian Treasury. [**Learn about boosting **](/protocols/Hermes/overview/tokenomics/utility-tokens/bhermes-boost) and [**how it is applied to gauges.**](/protocols/Hermes/overview/gauges/uni-v3#calculating-boost) ## Boosting Rewards diff --git a/versioned_docs/version-Maia/overview/tokenomics/03-supply.md b/versioned_docs/version-Maia/overview/tokenomics/03-supply.md index d4beb18..60dfd2a 100644 --- a/versioned_docs/version-Maia/overview/tokenomics/03-supply.md +++ b/versioned_docs/version-Maia/overview/tokenomics/03-supply.md @@ -27,7 +27,7 @@ This phase constitutes the V2 iteration of the Maian Ecosystem where the key dif During this phase, the platform focuses on three main participants: - [Vaults](../vaults/strategies) Liquidity Providers - [vMAIA](./vMaia) Lockers -- [Hermes](../../../Hermes/introduction) Bribers +- [Hermes](/protocols/Hermes/introduction) Bribers The liquidity providers deposit their assets into the vaults and earn yield on their deposited assets, the vMAIA Lockers lock their MAIA tokens and earn dividends from the platform's revenue, and the Hermes Bribers, protocols that are looking to rent liquidity in Hermes Protocol. diff --git a/versioned_docs/version-Maia/overview/vaults/01-strategies.md b/versioned_docs/version-Maia/overview/vaults/01-strategies.md index 3a63a5f..f52fded 100644 --- a/versioned_docs/version-Maia/overview/vaults/01-strategies.md +++ b/versioned_docs/version-Maia/overview/vaults/01-strategies.md @@ -14,7 +14,7 @@ The Maia DAO holds a position in bHermes, which allows users to leverage the ben MaiaDAO's vision: providing the user with the most utility with the least input materialized in meaningful partnerships with protocols that complement our product. That way our users' DeFi experience is less fragmented and more akin to the experience in a multiservice CEX, of course without the custody counterparty risks. -Both the Hermes V2 architecture using [Uniswap V3 pools](../../../Hermes/concepts/overview/gauges/uni-v3) under the hood and Maia's strategy vaults will be a prime example of those synergies. +Both the Hermes V2 architecture using [Uniswap V3 pools](/protocols/Hermes/overview/gauges/uni-v3) under the hood and Maia's strategy vaults will be a prime example of those synergies. ## Upcoming Features diff --git a/versioned_docs/version-Maia/what-is-maia.md b/versioned_docs/version-Maia/what-is-maia.md index a78acfb..7b507e3 100644 --- a/versioned_docs/version-Maia/what-is-maia.md +++ b/versioned_docs/version-Maia/what-is-maia.md @@ -17,7 +17,7 @@ In order to sustainably bootstrap our surrounding ecosystem, Maia plans to conti ## What is the point of $MAIA? -$MAIA when locked as [vMAIA](./concepts/overview/tokenomics/vMaia) is a utility and governance token that drives the coordination mechanisms behind the whole Maian ecosystem. This allows us to decentralize the decision-making process, as well as entitle the token stakers to their share of the profits generated by the Maian Treasury. +$MAIA when locked as [vMAIA](./overview/tokenomics/vMaia) is a utility and governance token that drives the coordination mechanisms behind the whole Maian ecosystem. This allows us to decentralize the decision-making process, as well as entitle the token stakers to their share of the profits generated by the Maian Treasury. As a DAO we constantly push towards improving our decentralized governance structure and processes. Maia leveraged OHM's Staking & Bonding Mechanics in its initial distribution phase. The emissions were distributed via rebase and capped at a supply of 180,000 $MAIA. From now on, $MAIA will only be emitted via strategic bonds proposed through governance. @@ -37,8 +37,8 @@ Each $MAIA token is backed by a basket of blue-chip and revenue generating asset ## Where can I find more information about the ecosystem products -For info about Hermes, please check out our [**Hermes docs**](../Hermes/introduction) page. +For info about Hermes, please check out our [**Hermes docs**](/protocols/Hermes/introduction) page. -For info about Talos, please check out our [**Talos docs**](../Talos/introduction) page. +For info about Talos, please check out our [**Talos docs**](/protocols/Talos/introduction) page. -For info about Ulysses, please check out our [**Ulysses docs**](../Ulysses/introduction) page. +For info about Ulysses, please check out our [**Ulysses docs**](/protocols/Ulysses/introduction) page. diff --git a/versioned_docs/version-Ulysses/what-is-Ulysses.md b/versioned_docs/version-Ulysses/what-is-Ulysses.md index 8c9b439..b867ac1 100644 --- a/versioned_docs/version-Ulysses/what-is-Ulysses.md +++ b/versioned_docs/version-Ulysses/what-is-Ulysses.md @@ -14,9 +14,9 @@ In addition, offering a way for DeFi protocols to lower their operational and ma Ulysses Protocol has two major components, the Virtualized and the Unified Liquidity Management. The latter being inspired by the [Delta Algorithm](https://www.dropbox.com/s/gf3606jedromp61/Delta-Solving.The.Bridging-Trilemma.pdf?dl=0) put forward by Layer 0. We take this idea one step further by having a single token which represents a basket of Ulysses LPs of the same token from different chains; this unlocks full composability enabling anyone to use this token as they wish, for example in other AMMs like Uniswap V3, Money Markets like Aave, and so on. -An understanding of the concepts of Ulysses [Ports](./concepts/overview/omnichain/ports) and [Virtualized Liquidity](./concepts/overview/omnichain/virtual-liquidity) is necessary to fully grasp the mechanics of Ulysses Virtualized Liquidity Management. This is achieved through the use of [anycall V7](https://docs.multichain.org/developer-guide/anycall-v7) for cross-chain messaging. +An understanding of the concepts of Ulysses [Ports](./overview/omnichain/ports) and [Virtualized Liquidity](./overview/omnichain/virtual-liquidity) is necessary to fully grasp the mechanics of Ulysses Virtualized Liquidity Management. This is achieved through the use of [anycall V7](https://docs.multichain.org/developer-guide/anycall-v7) for cross-chain messaging. -To understand Ulysses Unified Liquidity Solution, it is necessary to first understand the difference between [Ulysses Unified Pools](./concepts/overview/unified-liquidity/pools) and [Ulysses Unified Tokens](./concepts/overview/unified-liquidity/tokens). +To understand Ulysses Unified Liquidity Solution, it is necessary to first understand the difference between [Ulysses Unified Pools](./overview/unified-liquidity/pools) and [Ulysses Unified Tokens](./overview/unified-liquidity/tokens). ## Where can I find more information about ecosystem products