• Stars
    star
    101
  • Rank 327,521 (Top 7 %)
  • Language
    TypeScript
  • License
    GNU Lesser Genera...
  • Created over 3 years ago
  • Updated about 1 year ago

Reviews

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

Repository Details

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

Zodiac Reality Module

Build Status Coverage Status Contributor Covenant

The Reality Module belongs to the Zodiac collection of tools, which can be accessed through the Zodiac App available on Gnosis Safe, as well as in this repository.

If you have any questions about Zodiac, join the Gnosis Guild Discord. Follow @GnosisGuild on Twitter for updates.

About the Reality Module

This module allows on-chain execution based on the outcome of events reported by Reality.eth. While built initially to execute Gnosis Safe transactions according to Snapshot proposals, this module is framework agnostic. It can enable proposal execution from just about anywhere. For example, it can bring Discord polls on-chain.

This module allows for execution of transactions that have been approved through a Reality.eth question for execution. The question asked on Reality.eth consists of a proposal ID (e.g. an IPFS hash), which can be used to provide more information for the transaction to be executed, as well as an array of EIP-712-based transaction hashes that represent the transactions that should be executed.

These two components (proposalId and txHashes) uniquely identify a question on the module. While it is possible to ask the same question with different Reality.eth question parameters, it is only possible to execute transactions related to a specific question once.

Once the question on Reality.eth has resolved to "yes", meaning that the transactions should be executed, they are submitted to the immutable executor defined in the module. Transactions defined in questions that resolve to "no" or "invalid" cannot be executed by the module.

This module is intended to be used with Gnosis Safe, but it is ultimately framework agnostic.

Setup Guides

This module can be setup either using the Zodiac App's UI or by using command line tools; both methods allow for connecting to Snapshot.

View docs for using the Zodiac App

View docs for using the command line

Features

  • Submit proposals uniquely identified by a proposalId and an array of txHashes, to create a Reality.eth question that validates the execution of the connected transactions.
  • Proposals can be marked invalid by the executor using markProposalInvalid, thereby preventing the execution of the transactions related to that proposal.
  • The Reality.eth question parameters (templateId, timeout, arbitrator) can be set on the module by the executor.
  • A minimum bond can be set, which is the amount required to be staked on a Reality.eth answer before the transactions can be executed.
  • A cooldown can be specified representing the minimum amount of time required to pass after the Reality.eth question has been answered before the transactions can be executed.

Flow

  • Create question on Reality.eth via the addProposal method of this module.
  • The question needs to be answered on Reality.eth with yes (1) to approve it for execution.
  • Once the question has a result and the cooldown period has passed, the transaction(s) can be executed via executeProposal.

Definitions

Transaction nonce or index

The nonce of a transaction makes it possible to have two transactions with the same to, value and data but still generate a different transaction hash. This is important as all hashes in the txHashes array should be unique. To make sure that this is the case, the module will always use the index of the transaction hash inside the txHashes array as a nonce. So the first transaction to be executed has the nonce with the value 0, the second with the value 1, and so on.

Therefore we can simplify it to the following statement: The nonce of a Reality Module transaction is equal to the index of that transaction's hash in the txHashes array.

Proposal nonce

There is a chance that a question is marked invalid on the oracle (e.g. if it is asked too early). In this case it should be possible to ask the question again, and we need to be able to generate a new question ID. For this it is possible to provide the next higher nonce compared to the last invalidated proposal. So in case the first proposal (with the default nonce of 0) was marked invalid on the oracle, a new proposal can be submitted with the nonce of 1.

Oracle / Reality.eth

The Reality Module depends on an oracle to determine if a proposal was expected and deemed valid. The following assumptions are being made:

  • The oracle MUST implement the Reality.eth contract interface.
  • It MUST not be possible to ask the same question with the same parameters again.
  • Once a result is known and finalized for a question, it MUST not change.
  • The oracle MUST use the same question ID generation algorithm as this module.

The reference oracle implementations are the Reality.eth contracts. These can be found on:

Failed transactions

The Reality Modules requires proposal transactions are successful (e.g. transactions should not internally revert for any reason). If any of the transactions of a proposal fail, it will not be possible to continue with the execution of the following transactions. This is to prevent subsequent transactions being executed in a scenario in which earlier transactions failed due to the gas limit being too low or due to other errors.

Transactions that failed will not be marked as executed, and therefore, they can be executed at any later point in time. This is a potential risk, and therefore it is recommended to either set an answer expiration time or invalidate the proposal (e.g. via another proposal).

Answer expiration

The Reality Module can be configured so that positive answers will expire after a certain time. This can be done by calling setAnswerExpiration with a duration in seconds. If the transactions related to the proposal are not executed before the answer expires, it will not be possible to execute them. This is useful in the case of transactions that revert and therefore cannot be executed in order to prevent them from being unexpectedly executed in the future. Negative answers (no or invalid) cannot expire.

Note: If the expiration time is set to 0, answers will never expire. This also means answers that expired before will become available again. To prevent this, it is recommended to call markProposalWithExpiredAnswerAsInvalid immediately after any proposal expires (or on all outstanding expired answers prior to setting the expiration date to 0). This will mark a proposal with an expired answer as invalid. This method can be called by anyone.

EIP-712 details

EIP-712 is used to generate the hashes for the transactions to be executed. The following EIP-712 domain and types are used.

Domain

{
  EIP712Domain: [
    { type: "uint256", name: "chainId" },
    { type: "address", name: "verifyingContract" }
  ]
}

TransactionType

{
  Transaction: [
    { type: "address", name: "to" },
    { type: "uint256", name: "value" },
    { type: "bytes", name: "data" },
    { type: "uint8", name: "operation" },
    { type: "uint256", name: "nonce" }
  ]
}

Solidity Compiler

The contracts have been developed with Solidity 0.8.0 in mind. This version of Solidity made all arithmetic checked by default, therefore eliminating the need for explicit overflow or underflow (or other arithmetic) checks.

Audits

An audit has been performed by the G0 group.

No issues have been discovered.

The audit results are available as a pdf in this repo or on the g0-group repo.

Security and Liability

All contracts are WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

GECO

Gnosis Ecosystem Fund
130
star
7

hashi

An EVM hash oracle aggregator
TypeScript
129
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

ido-contracts

Smart contracts for IDO usecase
TypeScript
111
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

gp-v2-services

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

util-contracts

Utility contracts for Gnosis
Solidity
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

research

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

thegraph-subgraphs-monitor

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

zodiac-safe-app

TypeScript
24
star
43

cow-token-allocation

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

delegate-registry

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

fund-recovery

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

token-lock

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

ido-ux

Interface for the ido-platform
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

truffle-nice-tools

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

conditional-markets-interface

Interface for conditional markets for Gnosis' Conditional Token Standard
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

dex-open-solver

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

gp-v2-trading-bot

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

ido-starter

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

heimdall-ios

🔐 App to manage and interact with Gnosis MultiSig Wallets https://wallet.gnosis.pm
Swift
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

dex-telegram

dFusion bot
TypeScript
9
star
74

zodiac-module-nomad

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

hg-subgraph

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

dex-plasma

Contracts for dex plasma batch auctions
JavaScript
6
star
90

dx-tools

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

run-with-testrpc

Runs commands with TestRPC in the background
JavaScript
5
star
92

dtl

Decentralized token lending using DutchX
JavaScript
5
star
93

pm-apollo-contracts

Contracts related to Gnosis Apollo and Olympia
JavaScript
5
star
94

owl-token

The OWL token and related smart contracts
JavaScript
5
star
95

safe-multisig-electron

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