Skip to content

Commit

Permalink
Merge pull request #555 from Augmint/interest_rounding_dashboard_fix
Browse files Browse the repository at this point in the history
loan & lock products interest rate rounding fix on stability dashboard
  • Loading branch information
admrid authored Mar 28, 2019
2 parents 1264b0e + fdb6f9d commit 5d19943
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
8 changes: 2 additions & 6 deletions src/containers/augmintToken/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ class AugmintToken extends React.Component {
{product.isActive && (
<StyledRow halign="justify">
<StyledCol width={1 / 2}>{product.termText}</StyledCol>
<StyledCol width={1 / 2}>
{Math.floor(product.interestRatePa * 10000) / 100 + "%"}
</StyledCol>
<StyledCol width={1 / 2}>{product.interestRatePaPt}%</StyledCol>
</StyledRow>
)}
</div>
Expand All @@ -153,9 +151,7 @@ class AugmintToken extends React.Component {
<StyledCol width={1 / 2} className="alignLeft">
{product.durationText}
</StyledCol>
<StyledCol width={1 / 2}>
{Math.floor(product.interestRatePa * 10000) / 100 + "%"}
</StyledCol>
<StyledCol width={1 / 2}>{product.interestRatePaPt}%</StyledCol>
</StyledRow>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/containers/loan/components/LoanProductDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export default function LoanProductDetails(props) {
<Col>
Interest p.a.:{" "}
<LoanInterestRatePaToolTip
interestRatePa={prod.interestRatePa}
interestRatePaPt={prod.interestRatePaPt}
id={"Loan_interest_rate_pa_tooltip"}
/>
</Col>
<Col>{Math.round(prod.interestRatePa * 10000) / 100}%</Col>
<Col>{prod.interestRatePaPt}%</Col>
</Row>
<Row>
<Col>
Expand Down
2 changes: 1 addition & 1 deletion src/containers/lock/components/LockDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function LockDetails(props) {
<Row>
<Col>Interest amount:</Col>
<Col>
{lock.interestEarned} A-EUR ({(lock.interestRatePa * 100).toFixed(2)} % p.a)
{lock.interestEarned} A-EUR ({lock.interestRatePaPt} % p.a)
</Col>
</Row>

Expand Down
4 changes: 1 addition & 3 deletions src/containers/lock/containers/LockForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ class LockContainer extends React.Component {
<TermTableCell>
{Math.floor(product.maxLockAmount)} A€
</TermTableCell>
<TermTableCell>
{Math.floor(product.interestRatePa * 10000) / 100} %
</TermTableCell>
<TermTableCell>{product.interestRatePaPt} %</TermTableCell>
<TermTableCell style={{ textAlign: "right" }}>
{this.props.lockAmount &&
`${Math.ceil(
Expand Down
2 changes: 1 addition & 1 deletion src/containers/lock/lockList/LockCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function LockCard(props) {
<DataRow>
<DataLabel>Interest amount:</DataLabel>
<DataValue>
{lock.interestEarned} A-EUR ({(lock.interestRatePa * 100).toFixed(2)} % p.a)
{lock.interestEarned} A-EUR ({lock.interestRatePa} % p.a)
</DataValue>
</DataRow>
</DataGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/modules/ethereum/loanTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function parseProducts(productsArray) {
termText: moment.duration(termInSecs, "seconds").humanize(), // TODO: less precision for duration: https://github.com/jsmreese/moment-duration-format
bn_discountRate,
interestRatePa,
interestRatePaPt: Math.round(interestRatePa * 10000) / 100,
discountRate,
bn_collateralRatio,
collateralRatio: bn_collateralRatio / PPM_DIV,
Expand Down Expand Up @@ -191,8 +192,8 @@ export async function collectLoansTx(loanManagerInstance, loansToCollect) {
typeof receipt.events.LoanCollected === "undefined"
? 0
: Array.isArray(receipt.events.LoanCollected)
? receipt.events.LoanCollected.length
: 1;
? receipt.events.LoanCollected.length
: 1;

if (loanCollectedEventsCount !== loansToCollect.length) {
throw new EthereumTransactionError(
Expand Down
4 changes: 4 additions & 0 deletions src/modules/ethereum/lockTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function parseProducts(productsArray) {
minimumLockAmount: bn_minimumLockAmount / DECIMALS_DIV,
maxLockAmount: bn_maxLockAmount / DECIMALS_DIV,
interestRatePa,
// using floor for the "advertised" interest rate to ensure that the actual interest will be higher even with small amount
interestRatePaPt: Math.floor(interestRatePa * 10000) / 100,
isActive: parseInt(bn_isActive, 10) === 1
});
}
Expand Down Expand Up @@ -182,6 +184,8 @@ function parseLocks(locksArray) {
lockedUntilText,
perTermInterest,
interestRatePa,
// this is the actual interest rate (can be higher than advertised because of rounding up in contract code)
interestRatePaPt: Math.round(interestRatePa * 10000) / 100,
durationInSecs,
durationInDays,
durationText,
Expand Down

0 comments on commit 5d19943

Please sign in to comment.