Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ttodua committed Jul 4, 2022
2 parents ca0943e + fbcb38e commit 30005a0
Showing 1 changed file with 102 additions and 19 deletions.
121 changes: 102 additions & 19 deletions js/wavesexchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = class wavesexchange extends Exchange {
'fetchIndexOHLCV': false,
'fetchLeverage': false,
'fetchLeverageTiers': false,
'fetchMarginMode': false,
'fetchMarkets': true,
'fetchMarkOHLCV': false,
'fetchMyTrades': true,
Expand All @@ -57,6 +58,7 @@ module.exports = class wavesexchange extends Exchange {
'fetchOrderBook': true,
'fetchOrders': true,
'fetchPosition': false,
'fetchPositionMode': false,
'fetchPositions': false,
'fetchPositionsRisk': false,
'fetchPremiumIndexOHLCV': false,
Expand Down Expand Up @@ -292,7 +294,7 @@ module.exports = class wavesexchange extends Exchange {
},
'precisionMode': TICK_SIZE,
'currencies': {
'WX': { 'id': 'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc', 'numericId': undefined, 'code': 'WX', 'precision': 0.00000001 },
'WX': { 'id': 'EMAMLxDnv3xiz8RXg8Btj33jcEw3wLczL3JKYYmuubpc', 'numericId': undefined, 'code': 'WX', 'precision': this.parseNumber ('1e-8') },
},
'options': {
'allowedCandles': 1440,
Expand All @@ -304,7 +306,7 @@ module.exports = class wavesexchange extends Exchange {
'wavesAddress': undefined,
'withdrawFeeUSDN': 7420,
'withdrawFeeWAVES': 100000,
'wavesPrecision': 0.00000001,
'wavesPrecision': this.parseNumber ('1e-8'),
'messagePrefix': 'W', // W for production, T for testnet
'networks': {
'ERC20': 'ETH',
Expand Down Expand Up @@ -605,7 +607,7 @@ module.exports = class wavesexchange extends Exchange {
const precision = market['precision'];
const precisionAmountDigits = this.precisionFromString (this.safeString (precision, 'amount'));
const precisionPriceDigits = this.precisionFromString (this.safeString (precision, 'price'));
const wavesPrecision = this.safeString (this.options, 'wavesPrecision', '0.00000001');
const wavesPrecision = this.safeString (this.options, 'wavesPrecision', '1e-8');
const amountPrecision = Math.pow (10, precisionAmountDigits);
const difference = precisionAmountDigits - precisionPriceDigits;
const pricePrecision = Math.pow (10, this.precisionFromString (wavesPrecision) - difference);
Expand Down Expand Up @@ -763,15 +765,7 @@ module.exports = class wavesexchange extends Exchange {
let symbol = undefined;
if ((baseId !== undefined) && (quoteId !== undefined)) {
const marketId = baseId + '/' + quoteId;
if (marketId in this.markets_by_id) {
market = this.markets_by_id[marketId];
} else {
const base = this.safeCurrencyCode (baseId);
const quote = this.safeCurrencyCode (quoteId);
symbol = base + '/' + quote;
}
}
if ((symbol === undefined) && (market !== undefined)) {
market = this.safeMarket (marketId, market, '/');
symbol = market['symbol'];
}
const data = this.safeValue (ticker, 'data', {});
Expand Down Expand Up @@ -849,6 +843,44 @@ module.exports = class wavesexchange extends Exchange {
return this.parseTicker (ticker, market);
}

async fetchTickers (symbols = undefined, params = {}) {
/**
* @method
* @name wavesexchange#fetchTickers
* @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
* @param {[str]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {dict} params extra parameters specific to the aax api endpoint
* @returns {dict} an array of [ticker structures]{@link https://docs.ccxt.com/en/latest/manual.html#ticker-structure}
*/
await this.loadMarkets ();
const response = await this.publicGetPairs (params);
//
// {
// "__type":"list",
// "data":[
// {
// "__type":"pair",
// "data":{
// "firstPrice":0.00012512,
// "lastPrice":0.00012441,
// "low":0.00012167,
// "high":0.00012768,
// "weightedAveragePrice":0.000124710697407246,
// "volume":209554.26356614,
// "quoteVolume":26.1336583539951,
// "volumeWaves":209554.26356614,
// "txsCount":6655
// },
// "amountAsset":"WAVES",
// "priceAsset":"8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS"
// }
// ]
// }
//
const data = this.safeValue (response, 'data', []);
return this.parseTickers (data, symbols);
}

async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
/**
* @method
Expand Down Expand Up @@ -973,6 +1005,14 @@ module.exports = class wavesexchange extends Exchange {
}

async fetchDepositAddress (code, params = {}) {
/**
* @method
* @name wavesexchange#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @param {str} code unified currency code
* @param {dict} params extra parameters specific to the wavesexchange api endpoint
* @returns {dict} an [address structure]{@link https://docs.ccxt.com/en/latest/manual.html#address-structure}
*/
await this.signIn ();
const networks = this.safeValue (this.options, 'networks', {});
const rawNetwork = this.safeStringUpper (params, 'network');
Expand Down Expand Up @@ -1135,7 +1175,7 @@ module.exports = class wavesexchange extends Exchange {
const precision = market['precision'];
const precisionDigitsAmount = this.precisionFromString (this.safeString (precision, 'amount'));
const precisionDigitsPrice = this.precisionFromString (this.safeString (precision, 'price'));
const wavesPrecision = this.safeString (this.options, 'wavesPrecision', '0.00000001');
const wavesPrecision = this.safeString (this.options, 'wavesPrecision', '1e-8');
const difference = precisionDigitsAmount - precisionDigitsPrice;
return parseInt (parseFloat (this.toPrecision (price, this.precisionFromString (wavesPrecision) - difference)));
}
Expand All @@ -1155,7 +1195,7 @@ module.exports = class wavesexchange extends Exchange {
return undefined;
}
const precise = new Precise (amount);
precise.decimals = precise.decimals + scale;
precise.decimals = this.sum (precise.decimals, scale);
precise.reduce ();
return precise.toString ();
}
Expand All @@ -1178,7 +1218,7 @@ module.exports = class wavesexchange extends Exchange {
const precision = market['precision'];
const precisionAmountDigits = this.precisionFromString (this.safeString (precision, 'amount'));
const precisionPriceDigits = this.precisionFromString (this.safeString (precision, 'price'));
const wavesPrecision = this.safeString (this.options, 'wavesPrecision', '0.00000001');
const wavesPrecision = this.safeString (this.options, 'wavesPrecision', '1e-8');
const scale = this.precisionFromString (wavesPrecision) - precisionAmountDigits + precisionPriceDigits;
return this.fromPrecision (price, scale);
}
Expand Down Expand Up @@ -1209,7 +1249,7 @@ module.exports = class wavesexchange extends Exchange {
* @param {str} type 'market' or 'limit'
* @param {str} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} price the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
* @param {float|undefined} price the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
* @param {dict} params extra parameters specific to the wavesexchange api endpoint
* @returns {dict} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
*/
Expand Down Expand Up @@ -1444,6 +1484,16 @@ module.exports = class wavesexchange extends Exchange {
}

async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
/**
* @method
* @name wavesexchange#fetchOrders
* @description fetches information on multiple orders made by the user
* @param {str} symbol unified market symbol of the market orders were made in
* @param {int|undefined} since the earliest time in ms to fetch orders for
* @param {int|undefined} limit the maximum number of orde structures to retrieve
* @param {dict} params extra parameters specific to the wavesexchange api endpoint
* @returns {[dict]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure
*/
this.checkRequiredDependencies ();
this.checkRequiredKeys ();
if (symbol === undefined) {
Expand Down Expand Up @@ -1487,6 +1537,16 @@ module.exports = class wavesexchange extends Exchange {
}

async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
/**
* @method
* @name wavesexchange#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @param {str|undefined} symbol unified market symbol
* @param {int|undefined} since the earliest time in ms to fetch open orders for
* @param {int|undefined} limit the maximum number of open orders structures to retrieve
* @param {dict} params extra parameters specific to the wavesexchange api endpoint
* @returns {[dict]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
*/
await this.loadMarkets ();
await this.signIn ();
let market = undefined;
Expand All @@ -1503,6 +1563,16 @@ module.exports = class wavesexchange extends Exchange {
}

async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
/**
* @method
* @name wavesexchange#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @param {str|undefined} symbol unified market symbol of the market orders were made in
* @param {int|undefined} since the earliest time in ms to fetch orders for
* @param {int|undefined} limit the maximum number of orde structures to retrieve
* @param {dict} params extra parameters specific to the wavesexchange api endpoint
* @returns {[dict]} a list of [order structures]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure
*/
await this.loadMarkets ();
await this.signIn ();
let market = undefined;
Expand Down Expand Up @@ -1835,14 +1905,27 @@ module.exports = class wavesexchange extends Exchange {
}

async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
/**
* @method
* @name wavesexchange#fetchMyTrades
* @description fetch all trades made by the user
* @param {str|undefined} symbol unified market symbol
* @param {int|undefined} since the earliest time in ms to fetch trades for
* @param {int|undefined} limit the maximum number of trades structures to retrieve
* @param {dict} params extra parameters specific to the wavesexchange api endpoint
* @returns {[dict]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html#trade-structure}
*/
await this.loadMarkets ();
const market = this.market (symbol);
const address = await this.getWavesAddress ();
const request = {
'sender': address,
'amountAsset': market['baseId'],
'priceAsset': market['quoteId'],
};
let market = undefined;
if (symbol !== undefined) {
market = this.market (symbol);
request['amountAsset'] = market['baseId'];
request['priceAsset'] = market['quoteId'];
}
const response = await this.publicGetTransactionsExchange (request);
const data = this.safeValue (response, 'data');
//
Expand Down

0 comments on commit 30005a0

Please sign in to comment.