Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release v1.0.12 #226

Merged
merged 22 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
39483f5
readme rewamp
szerintedmi May 9, 2019
f2ee394
dev docs updates
szerintedmi May 9, 2019
61adf67
readme typos
szerintedmi May 9, 2019
de123f0
chore(package): update truffle-hdwallet-provider to version 1.0.9
greenkeeper[bot] May 9, 2019
49f3712
chore(package): update lockfile yarn.lock
greenkeeper[bot] May 9, 2019
96b330d
Update docs/developmentEnvironment.md
treerz May 10, 2019
b9ce011
Merge pull request #219 from Augmint/readme
szerintedmi May 10, 2019
e1013a2
fix localtest loans discountrate rounding
szerintedmi May 12, 2019
bcb1600
simple test to verify the values in localTest_initialSetup.sol
treerz May 13, 2019
b57bfbb
fix typo in test
treerz May 13, 2019
6165a76
Merge pull request #221 from Augmint/loantermsfix
treerz May 13, 2019
7fcba9f
simple test to verify the values in localTest_initialSetup.sol (lock …
treerz May 13, 2019
a88c7f3
Merge pull request #222 from Augmint/test_improvements
treerz May 14, 2019
bc2e105
sb script: recreate loan products on mainnet
treerz May 14, 2019
2ce1f63
Merge pull request #223 from Augmint/scripts
szerintedmi May 14, 2019
57ebdf3
script to deploy the script
treerz May 14, 2019
a7c5bb1
Merge pull request #224 from Augmint/scripts
treerz May 14, 2019
c3d12c1
Merge branch 'staging' into greenkeeper/truffle-hdwallet-provider-1.0.9
treerz May 14, 2019
fa17c19
bump version number in package.json to 1.0.12
treerz May 14, 2019
9deec00
Merge pull request #220 from Augmint/greenkeeper/truffle-hdwallet-pro…
treerz May 14, 2019
2173650
Merge branch 'staging' into version_number
treerz May 14, 2019
dd9b646
Merge pull request #225 from Augmint/version_number
szerintedmi May 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 68 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,116 +13,113 @@ Decentralised stable cryptocurrency on Ethereum

## Concept

Augmint provides digital tokens, value of each token pegged to a fiat currency.
Decentralized stablecoins targeted to fiat currencies built on Ethereum.

The first Augmint token will be A-EUR (Augmint Euro), pegged to EUR.
The first Augmint token is AEUR.

The value of 1 A-EUR is always closely around 1 EUR.
**1 AEUR ≈ 1 EUR.**

Augmint tokens are cryptocurrency tokens with all the benefits of cryptocurrencies: stored securely in a decentralised manner and instantly transferable worldwide.
- Buy and sell AEUR for ETH or EUR.
- Get a loan in AEUR by depositing ETH.
- Lock AEUR to earn a premium.

Read more and try it: **[www.augmint.cc](http://www.augmint.cc)**
Try it: **[https://www.augmint.org](http://www.augmint.org)**

**[Our Trello board](https://trello.com/b/RYGAt2so/augmint-documents)** with a collection of documents about the project.
**[Manifesto](https://www.augmint.org/manifesto)**

**[White paper draft](http://bit.ly/augmint-wp)** - Work in progress. Please feel free to comment it: questions, ideas, suggestions are welcome.
**[White Paper](http://bit.ly/augmint-wp)**

## Components
### Related repos

[Web frontend repo](https://github.com/Augmint/augmint-web)
- [Web frontend](https://github.com/Augmint/augmint-web)
- [@augmint/js library](https://github.com/Augmint/augmint-js)

## Flows
## Flow diagrams

[Contract dependency graph](docs/contractDependencies.png)
- [Loan flow](docs/loanFlow.png)
- [Lock flow](docs/lockFlow.png)
- [Exchange flow](docs/exchangeFlow.png)
- [Flow of funds](https://docs.google.com/document/d/1IQwGEsImpAv2Nlz5IgU_iCJkEqlM2VUHf5SFkcvb80A/#heading=h.jsbfubuh6okn)

Sequence diagrams:
## Solidity Contracts

* [Loan flow](docs/loanFlow.png)
* [Lock flow](docs/lockFlow.png)
* [Exchange flow](docs/exchangeFlow.png)
* [Reserve Sales flow](docs/reserveSalesFlow.png) _(not implemented yet)_
### Dependencies

[Flow of funds](https://docs.google.com/document/d/1IQwGEsImpAv2Nlz5IgU_iCJkEqlM2VUHf5SFkcvb80A/#heading=h.jsbfubuh6okn)
[![Contract dependency graph](docs/contractDependencies.png)](docs/contractDependencies.png)

## Solidity Contracts
### List of contracts

* [Restricted.sol](./contracts/generic/Restricted.sol)
- [Restricted.sol](./contracts/generic/Restricted.sol)
Stores permissions per address
* [MultiSig.sol](./contracts/generic/MultiSig.sol)
- [MultiSig.sol](./contracts/generic/MultiSig.sol)
Abstract contract to manage multi signature approval and execution of atomic, one-off contract scripts
* [StabilityBoardProxy.sol](./contracts/generic/StabilityBoardProxy.sol)
- [StabilityBoardProxy.sol](./contracts/generic/StabilityBoardProxy.sol)
Augmint parameters can be set only via this contract with a quorum approving a contract script to run.
* [ERC20.sol](./contracts/generic/ERC20.sol)
- [ERC20.sol](./contracts/generic/ERC20.sol)
Standard [ERC20](https://theethereum.wiki/w/index.php/ERC20_Token_Standard) token interface.
* [SystemAccount.sol](./contracts/generic/ERC20.sol)
- [SystemAccount.sol](./contracts/generic/ERC20.sol)
Abstract contract to maintain balances of Augmint system accounts
* [AugmintReserves](./contracts/AugmintReserves.sol)
* Holds Augmint's ETH and token reserves
* [InterestEarnedAccount](./contracts/InterestEarnedAccount.sol)
* Holds interest earning from token lending - only from repaid loans, i.e. already "earned"
* Provides interest for Locks
* [FeeAccount.sol](./contracts/FeeAccount.sol)
* holds all fees: tokens from transfer and exchange fees (to be implemented) + ETH fees from defaulting fees
* calculates transferFees
* [AugmintToken.sol](./contracts/generic/AugmintToken.sol)
- [AugmintReserves](./contracts/AugmintReserves.sol)
- Holds Augmint's ETH and token reserves
- [InterestEarnedAccount](./contracts/InterestEarnedAccount.sol)
- Holds interest earning from token lending - only from repaid loans, i.e. already "earned"
- Provides interest for Locks
- [FeeAccount.sol](./contracts/FeeAccount.sol)
- holds all fees: tokens from transfer and exchange fees (to be implemented) + ETH fees from defaulting fees
- calculates transferFees
- [AugmintToken.sol](./contracts/generic/AugmintToken.sol)
Base contract for all Augmint tokens, [TokenAEur.sol](./contracts/TokenAEur.sol) being the first implementation.
* ERC20 standard functions
* maintains account token balances
* Generic `transferAndNotify` "convenience" function
* allows MonetarySupervisor to issue tokens on loan disbursement and for reserve
* allows accounts to burn their tokens (used by repay loan and burn from reserves via MonetarySupervisor contract)
* [MonetarySupervisor.sol](./contracts/MonetarySupervisor.sol)
* maintains system wide KPIs (totalLockAmount, totalLoanAmount)
* enforces system wide limits (Loan to Deposit ratio limits)
* issue to & from reserve functions
* [TokenAEur.sol](./contracts/TokenAEur.sol)
* First AugmintToken contract instance, pegged for pegged to EUR (A-EUR aka Augmint Euro aka A€ )
* Sets standard token parameters (name, symbol, decimals, peggedSymbol etc.)
* [Rates.sol](./contracts/Rates.sol)
- ERC20 standard functions
- maintains account token balances
- Generic `transferAndNotify` "convenience" function
- allows MonetarySupervisor to issue tokens on loan disbursement and for reserve
- allows accounts to burn their tokens (used by repay loan and burn from reserves via MonetarySupervisor contract)
- [MonetarySupervisor.sol](./contracts/MonetarySupervisor.sol)
- maintains system wide KPIs (totalLockAmount, totalLoanAmount)
- enforces system wide limits (Loan to Deposit ratio limits)
- issue to & from reserve functions
- [TokenAEur.sol](./contracts/TokenAEur.sol)
- First AugmintToken contract instance, pegged for pegged to EUR (A-EUR aka Augmint Euro aka A€ )
- Sets standard token parameters (name, symbol, decimals, peggedSymbol etc.)
- [Rates.sol](./contracts/Rates.sol)
A contract to return fiat/ETH exchange rates.
* [Exchange.sol](./contracts/Exchange.sol)
- [Exchange.sol](./contracts/Exchange.sol)
EUR / ETH exchange contract. Sell or buy A-EUR for ETH
* [LoanManager.sol](./contracts/LoanManager.sol)
* Loan products and their parameters
* Maintains all loans via new loan, repayment, collection functions
* Holds collateral in escrow
* [Locker.sol](./contracts/Lock.sol)
* Lock products and parameters
* Token funds locking and releasing
* Holds locked tokens (with interest)
- [LoanManager.sol](./contracts/LoanManager.sol)
- Loan products and their parameters
- Maintains all loans via new loan, repayment, collection functions
- Holds collateral in escrow
- [Locker.sol](./contracts/Lock.sol)
- Lock products and parameters
- Token funds locking and releasing
- Holds locked tokens (with interest)

## Contribution
## Contributions

Augmint is an open and transparent project.

We are seeking for great minds to extend our core team. Contribution in any area is much appreciated: development, testing, UX&UI design, legal, marketing spreading the word etc.
We are looking for great minds to extend our core team. Contributions in any area is much appreciated: development, testing, UX&UI design, legal, marketing, spreading the word etc.

**[Development environment setup](docs/developmentEnvironment.md)**
[Code of Conduct](CODE_OF_CONDUCT.md)

## Publish NPM package

When the abiniser directory changed:
- bump the version property in the package.json
- `npm publish --access public`
## [Development environment setup](docs/developmentEnvironment.md)

## Get in touch

Drop us an email: hello@augmint.cc
or
say hi on our [Discord server](https://discord.gg/PwDmsnu): [![Discord](https://img.shields.io/discord/407574313810788364.svg)](https://discord.gg/PwDmsnu)
- [hello@augmint.org](mailto:hello@augmint.org)
- [Discord server](https://discord.gg/PwDmsnu) [![Discord](https://img.shields.io/discord/407574313810788364.svg)](https://discord.gg/PwDmsnu)
- [Telegram](https://t.me/augmint)

## Authors

![DECENT](http://www.decent.org/images/logo-voronoi_120x33.png)
See team on [www.augmint.org](https://www.augmint.org)

The project was born at [DECENT Labs](http://www.decent.org)
<img src="https://github.com/Augmint/augmint-web/raw/staging/src/assets/images/decentlabs.png" alt="Decentlabs" width="60" height="60"> The project was born at [DECENT Labs](http://www.decent.org)

### Concept, initial version

* [szerintedmi](https://github.com/szerintedmi)
* [Charlie](https://github.com/krosza)

Check the whole team on [augmint.cc](http://www.augmint.cc)
- [szerintedmi](https://github.com/szerintedmi)
- [Charlie](https://github.com/krosza)

## Licence

Expand Down
12 changes: 6 additions & 6 deletions contracts/SB_scripts/localTest/localTest_initialSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ contract localTest_initialSetup {

// add test loan Products
// term (in sec), discountRate, loanCoverageRatio, minDisbursedAmount (w/ 4 decimals), defaultingFeePt, isActive
_loanManager.addLoanProduct(365 days, 854700, 550000, 1000, 50000, true); // 17% p.a.
_loanManager.addLoanProduct(180 days, 924752, 550000, 1000, 50000, true); // 16.5% p.a.
_loanManager.addLoanProduct(365 days, 854701, 550000, 1000, 50000, true); // 17% p.a.
_loanManager.addLoanProduct(180 days, 924753, 550000, 1000, 50000, true); // 16.5% p.a.

_loanManager.addLoanProduct(90 days, 962045, 600000, 1000, 50000, true); // 16%. p.a.
_loanManager.addLoanProduct(60 days, 975153, 600000, 1000, 50000, true); // 15.5% p.a.
_loanManager.addLoanProduct(30 days, 987821, 600000, 1000, 50000, true); // 15% p.a.
_loanManager.addLoanProduct(14 days, 994279, 600000, 1000, 50000, true); // 15% p.a.
_loanManager.addLoanProduct(90 days, 962046, 600000, 1000, 50000, true); // 16%. p.a.
_loanManager.addLoanProduct(60 days, 975154, 600000, 1000, 50000, true); // 15.5% p.a.
_loanManager.addLoanProduct(30 days, 987822, 600000, 1000, 50000, true); // 15% p.a.
_loanManager.addLoanProduct(14 days, 994280, 600000, 1000, 50000, true); // 15% p.a.
_loanManager.addLoanProduct(7 days, 997132, 600000, 1000, 50000, true); // 15% p.a.

_loanManager.addLoanProduct(1 hours, 999998, 980000, 2000, 50000, true); // due in 1hr for testing repayments ? p.a.
Expand Down
55 changes: 55 additions & 0 deletions contracts/SB_scripts/mainnet/Main0025_recreateLoanProducts.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Recreate loan products on mainnet (fix for discountRate rounding error) */

pragma solidity 0.4.24;

import "../../StabilityBoardProxy.sol";
import "../../LoanManager.sol";

contract Main0025_recreateLoanProducts {

StabilityBoardProxy public constant STABILITY_BOARD_PROXY = StabilityBoardProxy(0xde36a8773531406dCBefFdfd3C7b89fCed7A9F84);
LoanManager public constant LOAN_MANAGER = LoanManager(0x1cABc34618ecf2949F0405A86353e7705E01C38b);

function execute(Main0025_recreateLoanProducts /* self, not used */) external {
// called via StabilityBoardProxy
require(address(this) == address(STABILITY_BOARD_PROXY), "only execute via StabilityBoardProxy");


/******************************************************************************
* Disable current loan products
******************************************************************************/

LOAN_MANAGER.setLoanProductActiveState(1, false);
LOAN_MANAGER.setLoanProductActiveState(2, false);
LOAN_MANAGER.setLoanProductActiveState(3, false);
LOAN_MANAGER.setLoanProductActiveState(4, false);
LOAN_MANAGER.setLoanProductActiveState(5, false);


/******************************************************************************
* Add new loan products
******************************************************************************/

// Formulas used for conversion:

// IRPA: Interest Rate Per Annum : the percentage value on the UI
// LPDR: Loan Product Discount Rate : uint32 discountRate constructor parameter

// IRPA = (1_000_000 / LPDR - 1) * (365 / termInDays)
// LPDR = 1_000_000 / (IRPA * termInDays / 365 + 1)

// discountRates:
// [180, 90, 30, 14, 7].map(termInDays => Math.ceil(1000000 / (0.049 * termInDays / 365 + 1)))
// [976406, 988063, 995989, 998125, 999062]

// addLoanProduct:
// term, discountRate, collateralRatio, minDisbursedAmount, defaultingFeePt, isActive

LOAN_MANAGER.addLoanProduct(180 days, 976406, 600000, 800, 100000, true); // 4.9% p.a.
LOAN_MANAGER.addLoanProduct(90 days, 988063, 600000, 800, 100000, true); // 4.9% p.a.
LOAN_MANAGER.addLoanProduct(30 days, 995989, 600000, 800, 100000, true); // 4.9% p.a.
LOAN_MANAGER.addLoanProduct(14 days, 998125, 600000, 800, 100000, true); // 4.9% p.a.
LOAN_MANAGER.addLoanProduct(7 days, 999062, 600000, 800, 100000, true); // 4.9% p.a.

}
}
30 changes: 19 additions & 11 deletions docs/developmentEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
- [Install](#Install)
- [Launch](#Launch)
- [Tests](#Tests)
- [Publish NPM package](#Publish-NPM-package)
- [Docker Image](#Docker-Image)
- [Sequence diagrams](#Sequence-diagrams)
- [Non ganache launches/deploys](#Non-ganache-launchesdeploys) -
- [Non ganache launches/deploys](#Non-ganache-launchesdeploys)

## Install

Expand Down Expand Up @@ -103,9 +104,21 @@ yarn start
yarn test
```

## Publish NPM package

When the abiniser directory changed:

- bump the version property in the package.json
- release a new version as usual (staging -> master, git tag & github release)
- `npm publish` from master branch. test it with `--dry-run`

## Docker Image

A docker image with an initial state of the contracts in ganache is published for development of dependent packes: [hub.docker.com/r/augmint/contracts](https://hub.docker.com/r/augmint/contracts)
A docker image with an initial state of the contracts in ganache is published for development of dependent packages.

The image is published to [augmint/contracts dockerhub repo](https://hub.docker.com/r/augmint/contracts).

NB: `augmint-contracts`' own tests are also running on this container at Travis

## Running docker image

Expand All @@ -117,12 +130,6 @@ yarn docker:start
yarnd docker:stop
```

## Docker image

Docker images are used by dependent projects to quickly launch local ganache with all augmint contracts for testing Augmint.
The image is published to [augmint/contracts dockerhub repo](https://hub.docker.com/r/augmint/contracts).
NB: `augmint-contracts`' own tests are also running on this container at Travis,

### Build docker image

- `localchaindb:builddocker` : deletes local chain data folder (`./localchaindb`), launches ganache, migrates contracts and builds a docker image with `localdockerimage` name
Expand All @@ -135,9 +142,10 @@ Travis set to generate a docker image for master and staging branch builds. See

**Tags**

- `yarn docker:tag`: every published image tagged with `commit-xxxxx` and `build-travisbuildnumber`
- `yarn docker:tag:nextver` : on staging branch image tagged with `nextver`
- `yarn docker:tag:latest` : on master branch image tagged with `latest` and `vx.x.x` tags (from package.json version)
- `yarn docker:tag:build`: every published image tagged with `build-travisbuildnumber` and `commit-xxxxx`
- `yarn docker:tag:staging` : on staging branch image tagged with `staging`
- `yarn docker:tag:latest` : on master branch image tagged with `latest`
- `yarn docker:tag:version` : on master branch image tagged with `vx.x.x` tags (from git tag if it's in semver format)

## Sequence diagrams

Expand Down
7 changes: 7 additions & 0 deletions mainnet_migrations/37_deploy_Main0025_recreateLoanProducts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const Main0025_recreateLoanProducts = artifacts.require("./Main0025_recreateLoanProducts.sol");

module.exports = function(deployer) {
deployer.then(async () => {
await deployer.deploy(Main0025_recreateLoanProducts);
});
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augmint/contracts",
"version": "1.0.11",
"version": "1.0.12",
"description": "Augmint Stable Tokens - Solidity contract's abi and deployment descriptors",
"author": "“Augmint”",
"homepage": "https://github.com/Augmint/augmint-contracts#readme",
Expand Down Expand Up @@ -59,7 +59,7 @@
"solidity-coverage": "0.5.11",
"stringifier": "2.0.0",
"truffle": "4.1.14",
"truffle-hdwallet-provider": "1.0.8",
"truffle-hdwallet-provider": "1.0.9",
"wait-on": "3.2.0",
"web3v1": "npm:web3@1.0.0-beta.34"
},
Expand Down
21 changes: 21 additions & 0 deletions test/loanManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ contract("loanManager tests", accounts => {
loanProduct.id = res.productId;
});

it("Verifies default test loanproduct discount rates", async function() {
// correlates with loan products set up in localTest_initialSetup.sol

// IRPA: Interest Rate Per Annum : the percentage value on the UI
// LPDR: Loan Product Discount Rate : uint32 discountRate constructor parameter

// IRPA = (1_000_000 / LPDR - 1) * (365 / termInDays)
// LPDR = 1_000_000 / (IRPA * termInDays / 365 + 1)

const toLpdr = (irpa, termInDays) => Math.ceil(1000000 / (irpa * termInDays / 365 + 1))

const p = await loanTestHelpers.getProductsInfo(0, CHUNK_SIZE);
assert.equal(p[0].discountRate.toNumber(), toLpdr(0.17, 365))
assert.equal(p[1].discountRate.toNumber(), toLpdr(0.165, 180))
assert.equal(p[2].discountRate.toNumber(), toLpdr(0.16, 90))
assert.equal(p[3].discountRate.toNumber(), toLpdr(0.155, 60))
assert.equal(p[4].discountRate.toNumber(), toLpdr(0.15, 30))
assert.equal(p[5].discountRate.toNumber(), toLpdr(0.15, 14))
assert.equal(p[6].discountRate.toNumber(), toLpdr(0.15, 7))
});

it("Should add new product allow listing from offset 0", async function() {
const prod = {
// assuming prod attributes are same order as array returned
Expand Down
Loading