简体   繁体   中英

What's the different with UniSwap Router and UniSwap Factory?

People can swap token though with UniSwap Router(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) and also UniSwap Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f)

But what's the different? Why there are two contract exists for swaping token?

I saw there are many old txs on UniSwap Factory , Seems UniSwap Factory is not much active than UniSwap Router , Is it mean UniSwap Router is a new tech to replace UniSwap Factory ?

  • Factory is the core of the protocol and is responsible for creating new pair contracts
  • Router defines how trades are being carried over different pair contracts (pools) - how many hops, which tokens, etc. but cannot change the core logic - only how trades are routed
  • New routers can be deployed and they are not associated with the exchange; optimizing routers leads to a more efficient trading price impact

Here is a Python dataclass that explains some aspects of Uniswap v2 deployment .

With the Uniswap Factory, it's purpose is actually in it's name. It is a Factory contract which allows you to create uniswap liquidity pair contracts. And from the Uniswap Factory you can fetch the pair address of any ERC20 token that has an active pair.

The Uniswap Router on the other hand contains functions that allow trading of ERC20 tokens as well as adding/removing liquidity and hence essentially acts as the primary "back-end" for the Uniswap interface. More info about the router can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM