Skip to content

Commit

Permalink
v7.4.19
Browse files Browse the repository at this point in the history
v7.4.19
  • Loading branch information
platschi authored Aug 4, 2023
2 parents dcdef7c + 75d875e commit 013e5e3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kwenta",
"version": "7.4.17",
"version": "7.4.19",
"description": "Kwenta",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kwenta/app",
"version": "7.4.17",
"version": "7.4.19",
"scripts": {
"dev": "next",
"build": "next build",
Expand Down
11 changes: 8 additions & 3 deletions packages/app/src/__tests__/pages/smartMargin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,15 @@ describe('Futures market page - smart margin', () => {
// Update the mock to return some different data
sdk.futures.getMarkets = () =>
Promise.resolve([{ ...SDK_MARKETS[1], marketLimitUsd: wei(100000) } as PerpsMarketV2])
sdk.futures.getSmartMarginBalanceInfo = () =>
Promise.resolve({
freeMargin: wei('100000'),
keeperEthBal: wei('0.1'),
walletEthBal: wei('1'),
allowance: wei('1000'),
})

const store = setupStore(
preloadedStateWithSmartMarginAccount(mockSmartMarginAccount('1000000'))
)
const store = setupStore(preloadedStateWithSmartMarginAccount(mockSmartMarginAccount('100000')))
const { findByTestId, findByText } = render(
<MockProviders route="market/?accountType=smart_margin&asset=sETH" store={store}>
<Market />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default function TradeConfirmationModal({
const disabledReason = useMemo(() => {
if (showEthBalWarning) {
return t('futures.market.trade.confirmation.modal.disabled-eth-bal', {
depositAmount: stripZeros(keeperFee?.toString()),
depositAmount: formatNumber(stripZeros(keeperFee?.toString()), { suggestDecimals: true }),
})
}
if (positionDetails?.exceedsPriceProtection && !overridePriceProtection) {
Expand Down
29 changes: 2 additions & 27 deletions packages/app/src/state/__mocks__/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,9 @@ export const mockFuturesService = () => ({
getTradesForMarkets: () => [],
getAllTrades: () => [],
getConditionalOrders: () => [],
getIsolatedMarginTransfers: () => [],
getMarketMarginTransfers: () => [],
getDelayedOrders: () => [],
getSmartMarginTransfers: () => [],
getSmartMarginBalanceInfo: () => ({
freeMargin: wei('1000'),
keeperEthBal: wei('0.1'),
walletEthBal: wei('1'),
allowance: wei('1000'),
}),
getMarkets: () => {
return [...SDK_MARKETS]
},
submitCrossMarginOrder: mockSubmitCrossMarginOrder,
})

export const mockPerpsService = () => ({
getSmartMarginAccounts: () => ['0x7bCe4eF9d95129011528E502357C7772'],
getPreviousDayPrices: () => [],
getSmartMarginTradePreview: () => {
return { ...MOCK_TRADE_PREVIEW }
},
getFuturesPositions: () => [],
getTradesForMarkets: () => [],
getAllTrades: () => [],
getConditionalOrders: () => [],
getIsolatedMarginTransfers: () => [],
getDelayedOrders: () => [],
getSmartMarginTransfers: () => [],
getSmartMarginAccountTransfers: () => [],
getSmartMarginBalanceInfo: () => ({
freeMargin: wei('1000'),
keeperEthBal: wei('0.1'),
Expand Down
3 changes: 1 addition & 2 deletions packages/app/src/state/futures/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { truncateTimestamp } from '@kwenta/sdk/utils'
import { createSelector } from '@reduxjs/toolkit'
import { wei } from '@synthetixio/wei'

import { selectSNXUSDBalance, selectSusdBalance } from 'state/balances/selectors'
import {
selectAllCrossMarginTrades,
selectCrossMarginAccountData,
Expand Down Expand Up @@ -366,7 +365,7 @@ export const selectTradePrice = createSelector(
selectSmartMarginOrderPrice,
selectMarketIndexPrice,
(type, orderPrice, indexPrice) => {
return type === FuturesMarginType.CROSS_MARGIN ? indexPrice : wei(orderPrice || 0)
return type === FuturesMarginType.CROSS_MARGIN ? indexPrice : wei(orderPrice || indexPrice)
}
)

Expand Down
9 changes: 4 additions & 5 deletions packages/app/src/state/futures/smartMargin/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ export const selectSmartMarginDepositApproved = createSelector(
}
)

export const selectMarginInMarkets = (isSuspended: boolean = false) =>
export const selectIdleMarginInMarkets = (isSuspended: boolean = false) =>
createSelector(selectAllSmartMarginPositions, (positions) => {
const idleInMarkets = positions
.filter((p) => {
Expand All @@ -523,9 +523,9 @@ export const selectMarginInMarkets = (isSuspended: boolean = false) =>
return idleInMarkets
})

export const selectAvailableMarginInMarkets = selectMarginInMarkets()
export const selectAvailableMarginInMarkets = selectIdleMarginInMarkets()

export const selectLockedMarginInMarkets = selectMarginInMarkets(true)
export const selectLockedMarginInMarkets = selectIdleMarginInMarkets(true)

export const selectIdleAccountMargin = createSelector(
selectAvailableMarginInMarkets,
Expand Down Expand Up @@ -633,9 +633,8 @@ export const selectKeeperDepositExceedsBal = createSelector(
export const selectEditPositionModalInfo = createSelector(
selectEditPositionModalMarket,
selectSmartMarginActivePositions,
selectV2Markets,
selectPrices,
(modalMarketKey, smartPositions, markets, prices) => {
(modalMarketKey, smartPositions, prices) => {
const position = smartPositions.find((p) => p.market.marketKey === modalMarketKey)
if (!position || position.market.version === 3)
return { position: null, market: null, marketPrice: wei(0) }
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@
"disabled-min-margin": "Minimum market margin of $50 required",
"disabled-eth-bal": "Min ETH {{depositAmount}} balance required",
"disabled-exceeds-price-protection": "Price protection exceeded ",
"eth-bal-warning": "The limit order service requires some ETH to cover gas. The 0.01 ETH deposit will cover many orders and you can withdraw any unused balance.",
"eth-bal-warning": "Conditional orders require a small ETH deposit to use for gas when executing",
"delayed-disclaimer": "The fee amount will be deposited to cover trade and automated execution fees. If an order is cancelled or not executed, the deposit will be forfeited to the Synthetix debt pool.",
"stop-loss-warning": "Stop loss is close to the liquidation price and cannot be guaranteed to execute before you get liquidated, proceed anyway?",
"slippage-warning": "This trade incurs high slippage, proceed anyway?"
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kwenta/sdk",
"version": "1.0.5",
"version": "1.0.6",
"description": "SDK for headless interaction with Kwenta",
"main": "dist/index.js",
"directories": {
Expand Down
6 changes: 4 additions & 2 deletions packages/sdk/src/contracts/PerpsV2MarketInternalV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ class FuturesMarketInternal {
const minInitialMargin = await this._getSetting('minInitialMargin')

const positionDecreasing =
oldPos.size.gte(ZERO_BIG_NUM) === newPos.size.gte(ZERO_BIG_NUM) &&
newPos.size.abs().lt(oldPos.size.abs())
newPos.size.eq(ZERO_BIG_NUM) ||
(oldPos.size.gte(ZERO_BIG_NUM) === newPos.size.gte(ZERO_BIG_NUM) &&
newPos.size.abs().lt(oldPos.size.abs()))

if (!positionDecreasing) {
if (newPos.margin.add(fee).lt(minInitialMargin)) {
return {
Expand Down

1 comment on commit 013e5e3

@vercel
Copy link

@vercel vercel bot commented on 013e5e3 Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kwenta – ./packages/app

kwenta-kwenta.vercel.app
kwenta-git-main-kwenta.vercel.app
kwenta.io

Please sign in to comment.