Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit

* Install open zeppelin contracts

* Init foundry in governance

* Add wrapped ZRX token

* Add governance contracts testing to CI

* Set optimizer runs to default

* Upgrade to patched version of openzeppelin/contracts

* Test stakingakng / unwrapping ZRX

* Init npm package

* Lint fix, removing lib from gitignore

* Add openzeppelin contracts git submodule for foundry

* Add vanilla governor contract

* Fix reference paths to imported packages

* Temporarily switch to using a mocked version of ZRX

* Ignore foundry's lib in link checker

* Fix a conflict in gitignore between forge lib adn built lib

* Upload governance code coverage report to coveralls

* Flesh out test scenarios for wrapping/unwrapping

* Add basic ERC20 name and symbol tests

* Wire in basic timelock controller and governor test setup

* Test basic governor properties

* Add basic voting power delegation tests

* Add proposal execution happy path test

* Split ERC20Votes logic between wrapped token
and ZeroExVotes contracts

* Exclude BaseTest from coverage in coveralls

* Add protocol specific governor with produciton governance settings

* Add a dedicated instance for the treasury governor
This is currently using the default 1 token 1 vote mechanism but will be migrated

* Add test for updating governance settings
for voting delay, voting period and proposal threshold

* Create seperate timelock contract instance for treasury and protocol

* Test updating the timlock min delay

* Set timelock delay to 2 days for protocol and 1 sec for treasury

* Remove timelock from treasury governor

* Refactor _checkpointsLookup to return entire Checkpoint
instad of just number of votes

* Update the totalSupply checkpoints updating logic

* Quadratic voting power transfers and delegations

* Fix workflow yaml

* Initialise ZeroExVotes behind a ERC1967Proxy
Test it cannot be reinitialised

* Remove obsoleted console.logs from test

* Storage pack Checkpoint enum

* Remove keeping track of total balances for voting

* Switch to using the foundry artifact in test

* Fix rebase issue

* Add timelock control over the treasury governor

* Add test for wrapped token transfer

* Emit separate events for changing linear and quadratic voting power

* Add the ability to cancel a proposal

* Limit the governors' cancel function to security council only

* Eject security council after a proposal is cancelled

* Add ability for governance to set the security council

* Merge the governors test suites into one reusable set of tests

* Add an empty test function to base test contract
to remove it from coverage reports. Fudge but no other way to ignore it in report

* Security council can rollback protocol upgrades

* Upgrade to solidity 0.8.19

* Move IZeroExGovernor to src

* Abstract Security council interface into its own

* Emit events when assigning and ejecting the security council

* Use a cast to bytes4 instead of LibBytes

Co-authored-by: duncancmt <>

* Writing total supply checkpoints and setup of
quorum percentage of quadratic total supply for treasure governor

* Add test for transferring tokens when delegating

* Rename IZeroExSecurityCouncil to ISecurityCouncil

* Add security council restrictions to governors

* Remove obsolete overflow check

* Improve test coverage

* Upgrade open-zeppelin contracts to 4.8.2

* Test delegation by signature

* Test non security council requests
to rollback protocol changes cannot be executed

* Better revert messages

* Test correct interfaces are supported

* Remove obsoleted funciton

* Further test delegation by signature scenario

* Split the delegation functionality tests

* Add test for initialisation of voting contract

* Add test for reading checkpoints

* Update code comments

* Fix compilation warnings

* Run smt checker

* Add checkpoint tests

* Rename parameter in moveEntireVotingPower to match the one in movePartialVotingPower

* Switch moveEntireVotingPower to a more generic moveVotingPower implementation
as in the open-zeppelin contracts

* Install foundry earlier in CI

* Switch movePartialVotingPower to the generic moveVotingPower implementation

* Write totalSupplyCheckpoints via the generic _writeCheckpoint

* Add threshold for quadratic voting power

* Remove autoinserted code by OZ

* Add openzeppelin/contracts-upgradable

* Add initializable base to Voting contract

* Fix terminogy error in natspec

* Fix code comment

* Remove obsoleted overrides and add a missing modifier to moveVotingPower

* Remove amount check

Co-authored-by: duncancmt <>

* Fix a calculation error and clean tests

* Update thresholds for treasury governor

* Fix testShouldNotBeAbleToDelegateWithSignatureAfterExpiry

* Update from @duncancmt

without "memory-safe" the IR optimizer produces significantly worse code and it disables the stack limit evader

Co-authored-by: duncancmt <>

* Add onlyProxy to initializer

* Fix quadratic voting weight base

* Rename voting parameter for clarity

* Make addresses immutable (#680)

* Make addresses immutable

* Fix linting issues


Co-authored-by: elenadimitrova <>

* Prevent griefing by a malicious ZeroExVotes upgrade (#681)

* Gas optimization

* Minimal change to prevent malicious ZeroExVotes from griefing

* Add demonstration of griefing upgrade

* Fix rebase issues with tests

* Fix prettier issues

* Add checks to test


Co-authored-by: elenadimitrova <>

* Rename SecurityCouncil contract

* Add timestamp to delegator balance updates

* Make quadraticThreshold `immutable` for gas efficiency

* Remove the logic for ejecting security council

* Switch balance timestamp to be a block number

* Test votes migration for adding a new vote weight mechanism (#674)

* Add Emacs files to .gitignore

* Make some functions unproected to demonstrate a migration

* Add example (broken) migration

* Add migration test for voting logic

* Try to simplify tests

* Fix compilation errors

* Fix underflow test with new logic

* Flesh out migration test for voting

* Replace cube root library

* Fix stack too deep in coverage


Co-authored-by: elenadimitrova <>

* Change test case to testFail

* Update contracts/governance/test/ZeroExVotesMigration.sol

Co-authored-by: duncancmt <>


Co-authored-by: duncancmt <>
Co-authored-by: Duncan Townsend <>


Failed to load latest commit information.
Latest commit message
Commit time
March 10, 2023 01:13
February 5, 2018 10:25
October 20, 2020 20:53
October 20, 2020 20:53
January 17, 2023 10:53

0x is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. For more information on how it works, check out the 0x protocol specification.

This repository is a monorepo including the 0x protocol smart contracts and numerous developer tools. Each public sub-package is independently published to NPM.

Coverage Status Discord License


Visit our developer portal for a comprehensive list of core & community maintained packages. All packages maintained with this monorepo are listed below.

Solidity Packages

These packages are all under development. See /contracts/ for a list of deployed packages.

Package Version Description
@0x/contracts-zero-ex npm The contracts used for settling trades within the protocol
@0x/contracts-erc20 npm Implementations of various ERC20 tokens
@0x/contracts-test-utils npm TypeScript/Javascript shared utilities used for testing contracts
@0x/contracts-utils npm Generic libraries and utilities used throughout all of the contracts

TypeScript/Javascript Packages

0x-specific packages

Package Version Description
@0x/protocol-utils npm A set of utilities for generating, parsing, signing and validating 0x orders
@0x/contract-addresses npm A tiny utility library for getting known deployed contract addresses for a particular network.
@0x/contract-wrappers npm JS/TS wrappers for interacting with the 0x smart contracts
@0x/contract-artifacts npm 0x smart contract compilation artifacts


Node version 6.x or 8.x is required.

Most of the packages require additional typings for external dependencies. You can include those by prepending the @0x/typescript-typings package to your typeRoots config.

"typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],


We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.

Read our contribution guidelines.

Install dependencies

Make sure you are using Yarn v1.9.4. To install using brew:

brew install yarn@1.9.4

Then install dependencies

yarn install


To build all packages:

yarn build

To build a specific package:

PKG=@0x/protocol-utils yarn build

To build all contracts packages:

yarn build:contracts


To re-build all packages on change:

yarn watch

To watch a specific package and all it's dependent packages:


PKG=@0x/protocol-utils yarn watch


Clean all packages:

yarn clean

Clean a specific package

PKG=@0x/protocol-utils yarn clean


To re-build (clean & build) all packages:

yarn rebuild

To re-build (clean & build) a specific package & it's deps:

PKG=@0x/protocol-utils yarn rebuild


Lint all packages:

yarn lint

Lint a specific package:

PKG=@0x/protocol-utils yarn lint

Run Tests

Run all tests:

yarn test

Run a specific package's test:

PKG=@0x/protocol-utils yarn test

Run all contracts packages tests:

yarn test:contracts