How to use the speedomatic.unfix function in speedomatic

To help you get started, we’ve selected a few speedomatic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AugurProject / augur.js / scripts / helpers / check-mailbox.js View on Github external
augur.rpc.eth.getBalance([marketMailboxAddress, "latest"], function (attoEthBalance) {
        var ethBalance = speedomatic.bignum(attoEthBalance);
        var combined = speedomatic.unfix(ethBalance.add(cashBalance), "string");
        console.log(chalk.green.dim("Total balance:"), chalk.green(combined));
        process.exit();
      });
    });
github AugurProject / augur.js / scripts / helpers / get-account-balance.js View on Github external
augur.rpc.eth.getBalance([account, "latest"], function (err, etherBalance) {
        if (err) return console.error(err);
        if (etherBalance == null) return console.error("rpc.eth.getBalance failed:", etherBalance);
        var balances = {
          reputation: speedomatic.unfix(reputationBalance, "string"),
          ether: speedomatic.unfix(etherBalance, "string"),
        };
        console.log(chalk.cyan("Balances:"));
        console.log("Ether:      " + chalk.green(balances.ether));
        console.log("Reputation: " + chalk.green(balances.reputation));
        process.exit(0);
      });
    });
github AugurProject / augur.js / scripts / helpers / get-account-balance.js View on Github external
augur.rpc.eth.getBalance([account, "latest"], function (err, etherBalance) {
        if (err) return console.error(err);
        if (etherBalance == null) return console.error("rpc.eth.getBalance failed:", etherBalance);
        var balances = {
          reputation: speedomatic.unfix(reputationBalance, "string"),
          ether: speedomatic.unfix(etherBalance, "string"),
        };
        console.log(chalk.cyan("Balances:"));
        console.log("Ether:      " + chalk.green(balances.ether));
        console.log("Reputation: " + chalk.green(balances.reputation));
        process.exit(0);
      });
    });
github AugurProject / augur / packages / augur-ui / src / modules / auth / actions / get-ether-balance.ts View on Github external
augur.rpc.eth.getBalance([address, "latest"], (err: any, attoEtherBalance: String) => {
    if (err) return callback(err);
    const etherBalance = speedomatic.unfix(attoEtherBalance, "string");
    callback(null, etherBalance, address);
  });
}
github AugurProject / augur.js / src / parsers / position-in-market.js View on Github external
module.exports = function (positionInMarket) {
  var numOutcomes, position, i;
  if (!positionInMarket || positionInMarket.error) return positionInMarket;
  numOutcomes = positionInMarket.length;
  position = {};
  for (i = 0; i < numOutcomes; ++i) {
    position[i + 1] = speedomatic.unfix(speedomatic.hex(positionInMarket[i], true), "string");
  }
  return position;
};
github AugurProject / augur.js / src / parsers / order.js View on Github external
var fullPrecisionAmount = speedomatic.unfix(order[0]);
  var amount = roundToPrecision(fullPrecisionAmount, constants.MINIMUM_TRADE_SIZE);
  if (amount === null) return null;

  var fullPrecisionPrice = denormalizePrice({ minPrice: minPrice, maxPrice: maxPrice, normalizedPrice: speedomatic.unfixSigned(order[1]) });
  var price = roundToPrecision(new BigNumber(fullPrecisionPrice, 10), constants.PRECISION.zero, round, roundingMode);
  if (price === null) return null;

  return {
    amount: amount,
    fullPrecisionAmount: fullPrecisionAmount.toFixed(),
    price: price,
    fullPrecisionPrice: fullPrecisionPrice,
    owner: speedomatic.formatEthereumAddress(order[2]),
    tokensEscrowed: speedomatic.unfix(order[3], "string"),
    sharesEscrowed: speedomatic.unfix(order[4], "string"),
    betterOrderId: speedomatic.formatInt256(order[5]),
    worseOrderId: speedomatic.formatInt256(order[6]),
    gasPrice: speedomatic.encodeNumberAsBase10String(order[7]),
  };
};
github AugurProject / augur.js / src / parsers / order.js View on Github external
var fullPrecisionAmount = speedomatic.unfix(order[0]);
  var amount = roundToPrecision(fullPrecisionAmount, constants.MINIMUM_TRADE_SIZE);
  if (amount === null) return null;

  var fullPrecisionPrice = denormalizePrice({ minPrice: minPrice, maxPrice: maxPrice, normalizedPrice: speedomatic.unfixSigned(order[1]) });
  var price = roundToPrecision(new BigNumber(fullPrecisionPrice, 10), constants.PRECISION.zero, round, roundingMode);
  if (price === null) return null;

  return {
    amount: amount,
    fullPrecisionAmount: fullPrecisionAmount.toFixed(),
    price: price,
    fullPrecisionPrice: fullPrecisionPrice,
    owner: speedomatic.formatEthereumAddress(order[2]),
    tokensEscrowed: speedomatic.unfix(order[3], "string"),
    sharesEscrowed: speedomatic.unfix(order[4], "string"),
    betterOrderId: speedomatic.formatInt256(order[5]),
    worseOrderId: speedomatic.formatInt256(order[6]),
    gasPrice: speedomatic.encodeNumberAsBase10String(order[7]),
  };
};
github AugurProject / augur.js / src / reporting / format / is-special-value-consensus-outcome.js View on Github external
function isSpecialValueConsensusOutcome(fxpConsensusOutcome, minValue, maxValue) {
  var bnFxpConsensusOutcome, meanValue;
  bnFxpConsensusOutcome = speedomatic.bignum(fxpConsensusOutcome);
  if (bnFxpConsensusOutcome.eq(1)) {
    return "0";
  }
  meanValue = speedomatic.fix(maxValue).plus(speedomatic.fix(minValue)).dividedBy(2);
  if (bnFxpConsensusOutcome.eq(meanValue.plus(1))) {
    return speedomatic.unfix(meanValue, "string");
  }
  return false;
}
github AugurProject / augur-ui / src / utils / format-number.js View on Github external
export function formatGasCostToEther(num, opts, gasPrice) {
  const gas = unfix(num, "number");
  const estimatedGasCost = createBigNumber(gas).times(
    createBigNumber(gasPrice)
  );
  return formatGasCost(estimatedGasCost, opts).rounded;
}
github AugurProject / augur / packages / augur-tools / scripts / dp / lib / get-balances.js View on Github external
augur.rpc.eth.getBalance([address, "latest"], function (err, etherBalance) {
        if (err) return callback(err);
        if (etherBalance == null) return callback(new Error("rpc.eth.getBalance failed"));
        return callback(null, {
          reputation: speedomatic.unfix(reputationBalance, "string"),
          ether: speedomatic.unfix(etherBalance, "string"),
        });
      });
    });

speedomatic

Grab bag of formatting and ABI encoding/decoding functions

MIT
Latest version published 7 years ago

Package Health Score

46 / 100
Full package analysis

Popular speedomatic functions

Similar packages