├── .gitattributes ├── .gitignore ├── README.md ├── V1sidebars.js ├── V2sidebars.js ├── V3sidebars.js ├── babel.config.js ├── config.json ├── contract.hbs ├── docs └── V2 │ ├── concepts │ ├── 01-protocol-overview │ │ ├── 01-how-uniswap-works.md │ │ ├── 02-ecosystem-participants.md │ │ ├── 03-smart-contracts.md │ │ ├── 04-glossary.md │ │ ├── _category_.json │ │ └── images │ │ │ ├── anatomy.jpg │ │ │ ├── how-works.jpg │ │ │ ├── lp.jpg │ │ │ ├── participants.jpg │ │ │ └── trade.jpg │ ├── 02-core-concepts │ │ ├── 01-swaps.md │ │ ├── 02-pools.md │ │ ├── 03-flash-swaps.md │ │ ├── 04-oracles.md │ │ ├── _category_.json │ │ ├── images │ │ │ ├── anatomy.jpg │ │ │ ├── how-works.jpg │ │ │ ├── lp.jpg │ │ │ ├── pool.jpg │ │ │ ├── trade.jpg │ │ │ ├── v2_onchain_price_data.png │ │ │ └── v2_twap.png │ │ └── reference │ │ │ └── Integration-quick-start.js │ ├── 03-advanced-topics │ │ ├── 01-fees.md │ │ ├── 02-pricing.md │ │ ├── 03-understanding-returns.md │ │ ├── 04-security.md │ │ ├── 05-math.md │ │ ├── 06-research.md │ │ └── _category_.json │ ├── 11-governance │ │ ├── 01-overview.md │ │ ├── 02-process.md │ │ ├── 03-guide-to-voting.md │ │ ├── 04-glossary.md │ │ ├── 05-adversarial-circumstances.md │ │ ├── 06-governance-reference.md │ │ ├── _category_.json │ │ └── images │ │ │ ├── Delegate_To_Address.png │ │ │ ├── Proposal_Active.png │ │ │ ├── Proposal_Executed.png │ │ │ ├── Proposals_Overview.png │ │ │ ├── Submitting_Vote.png │ │ │ ├── Unlock_Voting.png │ │ │ ├── Unlocking_Votes.png │ │ │ ├── Voting.png │ │ │ └── gov_diagram-1.png │ └── _category_.json │ ├── guides │ ├── _category_.json │ ├── interface-integration │ │ ├── 01-using-the-api.md │ │ ├── 02-custom-interface-linking.md │ │ ├── 03-iframe-integration.md │ │ └── _category_.json │ ├── javascript-sdk │ │ ├── 01-quick-start.md │ │ ├── 02-fetching-data.md │ │ ├── 03-pricing.md │ │ ├── 04-trading.md │ │ ├── 05-getting-pair-addresses.md │ │ └── _category_.json │ └── smart-contract-integration │ │ ├── 01-quick-start.md │ │ ├── 02-trading-from-a-smart-contract.md │ │ ├── 03-providing-liquidity.md │ │ ├── 04-building-an-oracle.md │ │ ├── 05-using-flash-swaps.md │ │ ├── 06-getting-pair-addresses.md │ │ ├── 07-supporting-meta-transactions.md │ │ └── _category_.json │ └── reference │ ├── API │ ├── 01-overview.md │ ├── 02-entities.md │ ├── 03-queries.md │ └── _category_.json │ ├── Governance │ ├── 05-governance-reference.md │ ├── _category_.json │ └── images │ │ ├── Delegate_To_Address.png │ │ ├── Proposal_Active.png │ │ ├── Proposal_Executed.png │ │ ├── Proposals_Overview.png │ │ ├── Submitting_Vote.png │ │ ├── Unlock_Voting.png │ │ ├── Unlocking_Votes.png │ │ ├── Voting.png │ │ └── gov_diagram-1.png │ ├── SDK │ ├── 01-getting-started.md │ ├── 02-token.md │ ├── 03-pair.md │ ├── 04-route.md │ ├── 05-trade.md │ ├── 06-fractions.md │ ├── 07-fetcher.md │ ├── 08-other-exports.md │ └── _category_.json │ ├── _category_.json │ └── smart-contracts │ ├── 01-factory.md │ ├── 02-pair.md │ ├── 03-pair-erc-20.md │ ├── 04-library.md │ ├── 05-router01.md │ ├── 06-router02.md │ ├── 07-common-errors.md │ └── _category_.json ├── docusaurus.config.js ├── package.json ├── sdkSidebar.js ├── src ├── css │ ├── colors.css │ └── custom.css ├── pages │ └── styles.module.css └── theme │ └── DocVersionSuggestions │ └── index.js ├── static ├── .nojekyll ├── CNAME ├── img │ ├── Union.svg │ ├── favicon.ico │ ├── favicon.png │ ├── logo.svg │ ├── logo_circle.png │ ├── quickswaplogo.png │ ├── undraw_docusaurus_mountain.svg │ ├── undraw_docusaurus_react.svg │ ├── undraw_docusaurus_tree.svg │ └── uni_dark_icon.svg └── whitepaper.pdf ├── versioned_docs └── version-V2 │ ├── concepts │ ├── 01-protocol-overview │ │ ├── 01-how-uniswap-works.md │ │ ├── 02-ecosystem-participants.md │ │ ├── 03-smart-contracts.md │ │ ├── 04-glossary.md │ │ ├── _category_.json │ │ └── images │ │ │ ├── Ecosystem-Participants.png │ │ │ ├── How-Quickswap-Works.png │ │ │ ├── Liquidity-Provider.png │ │ │ ├── anatomy.jpg │ │ │ ├── how-works.jpg │ │ │ ├── lp.jpg │ │ │ ├── participants.jpg │ │ │ ├── quickswap-swaps.png │ │ │ └── trade.jpg │ ├── 02-core-concepts │ │ ├── 01-swaps.md │ │ ├── 02-pools.md │ │ ├── 03-flash-swaps.md │ │ ├── 04-oracles.md │ │ ├── _category_.json │ │ ├── images │ │ │ ├── anatomy.jpg │ │ │ ├── how-works.jpg │ │ │ ├── lp.jpg │ │ │ ├── pool.jpg │ │ │ ├── trade.jpg │ │ │ ├── v2_onchain_price_data.png │ │ │ └── v2_twap.png │ │ └── reference │ │ │ └── Integration-quick-start.js │ ├── 03-advanced-topics │ │ ├── 01-fees.md │ │ ├── 02-pricing.md │ │ ├── 03-understanding-returns.md │ │ ├── 04-security.md │ │ ├── 05-math.md │ │ ├── 06-research.md │ │ └── _category_.json │ ├── 11-governance │ │ ├── 01-overview.md │ │ ├── 02-process.md │ │ ├── _category_.json │ │ └── images │ │ │ ├── Delegate_To_Address.png │ │ │ ├── Proposal_Active.png │ │ │ ├── Proposal_Executed.png │ │ │ ├── Proposals_Overview.png │ │ │ ├── Submitting_Vote.png │ │ │ ├── Unlock_Voting.png │ │ │ ├── Unlocking_Votes.png │ │ │ ├── Voting.png │ │ │ └── gov_diagram-1.png │ └── _category_.json │ ├── guides │ ├── _category_.json │ ├── interface-integration │ │ ├── 01-using-the-api.md │ │ ├── 02-custom-interface-linking.md │ │ ├── 03-iframe-integration.md │ │ └── _category_.json │ ├── javascript-sdk │ │ ├── 01-quick-start.md │ │ ├── 02-fetching-data.md │ │ ├── 03-pricing.md │ │ ├── 04-trading.md │ │ ├── 05-getting-pair-addresses.md │ │ └── _category_.json │ └── smart-contract-integration │ │ ├── 01-quick-start.md │ │ ├── 02-trading-from-a-smart-contract.md │ │ ├── 03-providing-liquidity.md │ │ ├── 04-building-an-oracle.md │ │ ├── 05-using-flash-swaps.md │ │ ├── 06-getting-pair-addresses.md │ │ ├── 07-supporting-meta-transactions.md │ │ ├── 08-getting-v3-pool-addresses.md │ │ └── _category_.json │ └── reference │ ├── API │ ├── 01-overview.md │ ├── 02-entities.md │ ├── 03-queries.md │ └── _category_.json │ ├── SDK │ ├── 01-getting-started.md │ ├── 02-token.md │ ├── 03-pair.md │ ├── 04-route.md │ ├── 05-trade.md │ ├── 06-fractions.md │ ├── 07-fetcher.md │ ├── 08-other-exports.md │ └── _category_.json │ ├── _category_.json │ └── smart-contracts │ ├── _category_.json │ ├── v2 │ ├── 01-factory.md │ ├── 02-pair.md │ ├── 03-pair-erc-20.md │ ├── 04-library.md │ ├── 06-router02.md │ ├── 07-common-errors.md │ └── _category_.json │ └── v3 │ ├── 01-factory.md │ ├── 02-position-manager.md │ ├── 03-pool-deployer.md │ ├── 04-quoter.md │ ├── 05-migrator.md │ ├── 06-farming-center.md │ ├── 07-limit-farming.md │ ├── 08-pool.md │ ├── 09-audits.md │ └── _category_.json ├── versioned_sidebars └── version-V2-sidebars.js ├── versions.json └── yarn.lock /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | node_modules/ 4 | 5 | lib/core/metadata.js 6 | lib/core/MetadataBlog.js 7 | translated_docs 8 | build/ 9 | yarn.lock 10 | i18n/* 11 | .docusaurus/* 12 | 13 | artifacts/ 14 | cache/ 15 | typechain/ 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. 4 | 5 | # How to generate markdown files from solidity Natspec comments 6 | 7 | Install solidity doc gen 8 | `npm install solidity-docgen` 9 | 10 | Get the correct compiler version 11 | `npm install -D solc-0.7@npm:solc@0.7.6` 12 | 13 | Put the updated template `contract.hbs` in a /templates folder under the same directory as /contracts that you want to generate 14 | 15 | Run `npx solidity-docgen --solc-module solc-0.7 -t ./templates` 16 | 17 | # How to gernerate markdown files from typescript commments 18 | 19 | `npm install --save-dev typedoc typedoc-plugin-markdown` 20 | 21 | `typedoc --out src/index.ts` 22 | 23 | see https://www.npmjs.com/package/typedoc-plugin-markdown for details 24 | 25 | # How to Update search indices with algolia 26 | 27 | create .env file with `APPLICATION_ID` and the `API_KEY` (write access) 28 | Edit config.json file with 29 | 30 | - start url from updated website 31 | - sitemap url from updated website: ex) for docs: https://docs.quickswap.exchange/sitemap.xml 32 | - "v3-docs" index name 33 | - install jq : `brew install jq` 34 | run `docker run -it --env-file=.env -e "CONFIG=$(cat ./config.json | jq -r tostring)" algolia/docsearch-scraper` 35 | 36 | # How to add a new page 37 | 38 | Create a markdown file in its respective versioned docs, or versioned SDK, directory. 39 | 40 | 41 | ## Installation 42 | 43 | ```console 44 | yarn install 45 | ``` 46 | 47 | ## Local Development 48 | 49 | ```console 50 | yarn run start 51 | ``` 52 | 53 | This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. 54 | 55 | ## Clear cache 56 | 57 | ```console 58 | yarn docusaurus clear 59 | ``` 60 | 61 | ## Build 62 | 63 | ```console 64 | yarn build 65 | ``` 66 | 67 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 68 | 69 | ## Deployment 70 | 71 | ```console 72 | GIT_USER= USE_SSH=true yarn deploy 73 | ``` 74 | 75 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 76 | -------------------------------------------------------------------------------- /V1sidebars.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | mySidebar: [ 3 | { 4 | type: 'autogenerated', 5 | dirName: './versioned_docs/version-V1', // generate sidebar slice from the docs folder (or versioned_docs/) 6 | }, 7 | ], 8 | }; -------------------------------------------------------------------------------- /V2sidebars.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | mySidebar: [ 3 | { 4 | type: "category", 5 | label: "Concepts", 6 | items: [ 7 | { 8 | type: "category", 9 | label: "Protocol Overview", 10 | items: [ 11 | { 12 | type: "autogenerated", 13 | dirname: "./versioned_docs/version-V2/concepts/protocol-overview", 14 | }, 15 | ], 16 | }, 17 | { 18 | type: "category", 19 | label: "Core Concepts", 20 | items: [ 21 | { 22 | type: "autogenerated", 23 | dirname: "./versioned_docs/version-V2/concepts/core-concepts", 24 | }, 25 | ], 26 | }, 27 | { 28 | type: "category", 29 | label: "Advanced Topics ", 30 | items: [ 31 | { 32 | type: "autogenerated", 33 | dirname: "./versioned_docs/version-V2/concepts/advanced-topics", 34 | }, 35 | ], 36 | }, 37 | // { 38 | // type: "category", 39 | // label: "Governance", 40 | // items: [ 41 | // { 42 | // type: "autogenerated", 43 | // dirname: "./versioned_docs/version-V2/concepts/governance", 44 | // }, 45 | // ], 46 | // }, 47 | ], 48 | }, 49 | ], 50 | }; 51 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "index_name": "v3-docs", 3 | "start_urls": [ 4 | "https://docs.uniswap.org/" 5 | ], 6 | "sitemap_urls": [ 7 | "https://docs.uniswap.org/sitemap.xml" 8 | ], 9 | "sitemap_alternate_links": true, 10 | "stop_urls": [], 11 | "selectors": { 12 | "lvl0": { 13 | "selector": "(//ul[contains(@class,'menu__list')]//a[contains(@class, 'menu__link menu__link--sublist menu__link--active')]/text() | //nav[contains(@class, 'navbar')]//a[contains(@class, 'navbar__link--active')]/text())[last()]", 14 | "type": "xpath", 15 | "global": true, 16 | "default_value": "Documentation" 17 | }, 18 | "lvl1": "header h1", 19 | "lvl2": "article h2", 20 | "lvl3": "article h3", 21 | "lvl4": "article h4", 22 | "lvl5": "article h5, article td:first-child", 23 | "lvl6": "article h6", 24 | "text": "article p, article li, article td:last-child" 25 | }, 26 | "strip_chars": " .,;:#", 27 | "custom_settings": { 28 | "separatorsToIndex": "_", 29 | "attributesForFaceting": [ 30 | "language", 31 | "version", 32 | "type", 33 | "docusaurus_tag" 34 | ], 35 | "attributesToRetrieve": [ 36 | "hierarchy", 37 | "content", 38 | "anchor", 39 | "url", 40 | "url_without_anchor", 41 | "type" 42 | ] 43 | }, 44 | "conversation_id": [ 45 | "833762294" 46 | ], 47 | "nb_hits": 1335 48 | } -------------------------------------------------------------------------------- /contract.hbs: -------------------------------------------------------------------------------- 1 | {{{natspec.userdoc}}} 2 | {{{natspec.devdoc}}} 3 | 4 | {{#if ownFunctions}} 5 | ## Functions 6 | {{/if}} 7 | {{#ownFunctions}} 8 | ### {{name}} 9 | ```solidity 10 | function {{name}}( 11 | {{#natspec.params}} 12 | {{#lookup ../args.types @index}}{{/lookup}} {{param}}{{#if @last}}{{else}},{{/if}} 13 | {{/natspec.params}} 14 | ) {{visibility}}{{#if outputs}} returns ({{outputs}}){{/if}} 15 | ``` 16 | {{#if natspec.userdoc}}{{natspec.userdoc}}{{/if}} 17 | {{#if natspec.devdoc}}{{natspec.devdoc}}{{/if}} 18 | {{#if natspec.params}} 19 | #### Parameters: 20 | | Name | Type | Description | 21 | | :--- | :--- | :------------------------------------------------------------------- | 22 | {{#natspec.params}} 23 | |`{{param}}` | {{#lookup ../args.types @index}}{{/lookup}} | {{ description }}{{/natspec.params}}{{/if}} 24 | {{#if natspec.returns}} 25 | #### Return Values: 26 | | Name | Type | Description | 27 | | :----------------------------- | :------------ | :--------------------------------------------------------------------------- | 28 | {{#natspec.returns}} 29 | |`{{param}}`| {{#lookup ../args.types @index}}{{/lookup}} | {{{description}}}{{/natspec.returns}}{{/if}} 30 | {{/ownFunctions}} 31 | {{#if ownEvents}} 32 | ## Events 33 | {{/if}} 34 | {{#ownEvents}} 35 | ### {{name}} 36 | ```solidity 37 | event {{name}}( 38 | {{#natspec.params}} 39 | {{#lookup ../args.types @index}}{{/lookup}} {{param}}{{#if @last}}{{else}},{{/if}} 40 | {{/natspec.params}} 41 | ) 42 | ``` 43 | {{#if natspec.userdoc}}{{natspec.userdoc}}{{/if}} 44 | {{#if natspec.devdoc}}{{natspec.devdoc}}{{/if}} 45 | {{#if natspec.params}} 46 | #### Parameters: 47 | | Name | Type | Description | 48 | | :----------------------------- | :------------ | :--------------------------------------------- | 49 | {{#natspec.params}} 50 | |`{{param}}`| {{#lookup ../args.types @index}}{{/lookup}} | {{{description}}}{{/natspec.params}}{{/if}} 51 | {{/ownEvents}} -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/01-how-uniswap-works.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 01-how-uniswap-works 3 | title: How Uniswap works 4 | tags: protocol-overview, documentation 5 | slug: / 6 | --- 7 | 8 | ![](./images/anatomy.jpg) 9 | 10 | Uniswap is an _automated liquidity protocol_ powered by a constant product formula 11 | and implemented in a system of non-upgradeable smart contracts on the [Ethereum](https://ethereum.org/) blockchain. 12 | It obviates the need for trusted intermediaries, prioritizing **decentralization**, **censorship resistance**, 13 | and **security**. Uniswap is **open-source software** licensed under the 14 | [GPL](https://en.wikipedia.org/wiki/GNU_General_Public_License). 15 | 16 | Each Uniswap smart contract, or pair, manages a liquidity pool made up of reserves of two [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens. 17 | 18 | Anyone can become a liquidity provider (LP) for a pool by depositing an equivalent value of each underlying token in return for pool tokens. These tokens track pro-rata LP shares of the total reserves, and can be redeemed for the underlying assets at any time. 19 | 20 | ![](./images/lp.jpg) 21 | 22 | Pairs act as automated market makers, standing ready to accept one token for the other as long as the “constant product” formula is preserved. This formula, most simply expressed as `x * y = k`, states that trades must not change the product (`k`) of a pair’s reserve balances (`x` and `y`). Because `k` remains unchanged from the reference frame of a trade, it is often referred to as the invariant. This formula has the desirable property that larger trades (relative to reserves) execute at exponentially worse rates than smaller ones. 23 | 24 | In practice, Uniswap applies a 0.30% fee to trades, which is added to reserves. As a result, each trade actually increases `k`. This functions as a payout to LPs, which is realized when they burn their pool tokens to withdraw their portion of total reserves. In the future, this fee may be reduced to 0.25%, with the remaining 0.05% withheld as a protocol-wide charge. 25 | 26 | ![](./images/trade.jpg) 27 | 28 | Because the relative price of the two pair assets can only be changed through trading, divergences between the Uniswap price and external prices create arbitrage opportunities. This mechanism ensures that Uniswap prices always trend toward the market-clearing price. 29 | 30 | # Further reading 31 | 32 | To see how token swaps work in practice, and to walk through the lifecycle of a swap, check out [Swaps](../02-core-concepts/01-swaps.md). Or, to see how liquidity pools work, see [Pools](../02-core-concepts/02-pools.md). 33 | 34 | Ultimately, of course, the Uniswap protocol is just smart contract code running on Ethereum. To understand how they work, head over to [Smart Contracts](../../reference/smart-contracts/01-factory.md) 35 | -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/02-ecosystem-participants.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 02-ecosystem-participants 3 | title: Ecosystem Participants 4 | tags: protocol-overview, documentation 5 | related: '/docs/v2/core-concepts/pools' 6 | --- 7 | 8 | ![](./images/participants.jpg) 9 | 10 | The Uniswap ecosystem is primarily comprised of three types of users: liquidity providers, traders, and developers. Liquidity providers are incentivized to contribute [ERC-20](https://eips.ethereum.org/EIPS/eip-20) tokens to common liquidity pools. Traders can swap these tokens for one another for a fixed [0.30% fee](../03-advanced-topics/01-fees.md) (which goes to liquidity providers). Developers can integrate directly with Uniswap smart contracts to power new and exciting interactions with tokens, trading interfaces, retail experiences, and more. 11 | 12 | In total, interactions between these classes create a positive feedback loop, fueling digital economies by defining a common language through which tokens can be pooled, traded and used. 13 | 14 | # Liquidity Providers 15 | 16 | Liquidity providers, or LPs, are not a homogenous group: 17 | 18 | - Passive LPs are token holders who wish to passively invest their assets to accumulate trading fees. 19 | 20 | - Professional LPs are focused on market making as their primary strategy. They usually develop custom tools and ways of tracking their liquidity positions across different DeFi projects. 21 | 22 | - Token projects sometimes choose to become LPs to create a liquid marketplace for their token. This allows tokens to be bought and sold more easily, and unlocks interoperability with other DeFi projects through Uniswap. 23 | 24 | - Finally, some DeFi pioneers are exploring complex liquidity provision interactions like incentivized liquidity, liquidity as collateral, and other experimental strategies. Uniswap is the perfect protocol for projects to experiment with these kinds of ideas. 25 | 26 | # Traders 27 | 28 | There are a several categories of traders in the protocol ecosystem: 29 | 30 | - Speculators use a variety of community built tools and products to swap tokens using liquidity pulled from the Uniswap protocol. 31 | 32 | - Arbitrage bots seek profits by comparing prices across different platforms to find an edge. (Though it might seem extractive, these bots actually help equalize prices across broader Ethereum markets and keep things fair.) 33 | 34 | - DAPP users buy tokens on Uniswap for use in other applications on Ethereum. 35 | 36 | - Smart contracts that execute trades on the protocol by implementing swap functionality (from products like DEX aggregators to custom Solidity scripts). 37 | 38 | In all cases, trades are subject to the same flat fee for trading on the protocol. Each is important for increasing the accuracy of prices and incentivizing liquidity. 39 | 40 | # Developers/Projects 41 | 42 | There are far too many ways Uniswap is used in the wider Ethereum ecosystem to count, but some examples include: 43 | 44 | - The open-source, accessible nature of Uniswap means there are countless UX experiments and front-ends built to offer access to Uniswap functionality. You can find Uniswap functions in most of the major DeFi dashboard projects. There are also many [Uniswap-specific tools](https://github.com/Uniswap/universe) built by the community. 45 | 46 | - Wallets often integrate swapping and liquidity provision functionality as a core offering of their product. 47 | 48 | - DEX (decentralized exchange) aggregators pull liquidity from many liquidity protocols to offer traders the best prices but splitting their trades. Uniswap is the biggest single decentralized liquidity source for these projects. 49 | 50 | - Smart contract developers use the suite of functions available to invent new DeFi tools and other various experimental ideas. See projects like [Unisocks](https://unisocks.exchange/) or [Zora](https://ourzora.com/), among many, many others. 51 | 52 | # Uniswap Team and Community 53 | 54 | The Uniswap team along with the broader Uniswap community drives development of the protocol and ecosystem. 55 | -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/04-glossary.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 04-glossary 3 | title: Glossary 4 | tags: protocol-overview, documentation 5 | --- 6 | 7 | ### Automated market maker 8 | 9 | An automated market maker is a smart contract on Ethereum that holds on-chain liquidity reserves. Users can trade against these reserves at prices set by an automated market making formula. 10 | 11 | ### Constant product formula 12 | 13 | The automated market making algorithm used by Uniswap. 14 | See [x\*y=k](#x--y--k). 15 | 16 | ### ERC20 17 | 18 | ERC20 tokens are fungibile tokens on Ethereum. Uniswap supports all standard ERC20 implementations. 19 | 20 | ### Factory 21 | 22 | A smart contract that deploys a unique smart contract for any ERC20/ERC20 trading pair. 23 | 24 | ### Pair 25 | 26 | A smart contract deployed from the Uniswap V2 Factory that enables trading between two ERC20 tokens. 27 | 28 | ### Pool 29 | 30 | Liquidity within a pair is pooled across all liquidity providers. 31 | 32 | ### Liquidity provider / LP 33 | 34 | A liquidity provider is someone who deposits an equivalent value of two ERC20 tokens into the liquidity pool within a pair. Liquidity providers take on price risk and are compensated with fees. 35 | 36 | ### Mid price 37 | 38 | The price between what users can buy and sell tokens at a given moment. In Uniswap this is the ratio of the two ERC20 token reserves. 39 | 40 | ### Price impact 41 | 42 | The difference between the mid-price and the execution price of a trade. 43 | 44 | ### Slippage 45 | 46 | The amount the price moves in a trading pair between when a transaction is submitted and when it is executed. 47 | 48 | ### Core 49 | 50 | Smart contracts that are essential for Uniswap to exist. Upgrading to a new version of core would require a liquidity migration. 51 | 52 | ### Periphery 53 | 54 | External smart contracts that are useful, but not required for Uniswap to exist. New periphery contracts can always be deployed without migrating liquidity. 55 | 56 | ### Flash swap 57 | 58 | A trade that uses the tokens being purchased before paying for them. 59 | 60 | ### `x * y = k` 61 | 62 | The constant product formula. 63 | 64 | ### Invariant 65 | 66 | The "k" value in the constant product formula 67 | -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Protocol Overview", 3 | "position": 1 4 | } -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/images/anatomy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/01-protocol-overview/images/anatomy.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/images/how-works.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/01-protocol-overview/images/how-works.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/images/lp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/01-protocol-overview/images/lp.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/images/participants.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/01-protocol-overview/images/participants.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/01-protocol-overview/images/trade.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/01-protocol-overview/images/trade.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/01-swaps.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 01-swaps 3 | title: Swaps 4 | subtitle: Learn about the core functionality of the uniswap protocol. Token Swaps. 5 | tags: swaps, documentation 6 | --- 7 | 8 | ![](./images/trade.jpg) 9 | 10 | # Introduction 11 | 12 | Token swaps in Uniswap are a simple way to trade one ERC-20 token for another. 13 | 14 | For end-users, swapping is intuitive: a user picks an input token and an output token. They specify an input amount, and the protocol calculates how much of the output token they’ll receive. They then execute the swap with one click, receiving the output token in their wallet immediately. 15 | 16 | In this guide, we’ll look at what happens during a swap at the protocol level in order to gain a deeper understanding of how Uniswap works. 17 | 18 | Swaps in Uniswap are different from trades on traditional platforms. Uniswap does not use an order book to represent liquidity or determine prices. Uniswap uses an automated market maker mechanism to provide instant feedback on rates and slippage. 19 | 20 | As we learned in [Protocol Overview](../01-protocol-overview/01-how-uniswap-works.md), each pair on Uniswap is actually underpinned by a liquidity pool. Liquidity pools are smart contracts that hold balances of two unique tokens and enforces rules around depositing and withdrawing them. 21 | 22 | This rule is the [constant product formula](../01-protocol-overview/04-glossary.md#constant-product-formula). When either token is withdrawn (purchased), a proportional amount of the other must be deposited (sold), in order to maintain the constant. 23 | 24 | ## Anatomy of a swap 25 | 26 | At the most basic level, all swaps in Uniswap V2 happen within a single function, aptly named `swap`: 27 | 28 | ```solidity 29 | function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data); 30 | ``` 31 | 32 | # Receiving tokens 33 | 34 | As is probably clear from the function signature, Uniswap requires `swap` callers to _specify how many output tokens they would like to receive_ via the `amount{0,1}Out` parameters, which correspond to the desired amount of `token{0,1}`. 35 | 36 | # Sending Tokens 37 | 38 | What’s not as clear is how Uniswap _receives_ tokens as payment for the swap. Typically, smart contracts which need tokens to perform some functionality require callers to first make an approval on the token contract, then call a function that in turn calls transferFrom on the token contract. This is _not_ how V2 pairs accept tokens. Instead, pairs check their token balances at the _end_ of every interaction. Then, at the beginning of the _next_ interaction, current balances are differenced against the stored values to determine the amount of tokens that were sent by the current interactor. See the whitepaper for a justification of why this is the case. 39 | 40 | The takeaway is that **tokens must be transferred to pairs before swap is called** (the one exception to this rule is Flash Swaps). This means that to safely use the `swap` function, it must be called from _another smart contract_. The alternative (transferring tokens to the pair and then calling `swap`) is not safe to do non-atomically because the sent tokens would be vulnerable to arbitrage. 41 | 42 | # Developer resources 43 | 44 | - To see how to implement token swaps in a smart contract read [Trading from a smart contract](../../guides/smart-contract-integration/02-trading-from-a-smart-contract.md). 45 | - To see how to execute a swap from an interface read [Trading (SDK)](../../guides/javascript-sdk/04-trading.md) 46 | -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/03-flash-swaps.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 03-flash-swaps 3 | title: Flash Swaps 4 | tags: flash-swaps, documentation 5 | --- 6 | 7 | Uniswap flash swaps allow you to withdraw up to the full reserves of any ERC20 token on Uniswap and execute arbitrary logic at no upfront cost, provided that by the end of the transaction you either: 8 | 9 | - pay for the withdrawn ERC20 tokens with the corresponding pair tokens 10 | - return the withdrawn ERC20 tokens along with a small fee 11 | 12 | Flash swaps are incredibly useful because they obviate upfront capital requirements and unnecessary order-of-operations constraints for multi-step transactions involving Uniswap. 13 | 14 | # Examples 15 | 16 | ## Capital Free Arbitrage 17 | 18 | One particularly interesting use case for flash swaps is capital-free arbitrage. It's well-known that an integral part of Uniswap's design is to create incentives for arbitrageurs to trade the Uniswap price to a "fair" market price. While game-theoretically sound, this strategy is accessible only to those with sufficient capital to take advantage of arbitrage opportunities. Flash swaps remove this barrier entirely, effectively democratizing arbitrage. 19 | 20 | Imagine a scenario where the cost of buying 1 ETH on Uniswap is 200 DAI (which is calculated by calling `getAmountIn` with 1 ETH specified as an exact output), and on Oasis (or any other trading venue), 1 ETH buys 220 DAI. To anyone with 200 DAI available, this situation represents a risk-free profit of 20 DAI. Unfortunately, you may not have 200 DAI lying around. With flash swaps, however, this risk-free profit is available for anyone to take as long as they're able to pay gas fees. 21 | 22 | ### Withdrawing ETH from Uniswap 23 | 24 | The first step is to _optimistically_ withdraw 1 ETH from Uniswap via a flash swap. This will serve as the capital that we use to execute our arbitrage. Note that in this scenario, we're assuming that: 25 | 26 | - 1 ETH is the pre-calculated profit-maximizing trade 27 | - The price has not changed on Uniswap or Oasis since our calculation 28 | 29 | It may be the case that we'd like to calculate the profit-maximizing trade on-chain at the moment of execution, which is robust to price movements. This can be somewhat complex, depending on the strategy being executed. However, one common strategy is trading as profitably as possible _against a fixed external price_. (This price may be e.g., the average execution price of one or more orders on Oasis.) If the Uniswap market price is far enough above or below this external price, the following example contains code that calculates the amount to trade over Uniswap for maximum profit: [`ExampleSwapToPrice.sol`](https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/examples/ExampleSwapToPrice.sol). 30 | 31 | ExampleSwapToPrice.sol 32 | 33 | ### Trade at External Venue 34 | 35 | Once we've obtained our temporary capital of 1 ETH from Uniswap, we now can trade this for 220 DAI on Oasis. Once we've received the DAI, we need to pay Uniswap back. We've mentioned that the amount required to cover 1 ETH is 200 DAI, calculated via `getAmountIn`. So, after sending 200 of the DAI back to the Uniswap pair, you're left with 20 DAI of profit! 36 | 37 | ## Instant Leverage 38 | 39 | Flash swaps can be used to improve the efficiency of levering up using lending protocols and Uniswap. 40 | 41 | Consider Maker in its simplest form: a system which accepts ETH as collateral and allows DAI to be minted against it while ensuring that the value of the ETH never drops below 150% of the value of the DAI. 42 | 43 | Say we use this system to deposit a principal amount of 3 ETH, and mint the maximum amount of DAI. At a price of 1 ETH / 200 DAI, we receive 400 DAI. In theory, we could lever this position up by selling the DAI for more ETH, depositing this ETH, minting the maximum amount of DAI (which would be less this time), and repeating until we've reached our desired leverage level. 44 | 45 | It's quite simple to use Uniswap as a liquidity source for the DAI-to-ETH component of this process. However, looping through protocols in this way isn't particularly elegant, and can be gas-intensive. 46 | 47 | Luckily, flash swaps enable us to withdraw the _full_ ETH amount upfront. If we wanted 2x leverage against our 3 ETH principal, we could simply request 3 ETH in a flash swap and deposit 6 ETH into Maker. This gives us the ability to mint 800 DAI. If we mint as much as we need to cover our flash swap (say 605), the remainder serves as a safety margin against price movements. 48 | 49 | # Developer resources 50 | 51 | - To see how to integrate a flash swap in your smart contract read [Using Flash Swaps](../../guides/smart-contract-integration/05-using-flash-swaps.md). 52 | 53 | -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Core Concepts", 3 | "position": 2 4 | } -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/images/anatomy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/02-core-concepts/images/anatomy.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/images/how-works.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/02-core-concepts/images/how-works.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/images/lp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/02-core-concepts/images/lp.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/images/pool.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/02-core-concepts/images/pool.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/images/trade.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/02-core-concepts/images/trade.jpg -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/images/v2_onchain_price_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/02-core-concepts/images/v2_onchain_price_data.png -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/images/v2_twap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/02-core-concepts/images/v2_twap.png -------------------------------------------------------------------------------- /docs/V2/concepts/02-core-concepts/reference/Integration-quick-start.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Redirect } from '@reach/router' 3 | 4 | export default function Redirector({ path }) { 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /docs/V2/concepts/03-advanced-topics/01-fees.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 01-fees 3 | title: Fees 4 | tags: protocol-overview, documentation 5 | --- 6 | 7 | ## Liquidity provider fees 8 | 9 | There is a **0.3%** fee for swapping tokens. **This fee is split by liquidity providers proportional to their contribution to liquidity reserves.** 10 | 11 | Swapping fees are immediately deposited into liquidity reserves. This increases the value of liquidity tokens, functioning as a payout to all liquidity providers proportional to their share of the pool. Fees are collected by burning liquidity tokens to remove a proportional share of the underlying reserves. 12 | 13 | Since fees are added to liquidity pools, the invariant increases at the end of every trade. Within a single transaction, the invariant represents `token0_pool / token1_pool` at the end of the previous transaction. 14 | 15 | There are many community-developed tools to determine returns. You can also read more in the docs about how to think about [LP returns](../03-advanced-topics/03-understanding-returns.md). 16 | ## Protocol Fees 17 | 18 | At the moment there are no protocol fees. However, it is possible for a 0.05% fee to be turned on in the future. 19 | 20 | More information about a potential future protocol fee can be found [here](https://uniswap.org/blog/uniswap-v2/#path-to-sustainability). 21 | 22 | ## Protocol Charge Calculation 23 | 24 | In the future, it is possible that a protocol-wide charge of 0.05% per trade will take effect. This represents ⅙th (16.6̅%) of the 0.30% fee. The fee is in effect if feeTo is not `address(0)` (`0x0000000000000000000000000000000000000000`), indicating that feeTo is the recipient of the charge. 25 | 26 | This amount would not affect the fee paid by traders, but would affect the amount received by liquidity providers. 27 | 28 | Rather than calculating this charge on swaps, which would significantly increase gas costs for all users, the charge is instead calculated when liquidity is added or removed. See the whitepaper for more details. 29 | -------------------------------------------------------------------------------- /docs/V2/concepts/03-advanced-topics/04-security.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 04-security 3 | title: Security 4 | tags: advanced-topics, documentation 5 | --- 6 | 7 | # Audit & Formal Verification 8 | 9 | Between January 8 and April 30, a team of six engineers reviewed and formally verified crucial components of the smart contracts for Uniswap V2. 10 | 11 | Their past work includes smart contract development on and formal verification of multi-collateral DAI. 12 | 13 | The scope of work includes: 14 | 15 | - Formal verification of the core smart contracts 16 | - Code review of core smart contracts 17 | - Numerical error analysis 18 | - Code review of periphery smart contracts (during ongoing development) 19 | 20 | The report also has a "Design Comments" section that we highly recommend for gaining a deep technical understanding of some one the choices made in Uniswap V2. 21 | 22 | > [Read the report](https://uniswap.org/audit.html) 23 | 24 | # Bug Bounty 25 | 26 | Uniswap has an open and ongoing bug [bounty program](https://uniswap.org/bug-bounty/). 27 | 28 | # Considerations when building on Uniswap 29 | 30 | When integrating Uniswap V2 into another on-chain system, particular care must be taken to avoid security vulnerabilities, avenues for manipulations, and the potential loss of funds. 31 | 32 | As a preliminary note: smart contract integrations can happen at two levels: directly with [Pair](../../reference/smart-contracts/02-pair.md) contracts, or through the [Router](../../reference/smart-contracts/06-router02.md). Direct interactions offer maximal flexibility but require the most work to get right. Mediated interactions offer more limited capabilities but stronger safety guarantees. 33 | 34 | There are two primary categories of risk associated with Uniswap V2. The first involves so-called "static" errors. These can include sending too many tokens to a pair during a swap (or requesting too few tokens back) or allowing transactions to linger in the mempool long enough for the sender's expectations about prices to no longer be accurate. 35 | 36 | One may address these errors with fairly straightforward logic checks. Executing these logic checks is the primary purpose of routers. Those who interact directly with pairs must perform these checks themselves (with the help of the [Library](../../reference/smart-contracts/04-library.md). 37 | 38 | "Dynamic" risk, the second category, involves runtime pricing. Because Ethereum transactions occur in an adversarial environment, naively written smart contracts can, and will, be exploited for profit. For example, suppose a smart contract checks the asset ratio in a Uniswap pool at runtime and trades against it, assuming that the ratio represents the "fair" or "market" price of these assets. In that case, it is highly vulnerable to manipulation. A malicious actor could, e.g., trivially insert transactions before and after the naive transaction (a so-called "sandwich" attack), causing the smart contract to trade at a radically worse price, profit from this at the trader's expense, and then return the contracts to their original state, all at a low cost. (One important caveat is that these types of attacks are mitigated by trading in highly liquid pools, or at low values.) 39 | 40 | The best way to protect against these attacks is to introduce a price oracle. An oracle is any device that returns desired information, in this case, a pair's spot price. The best "oracle" is simply a traders' off-chain observation of the prevailing price, which can be passed into the trade as a safety check. This strategy is best suited to retail trading venues where users initiate transactions on their own behalf. However, it is often the case that a trusted price observation is not available (e.g., in multi-step, programmatic interactions involving Uniswap). Without a price oracle, these interactions will be forced to trade at whatever the (potentially manipulated) rate on Uniswap is. For details on the Uniswap V2 approach to oracles, see [Oracles](../02-core-concepts/04-oracles.md). 41 | -------------------------------------------------------------------------------- /docs/V2/concepts/03-advanced-topics/05-math.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 05-math 3 | title: Math 4 | tags: advanced-topics, documentation 5 | --- 6 | 7 | This section will be expanded in the future. In the mean time, the [Uniswap V2 whitepaper](https://uniswap.org/whitepaper.pdf) has most relevant math for Uniswap V2. 8 | -------------------------------------------------------------------------------- /docs/V2/concepts/03-advanced-topics/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Advanced Topics", 3 | "position": 3 4 | } -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/01-overview.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 01-overview 3 | title: Overview 4 | tags: smart-contracts, documentation 5 | --- 6 | 7 | # UNI Address 8 | 9 | `Uni` is deployed at `0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984` on the Ethereum [mainnet](https://etherscan.io/address/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984), and the [Ropsten](https://ropsten.etherscan.io/address/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984), [Rinkeby](https://rinkeby.etherscan.io/address/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984), [Görli](https://goerli.etherscan.io/address/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984), and [Kovan](https://kovan.etherscan.io/address/0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984) testnets. It was built from commit [ab22c08](https://github.com/Uniswap/governance/commit/ab22c084bacb2636a1aebf9759890063eb6e4946). 10 | 11 | ## ABI 12 | 13 | ```typescript 14 | import Uni from '@uniswap/governance/build/Uni.json' 15 | ``` 16 | 17 | [https://unpkg.com/@uniswap/governance@1.0.2/build/Uni.json](https://unpkg.com/@uniswap/governance@1.0.2/build/Uni.json) 18 | 19 | # Timelock 20 | 21 | `Timelock` is deployed at `0x1a9C8182C09F50C8318d769245beA52c32BE35BC` on the Ethereum [mainnet](https://etherscan.io/address/0x1a9C8182C09F50C8318d769245beA52c32BE35BC), and the [Ropsten](https://ropsten.etherscan.io/address/0x1a9C8182C09F50C8318d769245beA52c32BE35BC), [Rinkeby](https://rinkeby.etherscan.io/address/0x1a9C8182C09F50C8318d769245beA52c32BE35BC), [Görli](https://goerli.etherscan.io/address/0x1a9C8182C09F50C8318d769245beA52c32BE35BC), and [Kovan](https://kovan.etherscan.io/address/0x1a9C8182C09F50C8318d769245beA52c32BE35BC) testnets. It was built from commit [ab22c08](https://github.com/Uniswap/governance/commit/ab22c084bacb2636a1aebf9759890063eb6e4946). 22 | 23 | ## ABI 24 | 25 | ```typescript 26 | import Timelock from '@uniswap/governance/build/Timelock.json' 27 | ``` 28 | 29 | [https://unpkg.com/@uniswap/governance@1.0.2/build/Timelock.json](https://unpkg.com/@uniswap/governance@1.0.2/build/Timelock.json) 30 | 31 | # GovernorAlpha 32 | 33 | `GovernorAlpha` is deployed at `0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F` on the Ethereum [mainnet](https://etherscan.io/address/0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F), and the [Ropsten](https://ropsten.etherscan.io/address/0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F), [Rinkeby](https://rinkeby.etherscan.io/address/0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F), [Görli](https://goerli.etherscan.io/address/0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F), and [Kovan](https://kovan.etherscan.io/address/0x5e4be8Bc9637f0EAA1A755019e06A68ce081D58F) testnets. It was built from commit [ab22c08](https://github.com/Uniswap/governance/commit/ab22c084bacb2636a1aebf9759890063eb6e4946). 34 | 35 | ## ABI 36 | 37 | ```typescript 38 | import GovernorAlpha from '@uniswap/governance/build/GovernorAlpha.json' 39 | ``` 40 | 41 | [https://unpkg.com/@uniswap/governance@1.0.2/build/GovernorAlpha.json](https://unpkg.com/@uniswap/governance@1.0.2/build/GovernorAlpha.json) 42 | 43 | # Miscellaneous Addresses 44 | 45 | **The following addresses only exist on the Ethereum mainnet.** 46 | 47 | The UNI merkle distributor address is `0x090D4613473dEE047c3f2706764f49E0821D256e`. 48 | 49 | The staking rewards factory address is `0x3032Ab3Fa8C01d786D29dAdE018d7f2017918e12`. 50 | 51 | The four staking rewards addresses are: 52 | 53 | ```js 54 | 0x6c3e4cb2e96b01f4b866965a91ed4437839a121a 55 | 0x7fba4b8dc5e7616e59622806932dbea72537a56b 56 | 0xa1484c3aa22a66c62b77e0ae78e15258bd0cb711 57 | 0xca35e32e7926b96a9988f61d510e038108d8068e 58 | ``` 59 | 60 | The four year-long vesting contract addresses are: 61 | 62 | ```js 63 | 0x4750c43867ef5f89869132eccf19b9b6c4286e1a 64 | 0xe3953d9d317b834592ab58ab2c7a6ad22b54075d 65 | 0x4b4e140d1f131fdad6fb59c13af796fd194e4135 66 | 0x3d30b1ab88d487b0f3061f40de76845bec3f1e94 67 | ``` 68 | 69 | The `feeToSetterVester` address is `0x18e433c7Bf8A2E1d0197CE5d8f9AFAda1A771360`. 70 | 71 | The `feeTo` address is `0xDAF819c2437a82f9e01f6586207ebF961a7f0970`. 72 | -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/03-guide-to-voting.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 03-guide-to-voting 3 | title: Beginners Guide to Voting 4 | tags: goveranance, documentation 5 | --- 6 | 7 | This guide contains everything you need to start voting in Uniswap Governance. 8 | 9 | In order to participate you will need: 10 | 11 | - [UNI Tokens](https://uniswap.org/blog/uni/) 12 | - ETH for transaction costs 13 | - A browser with [Metamask](https://metamask.io/) installed 14 | 15 | The governance [process](https://uniswap.org/docs/v2/governance/process/) begins in the [Governance Forum](https://gov.uniswap.org/), where you can find proposals under consideration, gather information about community sentiment, and engage with the community. 16 | 17 | Once a given proposal has made it through the proposal process and is ready for voting, it will appear in the Uniswap [voting dashboard](https://app.uniswap.org/#/vote) - where you can view all current and former Uniswap proposals. 18 | 19 | ![](./images/Proposals_Overview.png) 20 | 21 | If a proposal is currently live for voting, it will say `active` next to the title. Clicking the proposal will show all the necessary information, documentation, and discussion needed for a voter to make an informed decision. 22 | 23 | ![](./images/Proposal_Active.png) 24 | 25 | Once a proposal has reached the voting stage it represents real, executable code which will alter the functionality of Uniswap Governance or anything under its jurisdiction - proper care should be taken to ensure that the code represented in the proposal has been audited and is found to be in good faith. 26 | 27 | ## Delegation 28 | 29 | UNI is a tradable asset and functions like most other standard ERC20 tokens, except it has a deeper power as a voting mechanism. In order for UNI to be used as a vote, the owner must first go through the delegation process. Delegating UNI binds the voting power of your tokens to an address so it may be used to vote. This address could be yourself, or a trusted party who you believe will vote in the best interest of Uniswap Governance. 30 | 31 | A democratic consensus, in our process called “quorum”, is determined by the percentage of UNI tokens in favor of, or against, a proposal. 1% of all UNI must be cast in favor to submit a proposal, and 4% in order to pass a vote. 32 | 33 | To delegate your UNI tokens and enact their voting power, visit the [Uniswap voting dashboard](https://app.uniswap.org/#/vote) and click the button that says “Unlock Voting”. 34 | 35 | Once you click this button, you will see a screen that gives you the option to self delegate, or add a delegate address. If you wish to delegate your UNI voting power to your own address, click “Self Delegate”. 36 | 37 | ![](./images/Unlock_Voting.png) 38 | 39 | When you click “Self Delegate”, a transaction will pop up in Metamask. If this doesn’t happen, double check that metamask is connected to app.uniswap.org, turn off any popup blockers, and try again. Click confirm, and once the transaction has processed, you will see that the voting dashboard homepage has changed to show the number of votes you have, and “Delegated to: Self”. 40 | 41 | If you wish to delegate your voting power to another party, choose “Add Delegate” and enter the ethereum address of your chosen voting party. 42 | 43 | ![](./images/Delegate_To_Address.png) 44 | 45 | An important note: much like voter registration in a larger democracy, for UNI to be used in a vote it must be delegated before both the voting period and the preceding proposal period. This means if you want your vote to count, you must delegate it in anticipation of any proposal you may be interested in. 46 | 47 | If you are unsure of how best to vote and are interested in delegating your UNI voting power to another party, you can visit the [Delegation Pitch](https://gov.uniswap.org/c/delegation-pitch/6) section of the governance forum. Here parties participating in Uniswap Governance pitch their platform and voting agenda for users to read and discuss. 48 | 49 | ## Voting 50 | 51 | If you have successfully self delegated and there is an active proposal, you are ready to vote in Uniswap Governance. 52 | 53 | To cast your vote, navigate to the proposals page and click on an active proposal. 54 | 55 | ![](./images/Proposals_Overview.png) 56 | 57 | After reviewing the attached details and deciding your opinion, choose “Vote For”, or “Vote Against”. 58 | 59 | ![](./images/Proposal_Active.png) 60 | 61 | Once you’ve chosen, a window will pop up allowing you to execute the vote. 62 | 63 | ![](./images/Voting.png) 64 | 65 | When you click to cast your vote, metamask will pop up asking you to confirm your transaction. Click “submit”, wait a bit, and check that the transaction has been confirmed. 66 | 67 | ![](./images/Submitting_Vote.png) 68 | 69 | That’s it! Once your transaction has been confirmed, you will have cast your vote and participated in Uniswap Governance. 70 | -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/04-glossary.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 04-glossary 3 | title: Glossary 4 | tags: goveranance, documentation 5 | --- 6 | 7 | - **UNI:** An ERC-20 token that designates the weight of a user's voting rights. The more UNI a user has in their wallet, the more weight their delegation or vote on a proposal holds. 8 | 9 | - **Delegation:** UNI holders cannot vote or create proposals until they delegate their voting rights to an address. Delegation can be given to one address at a time, including the holder's own address. Note that delegation does not lock tokens; it simply adds votes to the chosen delegation address. 10 | 11 | - **Proposal:** A proposal is executable code that modifies the governance contract or treasury and how they work. In order to create a proposal, a user must have at least 1% (10M UNI) of all UNI delegated to their address. Proposals are stored in the "proposals" mapping of the Governor smart contract. All proposals are subject to a 7-day voting period. If the proposer does not maintain their vote weight balance throughout the voting period, the proposal may be canceled by anyone. 12 | 13 | - **Quorum:** In order for a vote to pass, it must achieve quorum of 4% of all UNI (40M) voting in the affirmative. The purpose of the quorum is to ensure that the only measures that pass have adequate voter participation. 14 | 15 | - **Voting:** Users can vote for or against single proposals once they have voting rights delegated to their address. Votes can be cast while a proposal is in the "Active" state. Votes can be submitted immediately using "castVote" or submitted later with "castVoteBySig" (For more info on castVoteBySig and offline signatures, see EIP-712). If the majority of votes (and a 4% quorum of UNI) vote for a proposal, the proposal may be queued in the Timelock. 16 | 17 | - **Voting Period:** Once a proposal has been put forward, Uniswap community members will have a seven day period (the Voting Period) to cast their votes. 18 | 19 | - **Timelock:** All governance and other administrative actions are required to sit in the Timelock for a minimum of 2 days, after which they can be implemented. 20 | -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/05-adversarial-circumstances.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 05-adversarial-circumstances 3 | title: Adversarial Circumstances 4 | tags: goveranance, documentation 5 | --- 6 | 7 | This document explores some adversarial circumstances which Uniswap Governance may encounter in the future. Its goal is to help those interested in Uniswap Governance understand the reasoning behind some of its design, its limitations, and potential avenues for growth. 8 | 9 | # Scenario 1 10 | 11 | A good faith proposal is brought to vote but is found to have an exploitable edge case. A bad faith actor uses a series of DeFi leveraging strategies to quickly buy enough UNI during the voting period to sway the vote in favor of the proposal, passing it and exploiting the vulnerability. 12 | 13 | ## Circumvention 14 | 15 | UNI voting power must be delegated to an address either entirely before a proposal has been submitted or during the proposal delay period. For now, the proposal delay is set to one block, which is about 15 seconds. A proposal delay of one block leaves no opportunity for a third party to find an exploitable edge case and opportunistically purchase uni, self delegate and sway the vote. 16 | 17 | In the future, Uniswap Governance may vote to increase the proposal delay. While there are obvious benefits to an increased proposal delay, It may introduce some potential adverse outcomes such as opportunistic edge case exploitation. 18 | 19 | # Scenario 2 20 | 21 | A bad faith proposal is crafted and submitted to vote, which is unambiguously not in the best interest of Uniswap Governance. Multiple parties collude ahead of time to corner the UNI market to force the proposal through, gain access to the UNI reserves, and drain the funds. 22 | 23 | ## Circumvention 24 | 25 | Since UNI is a freely tradable asset, anyone can attempt a governance takeover via market buying. That said, to force-pass a bad faith vote would require a minimum of 40 million UNI. If not outright impossible, this amount would be prohibitively expensive and likely cost more when accounting for price fluctuation than the net gain from the attack. 26 | 27 | If a group somehow achieved a bad faith takeover, Timelock's delay would give affected agents time to withdraw their assets from the protocol. This would also be an opportunity to fork the protocol, a path that would likely be taken by the remaining good-faith actors. 28 | 29 | # Scenario 3 30 | 31 | A single party uses a flash loan to push through a proposal, potentially creating a pseudo-DDOS attack by spamming governance with proposals and preventing effective use. 32 | 33 | ## Circumvention 34 | 35 | A delegated balance of 10 million UNI is required to submit a vote, but the balance check is set exactly one block in the past. This prevents any flash loan proposals from being created, as flash loans cannot execute outside of a single block. 36 | 37 | The proposer must also maintain a minimum balance of 10 million UNI throughout the voting period, or anyone may cancel the proposal. This balance maintenance check prevents many highly leveraged proposal techniques that may span several blocks. 38 | 39 | # Scenario 4 40 | 41 | A bad faith proposal is created, which will genuinely incentivize bad faith voting. 42 | 43 | Exmaple: "The treasury will be drained. Any votes in favor will be sent the balance of the treasury. Any votes opposed will be locked from the funds of the treasury." 44 | 45 | ## Circumvention 46 | 47 | No mechanism explicitly prevents this type of scenario, but market forces disincentivize it. 48 | 49 | Because the treasury is comprised of UNI tokens exclusively, the market would react appropriately if a vote were to pass that would jeopardize the economic viability of Uniswap Governance and the UNI token. By the time the vote would pass, UNI's price would have fallen so low as to make the attack fruitless. 50 | 51 | UNI acting as the only asset of the governance treasury disincentivizes this form of bad faith voting. Uniswap Governance may choose in the future to diversify governance assets. While there are many benefits to this path, some fringe possibilities such as incentivized bad faith voting may appear. -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Governance", 3 | "position": 4 4 | } -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Delegate_To_Address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Delegate_To_Address.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Proposal_Active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Proposal_Active.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Proposal_Executed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Proposal_Executed.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Proposals_Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Proposals_Overview.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Submitting_Vote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Submitting_Vote.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Unlock_Voting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Unlock_Voting.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Unlocking_Votes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Unlocking_Votes.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/Voting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/Voting.png -------------------------------------------------------------------------------- /docs/V2/concepts/11-governance/images/gov_diagram-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuickSwap/quickswap-docs/9a032ba43e9da03f703f5a284e1766591669dd0c/docs/V2/concepts/11-governance/images/gov_diagram-1.png -------------------------------------------------------------------------------- /docs/V2/concepts/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Concepts", 3 | "position": 1 4 | } -------------------------------------------------------------------------------- /docs/V2/guides/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Guides", 3 | "position": 1 4 | } -------------------------------------------------------------------------------- /docs/V2/guides/interface-integration/02-custom-interface-linking.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 02-custom-interface-linking 3 | title: Custom Linking 4 | tags: frontend integration, documentation 5 | --- 6 | 7 | # Query Parameters 8 | 9 | The Uniswap front-end supports URL query parameters to allow for custom linking to the Uniswap frontend. Users and developers can use these query parameters to link to the Uniswap frontend with custom prefilled settings. 10 | 11 | Each Page has specific available URL parameters that can be set. Global parameters can be used on all pages. 12 | 13 | A parameter used on an incorrect page will have no effect on frontend settings. Parameters not set with a URL parameter will be set to standard frontend defaults. 14 | 15 | ## Global 16 | 17 | | Parameter | Type | Description | 18 | | :-------- | :------- | :------------------------------- | 19 | | theme | `String` | Sets them to dark or light mode. | 20 | 21 | ### Theme Options 22 | 23 | Theme can be set as `light` or `dark`. 24 | 25 | ### Example Usage 26 | 27 | `https://app.uniswap.org/#/swap?theme=dark` 28 | 29 | ## Swap Page 30 | 31 | | Parameter | Type | Description | 32 | | :------------- | :--------------- | :--------------------------------------------------------------------- | 33 | | inputCurrency | `address` | Input currency that will be swapped for output currency. | 34 | | outputCurrency | `address or ETH` | Output currency that input currency will be swapped for. | 35 | | exactAmount | `number` | The custom token amount to buy or sell. | 36 | | exactField | `string` | The field to set custom token amount for. Must be `input` or `output`. | 37 | 38 | ### Defaults 39 | 40 | ETH defaults as the input currency. When a different token is selected for either input or output ETH will default as the opposite selected currency. 41 | 42 | ### Constraints 43 | 44 | Addresses must be valid ERC20 addresses. Slippage and amount values must be valid numbers accepted by the frontend \(or error will prevent from swapping\). Slippage can 0, or within the range 10->9999 bips \(which converts to 0%, 0.01%->99%\) 45 | 46 | When selecting ETH as the output currency a user must also choose an inputCurrency that is not ETH \(to prevent ETH being populated in both fields\) 47 | 48 | ### Setting Amounts 49 | 50 | Two parameters, exactField and exactAmount can be used to set specific token amounts to be sold or bought. Both fields must be set in the URL or there will be no effect on the settings. 51 | 52 | ### Example Usage 53 | 54 | `https://app.uniswap.org/#/swap?exactField=input&exactAmount=10&inputCurrency=0x0F5D2fB29fb7d3CFeE444a200298f468908cC942` 55 | 56 | ## Pool Page 57 | 58 | The Pool page is made up of 2 subroutes: `add`, `remove`. 59 | 60 | ### Add Liquidity 61 | 62 | | Parameter | Type | Description | 63 | | :-------- | :-------- | :----------------------------------------------------------------------------------- | 64 | | Token0 | `address` | Pool to withdraw liquidity from. \(Must be an ERC20 address with an existing token\) | 65 | | Token1 | `address` | Pool to withdraw liquidity from. \(Must be an ERC20 address with an existing token\) | 66 | 67 | ### Example Usage 68 | 69 | `https://app.uniswap.org/#/add/0x6B175474E89094C44Da98b954EedeAC495271d0F-0xdAC17F958D2ee523a2206206994597C13D831ec7` 70 | 71 | ## Remove Liquidity 72 | 73 | | Parameter | Type | Description | 74 | | :-------- | :-------- | :----------------------------------------------------------------------------------- | 75 | | Token0 | `address` | Pool to withdraw liquidity from. \(Must be an ERC20 address with an existing token\) | 76 | | Token1 | `address` | Pool to withdraw liquidity from. \(Must be an ERC20 address with an existing token\) | 77 | 78 | Dash seperated. 79 | 80 | ### Example Usage 81 | 82 | `https://app.uniswap.org/#/remove/0x6B175474E89094C44Da98b954EedeAC495271d0F-0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2` 83 | -------------------------------------------------------------------------------- /docs/V2/guides/interface-integration/03-iframe-integration.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: 03-iframe-integration 3 | title: Iframe Integration 4 | tags: frontend integration, documentation 5 | --- 6 | 7 | Uniswap can be used within other sites as an iframe. An iframe shows an exact version of the uniswap frontend site and can have custom prefilled settings. 8 | 9 | # Why You May Want This 10 | 11 | Integrating the Uniswap site directly into your web application can be useful for a variety of reasons. 12 | 13 | The interface allows users to buy, sell, send, or provide liquidity for ERC20 tokens. An iframe integration may be useful if your application provides services around these ERC20 tokens. \(For example, users can buy DAI through a Uniswap iframe on your site, then allow users to lend that DAI on your site\). 14 | 15 | It can also be useful if your application requires users to acquire some token in order to use some service \(For example, allow users to buy "REP" token so they can engage in prediction markets on the Augur Dapp\). 16 | 17 | # iframe vs. custom UI 18 | 19 | One benefit of an iframe integration is that the your site will automatically keep up with any improvements/additions to the site. After the initital integration is setup no further work is needed to pull in updates as the exchange site is updated over time. 20 | 21 | # Example 22 | 23 | ``` 24 | iframe src="https://app.uniswap.org/#/swap?exactField=input&exactAmount=10&inputCurrency=0x6b175474e89094c44da98b954eedeac495271d0f" height="660px" width="100%" 25 | style=" 26 | border: 0; 27 | margin: 0 auto; 28 | margin-bottom: .5rem; 29 | display: block; 30 | border-radius: 10px; 31 | max-width: 960px; 32 | min-width: 300px; 33 | " 34 | ``` 35 | 36 | An example of an Iframe integration can be found on the FOAM site [https://map.foam.space/](https://map.foam.space/#/at/?lng=-74.0045300&lat=40.6771800&zoom=5.00) 37 | 38 | To see the Iframe click the dropdown in the top right and click "get foam". 39 | 40 | # Add To Your Site 41 | 42 | To include a Uniswap iframe within your site just add an iframe element within your website code and link to the Uniswap frontent. 43 | 44 | Linking to a ETH <-> DAI swap page would look something like this. To link to a token of your choice replace the address after "outputCurrency" with the token address of the token you want to link to. 45 | 46 | ```text 47 |