Buy
diff --git a/src/components/Trade/TradeModule/index.tsx b/src/components/Trade/TradeModule/index.tsx
index e1e18dd5..c5cca54b 100644
--- a/src/components/Trade/TradeModule/index.tsx
+++ b/src/components/Trade/TradeModule/index.tsx
@@ -6,12 +6,10 @@ import SwapForm from 'components/Trade/TradeModule/SwapForm'
interface Props {
buyAsset: Asset
sellAsset: Asset
- onChangeBuyAsset: (asset: Asset) => void
- onChangeSellAsset: (asset: Asset) => void
}
export default function TradeModule(props: Props) {
- const { buyAsset, sellAsset, onChangeBuyAsset, onChangeSellAsset } = props
+ const { buyAsset, sellAsset } = props
return (
)
diff --git a/src/constants/defaultSettings.ts b/src/constants/defaultSettings.ts
index eb19d961..43756554 100644
--- a/src/constants/defaultSettings.ts
+++ b/src/constants/defaultSettings.ts
@@ -1,11 +1,13 @@
-import { ASSETS } from 'constants/assets'
import { ORACLE_DENOM } from 'constants/oracle'
+import { getEnabledMarketAssets } from 'utils/assets'
+
+const enabledMarketAssets = getEnabledMarketAssets()
export const DEFAULT_SETTINGS: Settings = {
accountSummaryTabs: [true, true],
reduceMotion: false,
lendAssets: true,
- preferredAsset: ASSETS[0].denom,
+ tradingPair: { buy: enabledMarketAssets[0].denom, sell: enabledMarketAssets[1].denom },
displayCurrency: ORACLE_DENOM,
slippage: 0.02,
tutorial: true,
diff --git a/src/constants/localStorageKeys.ts b/src/constants/localStorageKeys.ts
index cec3137e..bda120b1 100644
--- a/src/constants/localStorageKeys.ts
+++ b/src/constants/localStorageKeys.ts
@@ -1,6 +1,6 @@
export enum LocalStorageKeys {
+ TRADING_PAIR = 'tradingPair',
ACCOUNT_SUMMARY_TABS = 'accountSummaryTabs',
- PREFERRED_ASSET = 'favouriteAsset',
DISPLAY_CURRENCY = 'displayCurrency',
REDUCE_MOTION = 'reduceMotion',
FAVORITE_ASSETS = 'favoriteAssets',
diff --git a/src/pages/TradePage.tsx b/src/pages/TradePage.tsx
index 9fb18906..7dfd9006 100644
--- a/src/pages/TradePage.tsx
+++ b/src/pages/TradePage.tsx
@@ -1,28 +1,40 @@
-import { useState } from 'react'
+import { useMemo } from 'react'
import MigrationBanner from 'components/MigrationBanner'
import AccountDetailsCard from 'components/Trade/AccountDetailsCard'
import TradeChart from 'components/Trade/TradeChart'
import TradeModule from 'components/Trade/TradeModule'
+import { DEFAULT_SETTINGS } from 'constants/defaultSettings'
+import { LocalStorageKeys } from 'constants/localStorageKeys'
+import useLocalStorage from 'hooks/useLocalStorage'
import useStore from 'store'
+import { byDenom } from 'utils/array'
import { getEnabledMarketAssets } from 'utils/assets'
export default function TradePage() {
+ const [tradingPair] = useLocalStorage
(
+ LocalStorageKeys.TRADING_PAIR,
+ DEFAULT_SETTINGS.tradingPair,
+ )
const enabledMarketAssets = getEnabledMarketAssets()
- const [buyAsset, setBuyAsset] = useState(enabledMarketAssets[0])
- const [sellAsset, setSellAsset] = useState(enabledMarketAssets[1])
const assetOverlayState = useStore((s) => s.assetOverlayState)
+ const buyAsset = useMemo(
+ () => enabledMarketAssets.find(byDenom(tradingPair.buy)) ?? enabledMarketAssets[0],
+ [tradingPair, enabledMarketAssets],
+ )
+ const sellAsset = useMemo(
+ () => enabledMarketAssets.find(byDenom(tradingPair.sell)) ?? enabledMarketAssets[1],
+ [tradingPair, enabledMarketAssets],
+ )
+
+ if (!tradingPair) return null
+
return (
-
+
diff --git a/src/types/interfaces/store/settings.d.ts b/src/types/interfaces/store/settings.d.ts
index f9e6e15c..bb51527a 100644
--- a/src/types/interfaces/store/settings.d.ts
+++ b/src/types/interfaces/store/settings.d.ts
@@ -2,7 +2,7 @@ interface Settings {
accountSummaryTabs: boolean[]
displayCurrency: string
reduceMotion: boolean
- preferredAsset: string
+ tradingPair: { buy: string; sell: string }
lendAssets: boolean
slippage: number
tutorial: boolean