From 39483f5b6a06cf408fc4373897a6038cde9ee59c Mon Sep 17 00:00:00 2001 From: szerintedmi Date: Thu, 9 May 2019 18:28:22 +0100 Subject: [PATCH 01/13] readme rewamp --- README.md | 137 ++++++++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 9f81f792..a14abfa8 100644 --- a/README.md +++ b/README.md @@ -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 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 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. -**[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) +Decentlabs 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 From f2ee394fba63886a73251e526040503ff846c237 Mon Sep 17 00:00:00 2001 From: szerintedmi Date: Thu, 9 May 2019 18:28:49 +0100 Subject: [PATCH 02/13] dev docs updates --- docs/developmentEnvironment.md | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/docs/developmentEnvironment.md b/docs/developmentEnvironment.md index e55081df..8c4b7e59 100644 --- a/docs/developmentEnvironment.md +++ b/docs/developmentEnvironment.md @@ -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 @@ -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 packes. + +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 @@ -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 @@ -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 From 61adf67ca31388df3f87b69e402fba7cd300556d Mon Sep 17 00:00:00 2001 From: szerintedmi Date: Thu, 9 May 2019 19:43:15 +0100 Subject: [PATCH 03/13] readme typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a14abfa8..113c91de 100644 --- a/README.md +++ b/README.md @@ -94,11 +94,11 @@ Try it: **[https://www.augmint.org](http://www.augmint.org)** - 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. [Code of Conduct](CODE_OF_CONDUCT.md) From de123f00a0c02f5607ede0830da5671b2f644a6d Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 9 May 2019 19:01:38 +0000 Subject: [PATCH 04/13] chore(package): update truffle-hdwallet-provider to version 1.0.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 299f2753..e433c6e8 100644 --- a/package.json +++ b/package.json @@ -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" }, From 49f37129094b805a3f78869caad921d1d7a291b6 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 9 May 2019 19:01:42 +0000 Subject: [PATCH 05/13] chore(package): update lockfile yarn.lock --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9defe0ce..8ab2aeff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3672,10 +3672,10 @@ trim-right@^1.0.1: resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= -truffle-hdwallet-provider@1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/truffle-hdwallet-provider/-/truffle-hdwallet-provider-1.0.8.tgz#76ab28e08b4c84dc8b3c98c9c2b4bba9c9d834e0" - integrity sha512-kG/WSEvwWSRuFbyEnoNgGQtKrKJMr/MwKoZfiPeT6L6d2gS2QnH2xbJbWxV+LtENjERSodjI9bbO/TN73CXWSQ== +truffle-hdwallet-provider@1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/truffle-hdwallet-provider/-/truffle-hdwallet-provider-1.0.9.tgz#1e7f239631ada08cacd7cdf3fdbc39f2033e04e7" + integrity sha512-1PfQgyOOapirCK8L/EiApzAo6mhlrnKi6GdXvNX2Gt/635QtYlGPwdFC6zMm5plEcOegdCz2CgbhXI6Fdbp98A== dependencies: any-promise "^1.3.0" bindings "^1.3.1" From 96b330dcaeef879b4a9c98175ac4b5881deab9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= <38250343+treer-euedge@users.noreply.github.com> Date: Fri, 10 May 2019 15:45:13 +0200 Subject: [PATCH 06/13] Update docs/developmentEnvironment.md --- docs/developmentEnvironment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developmentEnvironment.md b/docs/developmentEnvironment.md index 8c4b7e59..7c9b541f 100644 --- a/docs/developmentEnvironment.md +++ b/docs/developmentEnvironment.md @@ -114,7 +114,7 @@ When the abiniser directory changed: ## Docker Image -A docker image with an initial state of the contracts in ganache is published for development of dependent packes. +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). From e1013a2e9d96d95099d382b45217b572604a36d1 Mon Sep 17 00:00:00 2001 From: szerintedmi Date: Sun, 12 May 2019 08:23:03 +0100 Subject: [PATCH 07/13] fix localtest loans discountrate rounding --- .../SB_scripts/localTest/localTest_initialSetup.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/SB_scripts/localTest/localTest_initialSetup.sol b/contracts/SB_scripts/localTest/localTest_initialSetup.sol index d553b125..8f7b1e2c 100644 --- a/contracts/SB_scripts/localTest/localTest_initialSetup.sol +++ b/contracts/SB_scripts/localTest/localTest_initialSetup.sol @@ -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. From bcb1600f0d699ec955e02badbd3bb44dfd032098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Mon, 13 May 2019 13:44:24 +0200 Subject: [PATCH 08/13] simple test to verify the values in localTest_initialSetup.sol --- test/loanManager.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/loanManager.js b/test/loanManager.js index 9b49bb28..287f4d9a 100644 --- a/test/loanManager.js +++ b/test/loanManager.js @@ -37,6 +37,27 @@ contract("loanManager tests", accounts => { loanProduct.id = res.productId; }); + it("Verifies default test loanproducts", 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 toLdpr = (irpa, termInDays) => Math.ceil(1000000 / (irpa * termInDays / 365 + 1)) + + const p = await loanTestHelpers.getProductsInfo(0, CHUNK_SIZE); + assert.equal(p[0].discountRate.toNumber(), toLdpr(0.17, 365)) + assert.equal(p[1].discountRate.toNumber(), toLdpr(0.165, 180)) + assert.equal(p[2].discountRate.toNumber(), toLdpr(0.16, 90)) + assert.equal(p[3].discountRate.toNumber(), toLdpr(0.155, 60)) + assert.equal(p[4].discountRate.toNumber(), toLdpr(0.15, 30)) + assert.equal(p[5].discountRate.toNumber(), toLdpr(0.15, 14)) + assert.equal(p[6].discountRate.toNumber(), toLdpr(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 From b57bfbb4d8a16d4d0da17b343d1d4b7ebc406308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Mon, 13 May 2019 13:49:31 +0200 Subject: [PATCH 09/13] fix typo in test --- test/loanManager.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/loanManager.js b/test/loanManager.js index 287f4d9a..8bdbdd88 100644 --- a/test/loanManager.js +++ b/test/loanManager.js @@ -37,7 +37,7 @@ contract("loanManager tests", accounts => { loanProduct.id = res.productId; }); - it("Verifies default test loanproducts", async function() { + 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 @@ -46,16 +46,16 @@ contract("loanManager tests", accounts => { // IRPA = (1_000_000 / LPDR - 1) * (365 / termInDays) // LPDR = 1_000_000 / (IRPA * termInDays / 365 + 1) - const toLdpr = (irpa, termInDays) => Math.ceil(1000000 / (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(), toLdpr(0.17, 365)) - assert.equal(p[1].discountRate.toNumber(), toLdpr(0.165, 180)) - assert.equal(p[2].discountRate.toNumber(), toLdpr(0.16, 90)) - assert.equal(p[3].discountRate.toNumber(), toLdpr(0.155, 60)) - assert.equal(p[4].discountRate.toNumber(), toLdpr(0.15, 30)) - assert.equal(p[5].discountRate.toNumber(), toLdpr(0.15, 14)) - assert.equal(p[6].discountRate.toNumber(), toLdpr(0.15, 7)) + 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() { From 7fcba9fa16d4e263542ed8802117f6d43726defe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Mon, 13 May 2019 14:23:10 +0200 Subject: [PATCH 10/13] simple test to verify the values in localTest_initialSetup.sol (lock products) --- test/locker.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/locker.js b/test/locker.js index 0e4afe90..a5bddca1 100644 --- a/test/locker.js +++ b/test/locker.js @@ -38,6 +38,27 @@ contract("Lock", accounts => { ]); }); + it("Verifies default test lockproduct interest rates", async function() { + // correlates with lock products set up in localTest_initialSetup.sol + + // IRPA: Interest Rate Per Annum : the percentage value on the UI + // PTI: Per Term Interest : uint32 perTermInterest constructor parameter + + // IRPA = (PTI / 1_000_000) * (365 / termInDays) + // PTI = (IRPA * 1_000_000) * (termInDays / 365) + + const toPti = (irpa, termInDays) => Math.ceil((irpa * 1000000) * (termInDays / 365)) + + const p = await lockerInstance.getLockProducts(0, CHUNK_SIZE); + assert.equal(p[0][0].toNumber(), toPti(0.12, 365)) + assert.equal(p[1][0].toNumber(), toPti(0.115, 180)) + assert.equal(p[2][0].toNumber(), toPti(0.11, 90)) + assert.equal(p[3][0].toNumber(), toPti(0.105, 60)) + assert.equal(p[4][0].toNumber(), toPti(0.10, 30)) + assert.equal(p[5][0].toNumber(), toPti(0.10, 14)) + assert.equal(p[6][0].toNumber(), toPti(0.10, 7)) + }); + it("should allow lock products to be created", async function() { // create lock product with 5% per term, and 60 sec lock time: const tx = await lockerInstance.addLockProduct(50000, 60, 100, true); From bc2e1058af3b91e3d7071664b4156c513626d030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Tue, 14 May 2019 12:50:57 +0200 Subject: [PATCH 11/13] sb script: recreate loan products on mainnet --- .../mainnet/Main0025_recreateLoanProducts.sol | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 contracts/SB_scripts/mainnet/Main0025_recreateLoanProducts.sol diff --git a/contracts/SB_scripts/mainnet/Main0025_recreateLoanProducts.sol b/contracts/SB_scripts/mainnet/Main0025_recreateLoanProducts.sol new file mode 100644 index 00000000..4e2fefd3 --- /dev/null +++ b/contracts/SB_scripts/mainnet/Main0025_recreateLoanProducts.sol @@ -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. + + } +} \ No newline at end of file From 57ebdf34462b5bf693fbecd464fd75d263fdaf9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Tue, 14 May 2019 13:14:41 +0200 Subject: [PATCH 12/13] script to deploy the script --- .../37_deploy_Main0025_recreateLoanProducts.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 mainnet_migrations/37_deploy_Main0025_recreateLoanProducts.js diff --git a/mainnet_migrations/37_deploy_Main0025_recreateLoanProducts.js b/mainnet_migrations/37_deploy_Main0025_recreateLoanProducts.js new file mode 100644 index 00000000..1aef2848 --- /dev/null +++ b/mainnet_migrations/37_deploy_Main0025_recreateLoanProducts.js @@ -0,0 +1,7 @@ +const Main0025_recreateLoanProducts = artifacts.require("./Main0025_recreateLoanProducts.sol"); + +module.exports = function(deployer) { + deployer.then(async () => { + await deployer.deploy(Main0025_recreateLoanProducts); + }); +}; \ No newline at end of file From fa17c190a30ce395a4358356c9796b1c7ae4f432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Tue, 14 May 2019 13:42:29 +0200 Subject: [PATCH 13/13] bump version number in package.json to 1.0.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 299f2753..f764d831 100644 --- a/package.json +++ b/package.json @@ -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",