From 630cfaffdf44fe9a8a4d48910d17b4e173bc080f Mon Sep 17 00:00:00 2001 From: fetok12 Date: Mon, 4 Dec 2023 21:22:18 +0300 Subject: [PATCH 01/36] Markup fee --- server/api/controllers/withdrawal.js | 2 +- server/utils/hollaex-network-lib/index.js | 6 ++-- .../utils/hollaex-tools-lib/tools/wallet.js | 28 ++++++++++++------- .../containers/Admin/AdminFinancials/index.js | 6 ++-- web/src/containers/Withdraw/formUtils.js | 4 +-- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/server/api/controllers/withdrawal.js b/server/api/controllers/withdrawal.js index 2fcb75d6f2..ef693557ec 100644 --- a/server/api/controllers/withdrawal.js +++ b/server/api/controllers/withdrawal.js @@ -155,7 +155,7 @@ const performWithdrawal = (req, res) => { withdrawal.amount, { network: withdrawal.network, - // fee_markup: withdrawal.fee_markup, + fee_markup: withdrawal.fee_markup, additionalHeaders: { 'x-forwarded-for': req.headers['x-forwarded-for'] } diff --git a/server/utils/hollaex-network-lib/index.js b/server/utils/hollaex-network-lib/index.js index 60ae51e4d5..4668831420 100644 --- a/server/utils/hollaex-network-lib/index.js +++ b/server/utils/hollaex-network-lib/index.js @@ -511,9 +511,9 @@ class HollaExNetwork { if (opts.network) { data.network = opts.network; } - // if (opts.fee_markup) { - // data.fee_markup = opts.fee_markup - // } + if (opts.fee_markup) { + data.fee_markup = opts.fee_markup + } const headers = generateHeaders( isPlainObject(opts.additionalHeaders) ? { ...this.headers, ...opts.additionalHeaders } : this.headers, this.apiSecret, diff --git a/server/utils/hollaex-tools-lib/tools/wallet.js b/server/utils/hollaex-tools-lib/tools/wallet.js index d23dba8833..c7c902774a 100644 --- a/server/utils/hollaex-tools-lib/tools/wallet.js +++ b/server/utils/hollaex-tools-lib/tools/wallet.js @@ -5,7 +5,7 @@ const { sendEmail } = require(`${SERVER_PATH}/mail`); const { MAILTYPE } = require(`${SERVER_PATH}/mail/strings`); const { WITHDRAWALS_REQUEST_KEY } = require(`${SERVER_PATH}/constants`); const { verifyOtpBeforeAction } = require('./security'); -const { subscribedToCoin, getKitCoin, getKitSecrets } = require('./common'); +const { subscribedToCoin, getKitCoin, getKitSecrets, getKitConfig } = require('./common'); const { INVALID_OTP_CODE, INVALID_WITHDRAWAL_TOKEN, @@ -121,7 +121,7 @@ const sendRequestWithdrawalEmail = (user_id, address, amount, currency, opts = { }) => { let fee = opts.fee; let fee_coin = opts.fee_coin; - // let fee_markup + let fee_markup return verifyOtpBeforeAction(user_id, opts.otpCode) .then((validOtp) => { @@ -135,7 +135,7 @@ const sendRequestWithdrawalEmail = (user_id, address, amount, currency, opts = { const withdrawal = await validateWithdrawal(user, address, amount, currency, opts.network); fee = withdrawal.fee; fee_coin = withdrawal.fee_coin; - // fee_markup = withdrawal.fee_markup; + fee_markup = withdrawal.fee_markup; } @@ -147,7 +147,7 @@ const sendRequestWithdrawalEmail = (user_id, address, amount, currency, opts = { amount, fee, fee_coin, - // fee_markup, + fee_markup, transaction_id: uuid(), address, currency, @@ -166,14 +166,14 @@ const withdrawalRequestEmail = (user, data, domain, ip) => { return client.hsetAsync(WITHDRAWALS_REQUEST_KEY, token, stringData) .then(() => { - const { email, amount, fee, fee_coin, currency, address, network } = data; + const { email, amount, fee, fee_coin, fee_markup, currency, address, network } = data; sendEmail( MAILTYPE.WITHDRAWAL_REQUEST, email, { amount, fee, - // fee_markup, + fee_markup, fee_coin: (getKitCoin(fee_coin).display_name) ? getKitCoin(fee_coin).display_name : fee_coin, currency: (getKitCoin(currency).display_name) ? getKitCoin(currency).display_name : currency, transaction_id: token, @@ -290,7 +290,7 @@ const calculateWithdrawalMax = async (user_id, currency, selectedNetwork) => { if (amount === 0) return { amount }; const coinConfiguration = getKitCoin(currency); - // const coinMarkup = getKitConfig()?.coin_customizations?.[currency]; + const coinMarkup = getKitConfig()?.coin_customizations?.[currency]; const { fee, fee_coin } = getWithdrawalFee(currency, selectedNetwork, amount, user.verification_level); const { increment_unit } = coinConfiguration; @@ -345,6 +345,10 @@ const calculateWithdrawalMax = async (user_id, currency, selectedNetwork) => { ) { amount = new BigNumber(balance[`${currency}_available`]).minus(new BigNumber(fee)).toNumber(); + + if (coinMarkup?.fee_markup) { + amount = new BigNumber(amount).minus(new BigNumber(coinMarkup.fee_markup)).toNumber(); + } } amount = BigNumber.minimum(dailyAmount, amount).toNumber(); @@ -361,7 +365,7 @@ const calculateWithdrawalMax = async (user_id, currency, selectedNetwork) => { const validateWithdrawal = async (user, address, amount, currency, network = null) => { const coinConfiguration = getKitCoin(currency); - // const coinMarkup = getKitConfig()?.coin_customizations?.[currency]; + const coinMarkup = getKitConfig()?.coin_customizations?.[currency]; if (!subscribedToCoin(currency)) { throw new Error(INVALID_COIN(currency)); } @@ -403,10 +407,14 @@ const validateWithdrawal = async (user, address, amount, currency, network = nul throw new Error(UPGRADE_VERIFICATION_LEVEL(1)); } - const { fee, fee_coin } = getWithdrawalFee(currency, network, amount, user.verification_level); + let { fee, fee_coin } = getWithdrawalFee(currency, network, amount, user.verification_level); const balance = await getNodeLib().getUserBalance(user.network_id); + if (coinMarkup?.fee_markup) { + fee = math.number(math.add(math.bignumber(fee), math.bignumber(coinMarkup.fee_markup))); + } + if (fee_coin === currency) { const totalAmount = fee > 0 @@ -439,7 +447,7 @@ const validateWithdrawal = async (user, address, amount, currency, network = nul return { fee, fee_coin, - // ...(coinMarkup?.fee_markup && { fee_markup: coinMarkup.fee_markup }) + ...(coinMarkup?.fee_markup && { fee_markup: coinMarkup.fee_markup }) }; }; diff --git a/web/src/containers/Admin/AdminFinancials/index.js b/web/src/containers/Admin/AdminFinancials/index.js index 06f58e6808..51fc126da1 100644 --- a/web/src/containers/Admin/AdminFinancials/index.js +++ b/web/src/containers/Admin/AdminFinancials/index.js @@ -12,7 +12,7 @@ import Assets, { getTabParams } from './Assets'; import './index.css'; import Wallet from './Wallet'; import Balances from './Balances'; -// import CoinConfiguration from './CoinConfiguration'; +import CoinConfiguration from './CoinConfiguration'; import TransactionLimits from './TransactionLimits'; const TabPane = Tabs.TabPane; @@ -87,9 +87,9 @@ const AdminFinancials = ({ router, location, user }) => { - {/* + - */} + ); diff --git a/web/src/containers/Withdraw/formUtils.js b/web/src/containers/Withdraw/formUtils.js index 74d68e4190..6bde0ae2f0 100644 --- a/web/src/containers/Withdraw/formUtils.js +++ b/web/src/containers/Withdraw/formUtils.js @@ -96,8 +96,8 @@ export const generateInitialValues = ( initialValues.amount = ''; } - // const feeMarkup = coin_customizations?.[symbol]?.fee_markup; - // if (feeMarkup) initialValues.fee += feeMarkup; + const feeMarkup = coin_customizations?.[symbol]?.fee_markup; + if (feeMarkup) initialValues.fee += feeMarkup; initialValues.destination_tag = ''; initialValues.address = ''; From fc6d8e903c3a7ef16fcacb9a30d7f8dbb720607a Mon Sep 17 00:00:00 2001 From: Ali Beikverdi Date: Sat, 23 Dec 2023 06:35:36 +0900 Subject: [PATCH 02/36] eslint applied --- server/api/controllers/user.js | 2 +- server/utils/hollaex-tools-lib/tools/user.js | 58 ++++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/server/api/controllers/user.js b/server/api/controllers/user.js index 3141a084a0..04008dc13b 100644 --- a/server/api/controllers/user.js +++ b/server/api/controllers/user.js @@ -138,7 +138,7 @@ const getVerifyUser = (req, res) => { email, message: VERIFICATION_EMAIL_MESSAGE }); - }) + }); } else { return res.status(400).json({ message: PROVIDE_VALID_EMAIL_CODE diff --git a/server/utils/hollaex-tools-lib/tools/user.js b/server/utils/hollaex-tools-lib/tools/user.js index 113d90996f..f3a71bf30b 100644 --- a/server/utils/hollaex-tools-lib/tools/user.js +++ b/server/utils/hollaex-tools-lib/tools/user.js @@ -100,7 +100,7 @@ let kitIdToNetworkId = {}; const storeVerificationCode = (user, verification_code) => { const data = { code: verification_code, id: user.id, email: user.email }; client.setexAsync(`verification_code:user${verification_code}`, 5 * 60, JSON.stringify(data)); -} +}; const signUpUser = (email, password, opts = { referral: null }) => { if (!getKitConfig().new_user_is_activated) { @@ -187,7 +187,7 @@ const verifyUser = (email, code, domain) => { return all([ verificationCode, dbQuery.findOne('user', - { where: { id: verificationCode.id }, attributes: ['id', 'email', 'settings', 'network_id', 'email_verified'] }), + { where: { id: verificationCode.id }, attributes: ['id', 'email', 'settings', 'network_id', 'email_verified'] }), ]); }) .then(([verificationCode, user]) => { @@ -461,8 +461,8 @@ const findUserLatestLogin = (user, status) => { }).then(loginData => { if (loginData && new Date().getTime() - new Date(loginData.updated_at).getTime() < LOGIN_TIME_OUT) return loginData; return null; - }) -} + }); +}; /* Public Endpoints*/ @@ -798,7 +798,7 @@ const getAllUsersAdmin = (opts = { } } return { count, data }; - }) + }); } }; @@ -1437,29 +1437,29 @@ const getUpdatedKeys = (oldData, newData) => { let keys = []; for(const key of data){ if(!isEqual(oldData[key], newData[key])){ - keys.push(key); + keys.push(key); } } return keys; - } +}; const getValues = (data, prevData) => { const updatedKeys = getUpdatedKeys(prevData, data); - const updatedValues = updatedKeys.map(key => data[key]); + const updatedValues = updatedKeys.map(key => data[key]); const oldValues = updatedKeys.map(key => prevData[key]); - updatedValues.forEach((value, index) => { - if(typeof value === 'object' && value.constructor === Object) { - const values = getValues(value, oldValues[index]); - updatedKeys[index] = values.updatedKeys - updatedValues[index] = values.updatedValues - oldValues[index] = values.oldValues; - } - }) + updatedValues.forEach((value, index) => { + if(typeof value === 'object' && value.constructor === Object) { + const values = getValues(value, oldValues[index]); + updatedKeys[index] = values.updatedKeys; + updatedValues[index] = values.updatedValues; + oldValues[index] = values.oldValues; + } + }); return { updatedKeys, oldValues, updatedValues }; -} +}; const createAuditLog = (subject, adminEndpoint, method, data = {}, prevData = null) => { try { @@ -1470,7 +1470,7 @@ const createAuditLog = (subject, adminEndpoint, method, data = {}, prevData = nu post: 'inserted', put: 'updated', delete: 'deleted' - } + }; const excludedKeys = ['password', 'apiKey', 'secret', 'api-key', 'api-secret', 'hmac']; const action = adminEndpoint.split('/').slice(1).join(' '); @@ -1480,7 +1480,7 @@ const createAuditLog = (subject, adminEndpoint, method, data = {}, prevData = nu if (method === 'get') { user_id = data?.user_id?.value; data = Object.fromEntries(Object.entries(data).filter(([k, v]) => (v.value != null && excludedKeys.indexOf(k) === -1))); - const str = Object.keys(data).map((key) => "" + key + ":" + data[key].value).join(", "); + const str = Object.keys(data).map((key) => '' + key + ':' + data[key].value).join(', '); description = `${action} service ${methodDescriptions[method]}${str ? ` with ${str}` : ''}`; } else if(method === 'put' && prevData) { @@ -1507,7 +1507,7 @@ const createAuditLog = (subject, adminEndpoint, method, data = {}, prevData = nu return error; } -} +}; const getUserAudits = (opts = { user_id: null, @@ -1523,8 +1523,8 @@ const getUserAudits = (opts = { const exchangeInfo = getKitConfig().info; if(!['fiat', 'boost', 'enterprise'].includes(exchangeInfo.plan)) { - throw new Error(SERVICE_NOT_SUPPORTED); - } + throw new Error(SERVICE_NOT_SUPPORTED); + } const pagination = paginationQuery(opts.limit, opts.page); const timeframe = timeframeQuery(opts.startDate, opts.endDate); @@ -1560,7 +1560,7 @@ const getUserAudits = (opts = { }); } else { - return dbQuery.findAndCountAllWithRows('audit', options) + return dbQuery.findAndCountAllWithRows('audit', options); } }; @@ -2006,7 +2006,7 @@ const updateUserInfo = async (userId, data = {}, auditInfo) => { throw new Error('No fields to update'); } const oldValues = { user_id: userId }; - Object.keys(updateData).forEach(key => { oldValues[key] = user.dataValues[key] }); + Object.keys(updateData).forEach(key => { oldValues[key] = user.dataValues[key]; }); await user.update( updateData, @@ -2083,7 +2083,7 @@ const getExchangeUserSessions = (opts = { ], order: [ordering], ...(!opts.format && pagination), - } + }; if (opts.format) { query.attributes = ['id', 'login_id', 'status', 'last_seen', 'expiry_date', 'role', 'created_at', 'updated_at']; @@ -2239,10 +2239,10 @@ const deleteKitUser = async (userId) => { ); sendEmail( - MAILTYPE.USER_DELETED, - userEmail, - {}, - user.settings + MAILTYPE.USER_DELETED, + userEmail, + {}, + user.settings ); return updatedUser; From a72412d086dc2f260d6b56f5eccbd6ded4edbd7f Mon Sep 17 00:00:00 2001 From: fetok12 Date: Sat, 23 Dec 2023 02:25:58 +0300 Subject: [PATCH 03/36] Broker bybit rate issue --- server/api/controllers/order.js | 4 ++-- server/package.json | 2 +- server/utils/hollaex-tools-lib/tools/broker.js | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/server/api/controllers/order.js b/server/api/controllers/order.js index 9d97fbb9df..5b7c1b342c 100644 --- a/server/api/controllers/order.js +++ b/server/api/controllers/order.js @@ -156,8 +156,8 @@ const orderExecute = (req, res) => { toolsLib.order.executeUserOrder(user_id, opts, token) .then((result) => { - const { symbol, side, size } = result; - toolsLib.broker.reverseTransaction({ symbol, side, size }); + const { symbol, side, size, price } = result; + toolsLib.broker.reverseTransaction({ symbol, side, size, price }); return res.json(result); }) .catch((err) => { diff --git a/server/package.json b/server/package.json index e447beec9b..1a033e43d4 100644 --- a/server/package.json +++ b/server/package.json @@ -17,7 +17,7 @@ "bignumber.js": "9.1.1", "bluebird": "3.5.3", "body-parser": "1.19.0", - "ccxt": "1.92.89", + "ccxt": "4.1.96", "chai": "4.2.0", "chai-http": "4.3.0", "cors": "2.8.5", diff --git a/server/utils/hollaex-tools-lib/tools/broker.js b/server/utils/hollaex-tools-lib/tools/broker.js index 06dae05e90..668c1dfeb6 100644 --- a/server/utils/hollaex-tools-lib/tools/broker.js +++ b/server/utils/hollaex-tools-lib/tools/broker.js @@ -434,14 +434,14 @@ const testRebalance = async (data) => { }; const reverseTransaction = async (orderData) => { - const { symbol, side, size } = orderData; + const { symbol, side, size, price } = orderData; const notifyUser = async (data, userId) => { const user = await getUserByKitId(userId); sendEmail( MAILTYPE.ALERT, user.email, { - type: 'binance order info', + type: 'broker hedging order info', data }, user.settings @@ -467,10 +467,8 @@ const reverseTransaction = async (orderData) => { const formattedRebalancingSymbol = broker.rebalancing_symbol && broker.rebalancing_symbol.split('-').join('/').toUpperCase(); if (exchangeKey === 'bybit') { - const orderbook = await exchange.fetchOrderBook(formattedRebalancingSymbol); - const price = side === 'buy' ? orderbook['asks'][0][0] * 1.01 : orderbook['bids'][0][0] * 0.99; - - exchange.createOrder(formattedRebalancingSymbol, 'limit', side, size, price) + const marketPrice = side === 'buy' ? price * 1.01 : price * 0.99; + exchange.createOrder(formattedRebalancingSymbol, 'limit', side, size, marketPrice) .catch((err) => { notifyUser(err.message, broker.user_id); }); } else { From 0322f3164bfa365f8df902e8e5fbb6cc05949281 Mon Sep 17 00:00:00 2001 From: Ali Beikverdi Date: Thu, 28 Dec 2023 08:47:31 +0900 Subject: [PATCH 04/36] email verified set to false during signup in tools lib --- server/messages.js | 1 - server/utils/hollaex-tools-lib/tools/user.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/messages.js b/server/messages.js index a6b6821e6d..2e9d238bc3 100644 --- a/server/messages.js +++ b/server/messages.js @@ -158,7 +158,6 @@ exports.WRONG_PAGE = 'Value "page" must be an integer'; exports.WRONG_ORDER_BY = 'Value "order_by" cannot include whitespaces'; exports.WRONG_ORDER = 'Value "order" must be one of: ["asc", "desc"]'; exports.SAME_PASSWORD = 'New password must be different from previous password'; -exports.VERIFICATION_CODE_USED = 'Verification code already used'; exports.USERNAME_IS_TAKEN = 'Username is already taken. Select a different username'; exports.TOKEN_OTP_MUST_BE_ENABLED = 'OTP must be enabled to create a token'; exports.CODE_NOT_FOUND = 'Code not found'; diff --git a/server/utils/hollaex-tools-lib/tools/user.js b/server/utils/hollaex-tools-lib/tools/user.js index f3a71bf30b..b59a156739 100644 --- a/server/utils/hollaex-tools-lib/tools/user.js +++ b/server/utils/hollaex-tools-lib/tools/user.js @@ -49,7 +49,6 @@ const { USER_NOT_DEACTIVATED, CANNOT_CHANGE_ADMIN_ROLE, USER_VERIFIED, - VERIFICATION_CODE_USED, USER_NOT_REGISTERED_ON_NETWORK, SESSION_NOT_FOUND, SESSION_ALREADY_REVOKED, @@ -130,6 +129,7 @@ const signUpUser = (email, password, opts = { referral: null }) => { email, password, verification_level: 1, + email_verified: false, settings: INITIAL_SETTINGS() }, { transaction }) .then((user) => { @@ -1436,9 +1436,9 @@ const getUpdatedKeys = (oldData, newData) => { let keys = []; for(const key of data){ - if(!isEqual(oldData[key], newData[key])){ + if(!isEqual(oldData[key], newData[key])){ keys.push(key); - } + } } return keys; From eec77f53e94f6be66748b2c7b921e18713f1af0f Mon Sep 17 00:00:00 2001 From: ram Date: Tue, 2 Jan 2024 20:47:59 +0530 Subject: [PATCH 05/36] Fixed the Donut UI issue and updated the percentage --- web/src/components/Chart/Charts/DonutChart.js | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/web/src/components/Chart/Charts/DonutChart.js b/web/src/components/Chart/Charts/DonutChart.js index b47d680e87..718ed9cbf1 100644 --- a/web/src/components/Chart/Charts/DonutChart.js +++ b/web/src/components/Chart/Charts/DonutChart.js @@ -23,7 +23,7 @@ function translate(x, y) { // function rotate (d) { // return `rotate(${180 / Math.PI * (d.startAngle + d.endAngle) / 2 + 45})`; // }; -const filterDonutPercentage = 1; +const filterDonutPercentage = 8; class DonutChart extends Component { state = { width: 0, @@ -204,20 +204,30 @@ class DonutChart extends Component { return arr; }; + const renderDonut = () => { + const data = sortedData.map((value, i) => + this.renderSlice(value, i, width, height) + ); + + if (this.state && this.state.isData) { + if (!isDonutValue) { + return filterByPercentage().map((value, i) => + this.renderSlice(value, i, width, height) + ); + } else { + return data; + } + } else { + return data; + } + }; + return (
- - {!isDonutValue - ? filterByPercentage().map((value, i) => - this.renderSlice(value, i, width, height) - ) - : sortedData.map((value, i) => - this.renderSlice(value, i, width, height) - )} - + {renderDonut()}
From 9d04e6979bfeffc518b597795a1242378dfb5ecf Mon Sep 17 00:00:00 2001 From: fetok12 Date: Wed, 3 Jan 2024 00:17:01 +0300 Subject: [PATCH 06/36] bybit broker price --- server/utils/hollaex-tools-lib/tools/broker.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/utils/hollaex-tools-lib/tools/broker.js b/server/utils/hollaex-tools-lib/tools/broker.js index 668c1dfeb6..c3df825022 100644 --- a/server/utils/hollaex-tools-lib/tools/broker.js +++ b/server/utils/hollaex-tools-lib/tools/broker.js @@ -248,7 +248,12 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, throw new Error(`${exchangePair[0].toUpperCase()} does not have market symbol ${formattedSymbol}`) } - marketPrice = ticker.last; + + if(exchangePair[0] === 'bybit') { + marketPrice = side === 'buy' ? ticker.bid : ticker.buy; + } else { + marketPrice = ticker.last; + } if (refresh_interval) client.setexAsync(userCachekey, refresh_interval, JSON.stringify(tickers)); } else { @@ -260,7 +265,12 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, if (refresh_interval) client.setexAsync(userCachekey, refresh_interval, JSON.stringify(tickers)); } - marketPrice = ticker.last; + + if(exchangePair[0] === 'bybit') { + marketPrice = side === 'buy' ? ticker.bid : ticker.buy; + } else { + marketPrice = ticker.last; + } } } else { From 405c5c6d50ad1355d0eb30d44fa5e7d6455fab6a Mon Sep 17 00:00:00 2001 From: fetok12 Date: Wed, 3 Jan 2024 00:21:22 +0300 Subject: [PATCH 07/36] bybit broker price --- server/utils/hollaex-tools-lib/tools/broker.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/utils/hollaex-tools-lib/tools/broker.js b/server/utils/hollaex-tools-lib/tools/broker.js index c3df825022..bc07907d54 100644 --- a/server/utils/hollaex-tools-lib/tools/broker.js +++ b/server/utils/hollaex-tools-lib/tools/broker.js @@ -249,8 +249,8 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, } - if(exchangePair[0] === 'bybit') { - marketPrice = side === 'buy' ? ticker.bid : ticker.buy; + if (exchangePair[0] === 'bybit') { + marketPrice = side === 'buy' ? ticker.bid : ticker.ask; } else { marketPrice = ticker.last; } @@ -265,9 +265,8 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, if (refresh_interval) client.setexAsync(userCachekey, refresh_interval, JSON.stringify(tickers)); } - - if(exchangePair[0] === 'bybit') { - marketPrice = side === 'buy' ? ticker.bid : ticker.buy; + if (exchangePair[0] === 'bybit') { + marketPrice = side === 'buy' ? ticker.bid : ticker.ask; } else { marketPrice = ticker.last; } From 8e23fdded0c50c0bc3ced1f9499e8b73d21674ec Mon Sep 17 00:00:00 2001 From: fetok12 Date: Wed, 3 Jan 2024 09:48:29 +0300 Subject: [PATCH 08/36] bybit broker price --- server/utils/hollaex-tools-lib/tools/broker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/utils/hollaex-tools-lib/tools/broker.js b/server/utils/hollaex-tools-lib/tools/broker.js index bc07907d54..858e903a81 100644 --- a/server/utils/hollaex-tools-lib/tools/broker.js +++ b/server/utils/hollaex-tools-lib/tools/broker.js @@ -250,7 +250,7 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, if (exchangePair[0] === 'bybit') { - marketPrice = side === 'buy' ? ticker.bid : ticker.ask; + marketPrice = side === 'buy' ? ticker.ask : ticker.bid; } else { marketPrice = ticker.last; } @@ -266,7 +266,7 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, client.setexAsync(userCachekey, refresh_interval, JSON.stringify(tickers)); } if (exchangePair[0] === 'bybit') { - marketPrice = side === 'buy' ? ticker.bid : ticker.ask; + marketPrice = side === 'buy' ? ticker.ask : ticker.bid; } else { marketPrice = ticker.last; } From ba57bfa20ab94e44039ddac44fb515c0e319a487 Mon Sep 17 00:00:00 2001 From: Ali Beikverdi Date: Wed, 3 Jan 2024 16:42:59 +0900 Subject: [PATCH 09/36] typo fix for disclaimer in staking --- web/src/containers/Admin/Stakes/CeFi.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/containers/Admin/Stakes/CeFi.js b/web/src/containers/Admin/Stakes/CeFi.js index 9598e2d771..835bdfe399 100644 --- a/web/src/containers/Admin/Stakes/CeFi.js +++ b/web/src/containers/Admin/Stakes/CeFi.js @@ -1078,7 +1078,7 @@ const CeFi = ({ coins, features, kit }) => { marginTop: 30, }} > - Disclamier + disclaimer

{ marginTop: 30, }} > - Warning disclamier (optional) + Warning disclaimer (optional)

- Add a disclamier + Add a disclaimer
Date: Wed, 3 Jan 2024 22:58:41 +0300 Subject: [PATCH 10/36] bybit broker price fetch --- server/api/controllers/order.js | 7 ++++++- server/utils/hollaex-tools-lib/tools/broker.js | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/api/controllers/order.js b/server/api/controllers/order.js index 5b7c1b342c..175adcb7aa 100644 --- a/server/api/controllers/order.js +++ b/server/api/controllers/order.js @@ -132,6 +132,11 @@ const getQuickTrade = (req, res) => { }); }; +const executeHedging = async ( symbol, side, size, price ) => { + await toolsLib.sleep(1000); + toolsLib.broker.reverseTransaction({ symbol, side, size, price }); +} + const orderExecute = (req, res) => { loggerOrders.verbose( req.uuid, @@ -157,7 +162,7 @@ const orderExecute = (req, res) => { toolsLib.order.executeUserOrder(user_id, opts, token) .then((result) => { const { symbol, side, size, price } = result; - toolsLib.broker.reverseTransaction({ symbol, side, size, price }); + executeHedging(symbol, side, size, price); return res.json(result); }) .catch((err) => { diff --git a/server/utils/hollaex-tools-lib/tools/broker.js b/server/utils/hollaex-tools-lib/tools/broker.js index bc07907d54..a5334dcf7d 100644 --- a/server/utils/hollaex-tools-lib/tools/broker.js +++ b/server/utils/hollaex-tools-lib/tools/broker.js @@ -476,8 +476,10 @@ const reverseTransaction = async (orderData) => { const formattedRebalancingSymbol = broker.rebalancing_symbol && broker.rebalancing_symbol.split('-').join('/').toUpperCase(); if (exchangeKey === 'bybit') { - const marketPrice = side === 'buy' ? price * 1.01 : price * 0.99; - exchange.createOrder(formattedRebalancingSymbol, 'limit', side, size, marketPrice) + const orderbook = await exchange.fetchOrderBook(formattedRebalancingSymbol); + const price = side === 'buy' ? orderbook['asks'][0][0] * 1.01 : orderbook['bids'][0][0] * 0.99; + + exchange.createOrder(formattedRebalancingSymbol, 'limit', side, size, price) .catch((err) => { notifyUser(err.message, broker.user_id); }); } else { From d204b1b17a611935b9c16715f924bbea2f20d57b Mon Sep 17 00:00:00 2001 From: fetok12 Date: Wed, 3 Jan 2024 23:49:02 +0300 Subject: [PATCH 11/36] bybit broker price fetch --- server/utils/hollaex-tools-lib/tools/broker.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/server/utils/hollaex-tools-lib/tools/broker.js b/server/utils/hollaex-tools-lib/tools/broker.js index a5334dcf7d..12d4013107 100644 --- a/server/utils/hollaex-tools-lib/tools/broker.js +++ b/server/utils/hollaex-tools-lib/tools/broker.js @@ -249,11 +249,7 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, } - if (exchangePair[0] === 'bybit') { - marketPrice = side === 'buy' ? ticker.bid : ticker.ask; - } else { - marketPrice = ticker.last; - } + marketPrice = ticker.last if (refresh_interval) client.setexAsync(userCachekey, refresh_interval, JSON.stringify(tickers)); } else { @@ -265,11 +261,7 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId, if (refresh_interval) client.setexAsync(userCachekey, refresh_interval, JSON.stringify(tickers)); } - if (exchangePair[0] === 'bybit') { - marketPrice = side === 'buy' ? ticker.bid : ticker.ask; - } else { - marketPrice = ticker.last; - } + marketPrice = ticker.last; } } else { From 1133fc9ab6cce2af610c20f635b13032663f07b4 Mon Sep 17 00:00:00 2001 From: Ali Beikverdi Date: Thu, 4 Jan 2024 17:20:58 +0900 Subject: [PATCH 12/36] space added to risky trade text --- web/src/containers/QuickTrade/components/RiskyTrade.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/src/containers/QuickTrade/components/RiskyTrade.js b/web/src/containers/QuickTrade/components/RiskyTrade.js index f9ed8975dd..dcc23e0442 100644 --- a/web/src/containers/QuickTrade/components/RiskyTrade.js +++ b/web/src/containers/QuickTrade/components/RiskyTrade.js @@ -40,6 +40,7 @@ export const RiskyTrade = ({ setShowRisky, coinData, onCloseDialog }) => { fullname, display_name )} +   {STRINGS['RISKY_TRADE_DISCLAIMER.MSG_2']} From 78cf0fd5f762f9eb3378e3e61bbe511b1a2158d6 Mon Sep 17 00:00:00 2001 From: fetok12 Date: Sat, 6 Jan 2024 02:25:29 +0300 Subject: [PATCH 13/36] Add address to burn & mint --- web/src/containers/Admin/CreateAsset/Burn.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/src/containers/Admin/CreateAsset/Burn.js b/web/src/containers/Admin/CreateAsset/Burn.js index caa2477fe9..3ad25aad81 100644 --- a/web/src/containers/Admin/CreateAsset/Burn.js +++ b/web/src/containers/Admin/CreateAsset/Burn.js @@ -42,6 +42,7 @@ const Burn = ({ transaction_id, status, fee, + address, } = values; const formProps = { @@ -52,6 +53,7 @@ const Burn = ({ fee, status: Number(status) ? true : false, transaction_id, + address, }; if (type === 'mint') { handleMint(formProps); @@ -183,6 +185,12 @@ const Burn = ({ +

+ Address (Optional) +

+ + +

Description