Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data-service/api/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import * as matchersApi from './matchers/matchers'
import * as addressModule from './address';
import { getLastPrice } from './matcher/getLastPrice';
import { getPairRestrictions } from './matcher/getPairRestrictions';
import { getAddressByAlias, getAliasesByAddress, getAliasesByIdList } from './aliases/aliases';
import { getFeeRates, getSettings } from './matcher/getSettings';
import * as pairsModule from './pairs/pairs';
Expand All @@ -30,7 +31,7 @@ export const node = { height };

export const matcher = {
getOrderBook, getOrdersByPair, addSignature, clearSignature, getOrders, signatureTimeout, factory, getLastPrice,
getFeeRates, getSettings
getFeeRates, getSettings, getPairRestrictions
};

export const matchers = matchersApi;
Expand Down
9 changes: 9 additions & 0 deletions data-service/api/matcher/getPairRestrictions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { AssetPair } from '@waves/data-entities';
import { request } from '../../utils/request';
import { get } from '../../config';

export function getPairRestrictions(pair: AssetPair) {
return request({
url: `${get('matcher')}/orderbook/${pair.amountAsset.id}/${pair.priceAsset.id}/info`
});
}
2 changes: 1 addition & 1 deletion locale/it/app.dex.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@
"waves": "Waves"
}
}
}
}
2 changes: 1 addition & 1 deletion locale/it/app.utils.json
Original file line number Diff line number Diff line change
Expand Up @@ -985,4 +985,4 @@
"help": "Byte restanti: {{bytes}}"
}
}
}
}
2 changes: 1 addition & 1 deletion locale/zh_CN/app.dex.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@
"waves": "Waves"
}
}
}
}
34 changes: 34 additions & 0 deletions src/modules/app/services/waves/matcher/Matcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
*/
currentMatcherAddress = '';

/**
* @type {TPairRestrictions | null}
*/
pairRestrictions = null;

constructor() {
this._orderBookCacheHash = Object.create(null);

Expand Down Expand Up @@ -113,6 +118,19 @@
return ds.api.matcher.getLastPrice(pair);
}

/**
* @param {AssetPair} pair
* @return {Promise<TPairRestrictions>}
*/
@decorators.cachable(0.5)
getPairRestrictions(pair) {
return ds.api.matcher.getPairRestrictions(pair)
.then((restrictions) => {
this.pairRestrictions = restrictions;
return restrictions;
});
}

/**
* @param {string} address
* @return {Promise<IScriptInfo<Money>>}
Expand Down Expand Up @@ -456,3 +474,19 @@
* @typedef {object} Matcher#IFeeMap
* @property {number}
*/

/**
* @typedef {object} TPairRestrictions
* @param {TRestrictions} restrictions
* @param {{tickSize: string}} matchingRules
*/

/**
* @typedef {object} TRestrictions
* @property {string} maxAmount
* @property {string} maxPrice
* @property {string} stepPrice
* @property {string} stepAmount
* @property {string} minPrice
* @property {string} minAmount
*/
8 changes: 6 additions & 2 deletions src/modules/dex/controllers/DexCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @param {Waves} waves
* @param {utils} utils
* @param {ModalManager} modalManager
* @param {Matcher} matcher
* @return {DexCtrl}
*/
const controller = function (
Expand All @@ -26,7 +27,8 @@
createPoll,
waves,
utils,
modalManager) {
modalManager,
matcher) {

const analytics = require('@waves/event-sender');

Expand Down Expand Up @@ -122,6 +124,7 @@
return this._showModalAndRedirect(userAssetIdPair.amount, userAssetIdPair.price);
}
const pair = await this._getPair();
matcher.getPairRestrictions(pair);
$location.search('assetId2', pair.amountAsset.id);
$location.search('assetId1', pair.priceAsset.id);
}
Expand Down Expand Up @@ -278,7 +281,8 @@
'createPoll',
'waves',
'utils',
'modalManager'
'modalManager',
'matcher'
];

angular.module('app.dex')
Expand Down
Loading