||2 months ago|
|.github/workflows||7 months ago|
|contracts||2 months ago|
|scripts||2 months ago|
|src||2 months ago|
|test||2 months ago|
|.editorconfig||11 months ago|
|.env.example||6 months ago|
|.eslintrc||11 months ago|
|.gitattributes||11 months ago|
|.gitignore||8 months ago|
|.nvmrc||11 months ago|
|.prettierignore||11 months ago|
|.prettierrc||11 months ago|
|.solcover.js||7 months ago|
|README.md||2 months ago|
|config.js||2 months ago|
|hardhat.config.js||2 months ago|
|package.json||2 months ago|
|yarn.lock||2 months ago|
Tornado Pool Factory
Separate instance of Tornado classic is needed for each [token, denomination] pair. This repository contains smart contracts of Tornado Pool Factory, which is used to create and register new pools:
- factory creates a new Tornado pool
- if there is pool registry on this chain (only ETH mainnet for now), the factory also creates governance proposal for registration new pool in instance registry
There are two deployed contracts:
InstanceFactory- instance factory for the creation of new Tornado ERC20/native pools
InstanceProposalCreator- governance proposal factory for the addition of new Tornado instances to the Tornado instance registry
Anyone for sidechains and only governance for mainnet can create a new instance by calling
createInstanceClone method of the factory with parameters:
address token- address of ERC20 token for a new instance, zero address for the native currency
uint256 denomination- denomination for new instance (tokens can only be deposited in certain denominations into Tornado instances)
Anyone can create a governance proposal for the addition of a new instance by calling
createProposalApprove/createProposalPermit method of the factory with parameters (proposal creation fee in TORN is charged from the sender):
address token- address of ERC20 token for a new instance, zero address for the native instance
uint24 uniswapPoolSwappingFee- fee value of Uniswap instance which will be used for
3000means 0.3% fee Uniswap pool. Zero value for the native instance.
uint256 denominations- list of denominations for each new instance (tokens can only be deposited in certain denominations into instances).
uint32 protocolFees- list of protocol fees for each new instance (this fee is only charged from registrated relayer during withdrawal process).
100means 1% of instance denomination fee for withdrawal throw registrated relayer.
max number of new instances in one proposal- the current version supports the addition of a maximum of 4 instances at once.
proposal creation fee- this fee is charged from creator of the proposal during
createProposalApprove/createProposalPermitfactory method execution. It can be changed by governance. Default value is stored in
TWAPSlotsMin- minimum number of TWAP slots for Uniswap pool that is chosen during
createProposalApprove/createProposalPermitfactory method call. It can be changed by governance. The default value is stored in
- This version of the factory creates a proposal for immutable Tornado instance initialization.
Setting up the repository:
yarn cp .env.example .env
Please fill out .env according to the template provided in it. Please ensure that all of the example values are set to the correct addresses.
To run test scripts:
Test scripts cover instance factory deployment, proposal deployment, and executing proposal.
Check config.js for actual values.
0x0000000000000000000000000000000000000000000000000000000047941987 address must be:
Check addresses with current config:
yarn compile node -e 'require("./src/generateAddresses").generateWithLog()'
Check config.js for the actual admin value for this sidechain (TornadoCash community multisig).
yarn hardhat run scripts/deploySidechainInstanceFactory.js --network mainnet
Deploy InstanceProposalCreator + InstanceFactory (ETH mainnet):
yarn hardhat run scripts/deployInstanceProposalCreator.js --network mainnet
Verify on Etherscan:
yarn hardhat verify --network <network-name> <contract-address> <constructor-arguments>