Allow UK spot trading
This commit is contained in:
parent
88651e9c14
commit
edac2473fc
|
@ -44,7 +44,7 @@ export default function AdvancedTradeForm({
|
|||
}: AdvancedTradeFormProps) {
|
||||
const { t } = useTranslation('common')
|
||||
const set = useMangoStore((s) => s.set)
|
||||
const { ipAllowed } = useIpAddress()
|
||||
const { ipAllowed, spotAllowed } = useIpAddress()
|
||||
const connected = useMangoStore((s) => s.wallet.connected)
|
||||
const actions = useMangoStore((s) => s.actions)
|
||||
const groupConfig = useMangoStore((s) => s.selectedMangoGroup.config)
|
||||
|
@ -617,6 +617,8 @@ export default function AdvancedTradeForm({
|
|||
!mangoAccount ||
|
||||
sizeTooLarge
|
||||
|
||||
const canTrade = ipAllowed || (market instanceof Market && spotAllowed)
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full">
|
||||
<ElementTitle className="hidden md:flex">
|
||||
|
@ -835,7 +837,7 @@ export default function AdvancedTradeForm({
|
|||
) : null}
|
||||
</div>
|
||||
<div className={`flex pt-4`}>
|
||||
{ipAllowed ? (
|
||||
{canTrade ? (
|
||||
<Button
|
||||
disabled={disabledTradeButton}
|
||||
onClick={onSubmit}
|
||||
|
|
|
@ -27,7 +27,7 @@ import { useTranslation } from 'next-i18next'
|
|||
export default function SimpleTradeForm({ initLeverage }) {
|
||||
const { t } = useTranslation('common')
|
||||
const set = useMangoStore((s) => s.set)
|
||||
const { ipAllowed } = useIpAddress()
|
||||
const { ipAllowed, spotAllowed } = useIpAddress()
|
||||
const connected = useMangoStore((s) => s.wallet.connected)
|
||||
const actions = useMangoStore((s) => s.actions)
|
||||
const groupConfig = useMangoStore((s) => s.selectedMangoGroup.config)
|
||||
|
@ -421,6 +421,8 @@ export default function SimpleTradeForm({ initLeverage }) {
|
|||
(side === 'sell' && baseSize === roundedDeposits) ||
|
||||
(side === 'buy' && baseSize === roundedBorrows)
|
||||
|
||||
const canTrade = ipAllowed || (market instanceof Market && spotAllowed)
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full">
|
||||
<ElementTitle>
|
||||
|
@ -668,7 +670,7 @@ export default function SimpleTradeForm({ initLeverage }) {
|
|||
</div>
|
||||
) : null}
|
||||
<div className={`col-span-12 flex pt-2`}>
|
||||
{ipAllowed ? (
|
||||
{canTrade ? (
|
||||
<Button
|
||||
disabled={disabledTradeButton}
|
||||
onClick={onSubmit}
|
||||
|
|
|
@ -34,8 +34,11 @@ const SANCTIONED_COUNTRY_CODES = SANCTIONED_COUNTRIES.map(
|
|||
(country) => country[0]
|
||||
)
|
||||
|
||||
const SPOT_ALLOWED = ['GB']
|
||||
|
||||
export default function useIpAddress() {
|
||||
const [ipAllowed, setIpAllowed] = useState(false)
|
||||
const [spotAllowed, setSpotAllowed] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const checkIpLocation = async () => {
|
||||
|
@ -47,11 +50,12 @@ export default function useIpAddress() {
|
|||
|
||||
if (ipCountryCode) {
|
||||
setIpAllowed(!SANCTIONED_COUNTRY_CODES.includes(ipCountryCode))
|
||||
setSpotAllowed(SPOT_ALLOWED.includes(ipCountryCode))
|
||||
}
|
||||
}
|
||||
|
||||
checkIpLocation()
|
||||
}, [])
|
||||
|
||||
return { ipAllowed }
|
||||
return { ipAllowed, spotAllowed }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue