• Stars
    star
    111
  • Rank 314,510 (Top 7 %)
  • Language
    TypeScript
  • License
    GNU Lesser Genera...
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Smart contracts for IDO usecase

EasyAuction

EasyAuction should become a platform to execute batch auctions for fair initial offerings and token buyback programs. Batch auctions are a market mechanism for matching limit orders of buyers and sellers of a particular good with one fair clearing price. Already in traditional finance, batch auctions have established themselves as a tool for initial offerings, and in the blockchain ecosystem, they are expected to become a fundamental DeFi building lego brick for price-discovery as well. The EasyAuction platform is inspired by the auction mechanism of the Gnosis Protocol v1, which has shown a significant product-market fit for initial dex offerings (IDOs) (cp. sales of DIA, mStable, etc…). EasyAuction improves significantly the user experience for IDOs, by settling up arbitrary many bids with a single clearing price instead of roughly 28 orders and thereby making the mechanism fairer, easier to use, and more predictable. Given the emerging regulations for IDOs and utility sales - see MiCA -, EasyAuction is intending to comply with them and enabling new projects a safe start without legal risks.

Use cases

Initial token offering with a fair price-discovery

This batch auction mechanism allows communities, projects, and DAOs to offer their future stakeholders fair participation within their ecosystem by acquiring utility and governance tokens. One of the promises of DeFi is the democratization and communitization of big corporate infrastructures to build open platforms for the public good. By running a batch auction, these projects facilitate one of the fairest distribution of stakes. Projects should demonstrate their interest in fair participation by setting a precedence for future processes by choosing this fair auction principle over private multi-stage sales. Auction based initial offerings are also picking up in the traditional finance world. Google was one of the first big tech companies using a similar auction mechanism with a unique clearing price to IPO. Nowadays, companies like Slack and Spotify are advocating similar approaches as well via Direct Listings: Selling their stocks in the pre-open auction on the first day of trading. Overall this market for initial token offerings is expected to grow significantly over time together with the ecosystem. Even on gnosis protocol version 1, a platform not intended for this use case, was able to facilitate IDOs with a total of more than 20 million funding.

Token buy back programs

Many decentralized projects have to buy back their tokens or auction off their tokens to clear deficits within their protocol. This EasyAuction platform allows them to schedule individual auctions to facilitate these kinds of operations.

Initial credit offering

First implementations of yTokens are live on the ethereum blockchain. The initial price finding and matching of creditor and debtor for such credit instruments can be done in a very fair manner for these kind of financial contracts.

Protocol description

The batch auction mechanism

In this auction type a pre-defined amount of tokens is auctioned off. Anyone can bid to buy these tokens by placing a buy-order with a specified limit price during the whole bidding time. At the end of the auction, the final price is calculated by the following method: The buy volumes from the highest bids are getting added up until this sum reaches the initial sell volume. The bid increasing the overall buy volume to is the bid defining the uniform clearing price. All bids with higher price will be settled and traded against the initial sell volume with the clearing price. All bids with a lower price will not be considered for the settlement. The principle is described best with the following diagram: image from nytimes

Specific implementation batch auction

EasyAuction allows anyone to start a new auction of any ERC20 token (auctioningToken) against another ERC20 token (biddingToken). The entity initiating the auction, the auctioneer, has to define the amount of token to be sold, the minimal price for the auction, the end-time for the order cancellation period, the end-time of the auction, plus some additional parameters. The auctioneer initiates the auction with an ethereum transaction transferring the auctioningTokens and setting the parameters. From this moment on, anyone can participate as a buyer and submit bids. Each buyer places sell-orders with a specified limit price into the system. Until the "end-time of the order cancellation period", orders can still be canceled. Once this time has passed they can only be placed until the auction end-date.

There is only one exception: If the auction is configured to allow atomic-closures, then the next step - the price calculation - and placing one last order even after the auction end-date can be done within one ethereum transaction. In all other cases, no further order placement is allowed once the auction end-date passed and the auction can be cleared by the on-chain price calculations. The price calculation can happen over several ethereum transactions, in case the calculation is consuming more gas than available in one ethereum block. By setting a minium sell-amount per order, the gas for a price calculation can be restricted, and even be forced to fit into one block. This can be useful, in case the auction should be atomically closable.

Once the price of an auction has been calculated, everyone can claim their part of the auction. The auctioneer can withdraw the bought funds, the buyers being matched in the auction can withdraw their bought tokens. The buyers bidding with a too low price which were not matched in the auction can withdraw their bidding funds back.

Comparison to Dutch auctions

The proposed batch auction system has a number of advantages over dutch auction.

  • The biggest advantage is certainly that buyers don't have to wait for a certain time to submit orders, but that they can submit orders at any time. This makes the system much more convenient for users.
  • Dutch auctions have a very high activity right before the auction is closing. If pieces of the infrastructure are not working reliable during this time period, then prices can fall further than expected, causing a loss for the auctioneer. Also, high gas prices during this short time period can be a hindering factor for buyers to quickly join the auction.
  • Dutch auctions calculate their price based the blocktime. This pricing is hard to predict for all participants, as the mining is a stochastical process Additionally, the unpredictability for the mining time of the next block
  • Dutch auctions are causing a gas price bidding war to close the auction. In contrast in batch auction, different buyers will bid against other bidder in the mem-pool. Especially, once EIP-1559 is implemented and the mining of a transaction is guaranteed for the next block, then bidders have to compete on bidding limit-prices instead of the gas-prices to get included into the auction.

Warnings

In case the auction is expected to raise more than 2^96 units of the biddingToken, don't start the auction,as it will not be settlable. This corresponds to about 79 billion DAI.

Prices between biddingToken and auctioningToken are expressed by a fraction whose components are stored as uint96. Make sure your expected prices are representable as such fractions.

Instructions

Backend

Install dependencies

git clone https://github.com/gnosis/ido-contracts
cd ido-contracts
yarn
yarn build

Running tests:

yarn test

Run migration:

yarn deploy --network $NETWORK

Verify on etherscan:

npx hardhat etherscan-verify --license None --network rinkeby

Running scripts

Create auctions

New auctions can be started with a hardhat script or via a safe app. The safe-app can be found here: Auction-Starter A new auction selling the token 0xc778417e063141139fce010982780140aa0cd5ab for 0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa can be started using the hardhat script like that:

export NETWORK=<Your Network>
export GAS_PRICE_GWEI=<Your gas price>
export INFURA_KEY=<Your infura key>
export PK=<Your private key>
yarn hardhat initiateAuction --auctioning-token "0xc778417e063141139fce010982780140aa0cd5ab" --bidding-token "0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa" --sell-amount 0.1 --min-buy-amount 50 --network $NETWORK

Please look in the hardhat script /src/tasks/initiate_new_auction to better understand all parameters.

A more complex example for starting an auction would look like this:

yarn hardhat initiateAuction --auctioning-token "0xc778417e063141139fce010982780140aa0cd5ab" --bidding-token "0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea" --sell-amount 0.5 --min-buy-amount 800 --auction-end-date 1619195139 --order-cancellation-end-date 1619195139 --allow-list-manager "0x80b8AcA4689EC911F048c4E0976892cCDE14031E" --allow-list-data "0x000000000000000000000000740a98f8f4fae0986fb3264fe4aacf94ac1ee96f"  --network $NETWORK

Settle auctions

Auctions can be settled with the clearAuction script permissionlessly by any account:

export NETWORK=<Your Network>
export GAS_PRICE_GWEI=<Your gas price>
export INFURA_KEY=<Your infura key>
export PK=<Your private key>
yarn hardhat clearAuction --auction-id <Your auction ID> --network $NETWORK

Allow-Listing: Generating signatures

Signatures for an auction with participation restriction can be created like that:

  1. Create a file: your_address_inputs.txt with comma separated addresses that should be allow-listed for the auction
  2. Initiate the auction and remember your auctionId
  3. Run the following script:
export NETWORK=<Your Network>
export INFURA_KEY=<Your infura key>
export PK=<Your private key _for the signing address_. The address for this key should not hold any ETH>
yarn hardhat generateSignatures --auction-id "Your auctionId" --file-with-address "./your_address_inputs.txt" --network $NETWORK

The generated signatures can be directly uploaded to the backend by adding the flag --post-to-api - or --post-to-dev-api in case you are testing with development environment - to the previous command. Uploading signatures allows all authorized users to create orders from the web interface without the extra friction of managing a signature.

Audit

The solidity code was audited by Adam Kolar, from the G0 Group. The report can be found here and here.

More Repositories

1

MultiSigWallet

Allows multiple parties to agree on transactions before execution.
JavaScript
1,071
star
2

zodiac

A library for composable tooling for onchain entities
TypeScript
433
star
3

ethcontract-rs

Generate type-safe bindings for interacting with Ethereum contracts.
Rust
242
star
4

gp-v2-contracts

Smart contracts for the Gnosis Protocol v2
TypeScript
158
star
5

pm-contracts

Collection of smart contracts for the Gnosis prediction market platform.
Solidity
158
star
6

hashi

An EVM hash oracle aggregator
TypeScript
134
star
7

GECO

Gnosis Ecosystem Fund
130
star
8

conditional-tokens-contracts

Smart contracts for conditional tokens.
Solidity
128
star
9

cowswap

🐮 CowSwap: First Gnosis Protocol v2 UI
TypeScript
112
star
10

zodiac-module-reality

A Zodiac module that uses Reality.eth as an oracle for triggering execution on a Safe.
TypeScript
101
star
11

dex-contracts

Smart contracts for the Gnosis Protocol v1
TypeScript
94
star
12

mock-contract

Simple Solidity contract to mock dependent contracts in truffle tests.
JavaScript
94
star
13

dex-research

Collection of research papers written within Gnosis
TeX
88
star
14

conditional-tokens-market-makers

Automated Market Maker (AMM) smart contracts for Conditional Tokens Markets.
JavaScript
85
star
15

cow-token

Repository containing the CowSwap Governance Token smart contract
TypeScript
69
star
16

evm-proxy-detection

Detect proxy contracts and their target addresses using an EIP-1193 compatible JSON-RPC request function
TypeScript
66
star
17

pm-js

Gnosis Prediction Markets JavaScript Library
JavaScript
66
star
18

zodiac-modifier-roles

TypeScript
56
star
19

bivrost-swift

🔥 🌈 Bridge between Solidity Contracts and Swift
Swift
56
star
20

ethers-multisend

An npm package for crafting multi-send transaction from a Zodiac Avatar, such as a Gnosis Safe, based on ethers.js
TypeScript
55
star
21

dex-zksnarks

Code to generate snark proofs for batch auction result validation of the Gnosis d.exchange
C++
45
star
22

dx-contracts

🇳🇱✖️DutchX core smart contracts
JavaScript
45
star
23

util-contracts

Utility contracts for Gnosis
Solidity
44
star
24

gp-v2-services

Off-chain services for Gnosis Protocol v2
Rust
44
star
25

canonical-weth

Canonical WETH package (see https://blog.0xproject.com/canonical-weth-a9aa7d0279dd)
JavaScript
44
star
26

django-eth-events

Python
43
star
27

safe-ios-legacy

Gnosis Safe is a multi signature (2FA) wallet for personal usage.
Swift
41
star
28

zodiac-pilot

Chrome extension to simulate Dapp interactions and record transactions
TypeScript
41
star
29

1155-to-20

ERC 1155 to ERC 20 converter
Solidity
37
star
30

cow-dex-solver

Rust
36
star
31

verify-on-etherscan

Automates verification on etherscan.io of ethereum contracts that were compiled and deployed with truffle
JavaScript
35
star
32

mech

Smart account with programmable ownership
TypeScript
33
star
33

dex-services

Off-chain services for the Gnosis Protocol v1.
Rust
31
star
34

dx-uniswap-arbitrage

Solidity
30
star
35

tabula

Instant web3 publications for writers, DAOs, and any Ethereum-based account.
TypeScript
30
star
36

dx-react

🇳🇱✖️DutchX Protocol Slow.Trade Interface - React Web
TypeScript
30
star
37

zodiac-guard-scope

A transaction guard that allows the owner to limit the multisig signers to calling specific function signatures on specific contracts.
TypeScript
30
star
38

zodiac-module-exit

TypeScript
29
star
39

dx-services

🇳🇱✖️DutchX Services, Bots and CLI
JavaScript
28
star
40

thegraph-subgraphs-monitor

Monitor subgraphs from https://thegraph.com/
Python
25
star
41

research

You will find an index of our research work here.
25
star
42

ido-ux

Interface for the ido-platform
TypeScript
24
star
43

zodiac-safe-app

TypeScript
24
star
44

cow-token-allocation

Data Collection and Processing for vCoW Token Allocation
Python
24
star
45

delegate-registry

A registry contract that contains delegates for addresses/ contracts.
JavaScript
24
star
46

fund-recovery

Recovery mechanisms for multi-signature wallets beyond backing up private keys.
24
star
47

token-lock

Lock ERC-20 tokens for a pre-defined amount of time
TypeScript
24
star
48

dx-daostack

🇳🇱✖️ Decentralized Autonomous Organization (DAO) for managing the DutchX
JavaScript
23
star
49

zodiac-module-bridge

TypeScript
20
star
50

dkg

Distributed key generation
Go
19
star
51

pm-trading-ui

Prediction Market Trading Interface for Gnosis Contracts
JavaScript
19
star
52

dx-docs

🇳🇱✖️Dutch X Documentation
Python
18
star
53

safe-browser-extension

JavaScript
18
star
54

reth

Mono repo for reth ethereum client
Rust
18
star
55

gp-v1-ui

TypeScript
16
star
56

pm-trading-db

Gnosis Core Database Layer
Python
16
star
57

solidity-arithmetic

A solidity library for performing arithmetic.
JavaScript
15
star
58

dex-subgraph

dFusion subgraph
TypeScript
14
star
59

conditional-markets-interface

Interface for conditional markets for Gnosis' Conditional Token Standard
JavaScript
13
star
60

truffle-nice-tools

A simple yet nice toolset for Truffle Framework development.
JavaScript
13
star
61

pydkg

A python implementation of distributed key generation over secp256k1
Python
12
star
62

dex-liquidity-provision

JavaScript
12
star
63

gnosis-exchange

Allows trading of any token pair with an on-chain market maker. Exchange rates serve as price oracle.
JavaScript
12
star
64

gp-v2-trading-bot

Script(s) to interact with gp-v2-contracs
TypeScript
11
star
65

dex-open-solver

Open source solver to the batch auction problem.
Python
11
star
66

heimdall-ios

🔐 App to manage and interact with Gnosis MultiSig Wallets https://wallet.gnosis.pm
Swift
11
star
67

ido-starter

Gnosis safe app to start auction on gnosis auction
TypeScript
11
star
68

module-factory

A factory for gnosis safe modules, deployed as minimal proxies.
TypeScript
10
star
69

safe-web3-provider

JavaScript
10
star
70

zodiac-modifier-delay

A Safe module that allows approved addresses to execute transactions after a time delay, during which transactions can be marked as invalid by the Safe.
TypeScript
10
star
71

dx-examples-dev

🇳🇱✖️DutchX Examples: How to build on top of DutchX
JavaScript
10
star
72

safe-app-template

A create-react-app template for a Gnosis Safe App
TypeScript
9
star
73

zodiac-module-nomad

TypeScript
9
star
74

dex-telegram

dFusion bot
TypeScript
9
star
75

dx-examples-liquidity-bots

🇳🇱✖️DutchX Example: How to run the Bots
JavaScript
9
star
76

wand-nft

TypeScript
8
star
77

pm-scripts

A command line tool that allows users to create and resolve prediction markets on top of Gnosis
JavaScript
8
star
78

zodiac-module-connext

TypeScript
8
star
79

Zodiac-Transaction-Encoder

Transaction Encoder
TypeScript
8
star
80

conditional-tokens-explorer

TypeScript
8
star
81

gp-ui

TypeScript
7
star
82

subgraph-voting-power

TypeScript
7
star
83

zodiac-module-siphon

Solidity
7
star
84

conditional-tokens-tutorial

TypeScript
7
star
85

react-multisend

A headless React library for crafting multi-send transactions from a Gnosis Safe
TypeScript
7
star
86

dappcon-website

Website for the Dappcon conference
JavaScript
6
star
87

pm-kyc-service

KYC Service written in Go for Prediction Markets application
Go
6
star
88

dex-plasma

Contracts for dex plasma batch auctions
JavaScript
6
star
89

dx-tools

🇳🇱✖️DutchX Tools: include Bots and CLI scripts
Shell
6
star
90

hg-subgraph

This repository contains the subgraph for Gnosis Prediction Markets 2.0
JavaScript
6
star
91

dtl

Decentralized token lending using DutchX
JavaScript
5
star
92

run-with-testrpc

Runs commands with TestRPC in the background
JavaScript
5
star
93

pm-apollo-contracts

Contracts related to Gnosis Apollo and Olympia
JavaScript
5
star
94

safe-multisig-electron

JavaScript
5
star
95

owl-token

The OWL token and related smart contracts
JavaScript
5
star
96

gp-v2-dune

A collection of tools to manage queries on Dune Analytics
TypeScript
5
star
97

zodiac-mod-starter-kit

Out of the box starting point for building Zodiac modules
TypeScript
5
star
98

token-splitter

Smart contract to split tokens between addresses
JavaScript
5
star
99

safe-token-distribution

TypeScript
5
star
100

sight-subgraph

This repository contains the subgraph (thegraph.com) for Conditional Tokens platform
TypeScript
5
star