Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Compare token symbols in scd cdp service
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbennett committed May 2, 2020
1 parent 2f85808 commit 0e6f067
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/dai-plugin-scd/src/EthereumCdpService.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default class EthereumCdpService extends PrivateService {
async getCollateralValue(cdpId, unit = ETH) {
const hexCdpId = numberToBytes32(cdpId);
const pethValue = PETH.wei(await this._tubContract().ink(hexCdpId));
if (unit === PETH) return pethValue;
if (unit.symbol === PETH.symbol) return pethValue;

const pethPrice = await this.get('price').getWethToPethRatio();
const ethValue = ETH(pethValue.times(pethPrice));
Expand All @@ -258,7 +258,7 @@ export default class EthereumCdpService extends PrivateService {
const ethPrice = await this.get('price').getEthPrice();
const usdValue = ethValue.times(ethPrice);

if (unit === USD) return usdValue;
if (unit.symbol === USD.symbol) return usdValue;

throw new Error(
`Don't know how to get collateral value in ${unit ? unit.symbol : unit}`
Expand Down Expand Up @@ -302,10 +302,10 @@ export default class EthereumCdpService extends PrivateService {
.call({}, (err, val) => (err ? reject(err) : resolve(val)));
});
const usdFee = USD.wei(rap);
switch (unit) {
case USD:
switch (unit.symbol) {
case USD.symbol:
return usdFee;
case MKR: {
case MKR.symbol: {
const price = await this.get('price').getMkrPrice();
return usdFee.div(price);
}
Expand Down

0 comments on commit 0e6f067

Please sign in to comment.