Skip to content

Commit

Permalink
Merge pull request #2583 from hollaex/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
abeikverdi authored Jan 17, 2024
2 parents c8bc4ef + 72fd843 commit 38e3d4e
Show file tree
Hide file tree
Showing 57 changed files with 904 additions and 356 deletions.
16 changes: 12 additions & 4 deletions server/api/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,8 @@ const mintAsset = (req, res) => {
transaction_id,
status,
email,
fee
fee,
address
} = req.swagger.params.data.value;

loggerAdmin.info(
Expand All @@ -958,7 +959,9 @@ const mintAsset = (req, res) => {
'status',
status,
'fee',
fee
fee,
'address',
address
);

toolsLib.user.getUserByKitId(user_id)
Expand All @@ -976,6 +979,7 @@ const mintAsset = (req, res) => {
transactionId: transaction_id,
status,
email,
address,
additionalHeaders: {
'x-forwarded-for': req.headers['x-forwarded-for']
}
Expand Down Expand Up @@ -1089,7 +1093,8 @@ const burnAsset = (req, res) => {
transaction_id,
status,
email,
fee
fee,
address
} = req.swagger.params.data.value;

loggerAdmin.info(
Expand All @@ -1105,7 +1110,9 @@ const burnAsset = (req, res) => {
'status',
status,
'fee',
fee
fee,
'address',
address
);

toolsLib.user.getUserByKitId(user_id)
Expand All @@ -1123,6 +1130,7 @@ const burnAsset = (req, res) => {
status,
email,
fee,
address,
additionalHeaders: {
'x-forwarded-for': req.headers['x-forwarded-for']
}
Expand Down
9 changes: 7 additions & 2 deletions server/api/controllers/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -156,8 +161,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;
executeHedging(symbol, side, size, price);
return res.json(result);
})
.catch((err) => {
Expand Down
2 changes: 1 addition & 1 deletion server/api/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const getVerifyUser = (req, res) => {
email,
message: VERIFICATION_EMAIL_MESSAGE
});
})
});
} else {
return res.status(400).json({
message: PROVIDE_VALID_EMAIL_CODE
Expand Down
2 changes: 1 addition & 1 deletion server/api/controllers/withdrawal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand Down
2 changes: 2 additions & 0 deletions server/api/swagger/definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,8 @@ definitions:
format: double
transaction_id:
type: string
address:
type: string
status:
type: boolean
email:
Expand Down
2 changes: 1 addition & 1 deletion server/api/swagger/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const definition = {
swagger: '2.0',
info: {
title: 'HollaEx Kit',
version: '2.9.2'
version: '2.9.3'
},
host: 'api.hollaex.com',
basePath: '/v2',
Expand Down
2 changes: 1 addition & 1 deletion server/mail/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const replaceHTMLContent = (type, html = '', email, data, language, domain) => {
html = html.replace(/\$\{fee\}/g, data.fee || '0');
html = html.replace(/\$\{address\}/g, data.address || '');
html = html.replace(/\$\{ip\}/g, data.ip || '');
html = html.replace(/\$\{link\}/g, data.confirmation_link || `${domain}/confirm-withdraw/${data.transaction_id}`);
html = html.replace(/\$\{link\}/g, data.confirmation_link || `${domain}/confirm-withdraw/${data.transaction_id}?currency=${data.currency}&amount=${data.amount}&address=${data.address}&fee=${data.fee}&network=${data.network}`);
if(data.network) {
html = html.replace(/\$\{network\}/g, data.network || '');
} else {
Expand Down
1 change: 0 additions & 1 deletion server/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.9.2",
"version": "2.9.3",
"private": false,
"description": "HollaEx Kit",
"keywords": [
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions server/plugins/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ const unstakingCheckRunner = () => {

try {
if(totalAmount > 0) {
await toolsLib.wallet.transferAssetByKitIds(stakePool.account_id, user.id, stakePool.currency, totalAmount, 'Admin transfer stake', user.email, { category: 'stake' });
await toolsLib.wallet.transferAssetByKitIds(stakePool.account_id, user.id, stakePool.currency, totalAmount, 'Admin transfer stake', false, { category: 'stake' });
}

if (stakePool.reward_currency !== stakePool.currency && amountAfterSlash > 0) {
await toolsLib.wallet.transferAssetByKitIds(stakePool.account_id, user.id, stakePool.reward_currency, amountAfterSlash, 'Admin transfer stake', user.email, { category: 'stake' });
await toolsLib.wallet.transferAssetByKitIds(stakePool.account_id, user.id, stakePool.reward_currency, amountAfterSlash, 'Admin transfer stake', false, { category: 'stake' });
}

} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion server/tools/dbs/checkConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Status.findOne()
maker_id: 1,
quote: 'xht',
spread: 0
}
},
coin_customizations: existingKitConfigurations.coin_customizations || {}
};

const secrets = {
Expand Down
6 changes: 3 additions & 3 deletions server/utils/hollaex-network-lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions server/utils/hollaex-tools-lib/tools/broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ const calculatePrice = async (side, spread, formula, refresh_interval, brokerId,
throw new Error(`${exchangePair[0].toUpperCase()} does not have market symbol ${formattedSymbol}`)
}

marketPrice = ticker.last;

marketPrice = ticker.last
if (refresh_interval)
client.setexAsync(userCachekey, refresh_interval, JSON.stringify(tickers));
} else {
Expand Down Expand Up @@ -434,14 +435,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
Expand Down
12 changes: 4 additions & 8 deletions server/utils/hollaex-tools-lib/tools/stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ const distributeStakingRewards = async (stakers, account_id, currency, reward_cu

try {
if(totalAmount > 0) {
await transferAssetByKitIds(account_id, user.id, currency, totalAmount, 'Admin transfer stake', user.email, { category: 'stake' });
await transferAssetByKitIds(account_id, user.id, currency, totalAmount, 'Admin transfer stake', false, { category: 'stake' });
}
if (reward_currency !== currency && amountAfterSlash > 0) {
await transferAssetByKitIds(account_id, user.id, reward_currency, amountAfterSlash, 'Admin transfer stake', user.email, { category: 'stake' });
await transferAssetByKitIds(account_id, user.id, reward_currency, amountAfterSlash, 'Admin transfer stake', false, { category: 'stake' });
}

} catch (error) {
Expand Down Expand Up @@ -334,8 +334,6 @@ const updateExchangeStakePool = async (id, data, auditInfo) => {
early_unstake,
slashing_principle_percentage,
slashing_earning_percentage,
min_amount,
max_amount,
status,
onboarding,
} = data;
Expand All @@ -352,8 +350,6 @@ const updateExchangeStakePool = async (id, data, auditInfo) => {
|| (duration && duration !== stakePool.duration)
|| (slashing && slashing !== stakePool.slashing)
|| (early_unstake && early_unstake !== stakePool.early_unstake)
|| (min_amount && min_amount !== stakePool.min_amount)
|| (max_amount && max_amount !== stakePool.max_amount)
|| (slashing_principle_percentage && slashing_principle_percentage !== stakePool.slashing_principle_percentage)
|| (slashing_earning_percentage && slashing_earning_percentage !== stakePool.slashing_earning_percentage)
)) {
Expand Down Expand Up @@ -541,7 +537,7 @@ const createExchangeStaker = async (stake_id, amount, user_id) => {
throw new Error(STAKE_POOL_MAX_AMOUNT_ERROR);
}

if (new BigNumber(amount).comparedTo(new BigNumber(stakePool.min_amount)) !== 1) {
if (new BigNumber(amount).comparedTo(new BigNumber(stakePool.min_amount)) === -1) {
throw new Error(STAKE_POOL_MIN_AMOUNT_ERROR);
}

Expand All @@ -562,7 +558,7 @@ const createExchangeStaker = async (stake_id, amount, user_id) => {
}


await transferAssetByKitIds(user_id, stakePool.account_id, stakePool.currency, amount, 'User transfer stake', user.email, { category: 'stake' });
await transferAssetByKitIds(user_id, stakePool.account_id, stakePool.currency, amount, 'User transfer stake', false, { category: 'stake' });


const stakerData = await getModel('staker').create(staker, {
Expand Down
Loading

0 comments on commit 38e3d4e

Please sign in to comment.