Skip to content

Commit

Permalink
v4.2.1
Browse files Browse the repository at this point in the history
v4.2.1
  • Loading branch information
platschi authored Nov 10, 2022
2 parents 13658a6 + b3fdeeb commit e2e0db2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "4.2.0",
"version": "4.2.1",
"scripts": {
"dev": "next",
"build": "next build",
Expand Down
5 changes: 3 additions & 2 deletions utils/futures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export const orderPriceInvalidLabel = (
};

const getPositionChangeState = (existingSize: Wei, newSize: Wei) => {
if (newSize.eq(0)) return 'closing';
if (existingSize.eq(newSize)) return 'edit_leverage';
if (existingSize.eq(0)) return 'increase_size';
if ((existingSize.gt(0) && newSize.lt(0)) || (existingSize.lt(0) && newSize.gt(0)))
Expand All @@ -317,8 +318,6 @@ export const calculateMarginDelta = (
fees: TradeFees,
position: FuturesPosition | null
) => {
if (nextTrade.nativeSizeDelta.add(position?.position?.size || 0).eq(zeroBN)) return zeroBN;

const existingSize = position?.position
? position?.position?.side === 'long'
? position?.position?.size
Expand All @@ -330,6 +329,8 @@ export const calculateMarginDelta = (
const posChangeState = getPositionChangeState(existingSize, newSize);

switch (posChangeState) {
case 'closing':
return zeroBN;
case 'edit_leverage':
const nextMargin = position?.position?.notionalValue.div(nextTrade.leverage) ?? zeroBN;
const delta = nextMargin.sub(position?.remainingMargin);
Expand Down

1 comment on commit e2e0db2

@vercel
Copy link

@vercel vercel bot commented on e2e0db2 Nov 10, 2022

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 – ./

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

Please sign in to comment.