Skip to content

Commit 1f3230c

Browse files
authored
Merge pull request #73 from Augmint/staging
v0.3.0
2 parents 993b41d + e4f22ce commit 1f3230c

31 files changed

+1284
-1659
lines changed

README.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99

1010
Decentralised stable cryptocurrency on Ethereum
1111

12+
## Concept
13+
14+
Decentralized stablecoins targeted to fiat currencies built on Ethereum.
15+
16+
The first Augmint token is AEUR.
17+
18+
**1 AEUR ≈ 1 EUR.**
19+
20+
- Buy and sell AEUR for ETH or EUR.
21+
- Get a loan in AEUR by depositing ETH.
22+
- Lock AEUR to earn a premium.
23+
24+
Try it: **[https://www.augmint.org](http://www.augmint.org)**
25+
26+
**[Manifesto](https://www.augmint.org/manifesto)**
27+
28+
**[White Paper](http://bit.ly/augmint-wp)**
29+
30+
### Related repos
31+
32+
- [Web frontend](https://github.com/Augmint/augmint-web)
33+
- [augmint-contracts](https://github.com/Augmint/augmint-contracts)
34+
1235
## augmint-js lib
1336

1437
This lib is heavily under construction. Anything can happen.
@@ -146,53 +169,31 @@ augmint-cli : start / stop augmint contracts. Docker image: augmint/contracts:vx
146169
147170
Also recreates the container if it exists but image is not as expected (ie. there was a version upgrade)
148171
149-
## Concept
150-
151-
Augmint provides digital tokens, value of each token pegged to a fiat currency.
152-
153-
The first Augmint token is A-EUR (Augmint Euro), pegged to EUR.
154-
155-
The value of 1 A-EUR is always closely around 1 EUR.
156-
157-
**[White paper](http://bit.ly/augmint-wp)**
158-
159-
Try it: **[www.augmint.org](http://www.augmint.org)**
160-
161-
**[Our Trello board](https://trello.com/b/RYGAt2so/augmint-documents)** with a collection of documents about the project.
162-
163-
## Other components
164-
165-
[Web frontend](https://github.com/Augmint/augmint-web)
166-
167-
[Solidity contracts](https://github.com/Augmint/augmint-contracts)
168-
169172
## Contributions
170173
171174
Augmint is an open and transparent project.
172175
173-
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.
174-
175-
## Get in touch
176+
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.
176177
177-
Drop us an email: [email protected]
178+
[Code of Conduct](CODE_OF_CONDUCT.md)
178179
179-
Say hi on our [Discord server](https://discord.gg/PwDmsnu): [![Discord](https://img.shields.io/discord/407574313810788364.svg)](https://discord.gg/PwDmsnu)
180+
## Get in touch
180181
181-
Talk to us on [Telegram](https://t.me/augmint)
182+
183+
- [Discord server](https://discord.gg/PwDmsnu) [![Discord](https://img.shields.io/discord/407574313810788364.svg)](https://discord.gg/PwDmsnu)
184+
- [Telegram](https://t.me/augmint)
182185
183186
## Authors
184187
185-
Check the team at [www.augmint.org](https://www.augmint.org)
188+
See team on [www.augmint.org](https://www.augmint.org)
186189
187-
The project was born at [DECENT Labs](http://www.decent.org)
190+
<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)
188191
189192
### Concept, initial version
190193
191194
- [szerintedmi](https://github.com/szerintedmi)
192195
- [Charlie](https://github.com/krosza)
193196
194-
Check the whole team on [augmint.org](http://www.augmint.org)
195-
196197
## Licence
197198
198199
This project is licensed under the GNU Affero General Public License v3.0 license - see the [LICENSE](LICENSE) file for details.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@augmint/js",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "Augmint Javascript Library",
55
"keywords": [
66
"augmint javascript library A-EUR stablecoin web3 dapp"
@@ -26,24 +26,25 @@
2626
"yarn": "1.15.2"
2727
},
2828
"dependencies": {
29-
"@augmint/contracts": "1.0.9",
30-
"bignumber.js": "5.0.0",
29+
"@augmint/contracts": "1.0.12",
3130
"bn.js": "4.11.8",
3231
"dotenv": "8.0.0",
3332
"ulog": "2.0.0-beta.6",
3433
"web3": "1.0.0-beta.36"
3534
},
3635
"devDependencies": {
36+
"@types/bn.js": "4.11.5",
3737
"@types/node": "^10.14.5",
3838
"chai": "4.2.0",
3939
"chai-as-promised": "7.1.1",
40+
"chai-exclude": "2.0.1",
4041
"cross-env": "5.2",
4142
"eslint": "5.16.0",
4243
"mocha": "6.1.4",
43-
"rollup": "1.11.3",
44+
"rollup": "1.12.3",
4445
"rollup-plugin-node-builtins": "2.1.2",
4546
"rollup-plugin-node-globals": "1.4.0",
46-
"rollup-plugin-typescript2": "0.21.0",
47+
"rollup-plugin-typescript2": "0.21.1",
4748
"sinon": "7.3.2",
4849
"tslint": "5.16.0",
4950
"tslint-config-prettier": "1.18.0",
@@ -61,14 +62,12 @@
6162
"ganache:run": "scripts/augmint-cli.sh ganache run --blockTime 1"
6263
},
6364
"greenkeeper": {
64-
"ignore": [
65-
"bignumber.js"
66-
]
65+
"ignore": ["@types/node"]
6766
},
6867
"main": "dist/index.js",
6968
"module": "dist/index.es.js",
7069
"files": [
7170
"dist"
7271
],
73-
"types": "dist/index.d.ts"
74-
}
72+
"types": "dist/src/index.d.ts"
73+
}

scripts/augmint-cli.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
2-
DOCKER_IMAGE=augmint/contracts:v1.0.9
2+
CONTRACTS_VERSION=`yarn list --pattern @augmint/contracts --depth=0 -s` # output: └─ @augmint/[email protected]
3+
DOCKER_IMAGE="augmint/contracts:v${CONTRACTS_VERSION##*@}"
34
CONTAINER_NAME=ganache
45

56
echo ""
@@ -34,7 +35,7 @@ function remove_container_if_image_mismatched {
3435
echo " It's likely because of an augmint-js upgrade since last local run of container. Removing existing $CONTAINER_NAME container."
3536

3637
stop_container_if_running
37-
38+
3839
docker rm $CONTAINER_NAME
3940
fi
4041
}
@@ -50,7 +51,7 @@ function print_instructions {
5051
case "$1" in
5152
ganache )
5253

53-
ADDITIONAL_GANACHE_LAUNCH_FLAGS=${@:3}
54+
ADDITIONAL_GANACHE_LAUNCH_FLAGS=${@:3}
5455

5556
case "$2" in
5657
run )
@@ -66,7 +67,7 @@ case "$1" in
6667
run_ganache
6768
;;
6869

69-
start )
70+
start )
7071
remove_container_if_image_mismatched
7172

7273
if [ "$(docker ps --quiet -all --filter name=^/$CONTAINER_NAME$)" ]; then
@@ -91,4 +92,4 @@ case "$1" in
9192
*)
9293
print_instructions
9394
;;
94-
esac
95+
esac

src/Augmint.ts

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import deployments from "../generated/deployments";
2-
import { AugmintContracts, Exchange as ExchangeInstance, Rates as RatesInstance, TokenAEur } from "../generated/index";
2+
import {
3+
AugmintContracts,
4+
Exchange as ExchangeInstance,
5+
LoanManager as LoanManagerInstance,
6+
Rates as RatesInstance,
7+
TokenAEur
8+
} from "../generated/index";
39
import { AugmintToken } from "./AugmintToken";
410
import * as constants from "./constants";
511
import { DeployedContract, IDeploymentItem } from "./DeployedContract";
612
import { DeployedEnvironment, ILatestContracts } from "./DeployedEnvironment";
713
import * as Errors from "./Errors";
814
import { EthereumConnection, IOptions } from "./EthereumConnection";
9-
import { Exchange } from "./Exchange";
15+
import { Exchange, IExchangeOptions } from "./Exchange";
1016
import * as gas from "./gas";
17+
import { ILoanManagerOptions, LoanManager } from "./LoanManager";
1118
import { Rates } from "./Rates";
1219
import { Transaction } from "./Transaction";
1320

@@ -43,6 +50,7 @@ export class Augmint {
4350
private _token: AugmintToken;
4451
private _rates: Rates;
4552
private _exchange: Exchange;
53+
private _loanManager: LoanManager;
4654

4755
private constructor(ethereumConnection: EthereumConnection, environment?: DeployedEnvironment) {
4856
this.ethereumConnection = ethereumConnection;
@@ -88,6 +96,14 @@ export class Augmint {
8896
return Transaction;
8997
}
9098

99+
static get Exchange(): typeof Exchange {
100+
return Exchange;
101+
}
102+
103+
static get LoanManager(): typeof LoanManager {
104+
return LoanManager;
105+
}
106+
91107
get token(): AugmintToken {
92108
if (!this._token) {
93109
const tokenContract: DeployedContract<TokenAEur> = this.deployedEnvironment.getLatestContract(
@@ -103,12 +119,7 @@ export class Augmint {
103119
const ratesContract: DeployedContract<RatesInstance> = this.deployedEnvironment.getLatestContract(
104120
AugmintContracts.Rates
105121
);
106-
this._rates = new Rates(ratesContract.connect(this.web3), {
107-
decimals: this.token.decimals,
108-
decimalsDiv: this.token.decimalsDiv,
109-
constants,
110-
ethereumConnection: this.ethereumConnection
111-
});
122+
this._rates = new Rates(ratesContract.connect(this.web3), this.ethereumConnection);
112123
}
113124
return this._rates;
114125
}
@@ -121,19 +132,41 @@ export class Augmint {
121132
this._exchange = new Exchange(exchangeContract.connect(this.web3), {
122133
token: this.token,
123134
rates: this.rates,
124-
ONE_ETH_IN_WEI: constants.ONE_ETH_IN_WEI,
125135
ethereumConnection: this.ethereumConnection
126136
});
127137
}
128138
return this._exchange;
129139
}
130140

131-
public getLegacyTokens(): AugmintToken[] {
132-
const legacyTokens: Array<DeployedContract<TokenAEur>> = this.deployedEnvironment.getLegacyContracts(
133-
AugmintContracts.TokenAEur
134-
);
141+
get loanManager(): LoanManager {
142+
if (!this._loanManager) {
143+
const loanManagerContract: DeployedContract<
144+
LoanManagerInstance
145+
> = this.deployedEnvironment.getLatestContract(AugmintContracts.LoanManager);
146+
this._loanManager = new LoanManager(loanManagerContract.connect(this.web3), {
147+
token: this.token,
148+
rates: this.rates,
149+
ethereumConnection: this.ethereumConnection
150+
});
151+
}
152+
return this._loanManager;
153+
}
154+
155+
public getLegacyTokens(addresses: string[] = []): AugmintToken[] {
156+
let legacyTokens: Array<DeployedContract<TokenAEur>> = [];
157+
158+
if (addresses.length === 0) {
159+
legacyTokens = this.deployedEnvironment.getLegacyContracts(AugmintContracts.TokenAEur);
160+
} else {
161+
legacyTokens = this.deployedEnvironment.getContractFromAddresses(AugmintContracts.TokenAEur, addresses);
162+
if (legacyTokens.length !== addresses.length) {
163+
throw new Error("legacy contracts length mismatch!");
164+
}
165+
}
166+
135167
return legacyTokens.map(
136-
tokenContract => new AugmintToken(tokenContract.connect(this.web3), { web3: this.web3 })
168+
(tokenContract: DeployedContract<TokenAEur>) =>
169+
new AugmintToken(tokenContract.connect(this.web3), { web3: this.web3 })
137170
);
138171
}
139172

@@ -148,15 +181,37 @@ export class Augmint {
148181
throw new Error("legacy contracts length mismatch!");
149182
}
150183
}
151-
const options = {
152-
decimalsDiv: this.token.decimalsDiv,
184+
const options: IExchangeOptions = {
153185
token: this.token, // FIXME: This should come from the exchange contract's augmintToken property
154186
rates: this.rates,
155-
ONE_ETH_IN_WEI: constants.ONE_ETH_IN_WEI,
156187
ethereumConnection: this.ethereumConnection
157188
};
158189
return legacyContracts.map(
159190
(contract: DeployedContract<ExchangeInstance>) => new Exchange(contract.connect(this.web3), options)
160191
);
161192
}
193+
194+
// augmint.getLegacyLoanManagers(Augmint.constants.SUPPORTED_LEGACY_LOANMANAGERS)
195+
public getLegacyLoanManagers(addresses: string[] = []): LoanManager[] {
196+
let legacyContracts: Array<DeployedContract<LoanManagerInstance>> = [];
197+
if (addresses.length === 0) {
198+
legacyContracts = this.deployedEnvironment.getLegacyContracts(AugmintContracts.LoanManager);
199+
} else {
200+
legacyContracts = this.deployedEnvironment.getContractFromAddresses(
201+
AugmintContracts.LoanManager,
202+
addresses
203+
);
204+
if (legacyContracts.length !== addresses.length) {
205+
throw new Error("legacy contracts length mismatch!");
206+
}
207+
}
208+
const options: ILoanManagerOptions = {
209+
token: this.token, // FIXME: This should come from LoanManager contract's augmintToken property
210+
rates: this.rates, // FIXME: This should come from LoanManager contract's rates property
211+
ethereumConnection: this.ethereumConnection
212+
};
213+
return legacyContracts.map(
214+
(contract: DeployedContract<LoanManagerInstance>) => new LoanManager(contract.connect(this.web3), options)
215+
);
216+
}
162217
}

src/Errors.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ export class ZeroRateError extends AugmintJsError {
1717
}
1818
}
1919

20-
// tslint:disable-next-line:max-classes-per-file
21-
export class InvalidPriceError extends AugmintJsError {
22-
constructor(message: string) {
23-
super(message);
24-
this.name = InvalidPriceError.name;
25-
Object.setPrototypeOf(this, InvalidPriceError.prototype);
26-
}
27-
}
28-
2920
// tslint:disable-next-line:max-classes-per-file
3021
export class TransactionError extends AugmintJsError {
3122
constructor(message: string) {

0 commit comments

Comments
 (0)