Coder Social home page Coder Social logo

second-state / how_to_deploy_uniswap Goto Github PK

View Code? Open in Web Editor NEW
140.0 6.0 95.0 668 KB

Detailed instructions on how to deploy Uniswap on an Ethereum compatible blockchain

License: Apache License 2.0

JavaScript 49.98% Solidity 25.57% Python 23.30% Shell 1.14%

how_to_deploy_uniswap's Introduction

//** Please note this is a draft and this code is under heavy development. Not to be used in production **

How to deploy Uniswap


Housekeeping

The code in this section is packaged up into a single ./utils/housekeeping.sh file for your convenience. Below are the details of all of the ./utils/housekeeping.sh commands for your understanding.

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install npm
npm install fs
npm install web3
npm install truffle-hdwallet-provider
sudo apt-get install apache2
# install Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

Update version of node

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

Clone the Uniswap Interface code using Git.

cd ~
git clone https://github.com/Uniswap/uniswap-interface.git

Change into the Uniswap Interface directory.

cd ~
cd uniswap-interface

Now, whilst in the ~/uniswap-interface directory, clone the "How To Install Uniswap" code using Git.

git clone https://github.com/second-state/how_to_deploy_uniswap.git

Change into the how_to_deploy_uniswap/ directory.

cd how_to_deploy_uniswap/

Accounts

Create 3 Ethereum compatible addresses using any method that you are comfortable with i.e. web3js etc.

Now paste the private and public keys of those addresses into the installation_data.json file as shown below.

vi ~/uniswap-interface/how_to_deploy_uniswap/installation_data.json

Here is an example of the private_key and public_key sections of that file.

  "private_key": {
    "alice": "your_new_key_here",
    "bob": "your_new_key_here",
    "charlie": "your_new_key_here"
  },
  "public_key": {
    "alice": "your_new_key_here",
    "bob": "your_new_key_here",
    "charlie": "your_new_key_here"
  }

You will need to fund these accounts with network tokens. So depending on your network, please go ahead and send at least 20 network tokens (from a Faucet etc.) to all three of these accounts.

Now place the RPC URL to your Ethereum compatible network in that same installation_data.json file.

vi ~/uniswap-interface/how_to_deploy_uniswap/installation_data.json

Here is an example of the rpc_endpoint section of that file.

"provider": {
	"rpc_endpoint": "http://rpc_url:port"
}

V1

Now run the Uniswap V1 smart contract installer.

cd ~/uniswap-interface/how_to_deploy_uniswap/uniswap_v1
node deploy_uniswap_v1.js

If you open the ../installation_data.json file, you will see that the Uniswap V1 contract addresses and the Alice and Bob (ERC20 and ERC20 Exchange) addresses have been automatically filled in.

"contract_address": {
    "uniswap_factory": "0x2DF5e651be537bB564005340EA5D8f6fA763b530",
    "weth": "",
    "uniswap_exchange_template": "0x68Fc886B0ca3D65AE8Ad21Fde01d8C4E2AD9d86c",
    "alice_exchange": "0x4A8f21726434951f5C1baA0F067d50fdA2a297e2",
    "bob_exchange": "0x61d82A90455EC7cDEdF7cF7F5267c0aF6657c626",
    "alice_erc20_token": "0x240Fc9370709bad1F4402186701C76e36a20848b",
    "bob_erc20_token": "0x09cB0AE6dddF68Aaad81b8f6B83c30dfdaA65b48",
    "uniswap_v2": "",
    "multicall": "",
    "migrator": "",
    "router": "",
    "ens_registry": "",
    "unisocks": ""
}

V2

Now run the Uniswap V2 smart contract installation script.

cd ~/uniswap-interface/how_to_deploy_uniswap/uniswap_v2

Important Warning

The feeToSetter has been hard-coded to the Charlie account inside the deploy_uniswap_v2.js script (that you are about to run). The feeToSetter is the account that is responsible for future profit that result from trades. This account is set to Charlie for demonstration purposes only. If you are running this script, you are responsible for correctly setting the feeToSetter account up and managing its private keys.

node deploy_uniswap_v2.js

Congratulations, the smart contracts are all deployed. You will see that all of the contract addresses in the installation_data.json file have been filled out.

"contract_address": {
	"uniswap_factory": "0x2DF5e651be537bB564005340EA5D8f6fA763b530",
	"weth": "0x043c7D26e381CB1bb025b4CE0A6E0C63D7767866",
	"uniswap_exchange_template": "0x68Fc886B0ca3D65AE8Ad21Fde01d8C4E2AD9d86c",
	"alice_exchange": "0x4A8f21726434951f5C1baA0F067d50fdA2a297e2",
	"bob_exchange": "0x61d82A90455EC7cDEdF7cF7F5267c0aF6657c626",
	"alice_erc20_token": "0x240Fc9370709bad1F4402186701C76e36a20848b",
	"bob_erc20_token": "0x09cB0AE6dddF68Aaad81b8f6B83c30dfdaA65b48",
	"uniswap_v2": "0x0fA47ae2b7Dee29571678580BBe9A8A88436E393",
	"multicall": "0x50F0463B01119Aa954ce40a7f21ecf4573E7605a",
	"migrator": "0x3cBe562Fd434aF61601937895000A91D014a49e7",
	"router": "0x5c192a0155D504772F3bc2689aF69116E098ECAa",
	"ens_registry": "0xA07e2676495eEDEdb5A50b9ba020Ba3A98f87D4E"
}

Interface

Now change into the uniswap_interface directory.

cd ~/uniswap-interface/how_to_deploy_uniswap/uniswap_interface

Now run the modify_addresses.py script

python3 modify_addresses.py

Change back to the Uniswap directory so we can build the application.

cd ~/uniswap-interface/

An ls should look like this (no build folder yet)

LICENSE  README.md  cypress  cypress.json  how_to_deploy_uniswap  node_modules  package.json  public  src  tsconfig.json  yarn.lock

Build the application's dependencies using the following command.

yarn

Chain id changes (optional)

ChainID Please note: the chainId for each network is actuall set inside the Uniswap SDK's code You may not need/want to change this but if you do i.e. you are using chainId 2 instead of 1 please perform the following tasks

Open the how_to_deploy_uniswap/uniswap_interface/change_chain_id.py file and edit the one_to_two and one_to_two_II and new_value and new_value_II variables to suite your situation i.e. changing from chainId 1 to 2 would look like this.

one_to_two = "MAINNET = 1"
one_to_two_II = "chainId\:\"1\""
one_to_two_III = "chainId:1"
one_to_two_IV ="1: 'mainnet'"

new_value = "MAINNET = 2"
new_value_II = "chainId\:\"2\""
new_value_III = "chainId:2"
new_value_IV = "2: 'mainnet'"

Be sure to escape / and . and : (as shown above) because these will break the command when executed.

Now run this file

python3.6 change_chain_id.py

In addition to the above change, if your chainId is not standard i.e. your mainnet is not 1, then you must also modify the export declare const WETH section of the node_modules/@uniswap/sdk/dist/entities/token.d.ts file. The first position in this enum 1: Token; represents the MAINNET so go ahead and change it to suit your needs. In our case 1: Token;

export declare const WETH: {
    1: Token;
    3: Token;
    4: Token;
    5: Token;
    42: Token;
};

In addition to the above change, again if your chainId is not standard then go ahead and also update the src/utils/index.ts file in the following two places i.e. 1: '', and ETHERSCAN_PREFIXES[1]

const ETHERSCAN_PREFIXES: { [chainId in ChainId]: string } = {
  1: '',
  3: 'ropsten.',
  4: 'rinkeby.',
  5: 'goerli.',
  42: 'kovan.'
}
const prefix = `https://${ETHERSCAN_PREFIXES[chainId] || ETHERSCAN_PREFIXES[1]}etherscan.io`

In addition to the above change, another file in the Uniswap Interface source code specifies supportedChainIds. If your chainId is not in the list then add it like this vi src/connectors/index.ts

export const injected = new InjectedConnector({
  supportedChainIds: [1, 2, 3, 4, 5, 42]
})

In that same file, also change the 1 to your chainId in line 14 i.e.

export const NETWORK_CHAIN_ID: number = parseInt(process.env.REACT_APP_CHAIN_ID ?? '1')

Hopefully you did not have to change the chainId. If you are all set then go ahead and build the Uniswap Interface application


Disable Unisocks (Optional)

This Unisocks contract, this other Uniswap contract and the hard-coded Unisocks metadata are deployed against real-world assets (socks) and therefore it makes no sense to include this in the build. In order to disable the Unisocks component of this build we need to do the following updates to the code.

useContract.ts

  • Comment out the import UNISOCKS_ABI from '../constants/abis/unisocks.json' line in the src/hooks/useContract.ts file

  • Comment out the useSocksController section of the ./src/hooks/useContract.ts file

export function useSocksController(): Contract | null {
  const { chainId } = useActiveWeb3React()
  return useContract(
    chainId === ChainId.MAINNET ? '0x65770b5283117639760beA3F867b69b3697a91dd' : undefined,
    UNISOCKS_ABI,
    false
  )
}

useSocksBalance.ts

  • mv src/hooks/useSocksBalance.ts src/hooks/useSocksBalance.ts.orig

src/components/Web3Status/index.tsx

  • Comment out import { useHasSocks } from '../../hooks/useSocksBalance' and const hasSocks = useHasSocks() which are in the src/components/Web3Status/index.tsx file
  • Also comment out this block of code
const SOCK = (
  <span role="img" aria-label="has socks emoji" style={{ marginTop: -4, marginBottom: -4 }}>
    🧦
  </span>
)

from the src/components/Web3Status/index.tsx file

  • Also delete the {hasSocks ? SOCK : null} line of code which is also in the src/components/Web3Status/index.tsx file

Environment variables

Open the .env and .env.production files and update the REACT_APP_CHAIN_ID and the REACT_APP_NETWORK_URL to suite your needs.

Change the hard-coded RPC

Open the how_to_deploy_uniswap/uniswap_interface/change_rpc.py file and edit the following variables to suite your needs.

infura = "https\:\/\/mainnet\.infura\.io\/v3\/faa4639b090f46499f29d894da0551a0"
new_rpc = "http\:\/\/oasis-ssvm-demo\.secondstate\.io\:8545"

Be sure to escape / and . and : (as shown above) because these will break the command when executed.

Now run this script

python3.6 change_rpc.py

Build

Modify any addresses which are lurking in dependencies etc.

cd how_to_deploy_uniswap/uniswap_interface/ && python3 modify_addresses.py
cd ../../
yarn run build

This will generate a new build directory as well as some new files, as shown below.

  450.29 KB  build/static/js/4.047da443.chunk.js
  276.48 KB  build/static/js/5.5c7ecd7f.chunk.js
  155.14 KB  build/static/js/9.1f17fe1e.chunk.js
  95.38 KB   build/static/js/main.38d70569.chunk.js
  67.14 KB   build/static/js/0.1e3e94eb.chunk.js
  66.33 KB   build/static/js/6.e890ef53.chunk.js
  6.56 KB    build/static/js/1.5f3a35e8.chunk.js
  1.24 KB    build/static/js/runtime-main.c8bb7174.js
  907 B      build/static/css/4.996ad921.chunk.css
  165 B      build/static/js/8.81f9e545.chunk.js
  164 B      build/static/js/7.494e051e.chunk.js

You will remember that we just ran the modify_addresses.py script. We are now going to run that again (but this time, over the build folder, which the above build command just created). This is just to make sure that there are no addresses which relate to the original Uniswap source code (but rather our newly created contract addresses).

cd how_to_deploy_uniswap/uniswap_interface/ && python3 modify_addresses.py

Now run the change_rpc.py again also.

python3.6 change_rpc.py

If you are modifying the chainId (if you did the work above), please run this again.

WARNING only run this if you are using a different chainId !

python3.6 change_chain_id.py

Now, we return to the Uniswap directory to copy the modified build files over to our Apache2 server, where they will be deployed for the end users.

cd ../../ && sudo cp -rp build/* /var/www/html/ && sudo /etc/init.d/apache2 restart

Uniswap

More

If code changes are made in the source files (i.e. a console.log statement etc.), the following command is a one-stop-shop for a restart

yarn run build && cd how_to_deploy_uniswap/uniswap_interface/ && python3 modify_addresses.py && cd ../../ && sudo cp -rp build/* /var/www/html/ && sudo /etc/init.d/apache2 restart

v1 For official information, please see the official documentation of Uniswap V1

V2 For official information, please see the official documentation of Uniswap V2

how_to_deploy_uniswap's People

Contributors

tpmccallum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

how_to_deploy_uniswap's Issues

Uniswap + Metamask + Binance Smart Chain

Tried to deploy and got this errors, what prices should I increase?

Name set to: Wrapped Ether
Deploying Multicall now, please wait ...
0x4b545c9dbbec85c34631bfabf6d574628318efc0242f05a8ca204792d4c905a2
Transaction hash: 0x4b545c9dbbec85c34631bfabf6d574628318efc0242f05a8ca204792d4c905a2
Deploying Migrator now, please wait ...
(node:30869) UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit.
at Object.callback (/root/node_modules/web3-core-method/src/index.js:333:46)
at sendTxCallback (/root/node_modules/web3-core-method/src/index.js:484:29)
at /root/node_modules/web3-core-requestmanager/src/index.js:147:9
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:15:549917
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:1:140344
at d (/root/node_modules/truffle-hdwallet-provider/dist/index.js:1:206203)
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:1:206256
at t.default (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:564796)
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:1:206574
at s (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:549761)
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:15:632708
at t.i.onreadystatechange (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:748948)
at t.e.dispatchEvent (/root/node_modules/truffle-hdwallet-provider/dist/index.js:1:142373)
at t._setReadyState (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:753708)
at t._onHttpResponseEnd (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:756793)
at IncomingMessage. (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:756051)
at IncomingMessage.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:30869) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:30869) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: The contract code couldn't be stored, please check your gas limit.
at Object.callback (/root/node_modules/web3-core-method/src/index.js:333:46)
at sendTxCallback (/root/node_modules/web3-core-method/src/index.js:484:29)
at /root/node_modules/web3-core-requestmanager/src/index.js:147:9
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:15:549917
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:1:140344
at d (/root/node_modules/truffle-hdwallet-provider/dist/index.js:1:206203)
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:1:206256
at t.default (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:564796)
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:1:206574
at s (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:549761)
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:15:632708
at t.i.onreadystatechange (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:748948)
at t.e.dispatchEvent (/root/node_modules/truffle-hdwallet-provider/dist/index.js:1:142373)
at t._setReadyState (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:753708)
at t._onHttpResponseEnd (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:756793)
at IncomingMessage. (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:756051)
at IncomingMessage.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
0xcabf4a9efd495c30006a7bab274edae212d75fde87d22aaf7430fce4b4baa33b
Transaction hash: 0xcabf4a9efd495c30006a7bab274edae212d75fde87d22aaf7430fce4b4baa33b
Contract address: 0x6c0EdD87dd4bb0b9f416A1bD6Fa90d4900255B71
0x6c0EdD87dd4bb0b9f416A1bD6Fa90d4900255B71
Data written to file
(node:30869) UnhandledPromiseRejectionWarning: Error: invalid address (arg="_router", coderType="address", value="")
at Object.throwError (/root/node_modules/ethers/utils/errors.js:68:17)
at CoderAddress.encode (/root/node_modules/ethers/utils/abi-coder.js:467:20)
at /root/node_modules/ethers/utils/abi-coder.js:605:59
at Array.forEach ()
at pack (/root/node_modules/ethers/utils/abi-coder.js:604:12)
at CoderTuple.encode (/root/node_modules/ethers/utils/abi-coder.js:764:16)
at AbiCoder.encode (/root/node_modules/ethers/utils/abi-coder.js:897:77)
at ABICoder.encodeParameters (/root/node_modules/web3-eth-abi/src/index.js:96:27)
at /root/node_modules/web3-eth-contract/src/index.js:426:24
at Array.map ()
at Object._encodeMethodABI (/root/node_modules/web3-eth-contract/src/index.js:425:12)
at Object._processExecuteArguments (/root/node_modules/web3-eth-contract/src/index.js:741:39)
at Object._executeMethod (/root/node_modules/web3-eth-contract/src/index.js:766:54)
at /root/uniswap-interface/how_to_deploy_uniswap/uniswap_v2/deploy_uniswap_v2.js:251:10
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:30869) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Error: invalid address

Hi.
When I tried to run the js file to deploy the V2 contracts, I got the following error:

(node:8924) Error: invalid address (argument="address", value="", code=INVALID_ARGUMENT, version=address/5.3.0) (argument="_factoryV1", value="", code=INVALID_ARGUMENT, version=abi/5.0.7)
at Logger.makeError (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\logger\lib\index.js:187:21)
at Logger.throwError (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\logger\lib\index.js:196:20)
at Logger.throwArgumentError (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\logger\lib\index.js:199:21)
at AddressCoder.Coder._throwError (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\abi\lib\coders\abstract-coder.js:40:16)
at AddressCoder.encode (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\abi\lib\coders\address.js:29:18)
at D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\abi\lib\coders\array.js:71:19
at Array.forEach ()
at Object.pack (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\abi\lib\coders\array.js:57:12)
at TupleCoder.encode (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\abi\lib\coders\tuple.js:36:24)
at AbiCoder.encode (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules@ethersproject\abi\lib\abi-coder.js:86:15)
at ABICoder.encodeParameters (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules\web3-eth-abi\lib\index.js:121:27)
at D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules\web3-eth-contract\lib\index.js:439:20
at Array.map ()
at Object._encodeMethodABI (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules\web3-eth-contract\lib\index.js:438:8)
at Object._processExecuteArguments (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules\web3-eth-contract\lib\index.js:701:39)
at Object._executeMethod (D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\node_modules\web3-eth-contract\lib\index.js:720:68)
at D:\Uniswap Implementation\how_to_deploy_uniswap-master\uniswap_v2\deploy_uniswap_v2.js:251:10
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:8924) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:96:32)

Could you please advise what is the cause of this error ?

Error: The contract code couldn't be stored, please check your gas limit.

/root/node_modules/web3-core-helpers/lib/errors.js:87
var error = new Error(message);
^

Error: The contract code couldn't be stored, please check your gas limit.
at Object.TransactionError (/root/node_modules/web3-core-helpers/lib/errors.js:87:21)
at Object.ContractCodeNotStoredError (/root/node_modules/web3-core-helpers/lib/errors.js:95:21)
at /root/node_modules/web3-core-method/lib/index.js:337:49
at processTicksAndRejections (node:internal/process/task_queues:96:5) {

How to solve it?thanks

Getting invalid address

Data written to file (node:5761) UnhandledPromiseRejectionWarning: Error: invalid address (argument="address", value="", code=INVALID_ARGUMENT, version=address/5.0.10) (argument="_factoryV1", value="", code=INVALID_ARGUMENT, version=abi/5.0.7) at Logger.makeError (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/logger/lib/index.js:179:21) at Logger.throwError (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/logger/lib/index.js:188:20) at Logger.throwArgumentError (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/logger/lib/index.js:191:21) at AddressCoder.Coder._throwError (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/abi/lib/coders/abstract-coder.js:40:16) at AddressCoder.encode (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/abi/lib/coders/address.js:29:18) at /Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/abi/lib/coders/array.js:71:19 at Array.forEach (<anonymous>) at Object.pack (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/abi/lib/coders/array.js:57:12) at TupleCoder.encode (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/abi/lib/coders/tuple.js:36:24) at AbiCoder.encode (/Users/yudiz/Documents/Practise/uniswap/node_modules/@ethersproject/abi/lib/abi-coder.js:86:15) at ABICoder.encodeParameters (/Users/yudiz/Documents/Practise/uniswap/node_modules/web3-eth-abi/lib/index.js:121:27) at /Users/yudiz/Documents/Practise/uniswap/node_modules/web3-eth-contract/lib/index.js:439:20 at Array.map (<anonymous>) at Object._encodeMethodABI (/Users/yudiz/Documents/Practise/uniswap/node_modules/web3-eth-contract/lib/index.js:438:8) at Object._processExecuteArguments (/Users/yudiz/Documents/Practise/uniswap/node_modules/web3-eth-contract/lib/index.js:701:39) at Object._executeMethod (/Users/yudiz/Documents/Practise/uniswap/node_modules/web3-eth-contract/lib/index.js:720:68) at /Users/yudiz/Documents/Practise/uniswap/uniswap-interface/how_to_deploy_uniswap/uniswap_v2/deploy_uniswap_v2.js:251:10 at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:93:5) (node:5761) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 78) (node:5761) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any solution? Deploying v2
Screenshot 2021-02-26 at 5 53 42 PM

gaz limit problem

Hi,
When try to deploy v2, their is an error.
I tryed to incread the gaz limit in deploy_uniswap_v2, as i saw a closed issue in the repo. (from 4700000 to 8000000) But doesn't change.
here is the error and new code

Maybe i didn't change the right place? Any idea how to make it work?

Thanks

Deploying Multicall now, please wait ...
0x481e3894ac8f062eaf4041d88664b6dc862780080b26565da9fc878598d2828d
Transaction hash: 0x481e3894ac8f062eaf4041d88664b6dc862780080b26565da9fc878598d2828d
(node:5155) UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit.
    at Object.TransactionError (/root/test/v2/uniswap-interface/node_modules/web3-core-helpers/lib/errors.js:87:21)
    at Object.ContractCodeNotStoredError (/root/test/v2/uniswap-interface/node_modules/web3-core-helpers/lib/errors.js:95:21)
    at /root/test/v2/uniswap-interface/node_modules/web3-core-method/lib/index.js:335:49
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5155) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 18)
(node:5155) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: The contract code couldn't be stored, please check your gas limit.
    at Object.TransactionError (/root/test/v2/uniswap-interface/node_modules/web3-core-helpers/lib/errors.js:87:21)
    at Object.ContractCodeNotStoredError (/root/test/v2/uniswap-interface/node_modules/web3-core-helpers/lib/errors.js:95:21)
    at /root/test/v2/uniswap-interface/node_modules/web3-core-method/lib/index.js:335:49
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  receipt: {
    blockHash: '0x9b3d13e58ea23a1467bf0c07b8d21cb347febb086b87fd854b94f2de53b42592',
    blockNumber: 8627389,
    contractAddress: '0x5D0836E8721471C7329b2Ede2c385f1EF97E7E3a',
    cumulativeGasUsed: 4700000,
    from: '0x101447c86a76fc22330f332b0ed147eaa8edf597',
    gasUsed: 4700000,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    status: false,
    to: null,
    transactionHash: '0x481e3894ac8f062eaf4041d88664b6dc862780080b26565da9fc878598d2828d',
    transactionIndex: 0,
    type: '0x0',
    events: {}
  }
}

deploy_uniswap_v2.js

// Uniswap V2 Multicall
    // V2 Multicall Deployment
    console.log("Deploying Multicall now, please wait ...");
    let uniswapMulticall;
    uniswapMulticall = await web3.eth.sendTransaction({
        from: accounts[2],
        data: uniswapMulticallBytecode
    }); // Charlie accounts[2] is the owner
    let uniswapMulticallInstance = new web3.eth.Contract(uniswapMulticallAbi, uniswapMulticall.contractAddress);
    uniswapMulticallInstance.deploy({
            data: uniswapMulticallBytecode
        })
        .send({
            from: accounts[2],
            gas: 8000000,
            gasPrice: '30000000000'
        }, function(error, transactionHash) {
            console.log(transactionHash);
        })
        .on('error', function(error) {
            console.log(error);
        })
        .on('transactionHash', function(transactionHash) {
            console.log("Transaction hash: " + transactionHash);
        })
        .on('receipt', function(receipt) {
            console.log("Contract address: " + receipt.contractAddress) // contains the new contract address
            data_object.contract_address.multicall = receipt.contractAddress;
            let data_to_write = JSON.stringify(data_object, null, 2);
            write_data(data_to_write);
        })
        .then(function(newContractInstance) {
            console.log(newContractInstance.options.address) // instance with the new contract address
        });

Uniswap + Metamask + BSC (Binance smart chain)

When deploying

node deploy_uniswap_v2.js

got the error below but the transaction is successful, what is wrong?

here I see success
https://testnet.bscscan.com/tx/0x27125601163a7aeb1a34f06fdeac20606c2b1d53c1346507e9cbe49beb301e3f

but I get this error
...
Data written to file
feeTo is currently set to: 0x0000000000000000000000000000000000000000
feeToSetter is currently set to: 0xc0a4272bb5df52134178Df25d77561CfB17ce407
Deploying ROUTER2 now, please wait ...
0x27125601163a7aeb1a34f06fdeac20606c2b1d53c1346507e9cbe49beb301e3f
Transaction hash: 0x27125601163a7aeb1a34f06fdeac20606c2b1d53c1346507e9cbe49beb301e3f
(node:17063) UnhandledPromiseRejectionWarning: Error: transaction underpriced
at /root/node_modules/truffle-hdwallet-provider/dist/index.js:15:632675
at t.i.onreadystatechange (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:748948)
at t.e.dispatchEvent (/root/node_modules/truffle-hdwallet-provider/dist/index.js:1:142373)
at t._setReadyState (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:753708)
at t._onHttpResponseEnd (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:756793)
at IncomingMessage. (/root/node_modules/truffle-hdwallet-provider/dist/index.js:15:756051)
at IncomingMessage.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:17063) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17063) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Contract address: 0x49985360d54F5C850F04FD0D925ae2762E4ddbEb
0x49985360d54F5C850F04FD0D925ae2762E4ddbEb
Data written to file
Name set to: Wrapped Ether
Symbol set to: WETH
Total Supply set to: 0

deploying using hard-hate locally?

Hello, nice guide, im trying to deploy uniswap locally, but i dont know how to change the chain-id since im not getting any info regarding it after running npx hardhat node

β€œThe contract code couldn't be stored, please check your gas limitβ€œ

Deploying Multicall now, please wait ... 0x4114c1e6fd314f7b35d546a53bbccc8e80000e6b842768505a858c2313ce3e06 Transaction hash: 0x4114c1e6fd314f7b35d546a53bbccc8e80000e6b842768505a858c2313ce3e06 Error: The contract code couldn't be stored, please check your gas limit. at Object.callback (/root/eth/uniswap-interface/node_modules/web3-core-method/src/index.js:333:46) at sendTxCallback (/root/eth/uniswap-interface/node_modules/web3-core-method/src/index.js:484:29) at /root/eth/uniswap-interface/node_modules/web3-core-requestmanager/src/index.js:147:9 at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:549917 at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:140344 at d (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:206203) at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:206256 at t.default (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:564796) at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:206574 at s (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:549761) at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:632708 at t.i.onreadystatechange (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:748948) at t.e.dispatchEvent (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:142373) at t._setReadyState (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:753708) at t._onHttpResponseEnd (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:756793) at IncomingMessage.<anonymous> (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:756051) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19) (node:17706) UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit. at Object.callback (/root/eth/uniswap-interface/node_modules/web3-core-method/src/index.js:333:46) at sendTxCallback (/root/eth/uniswap-interface/node_modules/web3-core-method/src/index.js:484:29) at /root/eth/uniswap-interface/node_modules/web3-core-requestmanager/src/index.js:147:9 at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:549917 at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:140344 at d (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:206203) at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:206256 at t.default (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:564796) at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:206574 at s (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:549761) at /root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:632708 at t.i.onreadystatechange (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:748948) at t.e.dispatchEvent (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:1:142373) at t._setReadyState (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:753708) at t._onHttpResponseEnd (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:756793) at IncomingMessage.<anonymous> (/root/eth/uniswap-interface/node_modules/truffle-hdwallet-provider/dist/index.js:15:756051) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19) (node:17706) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:17706) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Deploy Multicall or Migrator contract always report this error, increase gas did not solve the problem,
any suggestions?

Running uniswap with private blockchain

Hello, i can't seem to be able to get uniswap interface to work with my private Geth node, i dont quite understand the change_rpc.py file
Can anyone help me, just what i'll have to do?

deployed uniswap issue with metamask conneted

After initial metamask connection, balance is displayed on dApp, but after maybe 15-20 second all balances displayed in dApp ho to zero and stay like that stopping me to do any activity inside dApp

Just connected...

image

After 15 seconds...

image

yarn run build error

Hi,
During the yarn run build of the front end, i have an error

ts-gen: Writing file: src/types/v3/factories/ITickLens__factory.ts
ts-gen: Writing file: src/types/v3/factories/IV3Migrator__factory.ts
ts-gen: Writing file: src/types/v3/commons.ts
ts-gen: Writing file: src/types/v3/index.ts
ts-gen: πŸ’Ž All done! Generated files: 80
Creating an optimized production build...
Failed to compile.

/root/uniswap-interface/src/state/swap/hooks.ts
TypeScript error in /root/uniswap-interface/src/state/swap/hooks.ts(93,3):
Duplicate identifier ''''.  TS2300

    91 |   '': true, // v2 factory
    92 |   '0xf164fC0Ec4E93095b804a4795bBe1e041497b92a': true, // v2 router 01
  > 93 |   '': true, // v2 router 02
       |   ^
    94 | }
    95 |
    96 | /**


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any idea where it come from?

Thanks

Dex Aggregator

How do we add in Liquidity Source for 0x, Aave, 1inch or Uniswap V2 etc for more liquidity sources provider rather than just depend on our own liquidity pool?

Something like a DEX Aggregator like 1inch.

Means the swap will always work as long there is token at Uniswap or 0x or Aave, Sushi etc

It should behave like 1inch.

node deploy_uniswap_v2.js

"contract_address": {
"uniswap_factory": "0x2DF5e651be537bB564005340EA5D8f6fA763b530",
"weth": "0x043c7D26e381CB1bb025b4CE0A6E0C63D7767866",
"uniswap_exchange_template": "0x68Fc886B0ca3D65AE8Ad21Fde01d8C4E2AD9d86c",
"alice_exchange": "0x4A8f21726434951f5C1baA0F067d50fdA2a297e2",
"bob_exchange": "0x61d82A90455EC7cDEdF7cF7F5267c0aF6657c626",
"alice_erc20_token": "0x240Fc9370709bad1F4402186701C76e36a20848b",
"bob_erc20_token": "0x09cB0AE6dddF68Aaad81b8f6B83c30dfdaA65b48",
"uniswap_v2": "0x0fA47ae2b7Dee29571678580BBe9A8A88436E393",
"multicall": "0x50F0463B01119Aa954ce40a7f21ecf4573E7605a",
"migrator": "0x3cBe562Fd434aF61601937895000A91D014a49e7",
"router": "0x5c192a0155D504772F3bc2689aF69116E098ECAa",
"ens_registry": "0xA07e2676495eEDEdb5A50b9ba020Ba3A98f87D4E"
}

The above is not populated, mine just remain the same as it is

  "contract_address": {
            "uniswap_factory": "",
            "weth": "",
            "uniswap_exchange_template": "",
            "alice_exchange": "",
            "bob_exchange": "",
            "alice_erc20_token": "",
            "bob_erc20_token": "",
            "uniswap_v2": "",
            "multicall": "",
            "migrator": "",
            "router": "",
            "ens_registry": "",
            "gas_relay_hub_address": "",
            "unisocks": ""
    },

Problem with deploying to Avalanche solved with upgrading truffle-hdwallet-provider

I got the issue when using the script on avalanche

I solved the problem with changing

const HDWalletProvider = require('truffle-hdwallet-provider');
to
const HDWalletProvider = require('@truffle/hdwallet-provider');

and

npm i "@truffle/hdwallet-provider"

I also provided manually chainId to every signed transaction.

Hopefully, my solution may save time for someone.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.