Skip to content

Commit

Permalink
v7.5.8
Browse files Browse the repository at this point in the history
v7.5.8
  • Loading branch information
platschi authored Sep 7, 2023
2 parents 1f52f56 + c53f038 commit 9e22c45
Show file tree
Hide file tree
Showing 23 changed files with 585 additions and 262 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
continue-on-error: true

- name: Archive lighthouse artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # pin@v2
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # pin@v2
# run on lighthouse fail
if: always()
with:
Expand Down
Binary file added packages/app/src/assets/png/currencies/s1INCH.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sALGO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sCELO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sENJ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sEOS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sICP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sRUNE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sSEI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sUMA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sXLM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sXTZ.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sZEC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/app/src/assets/png/currencies/sZRX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion packages/app/src/state/futures/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ export const cancelDelayedOrder = createAsyncThunk<void, string, ThunkConfig>(
hash: null,
})
)
const tx = await sdk.futures.cancelDelayedOrder(marketAddress, account, true)

const tx = await sdk.futures.cancelDelayedOrder({
marketAddress,
account,
isOffchain: true,
})
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(fetchSmartMarginOpenOrders())
} catch (err) {
Expand Down
126 changes: 70 additions & 56 deletions packages/app/src/state/futures/smartMargin/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,14 @@ export const fetchSmartMarginTradePreview = createAsyncThunk<

try {
const leverageSide = selectSmartMarginLeverageSide(getState())
const preview = await sdk.futures.getSmartMarginTradePreview(
account || ZERO_ADDRESS,
params.market.key,
params.market.address,
{ ...params, leverageSide, marginDelta }
)
const preview = await sdk.futures.getSmartMarginTradePreview({
account: account || ZERO_ADDRESS,
market: {
marketAddress: params.market.address,
marketKey: params.market.key,
},
tradeParams: { ...params, leverageSide, marginDelta },
})

// Check the preview hasn't been cleared before query resolves
const count = selectSmartMarginPreviewCount(getState())
Expand Down Expand Up @@ -958,8 +960,8 @@ export const withdrawSmartMargin = createAsyncThunk<void, Wei, ThunkConfig>(
export const approveSmartMargin = createAsyncThunk<void, void, ThunkConfig>(
'futures/approveSmartMargin',
async (_, { getState, dispatch, extra: { sdk } }) => {
const account = selectSmartMarginAccount(getState())
if (!account) throw new Error('No smart margin account')
const address = selectSmartMarginAccount(getState())
if (!address) throw new Error('No smart margin account')
try {
dispatch(
setTransaction({
Expand All @@ -968,7 +970,7 @@ export const approveSmartMargin = createAsyncThunk<void, void, ThunkConfig>(
hash: null,
})
)
const tx = await sdk.futures.approveSmartMarginDeposit(account)
const tx = await sdk.futures.approveSmartMarginDeposit({ address })
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(fetchSmartMarginBalanceInfo())
} catch (err) {
Expand Down Expand Up @@ -1072,13 +1074,13 @@ export const submitSmartMarginOrder = createAsyncThunk<void, boolean, ThunkConfi
(o) => o.isStale && o.market.marketKey === marketInfo.marketKey
)

const tx = await sdk.futures.submitSmartMarginOrder(
{ address: marketInfo.marketAddress, key: marketInfo.marketKey },
wallet,
account,
orderInputs,
{ cancelPendingReduceOrders: isClosing, cancelExpiredDelayedOrders: !!staleOrder }
)
const tx = await sdk.futures.submitSmartMarginOrder({
market: marketInfo,
walletAddress: wallet,
smAddress: account,
order: orderInputs,
options: { cancelPendingReduceOrders: isClosing, cancelExpiredDelayedOrders: !!staleOrder },
})
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(fetchSmartMarginOpenOrders())
dispatch(setOpenModal(null))
Expand Down Expand Up @@ -1111,11 +1113,11 @@ export const submitSmartMarginAdjustMargin = createAsyncThunk<void, void, ThunkC
})
)

const tx = await sdk.futures.modifySmartMarginMarketMargin(
account,
market.marketAddress,
wei(marginDelta)
)
const tx = await sdk.futures.modifySmartMarginMarketMargin({
address: account,
market: market.marketAddress,
marginDelta: wei(marginDelta),
})
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(setOpenModal(null))
dispatch(refetchSmartMarginPosition())
Expand Down Expand Up @@ -1158,16 +1160,13 @@ export const submitSmartMarginAdjustPositionSize = createAsyncThunk<void, boolea
position?.activePosition.side === PositionSide.SHORT ? existingSize.neg() : existingSize
const isClosing = existingSize.add(nativeSizeDelta).eq(0)

const tx = await sdk.futures.modifySmartMarginPositionSize(
account,
{
key: market.marketKey,
address: market.marketAddress,
},
wei(nativeSizeDelta),
preview.desiredFillPrice,
isClosing
)
const tx = await sdk.futures.modifySmartMarginPositionSize({
address: account,
market,
sizeDelta: wei(nativeSizeDelta),
desiredFillPrice: preview.desiredFillPrice,
cancelPendingReduceOrders: isClosing,
})
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(setShowPositionModal(null))
dispatch(fetchBalances())
Expand Down Expand Up @@ -1231,18 +1230,18 @@ export const submitSmartMarginReducePositionOrder = createAsyncThunk<void, boole

const tx =
isClosing && orderType === 'market'
? await sdk.futures.closeSmartMarginPosition(
{ address: market.marketAddress, key: market.marketKey },
account,
preview.desiredFillPrice
)
: await sdk.futures.submitSmartMarginOrder(
{ address: market.marketAddress, key: market.marketKey },
wallet,
account,
orderInputs,
{ cancelPendingReduceOrders: isClosing }
)
? await sdk.futures.closeSmartMarginPosition({
market,
address: account,
desiredFillPrice: preview.desiredFillPrice,
})
: await sdk.futures.submitSmartMarginOrder({
market,
walletAddress: wallet,
smAddress: account,
order: orderInputs,
options: { cancelPendingReduceOrders: isClosing },
})

await monitorAndAwaitTransaction(dispatch, tx)
dispatch(setOpenModal(null))
Expand All @@ -1258,10 +1257,10 @@ export const submitSmartMarginReducePositionOrder = createAsyncThunk<void, boole

export const cancelConditionalOrder = createAsyncThunk<void, number, ThunkConfig>(
'futures/cancelConditionalOrder',
async (contractOrderId, { getState, dispatch, extra: { sdk } }) => {
const crossMarginAccount = selectSmartMarginAccount(getState())
async (orderId, { getState, dispatch, extra: { sdk } }) => {
const account = selectSmartMarginAccount(getState())
try {
if (!crossMarginAccount) throw new Error('No smart margin account')
if (!account) throw new Error('No smart margin account')
dispatch(
setTransaction({
status: TransactionStatus.AwaitingExecution,
Expand All @@ -1272,8 +1271,11 @@ export const cancelConditionalOrder = createAsyncThunk<void, number, ThunkConfig

// Handle contract id or subgraph id

dispatch(setSmartMarginOrderCancelling(contractOrderId))
const tx = await sdk.futures.cancelConditionalOrder(crossMarginAccount, contractOrderId)
dispatch(setSmartMarginOrderCancelling(orderId))
const tx = await sdk.futures.cancelConditionalOrder({
account,
orderId,
})
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(setSmartMarginOrderCancelling(undefined))
dispatch(setOpenModal(null))
Expand All @@ -1289,9 +1291,9 @@ export const cancelConditionalOrder = createAsyncThunk<void, number, ThunkConfig
export const withdrawAccountKeeperBalance = createAsyncThunk<void, Wei, ThunkConfig>(
'futures/withdrawAccountKeeperBalance',
async (amount, { getState, dispatch, extra: { sdk } }) => {
const crossMarginAccount = selectSmartMarginAccount(getState())
const address = selectSmartMarginAccount(getState())
try {
if (!crossMarginAccount) throw new Error('No smart margin account')
if (!address) throw new Error('No smart margin account')
dispatch(
setTransaction({
status: TransactionStatus.AwaitingExecution,
Expand All @@ -1300,7 +1302,10 @@ export const withdrawAccountKeeperBalance = createAsyncThunk<void, Wei, ThunkCon
})
)

const tx = await sdk.futures.withdrawAccountKeeperBalance(crossMarginAccount, amount)
const tx = await sdk.futures.withdrawAccountKeeperBalance({
address,
amount,
})
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(setOpenModal(null))
dispatch(fetchSmartMarginBalanceInfo())
Expand All @@ -1324,7 +1329,11 @@ export const executeDelayedOrder = createAsyncThunk<void, ExecuteDelayedOrderInp
hash: null,
})
)
const tx = await sdk.futures.executeDelayedOffchainOrder(marketKey, marketAddress, account)
const tx = await sdk.futures.executeDelayedOffchainOrder({
marketKey,
marketAddress,
account,
})
dispatch(updateTransactionHash(tx.hash))
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(fetchSmartMarginOpenOrders())
Expand All @@ -1341,7 +1350,7 @@ const submitSMTransferTransaction = async (
dispatch: AppDispatch,
sdk: KwentaSDK,
type: 'withdraw_smart_margin' | 'deposit_smart_margin',
account: string,
address: string,
amount: Wei
) => {
dispatch(
Expand All @@ -1353,10 +1362,11 @@ const submitSMTransferTransaction = async (
)

try {
const isPrepareOnly = false
const tx =
type === 'deposit_smart_margin'
? await sdk.futures.depositSmartMarginAccount(account, amount)
: await sdk.futures.withdrawSmartMarginAccount(account, amount)
? await sdk.futures.depositSmartMarginAccount({ address, amount, isPrepareOnly })
: await sdk.futures.withdrawSmartMarginAccount({ address, amount, isPrepareOnly })
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(fetchSmartMarginBalanceInfo())
dispatch(setOpenModal(null))
Expand Down Expand Up @@ -1446,7 +1456,11 @@ export const updateStopLossAndTakeProfit = createAsyncThunk<void, void, ThunkCon
})
)

const tx = await sdk.futures.updateStopLossAndTakeProfit(market.marketKey, account, params)
const tx = await sdk.futures.updateStopLossAndTakeProfit({
marketKey: market.marketKey,
account,
params,
})
await monitorAndAwaitTransaction(dispatch, tx)
dispatch(setShowPositionModal(null))
}
Expand Down
6 changes: 6 additions & 0 deletions packages/app/src/state/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export const migrations = {
prices: PRICES_INITIAL_STATE,
}
},
37: (state: any) => {
return {
...state,
stats: STATS_INITIAL_STATE,
}
},
}

export default migrations
2 changes: 1 addition & 1 deletion packages/app/src/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const LOG_REDUX = false
const persistConfig = {
key: 'root1',
storage,
version: 36,
version: 37,
blacklist: ['app', 'wallet'],
migrate: createMigrate(migrations, { debug: true }),
}
Expand Down
Loading

1 comment on commit 9e22c45

@vercel
Copy link

@vercel vercel bot commented on 9e22c45 Sep 7, 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-git-main-kwenta.vercel.app
kwenta-kwenta.vercel.app
kwenta.io

Please sign in to comment.