.github/workflows | ||
contracts | ||
scripts | ||
src | ||
test | ||
.editorconfig | ||
.env.example | ||
.eslintrc | ||
.gitattributes | ||
.gitignore | ||
.nvmrc | ||
.prettierignore | ||
.prettierrc | ||
.solcover.js | ||
config.js | ||
hardhat.config.js | ||
package.json | ||
README.md | ||
yarn.lock |
Tornado Instances Factory
About
This repository contains:
InstanceFactory
- instance factory for the creation new Tornado ERC20/native poolsInstanceProposalCreator
- governance proposal factory for the addition of new Tornado instances to the Tornado router
InstanceFactory
Anyone 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 instanceuint256 denomination
- denomination for new instance (tokens can only be deposited in certain denominations into instances)
InstanceProposalCreator
Anyone can create 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 sender):
address token
- address of ERC20 token for a new instance, zero address for the native instanceuint24 uniswapPoolSwappingFee
- fee value of Uniswap instance which will be used forTORN/token
price determination.3000
means 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).100
means 1% of instance denomination fee for withdrawal throw registrated relayer.
Factory parameters
InstanceProposalCreator
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 proposal duringcreateProposalApprove/createProposalPermit
factory method execution. It can be changed by governance. Default value is stored inconfig.js
.TWAPSlotsMin
- minimum number of TWAP slots for Uniswap pool that is chosen duringcreateProposalApprove/createProposalPermit
factory method call. It can be changed by governance. Default value is stored inconfig.js
.
Warnings
- This version of the factory creates a proposal for immutable Tornado instance initialization.
- For
InstanceProposalCreator
users should manually propose a proposal after its creation using the factory (in governance UI for example). Aspropose()
method caller must have 1000 TORN locked in the governance. Moreover, the proposer can't propose more than one proposal simultaneously.
Tests
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:
yarn test
Test scripts cover instance factory deployment, proposal deployment and executing proposal.
Deploy
Check config.js for actual values.
With salt
= 0x0000000000000000000000000000000000000000000000000000000047941987
address must be:
SidechainInstanceFactory
-0xE24B853247B37375A080553082a5385Dda95E8cf
SidechainInstanceFactory proxy
-0x168de886aC22e73b3306e234579794340a0eb746
InstanceFactory
-0x8B85eB475Ac8D286DcF307346a6EAE9E9c93665d
InstanceFactory proxy
-0xf30827C1588b17ABAeF855DF92bf6B60615F3e9C
InstanceProposalCreator
-0xe1FcF99262F00cCbe2CE6cC70CE956C7e5728C10
InstanceProposalCreator proxy
-0xa9189801C88fe8222001d2ee962A6A4150DB6026
Check addresses with current config:
yarn compile
node -e 'require("./src/generateAddresses").generateWithLog()'
Deploy SidechainInstanceFactory:
yarn hardhat run scripts/deploySidechainInstanceFactory.js --network mainnet
Deploy InstanceProposalCreator:
yarn hardhat run scripts/deployInstanceProposalCreator.js --network mainnet
Verify on Etherscan:
yarn hardhat verify --network <network-name> <contract-address> <constructor-arguments>