GithubHelp home page GithubHelp logo

levelkdev / fcr-contracts Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 4.0 2.05 MB

Smart contracts for futarchy curated registry

License: Apache License 2.0

JavaScript 59.15% Solidity 38.72% Shell 2.13%

fcr-contracts's Introduction

fcr-contracts

Smart contracts for futarchy curated registry.

Overview

Futarchy curated registries are similar to token curated registries. Token curated registries decide what to add/remove based on token weighted voting, while futarchy curated registries make these decisions using futarchy.

In this project, futarchy markets are created using CategoricalEvent and ScalarEvent smart contracts from the Gnosis platform. They are set up according to the model described here under Futarchy Market Setups #1.

Since futarchy markets are driven by future price predicion, we use the Gnosis DutchX as an oracle to resolve the price of the "FCR Token".

Setup

npm install

npm run compile to compile truffle artifacts to build/contracts

Smart Contracts

Registry.sol

Contains core registry functionality, and stores the state of registry listings. Adapted from skmgoldin/tcr/contracts/Registry.sol.

RegistryFactory.sol

Factory contract for creation of Registry instances.

Parameterizer.sol

From skmgoldin/tcr/contracts/Parameterizer. Used to set parameters for registries and challenges, such as minDeposit. New parameters values can be proposed with a token weighted vote. The voting process is implemented with PLCRVoting.

ParameterizerFactory.sol

Factory contract for creation of Parameterizer instances.

IDutchExchange.sol

Interface for DutchExchange contract. Provides the functions that are needed for the FCR implementation, so that dutch exchange can be mocked for testing.

Imports.sol

Used to force compilation of all contracts for testing. Not intended to be deployed to testnet/mainnet.

Challenge/FutarchyChallenge.sol

The futarchy based challenge implementation. For each new challenge issued via Registry, there will be one instance of FutarchyChallenge deployed.

The initiateFutarchy() function is used to create an instance of FutarchyOracle, which creates all events and markets for the futarchy based challenge decision.

Challenge/FutarchyChallengeFactory.sol

Factory contract for creation of FutarchyChallenge instances.

Challenge/ChallengeInterface.sol

Interface for a challenge instance. Implemented by FutarchyChallenge and used by FutarchyChallengeFactory.

Challenge/ChallengeFactoryInterface.sol

Interface for a challenge factory instance. Implemented by FutarchyChallengeFactory and used by Registry.

Challenge/Oracles/DutchExchangeMock.sol

Mock contract for testing with DutchX.

ScalarPriceOracle.sol

Allows an outcome to be set based on the average price of a given token trading pair on DutchX. Takes the average of the last 5 auctions for the token pair.

ScalarPriceOracleFactory.sol

Factory contract for creation of ScalarPriceOracle instances.

TimedOracle.sol

Allows a resolution date to be set, and provides a modifier resolutionDatePassed() to require that the resolution date has passed.

Testing

The test dir contains unit tests and integration tests. Unit tests run against individual contract instances. Integration tests run a series of transactions against multiple deployed contracts, and assert that certain conditions are met.

Run Unit Tests

npm run test

Run Integration Tests

npm run ganache to start ganache-cli npm run migrate-reset to run truffle migrations npm run integration-test <testName>

Compile With solc (debugging only)

The npm run solc-compile script is an optimization that allows you to compile contracts quickly with solc, rather than truffle compile which adds a lot of additional overhead.

First, run these prerequisite steps:

  • Install latest solc CLI install solidity.
  • Compile all contracts: npm run compile
  • Run the flattener: npm run flattener

Then follow these steps to make contract changes for debugging:

  1. Make a change in ./contracts_flattened/<ContractName>.sol
  2. Run npm run solc-compile <ContractName> (don't include .sol)
  3. If there are no errors, run npm run migrate-reset to deploy everything including your change.

Keep in mind that the truffle build data in build/contracts/ will be modified in ways that are likely not compatible with the truffle suite. Delete the entire build dir (rm -rf ./build) and npm run compile to go return to a stable state.

fcr-contracts's People

Contributors

akuanti avatar ewilz avatar irene-lin avatar kangarang avatar kmoneal avatar medvedev-evgeny avatar miguelmota avatar mikec avatar mzeitlin8 avatar skmgoldin avatar terryli0095 avatar yorhodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.