reload open orders more frequently
This commit is contained in:
parent
2355dfcaa6
commit
8f27393c22
|
@ -131,9 +131,7 @@ const BalancesTable = ({
|
|||
})
|
||||
}
|
||||
} finally {
|
||||
actions.reloadMangoAccount()
|
||||
actions.reloadOrders()
|
||||
|
||||
setSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,21 +59,21 @@ const useHydrateStore = () => {
|
|||
|
||||
useInterval(() => {
|
||||
if (mangoAccount) {
|
||||
actions.fetchTradeHistory()
|
||||
actions.reloadOrders()
|
||||
actions.updateOpenOrders()
|
||||
}
|
||||
}, 60 * SECONDS)
|
||||
}, 30 * SECONDS)
|
||||
|
||||
useInterval(() => {
|
||||
if (mangoAccount) {
|
||||
actions.reloadMangoAccount()
|
||||
actions.fetchWalletTokens()
|
||||
actions.fetchTradeHistory()
|
||||
actions.updateOpenOrders()
|
||||
}
|
||||
}, 90 * SECONDS)
|
||||
|
||||
useInterval(() => {
|
||||
actions.fetchMangoGroup()
|
||||
actions.fetchWalletTokens()
|
||||
}, 120 * SECONDS)
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -266,7 +266,7 @@
|
|||
"perpetual-futures": "Perpetual Futures",
|
||||
"perps": "Perps",
|
||||
"pnl-error": "Error settling PNL",
|
||||
"pnl-help": "Settling will update your USDC balance to reflect the unsettled PnL amount.",
|
||||
"pnl-help": "Redeeming will update your USDC balance to reflect the redeemed PnL amount.",
|
||||
"pnl-success": "Successfully settled PNL",
|
||||
"portfolio": "Portfolio",
|
||||
"position": "Position",
|
||||
|
|
|
@ -366,11 +366,10 @@ const useMangoStore = create<MangoStore>((set, get) => {
|
|||
const mangoClient = get().connection.client
|
||||
const wallet = get().wallet.current
|
||||
const actions = get().actions
|
||||
const walletPk = wallet?.publicKey
|
||||
|
||||
if (!walletPk) return
|
||||
if (!wallet?.publicKey || !mangoGroup) return
|
||||
return mangoClient
|
||||
.getMangoAccountsForOwner(mangoGroup, walletPk, true)
|
||||
.getMangoAccountsForOwner(mangoGroup, wallet?.publicKey, true)
|
||||
.then((mangoAccounts) => {
|
||||
if (mangoAccounts.length > 0) {
|
||||
const sortedAccounts = mangoAccounts
|
||||
|
@ -566,16 +565,23 @@ const useMangoStore = create<MangoStore>((set, get) => {
|
|||
}
|
||||
},
|
||||
async reloadOrders() {
|
||||
const set = get().set
|
||||
const mangoAccount = get().selectedMangoAccount.current
|
||||
const connection = get().connection.current
|
||||
if (mangoAccount) {
|
||||
await Promise.all([
|
||||
const [spotOpenOrdersAccounts, advancedOrders] = await Promise.all([
|
||||
mangoAccount.loadOpenOrders(
|
||||
connection,
|
||||
new PublicKey(serumProgramId)
|
||||
),
|
||||
mangoAccount.loadAdvancedOrders(connection),
|
||||
])
|
||||
mangoAccount.spotOpenOrdersAccounts = spotOpenOrdersAccounts
|
||||
mangoAccount.advancedOrders = advancedOrders
|
||||
set((state) => {
|
||||
state.selectedMangoAccount.current = mangoAccount
|
||||
state.selectedMangoAccount.lastUpdatedAt = new Date().toISOString()
|
||||
})
|
||||
}
|
||||
},
|
||||
async updateOpenOrders() {
|
||||
|
|
Loading…
Reference in New Issue