Skip to content

Commit

Permalink
Refactor to make quality adjustment for XRP more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Clark committed Jul 10, 2015
1 parent 38b254e commit fb8eefd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api/ledger/parse/utils.js
Expand Up @@ -8,8 +8,11 @@ const BigNumber = require('bignumber.js');

function adjustQualityForXRP(quality: string, takerGetsCurrency: string,
takerPaysCurrency: string) {
const shift = (takerGetsCurrency === 'XRP' ? 6 : 0)
- (takerPaysCurrency === 'XRP' ? 6 : 0);
// quality = takerPays.value/takerGets.value
// using drops (1e-6 XRP) for XRP values
const numeratorShift = (takerPaysCurrency === 'XRP' ? -6 : 0);
const denominatorShift = (takerGetsCurrency === 'XRP' ? -6 : 0);
const shift = numeratorShift - denominatorShift;
return shift === 0 ? quality :
(new BigNumber(quality)).shift(shift).toString();
}
Expand Down

0 comments on commit fb8eefd

Please sign in to comment.