IPC removed, replaced by WS
This commit is contained in:
1 parent
ba4217fb24
commit
656c193511
503 files changed
+28128
-34498
No files matched your search
+57
-38
@@ -47,10 +47,10 @@ module.exports = class bytetrade extends Exchange {
|
||||
'1M': '1M',
|
||||
},
|
||||
'urls': {
|
||||
'test': 'https://api-v2-test.bytetrade.com',
|
||||
'test': 'https://api-v2-test.byte-trade.com',
|
||||
'logo': 'https://user-images.githubusercontent.com/1294454/67288762-2f04a600-f4e6-11e9-9fd6-c60641919491.jpg',
|
||||
'api': 'https://api-v2.bytetrade.com',
|
||||
'www': 'https://www.bytetrade.com',
|
||||
'api': 'https://api-v2.byte-trade.com',
|
||||
'www': 'https://www.byte-trade.com',
|
||||
'doc': 'https://github.com/Bytetrade/bytetrade-official-api-docs/wiki',
|
||||
},
|
||||
'api': {
|
||||
@@ -92,6 +92,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
},
|
||||
},
|
||||
'commonCurrencies': {
|
||||
'44': 'ByteHub',
|
||||
'48': 'Blocktonic',
|
||||
},
|
||||
'exceptions': {
|
||||
@@ -116,7 +117,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
code = this.safeString (currency, 'name');
|
||||
}
|
||||
const name = this.safeString (currency, 'fullname');
|
||||
// in bytetrade.com DEX, request https://api-v2.bytetrade.com/currencies will return currencies,
|
||||
// in byte-trade.com DEX, request https://api-v2.byte-trade.com/currencies will return currencies,
|
||||
// the api doc is https://github.com/Bytetrade/bytetrade-official-api-docs/wiki/rest-api#get-currencies-get-currencys-supported-in-bytetradecom
|
||||
// we can see the coin name is none-unique in the result, the coin which code is 18 is the CyberMiles ERC20, and the coin which code is 35 is the CyberMiles main chain, but their name is same.
|
||||
// that is because bytetrade is a DEX, supports people create coin with the same name, but the id(code) of coin is unique, so we should use the id or name and id as the identity of coin.
|
||||
@@ -216,6 +217,9 @@ module.exports = class bytetrade extends Exchange {
|
||||
const id = this.safeString (market, 'symbol');
|
||||
let base = this.safeString (market, 'baseName');
|
||||
let quote = this.safeString (market, 'quoteName');
|
||||
const normalBase = base.split ('@')[0];
|
||||
const normalQuote = quote.split ('@')[0];
|
||||
const normalSymbol = normalBase + '/' + normalQuote;
|
||||
const baseId = this.safeString (market, 'base');
|
||||
const quoteId = this.safeString (market, 'quote');
|
||||
if (baseId in this.commonCurrencies) {
|
||||
@@ -230,9 +234,6 @@ module.exports = class bytetrade extends Exchange {
|
||||
const price = this.safeValue (limits, 'price', {});
|
||||
const precision = this.safeValue (market, 'precision', {});
|
||||
const active = this.safeString (market, 'active');
|
||||
const normalBase = base.split ('@')[0];
|
||||
const normalQuote = quote.split ('@')[0];
|
||||
const normalSymbol = normalBase + '/' + normalQuote;
|
||||
const entry = {
|
||||
'id': id,
|
||||
'symbol': symbol,
|
||||
@@ -540,6 +541,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
return {
|
||||
'info': order,
|
||||
'id': id,
|
||||
'clientOrderId': undefined,
|
||||
'timestamp': timestamp,
|
||||
'datetime': datetime,
|
||||
'lastTradeTimestamp': lastTradeTimestamp,
|
||||
@@ -554,6 +556,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
'remaining': remaining,
|
||||
'status': status,
|
||||
'fee': fee,
|
||||
'trades': undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -575,23 +578,25 @@ module.exports = class bytetrade extends Exchange {
|
||||
typeNum = 1;
|
||||
} else {
|
||||
typeNum = 2;
|
||||
price = 0;
|
||||
}
|
||||
const normalSymbol = market['normalSymbol'];
|
||||
const baseId = market['baseId'];
|
||||
const baseCurrency = this.currency (market['base']);
|
||||
const amountTruncated = this.amountToPrecision (symbol, amount);
|
||||
const amountChain = this.toWei (amountTruncated, 'ether', baseCurrency['precision']['amount']);
|
||||
const amountChain = this.toWei (amountTruncated, baseCurrency['precision']['amount']);
|
||||
const quoteId = market['quoteId'];
|
||||
const quoteCurrency = this.currency (market['quote']);
|
||||
const priceRounded = this.priceToPrecision (symbol, price);
|
||||
const priceChain = this.toWei (priceRounded, 'ether', quoteCurrency['precision']['amount']);
|
||||
const priceChain = this.toWei (priceRounded, quoteCurrency['precision']['amount']);
|
||||
const now = this.milliseconds ();
|
||||
const expiration = this.milliseconds ();
|
||||
let datetime = this.iso8601 (now);
|
||||
datetime = datetime.split ('.')[0];
|
||||
let expirationDatetime = this.iso8601 (expiration);
|
||||
expirationDatetime = expirationDatetime.split ('.')[0];
|
||||
const chainName = 'Sagittarius';
|
||||
const defaultDappId = 'Sagittarius';
|
||||
const dappId = this.safeString (params, 'dappId', defaultDappId);
|
||||
const defaultFee = this.safeString (this.options, 'fee', '300000000000000');
|
||||
const fee = this.safeString (params, 'fee', defaultFee);
|
||||
const eightBytes = this.integerPow ('2', '64');
|
||||
@@ -622,8 +627,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
this.numberToLE (parseInt (baseId), 4),
|
||||
this.numberToLE (0, 1),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (chainName.length, 1),
|
||||
this.stringToBinary (this.encode (chainName)),
|
||||
this.numberToLE (dappId.length, 1),
|
||||
this.stringToBinary (this.encode (dappId)),
|
||||
this.numberToLE (0, 1),
|
||||
];
|
||||
const txByteStringArray = [
|
||||
@@ -652,8 +657,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
this.numberToLE (parseInt (baseId), 4),
|
||||
this.numberToLE (0, 1),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (chainName.length, 1),
|
||||
this.stringToBinary (this.encode (chainName)),
|
||||
this.numberToLE (dappId.length, 1),
|
||||
this.stringToBinary (this.encode (dappId)),
|
||||
this.numberToLE (0, 1),
|
||||
];
|
||||
const txbytestring = this.binaryConcatArray (txByteStringArray);
|
||||
@@ -696,7 +701,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
],
|
||||
],
|
||||
'validate_type': 0,
|
||||
'dapp': 'Sagittarius',
|
||||
'dapp': dappId,
|
||||
'signatures': [
|
||||
mySignature,
|
||||
],
|
||||
@@ -725,6 +730,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
'cost': undefined,
|
||||
'trades': undefined,
|
||||
'fee': undefined,
|
||||
'clientOrderId': undefined,
|
||||
'average': undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -825,7 +832,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
datetime = datetime.split ('.')[0];
|
||||
let expirationDatetime = this.iso8601 (expiration);
|
||||
expirationDatetime = expirationDatetime.split ('.')[0];
|
||||
const chainName = 'Sagittarius';
|
||||
const defaultDappId = 'Sagittarius';
|
||||
const dappId = this.safeString (params, 'dappId', defaultDappId);
|
||||
const byteStringArray = [
|
||||
this.numberToBE (1, 32),
|
||||
this.numberToLE (Math.floor (now / 1000), 4),
|
||||
@@ -844,8 +852,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
this.numberToLE (parseInt (baseId), 4),
|
||||
this.numberToLE (0, 1),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (chainName.length, 1),
|
||||
this.stringToBinary (this.encode (chainName)),
|
||||
this.numberToLE (dappId.length, 1),
|
||||
this.stringToBinary (this.encode (dappId)),
|
||||
this.numberToLE (0, 1),
|
||||
];
|
||||
const bytestring = this.binaryConcatArray (byteStringArray);
|
||||
@@ -871,7 +879,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
],
|
||||
],
|
||||
'validate_type': 0,
|
||||
'dapp': 'Sagittarius',
|
||||
'dapp': dappId,
|
||||
'signatures': [
|
||||
mySignature,
|
||||
],
|
||||
@@ -900,10 +908,12 @@ module.exports = class bytetrade extends Exchange {
|
||||
'cost': undefined,
|
||||
'trades': undefined,
|
||||
'fee': undefined,
|
||||
'clientOrderId': undefined,
|
||||
'average': undefined,
|
||||
};
|
||||
}
|
||||
|
||||
async transfer (code, amount, address, params = {}) {
|
||||
async transfer (code, amount, address, message = '', params = {}) {
|
||||
this.checkRequiredDependencies ();
|
||||
if (this.apiKey === undefined) {
|
||||
throw new ArgumentsRequired ('transfer requires this.apiKey');
|
||||
@@ -911,7 +921,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
await this.loadMarkets ();
|
||||
const currency = this.currency (code);
|
||||
const amountTruncate = this.decimalToPrecision (amount, TRUNCATE, currency['info']['transferPrecision'], DECIMAL_PLACES, NO_PADDING);
|
||||
const amountChain = this.toWei (amountTruncate, 'ether', currency['precision']['amount']);
|
||||
const amountChain = this.toWei (amountTruncate, currency['precision']['amount']);
|
||||
const assetType = parseInt (currency['id']);
|
||||
const now = this.milliseconds ();
|
||||
const expiration = now;
|
||||
@@ -920,7 +930,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
let expirationDatetime = this.iso8601 (expiration);
|
||||
expirationDatetime = expirationDatetime.split ('.')[0];
|
||||
const feeAmount = '300000000000000';
|
||||
const chainName = 'Sagittarius';
|
||||
const defaultDappId = 'Sagittarius';
|
||||
const dappId = this.safeString (params, 'dappId', defaultDappId);
|
||||
const eightBytes = this.integerPow ('2', '64');
|
||||
const byteStringArray = [
|
||||
this.numberToBE (1, 32),
|
||||
@@ -928,7 +939,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (Math.floor (expiration / 1000), 4),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (0, 1),
|
||||
this.numberToLE (28, 1),
|
||||
this.numberToLE (0, 8),
|
||||
this.numberToLE (feeAmount, 8), // string for 32 bit php
|
||||
this.numberToLE (this.apiKey.length, 1),
|
||||
@@ -938,10 +949,13 @@ module.exports = class bytetrade extends Exchange {
|
||||
this.numberToLE (assetType, 4),
|
||||
this.numberToLE (this.integerDivide (amountChain, eightBytes), 8),
|
||||
this.numberToLE (this.integerModulo (amountChain, eightBytes), 8),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (message.length, 1),
|
||||
this.stringToBinary (this.encode (message)),
|
||||
this.numberToLE (0, 1),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (chainName.length, 1),
|
||||
this.stringToBinary (this.encode (chainName)),
|
||||
this.numberToLE (dappId.length, 1),
|
||||
this.stringToBinary (this.encode (dappId)),
|
||||
this.numberToLE (0, 1),
|
||||
];
|
||||
const bytestring = this.binaryConcatArray (byteStringArray);
|
||||
@@ -955,18 +969,19 @@ module.exports = class bytetrade extends Exchange {
|
||||
'to': address,
|
||||
'asset_type': parseInt (currency['id']),
|
||||
'amount': amountChain.toString (),
|
||||
'message': message,
|
||||
};
|
||||
const fatty = {
|
||||
'timestamp': datetime,
|
||||
'expiration': expirationDatetime,
|
||||
'operations': [
|
||||
[
|
||||
0,
|
||||
28,
|
||||
operation,
|
||||
],
|
||||
],
|
||||
'validate_type': 0,
|
||||
'dapp': 'Sagittarius',
|
||||
'dapp': dappId,
|
||||
'signatures': [
|
||||
mySignature,
|
||||
],
|
||||
@@ -999,6 +1014,9 @@ module.exports = class bytetrade extends Exchange {
|
||||
'remaining': undefined,
|
||||
'cost': undefined,
|
||||
'fee': undefined,
|
||||
'clientOrderId': undefined,
|
||||
'average': undefined,
|
||||
'trades': undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1178,12 +1196,13 @@ module.exports = class bytetrade extends Exchange {
|
||||
datetime = datetime.split ('.')[0];
|
||||
let expirationDatetime = this.iso8601 (expiration);
|
||||
expirationDatetime = expirationDatetime.split ('.')[0];
|
||||
const chainName = 'Sagittarius';
|
||||
const defaultDappId = 'Sagittarius';
|
||||
const dappId = this.safeString (params, 'dappId', defaultDappId);
|
||||
const feeAmount = '300000000000000';
|
||||
const currency = this.currency (code);
|
||||
const coinId = currency['id'];
|
||||
const amountTruncate = this.decimalToPrecision (amount, TRUNCATE, currency['info']['transferPrecision'], DECIMAL_PLACES, NO_PADDING);
|
||||
const amountChain = this.toWei (amountTruncate, 'ether', currency['info']['externalPrecision']);
|
||||
const amountChain = this.toWei (amountTruncate, currency['info']['externalPrecision']);
|
||||
const eightBytes = this.integerPow ('2', '64');
|
||||
let assetFee = 0;
|
||||
let byteStringArray = [];
|
||||
@@ -1210,8 +1229,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
this.numberToLE (this.integerModulo (assetFee, eightBytes), 8),
|
||||
this.numberToLE (0, 1),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (chainName.length, 1),
|
||||
this.stringToBinary (this.encode (chainName)),
|
||||
this.numberToLE (dappId.length, 1),
|
||||
this.stringToBinary (this.encode (dappId)),
|
||||
this.numberToLE (0, 1),
|
||||
];
|
||||
} else {
|
||||
@@ -1240,8 +1259,8 @@ module.exports = class bytetrade extends Exchange {
|
||||
this.numberToLE (this.integerModulo (amountChain, eightBytes), 8),
|
||||
this.numberToLE (0, 1),
|
||||
this.numberToLE (1, 1),
|
||||
this.numberToLE (chainName.length, 1),
|
||||
this.stringToBinary (this.encode (chainName)),
|
||||
this.numberToLE (dappId.length, 1),
|
||||
this.stringToBinary (this.encode (dappId)),
|
||||
this.numberToLE (0, 1),
|
||||
];
|
||||
}
|
||||
@@ -1273,7 +1292,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
],
|
||||
],
|
||||
'validate_type': 0,
|
||||
'dapp': 'Sagittarius',
|
||||
'dapp': dappId,
|
||||
'signatures': [
|
||||
mySignature,
|
||||
],
|
||||
@@ -1281,7 +1300,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
request = {
|
||||
'chainType': chainId,
|
||||
'trObj': this.json (fatty),
|
||||
'chainContractAddresss': chainContractAddress,
|
||||
'chainContractAddress': chainContractAddress,
|
||||
};
|
||||
} else {
|
||||
operation = {
|
||||
@@ -1310,7 +1329,7 @@ module.exports = class bytetrade extends Exchange {
|
||||
],
|
||||
],
|
||||
'validate_type': 0,
|
||||
'dapp': 'Sagittarius',
|
||||
'dapp': dappId,
|
||||
'signatures': [
|
||||
mySignature,
|
||||
],
|
||||
@@ -1320,14 +1339,14 @@ module.exports = class bytetrade extends Exchange {
|
||||
'chainType': chainId,
|
||||
'toExternalAddress': 'noneed',
|
||||
'trObj': this.json (fatty),
|
||||
'chainContractAddresss': chainContractAddress,
|
||||
'chainContractAddress': chainContractAddress,
|
||||
};
|
||||
} else {
|
||||
request = {
|
||||
'chainType': chainId,
|
||||
'toExternalAddress': address,
|
||||
'trObj': this.json (fatty),
|
||||
'chainContractAddresss': chainContractAddress,
|
||||
'chainContractAddress': chainContractAddress,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user