merge main
This commit is contained in:
commit
38a34fb732
|
@ -15,7 +15,6 @@ const GovernanceDelegate = () => {
|
|||
const connectionContext = GovernanceStore((s) => s.connectionContext)
|
||||
const vsrClient = GovernanceStore((s) => s.vsrClient)
|
||||
const getCurrentVotingPower = GovernanceStore((s) => s.getCurrentVotingPower)
|
||||
const voter = GovernanceStore((s) => s.voter.tokenOwnerRecord)
|
||||
|
||||
const [selectedDelegatePk, setSelectedDelegatePk] = useLocalStorageState(
|
||||
`${publicKey?.toBase58()}${GOVERNANCE_DELEGATE_KEY}`
|
||||
|
@ -28,8 +27,7 @@ const GovernanceDelegate = () => {
|
|||
if (
|
||||
publicKey?.toBase58() &&
|
||||
connectionContext?.endpoint &&
|
||||
vsrClient?.program.programId.toBase58() &&
|
||||
voter
|
||||
vsrClient?.program.programId.toBase58()
|
||||
) {
|
||||
getCurrentVotingPower(publicKey, vsrClient, connectionContext)
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
|
||||
const vsrClient = GovernanceStore((s) => s.vsrClient)
|
||||
const proposals = GovernanceStore((s) => s.proposals)
|
||||
const proposalsLoading = GovernanceStore((s) => s.loadingProposals)
|
||||
|
||||
const [advForm, setAdvForm] = useState<ListMarketForm>({
|
||||
...defaultFormValues,
|
||||
|
@ -332,10 +333,15 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
<Button
|
||||
className="mt-6"
|
||||
onClick={goToPropsPage}
|
||||
disabled={loadingMarketProps || !quoteToken || !baseToken}
|
||||
disabled={
|
||||
loadingMarketProps ||
|
||||
!quoteToken ||
|
||||
!baseToken ||
|
||||
proposalsLoading
|
||||
}
|
||||
size="large"
|
||||
>
|
||||
{loadingMarketProps ? (
|
||||
{loadingMarketProps || proposalsLoading ? (
|
||||
<Loading className="w-4"></Loading>
|
||||
) : (
|
||||
t('next')
|
||||
|
|
|
@ -73,7 +73,7 @@ const SwapForm = () => {
|
|||
const { group } = useMangoGroup()
|
||||
const [swapFormSizeUi] = useLocalStorageState(SIZE_INPUT_UI_KEY, 'slider')
|
||||
const { ipAllowed, ipCountry } = useIpAddress()
|
||||
const { isUnownedAccount } = useUnownedAccount()
|
||||
const { isUnownedAccount, isDelegatedAccount } = useUnownedAccount()
|
||||
|
||||
const {
|
||||
margin: useMargin,
|
||||
|
@ -87,7 +87,6 @@ const SwapForm = () => {
|
|||
const [debouncedAmountIn] = useDebounce(amountInFormValue, 300)
|
||||
const [debouncedAmountOut] = useDebounce(amountOutFormValue, 300)
|
||||
const { mangoAccount } = useMangoAccount()
|
||||
const { isDelegatedAccount } = useUnownedAccount()
|
||||
const { connected, publicKey } = useWallet()
|
||||
|
||||
const amountInAsDecimal: Decimal | null = useMemo(() => {
|
||||
|
@ -109,6 +108,7 @@ const SwapForm = () => {
|
|||
slippage,
|
||||
swapMode,
|
||||
wallet: publicKey?.toBase58(),
|
||||
mode: isDelegatedAccount ? 'JUPITER' : 'ALL',
|
||||
})
|
||||
|
||||
const setAmountInFormValue = useCallback(
|
||||
|
@ -458,7 +458,6 @@ const SwapForm = () => {
|
|||
amountOut={
|
||||
selectedRoute ? amountOutAsDecimal.toNumber() : undefined
|
||||
}
|
||||
isDelegatedAccount={isDelegatedAccount}
|
||||
/>
|
||||
) : (
|
||||
<Button
|
||||
|
@ -541,7 +540,6 @@ const SwapFormSubmitButton = ({
|
|||
selectedRoute,
|
||||
setShowConfirm,
|
||||
useMargin,
|
||||
isDelegatedAccount,
|
||||
}: {
|
||||
amountIn: Decimal
|
||||
amountOut: number | undefined
|
||||
|
@ -550,7 +548,6 @@ const SwapFormSubmitButton = ({
|
|||
selectedRoute: RouteInfo | undefined | null
|
||||
setShowConfirm: (x: boolean) => void
|
||||
useMargin: boolean
|
||||
isDelegatedAccount: boolean
|
||||
}) => {
|
||||
const { t } = useTranslation('common')
|
||||
const { connected } = useWallet()
|
||||
|
@ -566,8 +563,7 @@ const SwapFormSubmitButton = ({
|
|||
(!amountIn.toNumber() ||
|
||||
showInsufficientBalance ||
|
||||
!amountOut ||
|
||||
!selectedRoute ||
|
||||
isDelegatedAccount)
|
||||
!selectedRoute)
|
||||
|
||||
const onClick = connected ? () => setShowConfirm(true) : handleConnect
|
||||
|
||||
|
@ -579,9 +575,7 @@ const SwapFormSubmitButton = ({
|
|||
disabled={disabled}
|
||||
size="large"
|
||||
>
|
||||
{isDelegatedAccount ? (
|
||||
<div>Swap Unavailable for Delegates</div>
|
||||
) : connected ? (
|
||||
{connected ? (
|
||||
showInsufficientBalance ? (
|
||||
<div className="flex items-center">
|
||||
<ExclamationCircleIcon className="mr-2 h-5 w-5 flex-shrink-0" />
|
||||
|
|
|
@ -45,6 +45,7 @@ import RoutesModal from './RoutesModal'
|
|||
import { createAssociatedTokenAccountIdempotentInstruction } from '@blockworks-foundation/mango-v4'
|
||||
import FormatNumericValue from '@components/shared/FormatNumericValue'
|
||||
import { isMangoError } from 'types'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
|
||||
type JupiterRouteInfoProps = {
|
||||
amountIn: Decimal
|
||||
|
@ -188,6 +189,7 @@ const SwapReviewRouteInfo = ({
|
|||
}: JupiterRouteInfoProps) => {
|
||||
const { t } = useTranslation(['common', 'trade'])
|
||||
const slippage = mangoStore((s) => s.swap.slippage)
|
||||
const wallet = useWallet()
|
||||
const [showRoutesModal, setShowRoutesModal] = useState<boolean>(false)
|
||||
const [swapRate, setSwapRate] = useState<boolean>(false)
|
||||
const [feeValue] = useState<number | null>(null)
|
||||
|
@ -260,7 +262,14 @@ const SwapReviewRouteInfo = ({
|
|||
const set = mangoStore.getState().set
|
||||
const connection = mangoStore.getState().connection
|
||||
|
||||
if (!mangoAccount || !group || !inputBank || !outputBank) return
|
||||
if (
|
||||
!mangoAccount ||
|
||||
!group ||
|
||||
!inputBank ||
|
||||
!outputBank ||
|
||||
!wallet.publicKey
|
||||
)
|
||||
return
|
||||
setSubmitting(true)
|
||||
const [ixs, alts] =
|
||||
selectedRoute.routerName === 'Mango'
|
||||
|
@ -273,7 +282,7 @@ const SwapReviewRouteInfo = ({
|
|||
: await fetchJupiterTransaction(
|
||||
connection,
|
||||
selectedRoute,
|
||||
mangoAccount.owner,
|
||||
wallet.publicKey,
|
||||
slippage,
|
||||
inputBank.mint,
|
||||
outputBank.mint
|
||||
|
@ -323,7 +332,14 @@ const SwapReviewRouteInfo = ({
|
|||
} finally {
|
||||
onClose()
|
||||
}
|
||||
}, [amountIn, onClose, selectedRoute, soundSettings])
|
||||
}, [
|
||||
amountIn,
|
||||
onClose,
|
||||
selectedRoute,
|
||||
slippage,
|
||||
soundSettings,
|
||||
wallet.publicKey,
|
||||
])
|
||||
|
||||
const [balance, borrowAmount] = useMemo(() => {
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
|
|
|
@ -6,6 +6,8 @@ import { RouteInfo } from 'types/jupiter'
|
|||
import { MANGO_ROUTER_API_URL } from 'utils/constants'
|
||||
import useJupiterSwapData from './useJupiterSwapData'
|
||||
|
||||
type SwapModes = 'ALL' | 'JUPITER' | 'MANGO'
|
||||
|
||||
type useQuoteRoutesPropTypes = {
|
||||
inputMint: string
|
||||
outputMint: string
|
||||
|
@ -13,6 +15,7 @@ type useQuoteRoutesPropTypes = {
|
|||
slippage: number
|
||||
swapMode: string
|
||||
wallet: string | undefined | null
|
||||
mode?: SwapModes
|
||||
}
|
||||
|
||||
const fetchJupiterRoutes = async (
|
||||
|
@ -112,7 +115,7 @@ export const handleGetRoutes = async (
|
|||
swapMode = 'ExactIn',
|
||||
feeBps = 0,
|
||||
wallet: string | undefined | null,
|
||||
mode: 'ALL' | 'JUPITER' | 'MANGO' = 'ALL'
|
||||
mode: SwapModes = 'ALL'
|
||||
) => {
|
||||
try {
|
||||
wallet ||= PublicKey.default.toBase58()
|
||||
|
@ -179,6 +182,7 @@ const useQuoteRoutes = ({
|
|||
slippage,
|
||||
swapMode,
|
||||
wallet,
|
||||
mode = 'ALL',
|
||||
}: useQuoteRoutesPropTypes) => {
|
||||
const { inputTokenInfo, outputTokenInfo } = useJupiterSwapData()
|
||||
|
||||
|
@ -205,7 +209,8 @@ const useQuoteRoutes = ({
|
|||
slippage,
|
||||
swapMode,
|
||||
0,
|
||||
wallet
|
||||
wallet,
|
||||
mode
|
||||
),
|
||||
{
|
||||
cacheTime: 1000 * 60,
|
||||
|
|
Loading…
Reference in New Issue