updateCruzToBtcWithVinex function

void updateCruzToBtcWithVinex(
  1. ExchangeRates rates,
  2. {bool rateLimit = false}
)

Updates CRUZ → BTC.

Implementation

void updateCruzToBtcWithVinex(ExchangeRates rates, {bool rateLimit = false}) {
  if (rates.prepareUpdateRate('CRUZ', 'BTC', rateLimit: rateLimit) == null) {
    return;
  }

  /// {"status":200,"data":{"id":4000027,"symbol":"BTC_CRUZ","assetId1":1,"assetId2":3000015,"lastPrice":0,"bidPrice":0,"askPrice":0,"volume":0,"weeklyVolume":0,"monthlyVolume":0,"volume24h":0,"asset2Volume24h":0,"change24h":0,"high24h":0,"low24h":0,"createdAt":1564564587,"updatedAt":1565380556,"status":true,"statusTrading":1,"threshold":0.001,"tradingFee":0.001,"makerFee":null,"takerFee":null,"decPrice":8,"decAmount":8,"totalVolume":0,"tokenInfo1":{"id":1,"name":"Bitcoin","symbol":"BTC"},"tokenInfo2":{"id":3000015,"name":"Cruzbit","symbol":"CRUZ"}}}
  rates.httpClient
      .request('https://api.vinex.network/api/v2/markets/BTC_CRUZ')
      .then((resp) {
    Map<String, dynamic> data = jsonDecode(resp.text)['data'];
    String base = data['tokenInfo2']['symbol'],
        currency = data['tokenInfo1']['symbol'];
    assert(base == 'CRUZ');
    assert(currency == 'BTC');
    rates.updateRate(base, currency, data['lastPrice'], 'Vinex');
  });
}