How to use the ripple-lib.Currency function in ripple-lib

To help you get started, we’ve selected a few ripple-lib 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 ripple-unmaintained / ripple-watch / bot.js View on Github external
#!/usr/bin/node

var Amount        = require("ripple-lib").Amount;
var Currency      = require("ripple-lib").Currency;
var Remote        = require("ripple-lib").Remote;
var Transaction   = require("ripple-lib").Transaction;
var UInt160       = require("ripple-lib").UInt160;
var async         = require("async");
var extend        = require("extend");
var irc           = require("irc");
var gateways      = require("./config").gateways;
var hotwallets    = require("./config").hotwallets;
var irc_config    = require("./config").irc_config;
var remote_config = require("./config").remote_config;

// extend(require("ripple-lib/src/js/config"), require("./config"));

var self  = this;

self.total_coins  = undefined;
github ripple-unmaintained / ripple-chart / rchart.js View on Github external
#!/usr/bin/node
//
// ripple-chart: rchart.js
//
// Ripple server for bitcoincharts.com as per http://bitcoincharts.com/about/exchanges/
//

var async           = require('async');
var EventEmitter    = require('events').EventEmitter;
var http            = require("http");
var mysql           = require('mysql');
var url             = require("url");
var Amount          = require("ripple-lib").Amount;
var Currency        = require("ripple-lib").Currency;
var Remote          = require("ripple-lib").Remote;
var UInt160         = require("ripple-lib").UInt160;

var Range           = require('./range').Range;

var config          = require("./config").config;
var httpd_config    = require("./config").httpd_config;
var markets         = require("./config").markets;
var mysql_config    = require("./config").mysql_config;
var rippled_config  = require("./config").rippled_config;

var remote;
var currencies      = Object.keys(markets);
var sources         = [];

var pairs   = [
github ripple-unmaintained / ripple-chart / rbc.js View on Github external
//
// Ripple server for bitcoincharts.com as per http://bitcoincharts.com/about/exchanges/
//
// Served at: /CUR/trades.json?since=123
// Served at: /CUR/orderbook.json
//
// TODO:
// - Finding min ledger is broken
//

var async           = require('async');
var http            = require("http");
var mysql           = require('mysql');
var url             = require("url");
var Amount          = require("ripple-lib").Amount;
var Currency        = require("ripple-lib").Currency;
var Remote          = require("ripple-lib").Remote;
var UInt160         = require("ripple-lib").UInt160;

var Range           = require('./range').Range;

var btc_gateways    = require("./config").btc_gateways;
var config          = require("./config").config;
var httpd_config    = require("./config").httpd_config;
var markets         = require("./config").markets;
var mysql_config    = require("./config").mysql_config;
var rippled_config  = require("./config").rippled_config;

var remote;
var sources = [];

var processed = {
github ripple / ripple-data-api / api / library / hbase / hbase-client.js View on Github external
function handleInterest (rows) {
    var base    = ripple.Currency.from_json(options.base.currency);
    var counter = ripple.Currency.from_json(options.counter.currency);

    if (base.has_interest()) {
      if (options.unreduced) {
        rows.forEach(function(row, i){

          //apply interest to the base amount
          var amount = ripple.Amount.from_human(row.base_amount + " " + options.base.currency)
            .applyInterest(new Date(row.time*1000))
            .to_human();
          var pct = row.base_amount/amount;

          row.base_amount = amount;
          row.rate       *= pct;
        });

      } else {
github ripple / ripple-data-api / api / routes / offersExercised.js View on Github external
function handleInterest (rows) {
    var base    = ripple.Currency.from_json(params.base.currency);
    var counter = ripple.Currency.from_json(params.counter.currency);
    
    if (base.has_interest()) {
      if (options.view.reduce === false) {
        rows.forEach(function(row, i){
          if (!i) return;
        
          //apply interest to the base amount
          amount = ripple.Amount.from_human(row[2] + " " + params.base.currency).applyInterest(new Date(row[0])).to_human(); 
          pct   = row[2]/amount; 
          
          rows[i][2]  = amount;
          rows[i][1] *= pct;         
        });
        
      } else {
github ripple / ripple-data-api / api / routes / offersExercised.js View on Github external
function handleInterest (rows) {
    var base    = ripple.Currency.from_json(params.base.currency);
    var counter = ripple.Currency.from_json(params.counter.currency);
    
    if (base.has_interest()) {
      if (options.view.reduce === false) {
        rows.forEach(function(row, i){
          if (!i) return;
        
          //apply interest to the base amount
          amount = ripple.Amount.from_human(row[2] + " " + params.base.currency).applyInterest(new Date(row[0])).to_human(); 
          pct   = row[2]/amount; 
          
          rows[i][2]  = amount;
          rows[i][1] *= pct;         
        });
        
      } else {
        rows.forEach(function(row, i){