2021-04-02 11:26:21 -07:00
|
|
|
import { useState, useEffect, useRef } from 'react'
|
2021-04-18 03:34:37 -07:00
|
|
|
import styled from '@emotion/styled'
|
2021-04-06 15:11:42 -07:00
|
|
|
import useMarket from '../hooks/useMarket'
|
2021-04-02 11:26:21 -07:00
|
|
|
import useIpAddress from '../hooks/useIpAddress'
|
|
|
|
import useConnection from '../hooks/useConnection'
|
|
|
|
import { PublicKey } from '@solana/web3.js'
|
2021-06-17 15:37:03 -07:00
|
|
|
import { getTokenBySymbol, IDS, PerpMarket } from '@blockworks-foundation/mango-client'
|
2021-04-02 11:26:21 -07:00
|
|
|
import { notify } from '../utils/notifications'
|
2021-06-17 15:37:03 -07:00
|
|
|
// import { placeAndSettle } from '../utils/mango'
|
2021-04-02 11:26:21 -07:00
|
|
|
import { calculateMarketPrice, getDecimalCount } from '../utils'
|
|
|
|
import FloatingElement from './FloatingElement'
|
2021-06-09 15:30:53 -07:00
|
|
|
import { floorToDecimal } from '../utils/index'
|
2021-04-02 11:26:21 -07:00
|
|
|
import useMangoStore from '../stores/useMangoStore'
|
2021-04-10 12:21:02 -07:00
|
|
|
import Button from './Button'
|
2021-04-12 13:01:55 -07:00
|
|
|
import TradeType from './TradeType'
|
2021-04-13 16:41:04 -07:00
|
|
|
import Input from './Input'
|
|
|
|
import Switch from './Switch'
|
2021-06-17 15:37:03 -07:00
|
|
|
import { Market } from '@project-serum/serum'
|
|
|
|
import { I80F48, NEG_ONE_I80F48 } from '@blockworks-foundation/mango-client/lib/src/fixednum'
|
2021-04-02 11:26:21 -07:00
|
|
|
|
2021-04-18 03:34:37 -07:00
|
|
|
const StyledRightInput = styled(Input)`
|
|
|
|
border-left: 1px solid transparent;
|
|
|
|
`
|
|
|
|
|
2021-04-12 20:39:08 -07:00
|
|
|
export default function TradeForm() {
|
2021-04-12 13:01:55 -07:00
|
|
|
const set = useMangoStore((s) => s.set)
|
2021-04-13 22:23:50 -07:00
|
|
|
const connected = useMangoStore((s) => s.wallet.connected)
|
2021-04-12 20:39:08 -07:00
|
|
|
const actions = useMangoStore((s) => s.actions)
|
2021-04-02 11:26:21 -07:00
|
|
|
const { connection, cluster } = useConnection()
|
2021-06-17 15:37:03 -07:00
|
|
|
const groupConfig = useMangoStore((s) => s.selectedMangoGroup.config);
|
|
|
|
const marketConfig = useMangoStore((s) => s.selectedMarket.config);
|
|
|
|
const market = useMangoStore((s) => s.selectedMarket.current);
|
2021-04-12 13:01:55 -07:00
|
|
|
const { side, baseSize, quoteSize, price, tradeType } = useMangoStore(
|
|
|
|
(s) => s.tradeForm
|
|
|
|
)
|
|
|
|
const { ipAllowed } = useIpAddress()
|
|
|
|
const [postOnly, setPostOnly] = useState(false)
|
|
|
|
const [ioc, setIoc] = useState(false)
|
|
|
|
const [submitting, setSubmitting] = useState(false)
|
2021-04-02 11:26:21 -07:00
|
|
|
|
2021-04-29 07:38:28 -07:00
|
|
|
const orderBookRef = useRef(useMangoStore.getState().selectedMarket.orderBook)
|
2021-06-17 15:37:03 -07:00
|
|
|
const orderbook = orderBookRef.current
|
2021-04-02 11:26:21 -07:00
|
|
|
useEffect(
|
|
|
|
() =>
|
|
|
|
useMangoStore.subscribe(
|
2021-06-17 15:37:03 -07:00
|
|
|
(orderBook) => (orderBookRef.current = orderBook),
|
2021-04-29 07:38:28 -07:00
|
|
|
(state) => state.selectedMarket.orderBook
|
2021-04-02 11:26:21 -07:00
|
|
|
),
|
|
|
|
[]
|
|
|
|
)
|
2021-06-17 15:37:03 -07:00
|
|
|
console.log({orderbook, orderBookRef});
|
2021-04-02 11:26:21 -07:00
|
|
|
|
2021-04-12 13:01:55 -07:00
|
|
|
const setSide = (side) =>
|
|
|
|
set((s) => {
|
|
|
|
s.tradeForm.side = side
|
|
|
|
})
|
|
|
|
|
|
|
|
const setBaseSize = (baseSize) =>
|
|
|
|
set((s) => {
|
2021-06-09 15:30:53 -07:00
|
|
|
if (!Number.isNaN(parseFloat(baseSize))) {
|
|
|
|
s.tradeForm.baseSize = parseFloat(baseSize)
|
|
|
|
} else {
|
|
|
|
s.tradeForm.baseSize = baseSize
|
|
|
|
}
|
2021-04-12 13:01:55 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
const setQuoteSize = (quoteSize) =>
|
|
|
|
set((s) => {
|
2021-06-09 15:30:53 -07:00
|
|
|
if (!Number.isNaN(parseFloat(quoteSize))) {
|
|
|
|
s.tradeForm.quoteSize = parseFloat(quoteSize)
|
|
|
|
} else {
|
|
|
|
s.tradeForm.quoteSize = quoteSize
|
|
|
|
}
|
2021-04-12 13:01:55 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
const setPrice = (price) =>
|
|
|
|
set((s) => {
|
2021-06-09 15:30:53 -07:00
|
|
|
if (!Number.isNaN(parseFloat(price))) {
|
|
|
|
s.tradeForm.price = parseFloat(price)
|
|
|
|
} else {
|
|
|
|
s.tradeForm.price = price
|
|
|
|
}
|
2021-04-12 13:01:55 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
const setTradeType = (type) =>
|
|
|
|
set((s) => {
|
|
|
|
s.tradeForm.tradeType = type
|
|
|
|
})
|
|
|
|
|
2021-04-29 07:38:28 -07:00
|
|
|
const markPriceRef = useRef(useMangoStore.getState().selectedMarket.markPrice)
|
2021-04-02 11:26:21 -07:00
|
|
|
const markPrice = markPriceRef.current
|
|
|
|
useEffect(
|
|
|
|
() =>
|
|
|
|
useMangoStore.subscribe(
|
|
|
|
(markPrice) => (markPriceRef.current = markPrice as number),
|
2021-04-29 07:38:28 -07:00
|
|
|
(state) => state.selectedMarket.markPrice
|
2021-04-02 11:26:21 -07:00
|
|
|
),
|
|
|
|
[]
|
|
|
|
)
|
2021-06-17 15:37:03 -07:00
|
|
|
let minOrderSize = "0";
|
|
|
|
if (market instanceof Market && market.minOrderSize) {
|
|
|
|
minOrderSize = market.minOrderSize.toString();
|
|
|
|
} else if (market instanceof PerpMarket) {
|
|
|
|
const baseDecimals = getTokenBySymbol(groupConfig, marketConfig.base_symbol).decimals;
|
|
|
|
const baseUnit = I80F48.fromNumber(Math.pow(10, baseDecimals));
|
|
|
|
const baseLotSize = I80F48.fromI64(market.contractSize);
|
|
|
|
minOrderSize = baseLotSize.div(baseUnit).toString();
|
|
|
|
}
|
|
|
|
const sizeDecimalCount = getDecimalCount(minOrderSize);
|
2021-04-02 11:26:21 -07:00
|
|
|
|
2021-06-17 15:37:03 -07:00
|
|
|
let tickSize = 1;
|
|
|
|
if (market instanceof Market) {
|
|
|
|
tickSize = market.tickSize;
|
|
|
|
} else if (market instanceof PerpMarket) {
|
|
|
|
const baseDecimals = getTokenBySymbol(groupConfig, marketConfig.base_symbol).decimals;
|
|
|
|
const baseUnit = I80F48.fromNumber(Math.pow(10, baseDecimals));
|
|
|
|
const baseLotSize = I80F48.fromI64(market.contractSize);
|
|
|
|
const quoteDecimals = getTokenBySymbol(groupConfig, groupConfig.quote_symbol).decimals;
|
|
|
|
const quoteUnit = I80F48.fromNumber(Math.pow(10, quoteDecimals));
|
|
|
|
const quoteLotSize = I80F48.fromI64(market.quoteLotSize);
|
|
|
|
tickSize = quoteLotSize.mul(baseUnit).div(baseLotSize).div(quoteUnit).toNumber();
|
|
|
|
}
|
2021-04-02 11:26:21 -07:00
|
|
|
|
2021-06-17 15:37:03 -07:00
|
|
|
|
2021-04-15 14:36:55 -07:00
|
|
|
const onSetPrice = (price: number | '') => {
|
|
|
|
setPrice(price)
|
|
|
|
if (!price) return
|
|
|
|
if (baseSize) {
|
|
|
|
onSetBaseSize(baseSize)
|
|
|
|
}
|
|
|
|
}
|
2021-04-02 11:26:21 -07:00
|
|
|
|
2021-04-12 20:39:08 -07:00
|
|
|
const onSetBaseSize = (baseSize: number | '') => {
|
2021-06-05 09:14:34 -07:00
|
|
|
const { price } = useMangoStore.getState().tradeForm
|
2021-04-02 11:26:21 -07:00
|
|
|
setBaseSize(baseSize)
|
|
|
|
if (!baseSize) {
|
2021-04-12 20:39:08 -07:00
|
|
|
setQuoteSize('')
|
2021-04-02 11:26:21 -07:00
|
|
|
return
|
|
|
|
}
|
2021-04-12 20:39:08 -07:00
|
|
|
const usePrice = Number(price) || markPrice
|
2021-04-02 11:26:21 -07:00
|
|
|
if (!usePrice) {
|
2021-04-12 20:39:08 -07:00
|
|
|
setQuoteSize('')
|
2021-04-02 11:26:21 -07:00
|
|
|
return
|
|
|
|
}
|
|
|
|
const rawQuoteSize = baseSize * usePrice
|
2021-06-09 15:30:53 -07:00
|
|
|
const quoteSize = baseSize && floorToDecimal(rawQuoteSize, sizeDecimalCount)
|
2021-04-02 11:26:21 -07:00
|
|
|
setQuoteSize(quoteSize)
|
|
|
|
}
|
|
|
|
|
2021-04-12 20:39:08 -07:00
|
|
|
const onSetQuoteSize = (quoteSize: number | '') => {
|
2021-04-02 11:26:21 -07:00
|
|
|
setQuoteSize(quoteSize)
|
|
|
|
if (!quoteSize) {
|
2021-04-12 20:39:08 -07:00
|
|
|
setBaseSize('')
|
2021-04-02 11:26:21 -07:00
|
|
|
return
|
|
|
|
}
|
2021-04-12 20:39:08 -07:00
|
|
|
|
2021-04-15 14:36:55 -07:00
|
|
|
if (!Number(price) && tradeType === 'Limit') {
|
2021-04-12 20:39:08 -07:00
|
|
|
setBaseSize('')
|
2021-04-02 11:26:21 -07:00
|
|
|
return
|
|
|
|
}
|
2021-04-15 14:36:55 -07:00
|
|
|
const usePrice = Number(price) || markPrice
|
2021-04-02 11:26:21 -07:00
|
|
|
const rawBaseSize = quoteSize / usePrice
|
2021-06-09 15:30:53 -07:00
|
|
|
const baseSize = quoteSize && floorToDecimal(rawBaseSize, sizeDecimalCount)
|
2021-04-02 11:26:21 -07:00
|
|
|
setBaseSize(baseSize)
|
|
|
|
}
|
|
|
|
|
|
|
|
const postOnChange = (checked) => {
|
|
|
|
if (checked) {
|
|
|
|
setIoc(false)
|
|
|
|
}
|
|
|
|
setPostOnly(checked)
|
|
|
|
}
|
|
|
|
const iocOnChange = (checked) => {
|
|
|
|
if (checked) {
|
|
|
|
setPostOnly(false)
|
|
|
|
}
|
|
|
|
setIoc(checked)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function onSubmit() {
|
2021-06-17 15:37:03 -07:00
|
|
|
/*
|
2021-04-02 11:26:21 -07:00
|
|
|
if (!price && tradeType === 'Limit') {
|
|
|
|
console.warn('Missing price')
|
|
|
|
notify({
|
|
|
|
message: 'Missing price',
|
|
|
|
type: 'error',
|
|
|
|
})
|
|
|
|
return
|
|
|
|
} else if (!baseSize) {
|
|
|
|
console.warn('Missing size')
|
|
|
|
notify({
|
|
|
|
message: 'Missing size',
|
|
|
|
type: 'error',
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-10 14:12:15 -07:00
|
|
|
const marginAccount = useMangoStore.getState().selectedMarginAccount.current
|
|
|
|
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
|
|
|
const wallet = useMangoStore.getState().wallet.current
|
|
|
|
|
|
|
|
if (!mangoGroup || !marketAddress || !marginAccount || !market) return
|
2021-04-02 11:26:21 -07:00
|
|
|
setSubmitting(true)
|
|
|
|
|
|
|
|
try {
|
|
|
|
let calculatedPrice
|
|
|
|
if (tradeType === 'Market') {
|
|
|
|
calculatedPrice =
|
|
|
|
side === 'buy'
|
2021-04-12 13:01:55 -07:00
|
|
|
? calculateMarketPrice(orderbook.asks, baseSize, side)
|
|
|
|
: calculateMarketPrice(orderbook.bids, baseSize, side)
|
2021-04-02 11:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
await placeAndSettle(
|
|
|
|
connection,
|
|
|
|
new PublicKey(IDS[cluster].mango_program_id),
|
|
|
|
mangoGroup,
|
|
|
|
marginAccount,
|
|
|
|
market,
|
|
|
|
wallet,
|
|
|
|
side,
|
|
|
|
calculatedPrice ?? price,
|
|
|
|
baseSize,
|
|
|
|
ioc ? 'ioc' : postOnly ? 'postOnly' : 'limit'
|
|
|
|
)
|
2021-04-10 14:12:15 -07:00
|
|
|
console.log('Successfully placed trade!')
|
2021-04-02 11:26:21 -07:00
|
|
|
|
2021-04-12 20:39:08 -07:00
|
|
|
setPrice('')
|
|
|
|
onSetBaseSize('')
|
2021-04-14 15:46:36 -07:00
|
|
|
actions.fetchMarginAccounts()
|
2021-04-02 11:26:21 -07:00
|
|
|
} catch (e) {
|
2021-04-11 21:17:23 -07:00
|
|
|
notify({
|
|
|
|
message: 'Error placing order',
|
|
|
|
description: e.message,
|
2021-05-21 15:00:39 -07:00
|
|
|
txid: e.txid,
|
2021-04-11 21:17:23 -07:00
|
|
|
type: 'error',
|
|
|
|
})
|
2021-04-02 11:26:21 -07:00
|
|
|
} finally {
|
|
|
|
setSubmitting(false)
|
|
|
|
}
|
2021-06-17 15:37:03 -07:00
|
|
|
*/
|
2021-04-02 11:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const handleTradeTypeChange = (tradeType) => {
|
|
|
|
setTradeType(tradeType)
|
|
|
|
if (tradeType === 'Market') {
|
|
|
|
setIoc(true)
|
2021-04-12 13:01:55 -07:00
|
|
|
setPrice('')
|
2021-04-02 11:26:21 -07:00
|
|
|
} else {
|
2021-06-17 15:37:03 -07:00
|
|
|
const priceOnBook = side === 'buy' ? orderbook?.asks : orderbook?.bids;
|
|
|
|
if (priceOnBook && priceOnBook.length > 0 && priceOnBook[0].length > 0) {
|
|
|
|
setPrice(priceOnBook[0][0]);
|
|
|
|
}
|
2021-04-02 11:26:21 -07:00
|
|
|
setIoc(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 15:18:23 -07:00
|
|
|
const disabledTradeButton =
|
2021-04-18 06:45:11 -07:00
|
|
|
(!price && tradeType === 'Limit') || !baseSize || !connected || submitting
|
|
|
|
|
2021-04-02 11:26:21 -07:00
|
|
|
return (
|
|
|
|
<FloatingElement>
|
|
|
|
<div>
|
2021-04-12 13:01:55 -07:00
|
|
|
<div className={`flex text-base text-th-fgd-4`}>
|
|
|
|
<button
|
|
|
|
onClick={() => setSide('buy')}
|
|
|
|
className={`flex-1 outline-none focus:outline-none`}
|
2021-04-02 11:26:21 -07:00
|
|
|
>
|
2021-04-12 13:01:55 -07:00
|
|
|
<div
|
2021-04-18 06:45:11 -07:00
|
|
|
className={`hover:text-th-green pb-1 transition-colors duration-500
|
2021-04-12 13:01:55 -07:00
|
|
|
${
|
|
|
|
side === 'buy' &&
|
|
|
|
`text-th-green hover:text-th-green border-b-2 border-th-green`
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
Buy
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
onClick={() => setSide('sell')}
|
|
|
|
className={`flex-1 outline-none focus:outline-none`}
|
2021-04-02 11:26:21 -07:00
|
|
|
>
|
2021-04-12 13:01:55 -07:00
|
|
|
<div
|
2021-04-18 06:45:11 -07:00
|
|
|
className={`hover:text-th-red pb-1 transition-colors duration-500
|
2021-04-12 13:01:55 -07:00
|
|
|
${
|
|
|
|
side === 'sell' &&
|
|
|
|
`text-th-red hover:text-th-red border-b-2 border-th-red`
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
Sell
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</div>
|
2021-04-13 16:41:04 -07:00
|
|
|
<Input.Group className="mt-4">
|
|
|
|
<Input
|
2021-04-02 11:26:21 -07:00
|
|
|
type="number"
|
2021-06-09 15:30:53 -07:00
|
|
|
min="0"
|
2021-06-17 15:37:03 -07:00
|
|
|
step={tickSize}
|
2021-06-09 15:30:53 -07:00
|
|
|
onChange={(e) => onSetPrice(e.target.value)}
|
2021-04-12 13:01:55 -07:00
|
|
|
value={price}
|
2021-04-02 11:26:21 -07:00
|
|
|
disabled={tradeType === 'Market'}
|
2021-04-12 13:01:55 -07:00
|
|
|
prefix={'Price'}
|
2021-06-17 15:37:03 -07:00
|
|
|
suffix={groupConfig.quote_symbol}
|
2021-04-26 05:53:27 -07:00
|
|
|
className="rounded-r-none"
|
2021-04-18 03:34:37 -07:00
|
|
|
wrapperClassName="w-3/5"
|
2021-04-02 11:26:21 -07:00
|
|
|
/>
|
2021-04-12 13:01:55 -07:00
|
|
|
<TradeType
|
2021-04-02 11:26:21 -07:00
|
|
|
onChange={handleTradeTypeChange}
|
|
|
|
value={tradeType}
|
2021-04-18 03:34:37 -07:00
|
|
|
className="hover:border-th-primary flex-grow"
|
2021-04-12 13:01:55 -07:00
|
|
|
/>
|
2021-04-13 16:41:04 -07:00
|
|
|
</Input.Group>
|
2021-04-12 13:01:55 -07:00
|
|
|
|
2021-04-13 16:41:04 -07:00
|
|
|
<Input.Group className="mt-4">
|
|
|
|
<Input
|
2021-04-02 11:26:21 -07:00
|
|
|
type="number"
|
2021-06-09 15:30:53 -07:00
|
|
|
min="0"
|
2021-06-17 15:37:03 -07:00
|
|
|
step={minOrderSize}
|
2021-06-09 15:30:53 -07:00
|
|
|
onChange={(e) => onSetBaseSize(e.target.value)}
|
2021-04-12 13:01:55 -07:00
|
|
|
value={baseSize}
|
2021-04-26 05:53:27 -07:00
|
|
|
className="rounded-r-none"
|
2021-04-18 03:34:37 -07:00
|
|
|
wrapperClassName="w-3/5"
|
2021-04-12 13:01:55 -07:00
|
|
|
prefix={'Size'}
|
2021-06-17 15:37:03 -07:00
|
|
|
suffix={marketConfig.base_symbol}
|
2021-04-02 11:26:21 -07:00
|
|
|
/>
|
2021-04-18 03:34:37 -07:00
|
|
|
<StyledRightInput
|
2021-04-02 11:26:21 -07:00
|
|
|
type="number"
|
2021-06-09 15:30:53 -07:00
|
|
|
min="0"
|
2021-06-17 15:37:03 -07:00
|
|
|
step={minOrderSize}
|
2021-06-09 15:30:53 -07:00
|
|
|
onChange={(e) => onSetQuoteSize(e.target.value)}
|
2021-04-12 13:01:55 -07:00
|
|
|
value={quoteSize}
|
2021-04-18 03:34:37 -07:00
|
|
|
className="rounded-l-none"
|
|
|
|
wrapperClassName="w-2/5"
|
2021-06-17 15:37:03 -07:00
|
|
|
suffix={groupConfig.quote_symbol}
|
2021-04-02 11:26:21 -07:00
|
|
|
/>
|
2021-04-13 16:41:04 -07:00
|
|
|
</Input.Group>
|
2021-04-02 11:26:21 -07:00
|
|
|
{tradeType !== 'Market' ? (
|
2021-04-18 03:34:37 -07:00
|
|
|
<div className="flex items-center mt-4">
|
2021-04-13 16:41:04 -07:00
|
|
|
<Switch checked={postOnly} onChange={postOnChange}>
|
2021-04-12 15:15:15 -07:00
|
|
|
POST
|
2021-04-13 16:41:04 -07:00
|
|
|
</Switch>
|
2021-04-12 15:15:15 -07:00
|
|
|
<div className="ml-4">
|
2021-04-13 16:41:04 -07:00
|
|
|
<Switch checked={ioc} onChange={iocOnChange}>
|
2021-04-12 15:15:15 -07:00
|
|
|
IOC
|
2021-04-13 16:41:04 -07:00
|
|
|
</Switch>
|
2021-04-12 15:15:15 -07:00
|
|
|
</div>
|
2021-04-02 11:26:21 -07:00
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
2021-04-18 18:58:16 -07:00
|
|
|
<div className={`flex pt-6`}>
|
2021-04-05 07:32:11 -07:00
|
|
|
{ipAllowed ? (
|
2021-04-18 15:18:23 -07:00
|
|
|
connected ? (
|
|
|
|
side === 'buy' ? (
|
|
|
|
<Button
|
|
|
|
disabled={disabledTradeButton}
|
2021-04-19 09:54:04 -07:00
|
|
|
onClick={onSubmit}
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`${
|
2021-04-18 15:18:23 -07:00
|
|
|
!disabledTradeButton &&
|
|
|
|
'border-th-green hover:border-th-green-dark'
|
|
|
|
} text-th-green hover:text-th-fgd-1 hover:bg-th-green-dark flex-grow`}
|
|
|
|
>
|
2021-06-12 10:46:06 -07:00
|
|
|
{`${
|
|
|
|
baseSize > 0
|
|
|
|
? 'Buy ' + baseSize
|
2021-06-17 15:37:03 -07:00
|
|
|
: 'Set BUY bid >= ' + minOrderSize
|
|
|
|
} ${marketConfig.base_symbol}`}
|
2021-04-18 15:18:23 -07:00
|
|
|
</Button>
|
|
|
|
) : (
|
|
|
|
<Button
|
|
|
|
disabled={disabledTradeButton}
|
|
|
|
onClick={onSubmit}
|
2021-04-20 07:19:08 -07:00
|
|
|
className={`${
|
2021-04-18 15:18:23 -07:00
|
|
|
!disabledTradeButton &&
|
|
|
|
'border-th-red hover:border-th-red-dark'
|
|
|
|
} text-th-red hover:text-th-fgd-1 hover:bg-th-red-dark flex-grow`}
|
|
|
|
>
|
2021-06-12 10:46:06 -07:00
|
|
|
{`${
|
|
|
|
baseSize > 0
|
|
|
|
? 'Sell ' + baseSize
|
2021-06-17 15:37:03 -07:00
|
|
|
: 'Set SELL bid >= ' + minOrderSize
|
|
|
|
} ${marketConfig.base_symbol}`}
|
2021-04-18 15:18:23 -07:00
|
|
|
</Button>
|
|
|
|
)
|
2021-04-05 07:32:11 -07:00
|
|
|
) : (
|
2021-04-19 09:15:49 -07:00
|
|
|
<>
|
2021-04-21 05:45:03 -07:00
|
|
|
<Button disabled className="flex-grow">
|
|
|
|
Connect Wallet
|
|
|
|
</Button>
|
2021-04-19 09:15:49 -07:00
|
|
|
{/* <div className="flex justify-between border border-th-fgd-4 rounded-md w-full">
|
|
|
|
<Button
|
|
|
|
onClick={() => wallet.connect()}
|
|
|
|
className={`rounded-r-none flex flex-grow items-center justify-center border-none`}
|
|
|
|
>
|
|
|
|
<WalletIcon className="fill-current h-4 w-4 mr-2" />
|
|
|
|
Connect Wallet
|
|
|
|
</Button>
|
|
|
|
<div className="relative h-full">
|
|
|
|
<WalletSelect />
|
|
|
|
</div>
|
|
|
|
</div> */}
|
|
|
|
</>
|
2021-04-05 07:32:11 -07:00
|
|
|
)
|
2021-04-02 11:26:21 -07:00
|
|
|
) : (
|
2021-04-12 15:15:15 -07:00
|
|
|
<Button disabled className="flex-grow">
|
|
|
|
<span className="text-lg font-light">Country Not Allowed</span>
|
2021-04-11 17:09:47 -07:00
|
|
|
</Button>
|
2021-04-05 07:32:11 -07:00
|
|
|
)}
|
|
|
|
</div>
|
2021-04-02 11:26:21 -07:00
|
|
|
</FloatingElement>
|
|
|
|
)
|
|
|
|
}
|