From 0e6f0673f2601d13daefec6cb514f596e7360097 Mon Sep 17 00:00:00 2001 From: Ethan Date: Fri, 1 May 2020 21:12:39 -0400 Subject: [PATCH] Compare token symbols in scd cdp service --- packages/dai-plugin-scd/src/EthereumCdpService.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/dai-plugin-scd/src/EthereumCdpService.js b/packages/dai-plugin-scd/src/EthereumCdpService.js index a12bb9555..d289b034f 100644 --- a/packages/dai-plugin-scd/src/EthereumCdpService.js +++ b/packages/dai-plugin-scd/src/EthereumCdpService.js @@ -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)); @@ -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}` @@ -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); }