trade page slippage will use swap settings; use shared comp for max swap

This commit is contained in:
tjs 2023-08-25 12:46:45 -04:00
parent 2a195c4a78
commit 8fee400e4f
2 changed files with 6 additions and 4 deletions

View File

@ -76,7 +76,7 @@ export const INPUT_PREFIX_CLASSNAMES =
export const DEFAULT_CHECKBOX_SETTINGS = { export const DEFAULT_CHECKBOX_SETTINGS = {
ioc: false, ioc: false,
post: false, post: false,
margin: false, margin: true,
} }
const AdvancedTradeForm = () => { const AdvancedTradeForm = () => {

View File

@ -32,7 +32,7 @@ import useUnownedAccount from 'hooks/useUnownedAccount'
import HealthImpact from '@components/shared/HealthImpact' import HealthImpact from '@components/shared/HealthImpact'
import Tooltip from '@components/shared/Tooltip' import Tooltip from '@components/shared/Tooltip'
import Checkbox from '@components/forms/Checkbox' import Checkbox from '@components/forms/Checkbox'
import MaxMarketSwapAmount from './MaxMarketSwapAmount' // import MaxMarketSwapAmount from './MaxMarketSwapAmount'
import { floorToDecimal, formatNumericValue } from 'utils/numbers' import { floorToDecimal, formatNumericValue } from 'utils/numbers'
import { formatTokenSymbol } from 'utils/tokens' import { formatTokenSymbol } from 'utils/tokens'
import FormatNumericValue from '@components/shared/FormatNumericValue' import FormatNumericValue from '@components/shared/FormatNumericValue'
@ -43,9 +43,9 @@ import {
AddressLookupTableAccount, AddressLookupTableAccount,
TransactionInstruction, TransactionInstruction,
} from '@solana/web3.js' } from '@solana/web3.js'
import MaxSwapAmount from '@components/swap/MaxSwapAmount'
const set = mangoStore.getState().set const set = mangoStore.getState().set
const slippage = 100
function stringToNumberOrZero(s: string): number { function stringToNumberOrZero(s: string): number {
const n = parseFloat(s) const n = parseFloat(s)
@ -167,6 +167,8 @@ export default function SpotMarketOrderSwapForm() {
} }
}, [selectedMarket, side]) }, [selectedMarket, side])
const slippage = mangoStore.getState().swap.slippage
const { bestRoute: selectedRoute, isLoading } = useQuoteRoutes({ const { bestRoute: selectedRoute, isLoading } = useQuoteRoutes({
inputMint: inputBank?.mint.toString() || '', inputMint: inputBank?.mint.toString() || '',
outputMint: outputBank?.mint.toString() || '', outputMint: outputBank?.mint.toString() || '',
@ -384,7 +386,7 @@ export default function SpotMarketOrderSwapForm() {
<form onSubmit={(e) => handleSubmit(e)}> <form onSubmit={(e) => handleSubmit(e)}>
<div className="mt-3 px-3 md:px-4"> <div className="mt-3 px-3 md:px-4">
{!isUnownedAccount ? ( {!isUnownedAccount ? (
<MaxMarketSwapAmount <MaxSwapAmount
useMargin={savedCheckboxSettings.margin} useMargin={savedCheckboxSettings.margin}
setAmountIn={setAmountFromSlider} setAmountIn={setAmountFromSlider}
/> />