/havven

Havven Solidity smart contracts

Primary LanguagePythonMIT LicenseMIT

Havven

Havven is a decentralised payment network and stablecoin. It is critical to the system's viability that functionality is phased in over time. The initial release will provide a functional stablecoin and the opportunity to collect significant data on the market response. This will ultimately protect the system and those who back it as the network scales.

The first version of Havven will possess most of the key features of the system.

  • A two token system composed of a stablecoin (nomins) and collateral token (havvens).
  • Nomins are backed with a pool of value with which it is convertible.
  • The funds (ether) to stake nomins are provided by the owners of the backing token through the token sale.
  • Those staking the system, by owning havvens, are rewarded with fees charged on nomin transactions;

However it purposely omits others:

  • The nomin supply is centrally constrained, with only the havven foundation being able to expand it;
  • Users cannot issue nomins against their havvens, and therefore fee incentive mechanisms are not yet activated;
  • The backing capital cannot be expanded by the market, and so the currency’s ultimate total supply is constrained;

In the version 1.0 system, the nomin contract owner can only expand the supply of nomins if it can provide adequate backing. Users can buy and sell nomins into the pool for $1 USD worth of ether. The ether price is obtained from a trusted oracle. Fees charged on nomins are paid to owners of the havven token in proportion with the the number of havvens they hold.

Please note that this repository is under development. The code here will be under continual audit and improved up until release of the completed system.

Usage and requirements

Deployment and testing scripts require Python 3.6+, web3.py 4.0.0+, and pysolc 2.1.0+. To install, ensure that python is up to date and run:

pip3 install -r requirements.txt

Ensure BLOCKCHAIN_ADDRESS in utils/deployutils.py is pointing to a running Ethereum client or ganache-cli instance. Update other variables like the master address as appropriate. Then, from the root directory, deployment is as simple as:

python3 deploy.py

The test suite requires a ganache-cli instance to be running. For testing purposes there need to exist more accounts and ether for each account, so we run ganache-cli -e 1000000000000 -a 100 to prepare the test environment, and then run the tests as follow:

python3 run_tests.py

Files

The following files should be sufficient for deploying and testing version 1.0 of the havven system. We have leant heavily towards logical simplicity and explicitness where possible; while in documentation and naming conventions, verbosity and descriptiveness even to the point of excess. Some consideration has been given to efficiency, but typically architecturally, in determining how to allow operations to pay for themselves as they go. We have mostly forgone local and machine optimisations whenever they would come at the expense of clarity or simplicity.

  • deploy.py for deploying Havven contracts to the blockchain.
  • run_tests.py runs the test suite.
  • contracts/ contains smart contract code to be deployed.
  • contracts/Court.sol a court of arbitration to enable the balance of malicious contracts to be democratically confiscated.
  • contracts/ExternStateProxyToken.sol a foundation for generic ERC20 tokens with external state, and which exist behind a proxy.
  • contracts/TokenState.sol The balances of the ExternStateProxyToken contract.
  • contracts/ExternStateProxyFeeToken.sol a foundation for generic ERC20 tokens which also charge fees on transfers, with external state, and which exist behind a proxy.
  • contracts/EtherNomin.sol ether-backed nomin contract, with liquidation and confiscation logic.
  • contracts/Havven.sol havven collateral token, including calculations involving entitlements to fees being generated by nomins.
  • contracts/HavvenEscrow.sol vesting schedule manager, allows vested havvens to be freed up after certain dates.
  • contracts/Owned.sol a contract with an owner.
  • contracts/Proxy.sol a proxy contract that can pass function calls through to an underlying contract which implements the "proxyable" interface.
  • contracts/SafeDecimalMath.sol a math library for unsigned fixed point decimal arithmetic, with built-in safety checking.
  • tests/ test cases.
  • tests/contracts contracts used by the test suite.
  • utils/deployutils.py deployment helper functions.
  • utils/testutils.py testing helper functions.
  • utils/generalutils.py printing and test settings helper functions.