update tradeForm

This commit is contained in:
Tyler Shipe 2021-07-07 13:27:11 -04:00
parent 1bb61ad905
commit 6606dc1bff
3 changed files with 7 additions and 9 deletions

View File

@ -60,7 +60,7 @@ export default function MarginBalances() {
<div className="flex justify-between pb-5">
<div className="w-8 h-8" />
<div className="flex flex-col items-center">
<ElementTitle noMarignBottom>Margin Account</ElementTitle>
<ElementTitle noMarignBottom>Account</ElementTitle>
{selectedMangoAccount ? (
<Link href={'/account'}>
<a className="pt-1 text-th-fgd-3 text-xs underline hover:no-underline">

View File

@ -186,14 +186,12 @@ export default function TradeForm() {
async function onSubmit() {
if (!price && tradeType === 'Limit') {
console.warn('Missing price')
notify({
title: 'Missing price',
type: 'error',
})
return
} else if (!baseSize) {
console.warn('Missing size')
notify({
title: 'Missing size',
type: 'error',
@ -215,8 +213,9 @@ export default function TradeForm() {
}
const orderType = ioc ? 'ioc' : postOnly ? 'postOnly' : 'limit'
let txid
if (market instanceof Market) {
await mangoClient.placeSpotOrder(
txid = await mangoClient.placeSpotOrder(
mangoGroup,
mangoAccount,
mangoGroup.mangoCache,
@ -228,7 +227,7 @@ export default function TradeForm() {
orderType
)
} else {
await mangoClient.placePerpOrder(
txid = await mangoClient.placePerpOrder(
mangoGroup,
mangoAccount,
mangoGroup.mangoCache,
@ -241,8 +240,7 @@ export default function TradeForm() {
)
}
console.log('Successfully placed trade!')
notify({ title: 'Successfully placed trade', txid })
setPrice('')
onSetBaseSize('')
actions.fetchMangoAccounts()

View File

@ -38,7 +38,7 @@ export function useBalances(): Balances[] {
const tokenIndex = marketIndex
const net = (locked, tokenIndex) => {
const net = (nativeBaseLocked, tokenIndex) => {
const amount = mangoAccount
.getUiDeposit(
mangoCache.rootBankCache[tokenIndex],
@ -46,7 +46,7 @@ export function useBalances(): Balances[] {
tokenIndex
)
.add(
I80F48.fromNumber(locked).sub(
I80F48.fromNumber(nativeBaseLocked).sub(
mangoAccount.getUiBorrow(
mangoCache.rootBankCache[tokenIndex],
mangoGroup,