simplify balance click feature
This commit is contained in:
parent
1de3e4756e
commit
27f821c51c
|
@ -223,13 +223,11 @@ const Balance = ({ bank }: { bank: Bank }) => {
|
|||
if (balance > 0) {
|
||||
if (type === 'quote') {
|
||||
set((s) => {
|
||||
s.tradeForm.side = 'buy'
|
||||
s.tradeForm.baseSize = (balance / price).toString()
|
||||
s.tradeForm.quoteSize = balance.toString()
|
||||
})
|
||||
} else {
|
||||
set((s) => {
|
||||
s.tradeForm.side = 'sell'
|
||||
s.tradeForm.baseSize = balance.toString()
|
||||
s.tradeForm.quoteSize = (balance * price).toString()
|
||||
})
|
||||
|
@ -237,13 +235,11 @@ const Balance = ({ bank }: { bank: Bank }) => {
|
|||
} else {
|
||||
if (type === 'quote') {
|
||||
set((s) => {
|
||||
s.tradeForm.side = 'sell'
|
||||
s.tradeForm.baseSize = (balance / price).toString()
|
||||
s.tradeForm.quoteSize = balance.toString()
|
||||
})
|
||||
} else {
|
||||
set((s) => {
|
||||
s.tradeForm.side = 'buy'
|
||||
s.tradeForm.baseSize = balance.toString()
|
||||
s.tradeForm.quoteSize = (balance * price).toString()
|
||||
})
|
||||
|
|
|
@ -192,19 +192,13 @@ const AdvancedTradeForm = () => {
|
|||
const group = mangoStore.getState().group
|
||||
if (!group || !selectedMarket) return
|
||||
if (selectedMarket instanceof Serum3Market) {
|
||||
if (tradeForm.tradeType === 'Limit') {
|
||||
const baseBank = group?.getFirstBankByTokenIndex(
|
||||
selectedMarket.baseTokenIndex
|
||||
)
|
||||
if (baseBank.uiPrice) {
|
||||
const price = baseBank.uiPrice.toString()
|
||||
set((s) => {
|
||||
s.tradeForm.price = price
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const baseBank = group?.getFirstBankByTokenIndex(
|
||||
selectedMarket.baseTokenIndex
|
||||
)
|
||||
if (baseBank.uiPrice) {
|
||||
const price = baseBank.uiPrice.toString()
|
||||
set((s) => {
|
||||
s.tradeForm.price = ''
|
||||
s.tradeForm.price = price
|
||||
})
|
||||
}
|
||||
} else {
|
||||
|
@ -212,7 +206,7 @@ const AdvancedTradeForm = () => {
|
|||
s.tradeForm.price = selectedMarket._uiPrice.toString()
|
||||
})
|
||||
}
|
||||
}, [set, selectedMarket, tradeForm])
|
||||
}, [set, selectedMarket])
|
||||
|
||||
const handlePlaceOrder = useCallback(async () => {
|
||||
const client = mangoStore.getState().client
|
||||
|
|
Loading…
Reference in New Issue