use latest prettier
This commit is contained in:
parent
e63c0f4252
commit
3d8588d434
|
@ -110,7 +110,7 @@ export const calcPricePrecision = (num: number | string) => {
|
|||
export const formatPrice = (
|
||||
num: number,
|
||||
precision?: number,
|
||||
gr0 = true
|
||||
gr0 = true,
|
||||
): string => {
|
||||
if (!num) {
|
||||
return num.toString()
|
||||
|
@ -132,7 +132,7 @@ export const formatPrice = (
|
|||
const matchString: string = match[0].slice(1)
|
||||
formated = formated.replace(
|
||||
/\.0{4,15}/g,
|
||||
`.0${SUBSCRIPT_NUMBER_MAP[matchString.length]}`
|
||||
`.0${SUBSCRIPT_NUMBER_MAP[matchString.length]}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ export function subscribeOnStream(
|
|||
onRealtimeCallback: any,
|
||||
subscriberUID: any,
|
||||
onResetCacheNeededCallback: any,
|
||||
lastBar: any
|
||||
lastBar: any,
|
||||
) {
|
||||
subscriptionItem = {
|
||||
resolution,
|
||||
|
|
|
@ -3,7 +3,7 @@ type CoingeckoOhlcv = [
|
|||
open: number,
|
||||
high: number,
|
||||
low: number,
|
||||
close: number
|
||||
close: number,
|
||||
][]
|
||||
|
||||
export type ChartDataItem = {
|
||||
|
@ -16,16 +16,16 @@ export type ChartDataItem = {
|
|||
export const fetchChartData = async (
|
||||
baseTokenId: string | undefined,
|
||||
quoteTokenId: string | undefined,
|
||||
daysToShow: string
|
||||
daysToShow: string,
|
||||
): Promise<ChartDataItem[]> => {
|
||||
if (!baseTokenId || !quoteTokenId) return []
|
||||
try {
|
||||
const [inputResponse, outputResponse] = await Promise.all([
|
||||
fetch(
|
||||
`https://api.coingecko.com/api/v3/coins/${baseTokenId}/ohlc?vs_currency=usd&days=${daysToShow}`
|
||||
`https://api.coingecko.com/api/v3/coins/${baseTokenId}/ohlc?vs_currency=usd&days=${daysToShow}`,
|
||||
),
|
||||
fetch(
|
||||
`https://api.coingecko.com/api/v3/coins/${quoteTokenId}/ohlc?vs_currency=usd&days=${daysToShow}`
|
||||
`https://api.coingecko.com/api/v3/coins/${quoteTokenId}/ohlc?vs_currency=usd&days=${daysToShow}`,
|
||||
),
|
||||
])
|
||||
|
||||
|
@ -36,7 +36,7 @@ export const fetchChartData = async (
|
|||
const parsedData: ChartDataItem[] = []
|
||||
for (const inputTokenCandle of inputTokenData) {
|
||||
const outputTokenCandle = outputTokenData.find(
|
||||
(outputTokenCandle) => outputTokenCandle[0] === inputTokenCandle[0]
|
||||
(outputTokenCandle) => outputTokenCandle[0] === inputTokenCandle[0],
|
||||
)
|
||||
if (outputTokenCandle) {
|
||||
if (['usd-coin', 'tether'].includes(quoteTokenId)) {
|
||||
|
|
|
@ -72,11 +72,11 @@ const configurationData = {
|
|||
|
||||
const getTickerFromMktAddress = (
|
||||
group: Group,
|
||||
symbolAddress: string
|
||||
symbolAddress: string,
|
||||
): string | null => {
|
||||
try {
|
||||
const serumMkt = group.getSerum3MarketByExternalMarket(
|
||||
new PublicKey(symbolAddress)
|
||||
new PublicKey(symbolAddress),
|
||||
)
|
||||
|
||||
if (serumMkt) {
|
||||
|
@ -88,7 +88,7 @@ const getTickerFromMktAddress = (
|
|||
|
||||
const perpMarkets = Array.from(group.perpMarketsMapByMarketIndex.values())
|
||||
const perpMkt = perpMarkets.find(
|
||||
(perpMarket) => perpMarket.publicKey.toString() === symbolAddress
|
||||
(perpMarket) => perpMarket.publicKey.toString() === symbolAddress,
|
||||
)
|
||||
|
||||
if (perpMkt) {
|
||||
|
@ -102,12 +102,12 @@ let marketType: 'spot' | 'perp'
|
|||
|
||||
export const queryPerpBars = async (
|
||||
tokenAddress: string,
|
||||
resolution: typeof SUPPORTED_RESOLUTIONS[number],
|
||||
resolution: (typeof SUPPORTED_RESOLUTIONS)[number],
|
||||
periodParams: {
|
||||
firstDataRequest: boolean
|
||||
from: number
|
||||
to: number
|
||||
}
|
||||
},
|
||||
): Promise<Bar[]> => {
|
||||
const { from, to } = periodParams
|
||||
|
||||
|
@ -150,12 +150,12 @@ export const queryPerpBars = async (
|
|||
|
||||
export const queryBirdeyeBars = async (
|
||||
tokenAddress: string,
|
||||
resolution: typeof SUPPORTED_RESOLUTIONS[number],
|
||||
resolution: (typeof SUPPORTED_RESOLUTIONS)[number],
|
||||
periodParams: {
|
||||
firstDataRequest: boolean
|
||||
from: number
|
||||
to: number
|
||||
}
|
||||
},
|
||||
): Promise<Bar[]> => {
|
||||
const { from, to } = periodParams
|
||||
const urlParameters = {
|
||||
|
@ -167,7 +167,7 @@ export const queryBirdeyeBars = async (
|
|||
const query = Object.keys(urlParameters)
|
||||
.map(
|
||||
(name: string) =>
|
||||
`${name}=${encodeURIComponent((urlParameters as any)[name])}`
|
||||
`${name}=${encodeURIComponent((urlParameters as any)[name])}`,
|
||||
)
|
||||
.join('&')
|
||||
|
||||
|
@ -207,14 +207,14 @@ export default {
|
|||
_userInput: string,
|
||||
_exchange: string,
|
||||
_symbolType: string,
|
||||
_onResultReadyCallback: (items: SearchSymbolResultItem[]) => void
|
||||
_onResultReadyCallback: (items: SearchSymbolResultItem[]) => void,
|
||||
) => {
|
||||
return
|
||||
},
|
||||
|
||||
resolveSymbol: async (
|
||||
symbolAddress: string,
|
||||
onSymbolResolvedCallback: (symbolInfo: SymbolInfo) => void
|
||||
onSymbolResolvedCallback: (symbolInfo: SymbolInfo) => void,
|
||||
// _onResolveErrorCallback: any,
|
||||
// _extension: any
|
||||
) => {
|
||||
|
@ -283,9 +283,9 @@ export default {
|
|||
bars: Bar[],
|
||||
t: {
|
||||
noData: boolean
|
||||
}
|
||||
},
|
||||
) => void,
|
||||
onErrorCallback: (e: any) => void
|
||||
onErrorCallback: (e: any) => void,
|
||||
) => {
|
||||
try {
|
||||
const { firstDataRequest } = periodParams
|
||||
|
@ -298,14 +298,14 @@ export default {
|
|||
bars = await queryPerpBars(
|
||||
symbolInfo.address,
|
||||
resolution as any,
|
||||
periodParams
|
||||
periodParams,
|
||||
)
|
||||
} else {
|
||||
marketType = 'spot'
|
||||
bars = await queryBirdeyeBars(
|
||||
symbolInfo.address,
|
||||
resolution as any,
|
||||
periodParams
|
||||
periodParams,
|
||||
)
|
||||
}
|
||||
if (!bars || bars.length === 0) {
|
||||
|
@ -335,7 +335,7 @@ export default {
|
|||
resolution: string,
|
||||
onRealtimeCallback: (data: any) => void,
|
||||
subscriberUID: string,
|
||||
onResetCacheNeededCallback: () => void
|
||||
onResetCacheNeededCallback: () => void,
|
||||
) => {
|
||||
subscriptionIds.set(subscriberUID, symbolInfo.address)
|
||||
if (symbolInfo.description?.includes('PERP')) {
|
||||
|
@ -345,7 +345,7 @@ export default {
|
|||
onRealtimeCallback,
|
||||
subscriberUID,
|
||||
onResetCacheNeededCallback,
|
||||
lastBarsCache.get(symbolInfo.address)
|
||||
lastBarsCache.get(symbolInfo.address),
|
||||
)
|
||||
} else {
|
||||
subscribeOnSpotStream(
|
||||
|
@ -354,7 +354,7 @@ export default {
|
|||
onRealtimeCallback,
|
||||
subscriberUID,
|
||||
onResetCacheNeededCallback,
|
||||
lastBarsCache.get(symbolInfo.address)
|
||||
lastBarsCache.get(symbolInfo.address),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
|
@ -66,12 +66,12 @@ const configurationData = {
|
|||
|
||||
export const queryBars = async (
|
||||
tokenAddress: string,
|
||||
resolution: typeof SUPPORTED_RESOLUTIONS[number],
|
||||
resolution: (typeof SUPPORTED_RESOLUTIONS)[number],
|
||||
periodParams: {
|
||||
firstDataRequest: boolean
|
||||
from: number
|
||||
to: number
|
||||
}
|
||||
},
|
||||
): Promise<Bar[]> => {
|
||||
const { from, to } = periodParams
|
||||
const urlParameters = {
|
||||
|
@ -121,14 +121,14 @@ export default {
|
|||
_userInput: string,
|
||||
_exchange: string,
|
||||
_symbolType: string,
|
||||
_onResultReadyCallback: (items: SearchSymbolResultItem[]) => void
|
||||
_onResultReadyCallback: (items: SearchSymbolResultItem[]) => void,
|
||||
) => {
|
||||
return
|
||||
},
|
||||
|
||||
resolveSymbol: async (
|
||||
symbolAddress: string,
|
||||
onSymbolResolvedCallback: (symbolInfo: SymbolInfo) => void
|
||||
onSymbolResolvedCallback: (symbolInfo: SymbolInfo) => void,
|
||||
// _onResolveErrorCallback: any,
|
||||
// _extension: any
|
||||
) => {
|
||||
|
@ -187,16 +187,16 @@ export default {
|
|||
bars: Bar[],
|
||||
t: {
|
||||
noData: boolean
|
||||
}
|
||||
},
|
||||
) => void,
|
||||
onErrorCallback: (e: any) => void
|
||||
onErrorCallback: (e: any) => void,
|
||||
) => {
|
||||
try {
|
||||
const { firstDataRequest } = periodParams
|
||||
const bars = await queryBars(
|
||||
symbolInfo.address,
|
||||
resolution as any,
|
||||
periodParams
|
||||
periodParams,
|
||||
)
|
||||
if (!bars || bars.length === 0) {
|
||||
// "noData" should be set if there is no data in the requested period.
|
||||
|
@ -226,7 +226,7 @@ export default {
|
|||
resolution: string,
|
||||
onRealtimeCallback: (data: any) => void,
|
||||
subscriberUID: string,
|
||||
onResetCacheNeededCallback: () => void
|
||||
onResetCacheNeededCallback: () => void,
|
||||
) => {
|
||||
subscribeOnStream(
|
||||
symbolInfo,
|
||||
|
@ -234,7 +234,7 @@ export default {
|
|||
onRealtimeCallback,
|
||||
subscriberUID,
|
||||
onResetCacheNeededCallback,
|
||||
lastBarsCache.get(symbolInfo.address)
|
||||
lastBarsCache.get(symbolInfo.address),
|
||||
)
|
||||
},
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ export function subscribeOnStream(
|
|||
onRealtimeCallback: any,
|
||||
subscriberUID: any,
|
||||
onResetCacheNeededCallback: any,
|
||||
lastBar: any
|
||||
lastBar: any,
|
||||
) {
|
||||
subscriptionItem = {
|
||||
resolution,
|
||||
|
|
|
@ -6,7 +6,7 @@ export type NotificationSettings = {
|
|||
|
||||
export const fetchNotificationSettings = async (
|
||||
wallet: string,
|
||||
token: string
|
||||
token: string,
|
||||
) => {
|
||||
const data = await fetch(
|
||||
`${NOTIFICATION_API}notifications/user/getSettings`,
|
||||
|
@ -15,7 +15,7 @@ export const fetchNotificationSettings = async (
|
|||
authorization: token,
|
||||
publickey: wallet,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
const body = await data.json()
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
|||
const [inputAmount, setInputAmount] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [selectedToken, setSelectedToken] = useState(
|
||||
token || INPUT_TOKEN_DEFAULT
|
||||
token || INPUT_TOKEN_DEFAULT,
|
||||
)
|
||||
const [showTokenList, setShowTokenList] = useState(false)
|
||||
const [sizePercentage, setSizePercentage] = useState('')
|
||||
|
@ -91,11 +91,11 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
|||
setSizePercentage(percentage)
|
||||
const amount = floorToDecimal(
|
||||
new Decimal(percentage).div(100).mul(tokenMax),
|
||||
bank.mintDecimals
|
||||
bank.mintDecimals,
|
||||
)
|
||||
setInputAmount(amount.toFixed())
|
||||
},
|
||||
[tokenMax, bank]
|
||||
[tokenMax, bank],
|
||||
)
|
||||
|
||||
const setMax = useCallback(() => {
|
||||
|
@ -123,7 +123,7 @@ function BorrowForm({ onSuccess, token }: BorrowFormProps) {
|
|||
mangoAccount,
|
||||
bank!.mint,
|
||||
Number(inputAmount),
|
||||
true
|
||||
true,
|
||||
)
|
||||
notify({
|
||||
title: 'Transaction confirmed',
|
||||
|
|
|
@ -43,7 +43,7 @@ interface DepositFormProps {
|
|||
|
||||
export const walletBalanceForToken = (
|
||||
walletTokens: TokenAccount[],
|
||||
token: string
|
||||
token: string,
|
||||
): { maxAmount: number; maxDecimals: number } => {
|
||||
const group = mangoStore.getState().group
|
||||
const bank = group?.banksMapByName.get(token)?.[0]
|
||||
|
@ -67,7 +67,7 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
|
|||
const [inputAmount, setInputAmount] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [selectedToken, setSelectedToken] = useState(
|
||||
token || INPUT_TOKEN_DEFAULT
|
||||
token || INPUT_TOKEN_DEFAULT,
|
||||
)
|
||||
const [showTokenList, setShowTokenList] = useState(false)
|
||||
const [sizePercentage, setSizePercentage] = useState('')
|
||||
|
@ -98,11 +98,11 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
|
|||
setSizePercentage(percentage)
|
||||
const amount = floorToDecimal(
|
||||
new Decimal(tokenMax.maxAmount).mul(percentage).div(100),
|
||||
tokenMax.maxDecimals
|
||||
tokenMax.maxDecimals,
|
||||
)
|
||||
setInputAmount(amount.toFixed())
|
||||
},
|
||||
[tokenMax]
|
||||
[tokenMax],
|
||||
)
|
||||
|
||||
const handleSelectToken = (token: string) => {
|
||||
|
@ -124,7 +124,7 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
|
|||
group,
|
||||
mangoAccount,
|
||||
bank.mint,
|
||||
parseFloat(inputAmount)
|
||||
parseFloat(inputAmount),
|
||||
)
|
||||
notify({
|
||||
title: 'Transaction confirmed',
|
||||
|
@ -225,7 +225,7 @@ function DepositForm({ onSuccess, token }: DepositFormProps) {
|
|||
value={inputAmount}
|
||||
onValueChange={(e: NumberFormatValues) => {
|
||||
setInputAmount(
|
||||
!Number.isNaN(Number(e.value)) ? e.value : ''
|
||||
!Number.isNaN(Number(e.value)) ? e.value : '',
|
||||
)
|
||||
}}
|
||||
isAllowed={withValueLimit}
|
||||
|
|
|
@ -22,7 +22,7 @@ const HealthImpactTokenChange = ({
|
|||
mangoAccount.simHealthRatioWithTokenPositionUiChanges(
|
||||
group,
|
||||
[{ mintPk, uiTokenAmount }],
|
||||
HealthType.maint
|
||||
HealthType.maint,
|
||||
)
|
||||
|
||||
return projectedHealth! > 100
|
||||
|
|
|
@ -36,7 +36,7 @@ const termsLastUpdated = 1679441610978
|
|||
const Layout = ({ children }: { children: ReactNode }) => {
|
||||
const [isCollapsed, setIsCollapsed] = useLocalStorageState(
|
||||
SIDEBAR_COLLAPSE_KEY,
|
||||
false
|
||||
false,
|
||||
)
|
||||
|
||||
const { width } = useViewport()
|
||||
|
@ -52,9 +52,12 @@ const Layout = ({ children }: { children: ReactNode }) => {
|
|||
const animationFrames = 15
|
||||
|
||||
for (let x = 1; x <= animationFrames; x++) {
|
||||
setTimeout(() => {
|
||||
setTimeout(
|
||||
() => {
|
||||
window.dispatchEvent(new Event('resize'))
|
||||
}, (sideBarAnimationDuration / animationFrames) * x)
|
||||
},
|
||||
(sideBarAnimationDuration / animationFrames) * x,
|
||||
)
|
||||
}
|
||||
}, [isCollapsed])
|
||||
|
||||
|
@ -124,7 +127,7 @@ const TermsOfUse = () => {
|
|||
const { connected } = useWallet()
|
||||
const [acceptTerms, setAcceptTerms] = useLocalStorageState(
|
||||
ACCEPT_TERMS_KEY,
|
||||
''
|
||||
'',
|
||||
)
|
||||
|
||||
const showTermsOfUse = useMemo(() => {
|
||||
|
|
|
@ -38,17 +38,23 @@ const HydrateStore = () => {
|
|||
actions.fetchGroup()
|
||||
}, [marketName])
|
||||
|
||||
useInterval(() => {
|
||||
useInterval(
|
||||
() => {
|
||||
actions.fetchGroup()
|
||||
}, (slowNetwork ? 40 : 20) * SECONDS)
|
||||
},
|
||||
(slowNetwork ? 40 : 20) * SECONDS,
|
||||
)
|
||||
|
||||
// refetches open orders every 30 seconds
|
||||
// only the selected market's open orders are updated via websocket
|
||||
useInterval(() => {
|
||||
useInterval(
|
||||
() => {
|
||||
if (mangoAccountAddress) {
|
||||
actions.fetchOpenOrders()
|
||||
}
|
||||
}, (slowNetwork ? 60 : 30) * SECONDS)
|
||||
},
|
||||
(slowNetwork ? 60 : 30) * SECONDS,
|
||||
)
|
||||
|
||||
// refetch trade history and activity feed when switching accounts
|
||||
useEffect(() => {
|
||||
|
@ -59,10 +65,13 @@ const HydrateStore = () => {
|
|||
}, [mangoAccountAddress])
|
||||
|
||||
// reload and parse market fills from the event queue
|
||||
useInterval(async () => {
|
||||
useInterval(
|
||||
async () => {
|
||||
const actions = mangoStore.getState().actions
|
||||
actions.loadMarketFills()
|
||||
}, (slowNetwork ? 60 : 20) * SECONDS)
|
||||
},
|
||||
(slowNetwork ? 60 : 20) * SECONDS,
|
||||
)
|
||||
|
||||
// The websocket library solana/web3.js uses closes its websocket connection when the subscription list
|
||||
// is empty after opening its first time, preventing subsequent subscriptions from receiving responses.
|
||||
|
@ -92,11 +101,11 @@ const HydrateStore = () => {
|
|||
if (context.slot > lastSeenSlot) {
|
||||
const decodedMangoAccount = client.program.coder.accounts.decode(
|
||||
'mangoAccount',
|
||||
info?.data
|
||||
info?.data,
|
||||
)
|
||||
const newMangoAccount = MangoAccount.from(
|
||||
mangoAccount.publicKey,
|
||||
decodedMangoAccount
|
||||
decodedMangoAccount,
|
||||
)
|
||||
if (newMangoAccount.serum3Active().length > 0) {
|
||||
await newMangoAccount.reloadSerum3OpenOrders(client)
|
||||
|
@ -107,7 +116,7 @@ const HydrateStore = () => {
|
|||
})
|
||||
actions.fetchOpenOrders()
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
return () => {
|
||||
|
|
|
@ -45,7 +45,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
const [inputAmount, setInputAmount] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [selectedToken, setSelectedToken] = useState(
|
||||
token || INPUT_TOKEN_DEFAULT
|
||||
token || INPUT_TOKEN_DEFAULT,
|
||||
)
|
||||
const [showTokenList, setShowTokenList] = useState(false)
|
||||
const [sizePercentage, setSizePercentage] = useState('')
|
||||
|
@ -69,7 +69,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
const borrowAmount = useMemo(() => {
|
||||
if (!mangoAccount || !bank) return new Decimal(0)
|
||||
const amount = new Decimal(
|
||||
mangoAccount.getTokenBorrowsUi(bank)
|
||||
mangoAccount.getTokenBorrowsUi(bank),
|
||||
).toDecimalPlaces(bank.mintDecimals, Decimal.ROUND_UP)
|
||||
return amount
|
||||
}, [bank, mangoAccount])
|
||||
|
@ -78,7 +78,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
if (!bank) return
|
||||
const amount = new Decimal(borrowAmount).toDecimalPlaces(
|
||||
bank.mintDecimals,
|
||||
Decimal.ROUND_UP
|
||||
Decimal.ROUND_UP,
|
||||
)
|
||||
setInputAmount(amount.toFixed())
|
||||
setSizePercentage('100')
|
||||
|
@ -95,7 +95,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
|
||||
setInputAmount(amount.toFixed())
|
||||
},
|
||||
[bank, borrowAmount]
|
||||
[bank, borrowAmount],
|
||||
)
|
||||
|
||||
const handleSelectToken = (token: string) => {
|
||||
|
@ -130,7 +130,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
mangoAccount,
|
||||
bank.mint,
|
||||
actualAmount,
|
||||
true
|
||||
true,
|
||||
)
|
||||
notify({
|
||||
title: 'Transaction confirmed',
|
||||
|
@ -154,7 +154,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
})
|
||||
}
|
||||
},
|
||||
[bank, publicKey?.toBase58(), sizePercentage]
|
||||
[bank, publicKey?.toBase58(), sizePercentage],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -236,7 +236,7 @@ function RepayForm({ onSuccess, token }: RepayFormProps) {
|
|||
value={inputAmount}
|
||||
onValueChange={(e: NumberFormatValues) => {
|
||||
setInputAmount(
|
||||
!Number.isNaN(Number(e.value)) ? e.value : ''
|
||||
!Number.isNaN(Number(e.value)) ? e.value : '',
|
||||
)
|
||||
}}
|
||||
isAllowed={withValueLimit}
|
||||
|
|
|
@ -10,7 +10,7 @@ const tpsWarningThreshold = 1300
|
|||
|
||||
const getRecentPerformance = async (
|
||||
connection: Connection,
|
||||
setTps: (x: number) => void
|
||||
setTps: (x: number) => void,
|
||||
) => {
|
||||
try {
|
||||
const samples = 2
|
||||
|
|
|
@ -38,13 +38,13 @@ const TokenList = () => {
|
|||
const { t } = useTranslation(['common', 'token', 'trade'])
|
||||
const [showZeroBalances, setShowZeroBalances] = useLocalStorageState(
|
||||
SHOW_ZERO_BALANCES_KEY,
|
||||
true
|
||||
true,
|
||||
)
|
||||
const { mangoAccount, mangoAccountAddress } = useMangoAccount()
|
||||
const { initContributions } = useHealthContributions()
|
||||
const spotBalances = mangoStore((s) => s.mangoAccount.spotBalances)
|
||||
const totalInterestData = mangoStore(
|
||||
(s) => s.mangoAccount.interestTotals.data
|
||||
(s) => s.mangoAccount.interestTotals.data,
|
||||
)
|
||||
const { width } = useViewport()
|
||||
const showTableView = width ? width > breakpoints.md : false
|
||||
|
@ -136,7 +136,7 @@ const TokenList = () => {
|
|||
const hasInterestEarned = totalInterestData.find(
|
||||
(d) =>
|
||||
d.symbol.toLowerCase() === symbol.toLowerCase() ||
|
||||
(symbol === 'ETH (Portal)' && d.symbol === 'ETH')
|
||||
(symbol === 'ETH (Portal)' && d.symbol === 'ETH'),
|
||||
)
|
||||
|
||||
const interestAmount = hasInterestEarned
|
||||
|
@ -273,7 +273,7 @@ const MobileTokenListItem = ({ bank }: { bank: BankWithBalance }) => {
|
|||
const { mangoAccount } = useMangoAccount()
|
||||
const { initContributions } = useHealthContributions()
|
||||
const totalInterestData = mangoStore(
|
||||
(s) => s.mangoAccount.interestTotals.data
|
||||
(s) => s.mangoAccount.interestTotals.data,
|
||||
)
|
||||
const tokenBank = bank.bank
|
||||
const mint = tokenBank.mint
|
||||
|
@ -282,7 +282,7 @@ const MobileTokenListItem = ({ bank }: { bank: BankWithBalance }) => {
|
|||
const hasInterestEarned = totalInterestData.find(
|
||||
(d) =>
|
||||
d.symbol.toLowerCase() === symbol.toLowerCase() ||
|
||||
(symbol === 'ETH (Portal)' && d.symbol === 'ETH')
|
||||
(symbol === 'ETH (Portal)' && d.symbol === 'ETH'),
|
||||
)
|
||||
|
||||
const interestAmount = hasInterestEarned
|
||||
|
@ -464,7 +464,7 @@ const ActionsMenu = ({
|
|||
? setShowWithdrawModal(true)
|
||||
: setShowRepayModal(true)
|
||||
},
|
||||
[]
|
||||
[],
|
||||
)
|
||||
|
||||
const balance = useMemo(() => {
|
||||
|
@ -474,7 +474,7 @@ const ActionsMenu = ({
|
|||
|
||||
const handleSwap = useCallback(() => {
|
||||
const tokenInfo = mangoTokens.find(
|
||||
(t) => t.address === bank.mint.toString()
|
||||
(t) => t.address === bank.mint.toString(),
|
||||
)
|
||||
const group = mangoStore.getState().group
|
||||
if (balance && balance > 0) {
|
||||
|
@ -493,7 +493,7 @@ const ActionsMenu = ({
|
|||
} else {
|
||||
if (tokenInfo?.symbol === 'USDC') {
|
||||
const solTokenInfo = mangoTokens.find(
|
||||
(t) => t.address === WRAPPED_SOL_MINT.toString()
|
||||
(t) => t.address === WRAPPED_SOL_MINT.toString(),
|
||||
)
|
||||
const solBank = group?.getFirstBankByMint(WRAPPED_SOL_MINT)
|
||||
set((s) => {
|
||||
|
|
|
@ -49,7 +49,7 @@ function WithdrawForm({ onSuccess, token }: WithdrawFormProps) {
|
|||
const [inputAmount, setInputAmount] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [selectedToken, setSelectedToken] = useState(
|
||||
token || INPUT_TOKEN_DEFAULT
|
||||
token || INPUT_TOKEN_DEFAULT,
|
||||
)
|
||||
const [showTokenList, setShowTokenList] = useState(false)
|
||||
const [sizePercentage, setSizePercentage] = useState('')
|
||||
|
@ -82,17 +82,17 @@ function WithdrawForm({ onSuccess, token }: WithdrawFormProps) {
|
|||
if (percentage !== '100') {
|
||||
amount = floorToDecimal(
|
||||
new Decimal(adjustedTokenMax).mul(percentage).div(100),
|
||||
bank.mintDecimals
|
||||
bank.mintDecimals,
|
||||
)
|
||||
} else {
|
||||
amount = floorToDecimal(
|
||||
new Decimal(adjustedTokenMax),
|
||||
bank.mintDecimals
|
||||
bank.mintDecimals,
|
||||
)
|
||||
}
|
||||
setInputAmount(amount.toString())
|
||||
},
|
||||
[bank, adjustedTokenMax]
|
||||
[bank, adjustedTokenMax],
|
||||
)
|
||||
|
||||
const setMax = useCallback(() => {
|
||||
|
@ -116,7 +116,7 @@ function WithdrawForm({ onSuccess, token }: WithdrawFormProps) {
|
|||
mangoAccount,
|
||||
bank.mint,
|
||||
withdrawAmount,
|
||||
false
|
||||
false,
|
||||
)
|
||||
notify({
|
||||
title: 'Transaction confirmed',
|
||||
|
@ -227,7 +227,7 @@ function WithdrawForm({ onSuccess, token }: WithdrawFormProps) {
|
|||
value={inputAmount}
|
||||
onValueChange={(e: NumberFormatValues) =>
|
||||
setInputAmount(
|
||||
!Number.isNaN(Number(e.value)) ? e.value : ''
|
||||
!Number.isNaN(Number(e.value)) ? e.value : '',
|
||||
)
|
||||
}
|
||||
isAllowed={withValueLimit}
|
||||
|
|
|
@ -29,7 +29,7 @@ import { breakpoints } from 'utils/theme'
|
|||
|
||||
export const handleCopyAddress = (
|
||||
mangoAccount: MangoAccount,
|
||||
successMessage: string
|
||||
successMessage: string,
|
||||
) => {
|
||||
copyToClipboard(mangoAccount.publicKey.toString())
|
||||
notify({
|
||||
|
@ -121,7 +121,7 @@ const AccountActions = () => {
|
|||
mangoAccount!,
|
||||
t('copy-address-success', {
|
||||
pk: abbreviateAddress(mangoAccount!.publicKey),
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
>
|
||||
|
|
|
@ -40,7 +40,7 @@ const AccountHeroStats = ({
|
|||
useAccountHourlyVolumeStats()
|
||||
|
||||
const totalInterestData = mangoStore(
|
||||
(s) => s.mangoAccount.interestTotals.data
|
||||
(s) => s.mangoAccount.interestTotals.data,
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -63,7 +63,7 @@ const AccountHeroStats = ({
|
|||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!mangoAccountAddress,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const {
|
||||
|
@ -79,7 +79,7 @@ const AccountHeroStats = ({
|
|||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!mangoAccountAddress,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const maintHealth = useMemo(() => {
|
||||
|
@ -91,7 +91,7 @@ const AccountHeroStats = ({
|
|||
const leverage = useMemo(() => {
|
||||
if (!group || !mangoAccount) return 0
|
||||
const assetsValue = toUiDecimalsForQuote(
|
||||
mangoAccount.getAssetsValue(group).toNumber()
|
||||
mangoAccount.getAssetsValue(group).toNumber(),
|
||||
)
|
||||
|
||||
if (isNaN(assetsValue / accountValue)) {
|
||||
|
@ -110,7 +110,7 @@ const AccountHeroStats = ({
|
|||
if (totalInterestData.length) {
|
||||
return totalInterestData.reduce(
|
||||
(a, c) => a + (c.borrow_interest_usd * -1 + c.deposit_interest_usd),
|
||||
0
|
||||
0,
|
||||
)
|
||||
}
|
||||
return 0.0
|
||||
|
@ -120,7 +120,7 @@ const AccountHeroStats = ({
|
|||
if (fundingData?.length && mangoAccountAddress) {
|
||||
return fundingData.reduce(
|
||||
(a, c) => a + c.long_funding + c.short_funding,
|
||||
0
|
||||
0,
|
||||
)
|
||||
}
|
||||
return 0.0
|
||||
|
@ -268,7 +268,7 @@ const AccountHeroStats = ({
|
|||
value={
|
||||
group && mangoAccount
|
||||
? toUiDecimalsForQuote(
|
||||
mangoAccount.getCollateralValue(group)
|
||||
mangoAccount.getCollateralValue(group),
|
||||
)
|
||||
: 0
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ const AccountHeroStats = ({
|
|||
value={
|
||||
group && mangoAccount
|
||||
? toUiDecimalsForQuote(
|
||||
mangoAccount.getAssetsValue(group, HealthType.init)
|
||||
mangoAccount.getAssetsValue(group, HealthType.init),
|
||||
)
|
||||
: 0
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ const AccountPage = () => {
|
|||
const isMobile = width ? width < breakpoints.md : false
|
||||
const [activeTab, setActiveTab] = useLocalStorageState(
|
||||
'accountHeroKey-0.1',
|
||||
'account-value'
|
||||
'account-value',
|
||||
)
|
||||
const { performanceData, rollingDailyData } = useAccountPerformanceData()
|
||||
const router = useRouter()
|
||||
|
@ -53,7 +53,7 @@ const AccountPage = () => {
|
|||
const query = { ...router.query, ['view']: view }
|
||||
router.push({ pathname: router.pathname, query })
|
||||
},
|
||||
[router]
|
||||
[router],
|
||||
)
|
||||
|
||||
const handleCloseDailyPnlModal = () => {
|
||||
|
|
|
@ -40,7 +40,7 @@ const AccountValue = ({
|
|||
const [showExpandChart, setShowExpandChart] = useState<boolean>(false)
|
||||
const [animationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
const { width } = useViewport()
|
||||
const { performanceLoading: loading } = useAccountPerformanceData()
|
||||
|
|
|
@ -48,7 +48,7 @@ export const getFee = (activity: any, mangoAccountAddress: string) => {
|
|||
const value = price * quantity
|
||||
fee = {
|
||||
value: formatFee(
|
||||
mangoAccountAddress === maker ? maker_fee * value : taker_fee * value
|
||||
mangoAccountAddress === maker ? maker_fee * value : taker_fee * value,
|
||||
),
|
||||
symbol: 'USDC',
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ export const getFee = (activity: any, mangoAccountAddress: string) => {
|
|||
if (side === 'liqee') {
|
||||
fee = {
|
||||
value: formatNumericValue(
|
||||
Math.abs(liab_amount) - Math.abs(asset_amount * asset_price)
|
||||
Math.abs(liab_amount) - Math.abs(asset_amount * asset_price),
|
||||
),
|
||||
symbol: liab_symbol,
|
||||
}
|
||||
} else {
|
||||
fee = {
|
||||
value: formatNumericValue(
|
||||
Math.abs(asset_amount * asset_price) - Math.abs(liab_amount)
|
||||
Math.abs(asset_amount * asset_price) - Math.abs(liab_amount),
|
||||
),
|
||||
symbol: liab_symbol,
|
||||
}
|
||||
|
@ -81,14 +81,14 @@ export const getFee = (activity: any, mangoAccountAddress: string) => {
|
|||
if (base_transfer > 0) {
|
||||
fee = {
|
||||
value: formatNumericValue(
|
||||
Math.abs(base_transfer * price) - Math.abs(quote_transfer)
|
||||
Math.abs(base_transfer * price) - Math.abs(quote_transfer),
|
||||
),
|
||||
symbol: 'USDC',
|
||||
}
|
||||
} else {
|
||||
fee = {
|
||||
value: formatNumericValue(
|
||||
Math.abs(quote_transfer) - Math.abs(base_transfer * price)
|
||||
Math.abs(quote_transfer) - Math.abs(base_transfer * price),
|
||||
),
|
||||
symbol: 'USDC',
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ export const getFee = (activity: any, mangoAccountAddress: string) => {
|
|||
|
||||
export const getCreditAndDebit = (
|
||||
activity: any,
|
||||
mangoAccountAddress: string
|
||||
mangoAccountAddress: string,
|
||||
) => {
|
||||
const { activity_type } = activity
|
||||
let credit = { value: '0', symbol: '' }
|
||||
|
@ -270,7 +270,7 @@ const ActivityFeedTable = () => {
|
|||
const { connected } = useWallet()
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0]
|
||||
EXPLORERS[0],
|
||||
)
|
||||
const { width } = useViewport()
|
||||
const showTableView = width ? width > breakpoints.md : false
|
||||
|
@ -285,7 +285,7 @@ const ActivityFeedTable = () => {
|
|||
actions.fetchActivityFeed(
|
||||
mangoAccountAddress,
|
||||
offset + PAGINATION_PAGE_LENGTH,
|
||||
queryParams
|
||||
queryParams,
|
||||
)
|
||||
}, [actions, offset, queryParams, mangoAccountAddress])
|
||||
|
||||
|
@ -376,7 +376,7 @@ const ActivityFeedTable = () => {
|
|||
<div className="flex items-center justify-end">
|
||||
<Tooltip
|
||||
content={`View on ${t(
|
||||
`settings:${preferredExplorer.name}`
|
||||
`settings:${preferredExplorer.name}`,
|
||||
)}`}
|
||||
placement="top-end"
|
||||
>
|
||||
|
@ -515,7 +515,7 @@ const MobileActivityFeedItem = ({
|
|||
const { t } = useTranslation(['common', 'activity'])
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0]
|
||||
EXPLORERS[0],
|
||||
)
|
||||
const { mangoAccountAddress } = useMangoAccount()
|
||||
const { activity_type, block_datetime } = activity
|
||||
|
|
|
@ -50,7 +50,7 @@ const ActivityFilters = () => {
|
|||
const actions = mangoStore((s) => s.actions)
|
||||
const { mangoAccountAddress } = useMangoAccount()
|
||||
const [advancedFilters, setAdvancedFilters] = useState<AdvancedFilters>(
|
||||
DEFAULT_ADVANCED_FILTERS
|
||||
DEFAULT_ADVANCED_FILTERS,
|
||||
)
|
||||
const [params, setParams] = useState<string[]>([])
|
||||
const { t } = useTranslation(['common', 'activity'])
|
||||
|
@ -64,7 +64,7 @@ const ActivityFilters = () => {
|
|||
if (entry[1].length) {
|
||||
// ETH should be renamed to ETH (Portal) in the database
|
||||
const alignSymbolsToBackend = entry[1].map((e: string) =>
|
||||
e === 'ETH (Portal)' ? 'ETH' : e
|
||||
e === 'ETH (Portal)' ? 'ETH' : e,
|
||||
)
|
||||
advancedParams =
|
||||
advancedParams + `&${entry[0]}=${alignSymbolsToBackend}`
|
||||
|
|
|
@ -19,7 +19,7 @@ const AssetsLiabilities = ({ isMobile }: { isMobile: boolean }) => {
|
|||
const { theme } = useTheme()
|
||||
const [animationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
|
||||
const [assetsValue, assetsRatio, liabsValue, liabsRatio] = useMemo(() => {
|
||||
|
|
|
@ -54,16 +54,16 @@ const CreateAccountForm = ({
|
|||
group,
|
||||
newAccountNum,
|
||||
name || `Account ${newAccountNum + 1}`,
|
||||
16 // tokenCount
|
||||
16, // tokenCount
|
||||
)
|
||||
if (tx) {
|
||||
const pk = wallet.adapter.publicKey
|
||||
const mangoAccounts = await client.getMangoAccountsForOwner(group, pk!)
|
||||
const reloadedMangoAccounts = await Promise.all(
|
||||
mangoAccounts.map((ma) => ma.reloadSerum3OpenOrders(client))
|
||||
mangoAccounts.map((ma) => ma.reloadSerum3OpenOrders(client)),
|
||||
)
|
||||
const newAccount = mangoAccounts.find(
|
||||
(acc) => acc.accountNum === newAccountNum
|
||||
(acc) => acc.accountNum === newAccountNum,
|
||||
)
|
||||
if (newAccount) {
|
||||
await newAccount.reloadSerum3OpenOrders(client)
|
||||
|
|
|
@ -36,7 +36,7 @@ import SheenLoader from '@components/shared/SheenLoader'
|
|||
const fetchHourlyFunding = async (mangoAccountPk: string) => {
|
||||
try {
|
||||
const data = await fetch(
|
||||
`${MANGO_DATA_API_URL}/stats/funding-account-hourly?mango-account=${mangoAccountPk}`
|
||||
`${MANGO_DATA_API_URL}/stats/funding-account-hourly?mango-account=${mangoAccountPk}`,
|
||||
)
|
||||
const res = await data.json()
|
||||
if (res) {
|
||||
|
@ -80,7 +80,7 @@ const FundingChart = ({ hideChart }: { hideChart: () => void }) => {
|
|||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!mangoAccountAddress,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -100,7 +100,7 @@ const FundingChart = ({ hideChart }: { hideChart: () => void }) => {
|
|||
}
|
||||
const data = rawData.reduce((a: HourlyFundingChartData[], c) => {
|
||||
const found: HourlyFundingChartData | undefined = a.find(
|
||||
(item) => item['time'] === c.time
|
||||
(item) => item['time'] === c.time,
|
||||
)
|
||||
const marketKey = Object.keys(c)[0]
|
||||
const marketFunding = Object.values(c)[0]
|
||||
|
@ -123,7 +123,7 @@ const FundingChart = ({ hideChart }: { hideChart: () => void }) => {
|
|||
if (active && payload && payload.length) {
|
||||
const load = payload[0].payload
|
||||
const data: [string, any][] = Object.entries(load).filter(
|
||||
(p) => p[0] !== 'time' && p[0] !== 'total'
|
||||
(p) => p[0] !== 'time' && p[0] !== 'total',
|
||||
)
|
||||
return (
|
||||
<div className="rounded-md bg-th-bkg-2 p-4">
|
||||
|
|
|
@ -22,10 +22,10 @@ const HealthContributions = ({ hideView }: { hideView: () => void }) => {
|
|||
const { group } = useMangoGroup()
|
||||
const { mangoAccount, mangoAccountAddress } = useMangoAccount()
|
||||
const [initActiveIndex, setInitActiveIndex] = useState<number | undefined>(
|
||||
undefined
|
||||
undefined,
|
||||
)
|
||||
const [maintActiveIndex, setMaintActiveIndex] = useState<number | undefined>(
|
||||
undefined
|
||||
undefined,
|
||||
)
|
||||
const { initContributions, maintContributions } = useHealthContributions()
|
||||
|
||||
|
@ -37,7 +37,7 @@ const HealthContributions = ({ hideView }: { hideView: () => void }) => {
|
|||
if (item.asset === 'USDC') {
|
||||
const hasPerp =
|
||||
!!item.contributionDetails?.perpMarketContributions.find(
|
||||
(perp: PerpMarketContribution) => Math.abs(perp.contributionUi) > 0
|
||||
(perp: PerpMarketContribution) => Math.abs(perp.contributionUi) > 0,
|
||||
)
|
||||
initHealthContributions.push({
|
||||
...item,
|
||||
|
@ -73,7 +73,7 @@ const HealthContributions = ({ hideView }: { hideView: () => void }) => {
|
|||
if (item.asset === 'USDC') {
|
||||
const hasPerp =
|
||||
!!item.contributionDetails?.perpMarketContributions.find(
|
||||
(perp: PerpMarketContribution) => Math.abs(perp.contributionUi) > 0
|
||||
(perp: PerpMarketContribution) => Math.abs(perp.contributionUi) > 0,
|
||||
)
|
||||
maintHealthContributions.push({
|
||||
...item,
|
||||
|
@ -111,7 +111,7 @@ const HealthContributions = ({ hideView }: { hideView: () => void }) => {
|
|||
const splitData = initHealthContributions.reduce(
|
||||
(
|
||||
acc: { market: HealthContribution[]; token: HealthContribution[] },
|
||||
obj: HealthContribution
|
||||
obj: HealthContribution,
|
||||
) => {
|
||||
const isPerp = obj.asset.includes('PERP')
|
||||
const isSpotMarket = obj.asset.includes('/')
|
||||
|
@ -123,7 +123,7 @@ const HealthContributions = ({ hideView }: { hideView: () => void }) => {
|
|||
}
|
||||
return acc
|
||||
},
|
||||
{ market: [], token: [] }
|
||||
{ market: [], token: [] },
|
||||
)
|
||||
return [splitData.market, splitData.token]
|
||||
}, [initHealthContributions])
|
||||
|
@ -133,7 +133,7 @@ const HealthContributions = ({ hideView }: { hideView: () => void }) => {
|
|||
const splitData = maintHealthContributions.reduce(
|
||||
(
|
||||
acc: { market: HealthContribution[]; token: HealthContribution[] },
|
||||
obj: HealthContribution
|
||||
obj: HealthContribution,
|
||||
) => {
|
||||
const isPerp = obj.asset.includes('PERP')
|
||||
const isSpotMarket = obj.asset.includes('/')
|
||||
|
@ -145,7 +145,7 @@ const HealthContributions = ({ hideView }: { hideView: () => void }) => {
|
|||
}
|
||||
return acc
|
||||
},
|
||||
{ market: [], token: [] }
|
||||
{ market: [], token: [] },
|
||||
)
|
||||
const markets = splitData.market.filter((d) => d.contribution > 0)
|
||||
const tokens = splitData.token
|
||||
|
|
|
@ -109,7 +109,7 @@ const HistoryTabs = () => {
|
|||
paid: `${formatNumericValue(swap_in_amount, inDecimals)} ${inSymbol}`,
|
||||
received: `${formatNumericValue(
|
||||
swap_out_amount,
|
||||
outDecimals
|
||||
outDecimals,
|
||||
)} ${outSymbol}`,
|
||||
value: formatCurrencyValue(swap_out_price_usd * swap_out_amount),
|
||||
borrow: `${borrowAmount} ${inSymbol}`,
|
||||
|
@ -135,7 +135,7 @@ const HistoryTabs = () => {
|
|||
let market
|
||||
if ('market' in trade) {
|
||||
market = group.getSerum3MarketByExternalMarket(
|
||||
new PublicKey(trade.market)
|
||||
new PublicKey(trade.market),
|
||||
)
|
||||
} else if ('perp_market' in trade) {
|
||||
market = group.getPerpMarketByMarketIndex(trade.market_index)
|
||||
|
|
|
@ -22,7 +22,7 @@ const LiquidationDetails = ({
|
|||
const { t } = useTranslation(['common', 'activity', 'settings'])
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0]
|
||||
EXPLORERS[0],
|
||||
)
|
||||
|
||||
const getAssetLiquidatedReturned = (details: SpotOrPerpLiquidationItem) => {
|
||||
|
@ -209,7 +209,7 @@ const LiquidationDetails = ({
|
|||
>
|
||||
<span className="mr-1.5">
|
||||
{abbreviateAddress(
|
||||
new PublicKey(activity.activity_details.counterparty)
|
||||
new PublicKey(activity.activity_details.counterparty),
|
||||
)}
|
||||
</span>
|
||||
<ArrowTopRightOnSquareIcon className="h-3 w-3" />
|
||||
|
|
|
@ -38,13 +38,13 @@ const MangoAccountSummary = () => {
|
|||
const [accountPnl, accountValue, freeCollateral, health] = useMemo(() => {
|
||||
if (!group || !mangoAccount) return [0, 0, 0, 0]
|
||||
const accountPnl = toUiDecimalsForQuote(
|
||||
mangoAccount.getPnl(group).toNumber()
|
||||
mangoAccount.getPnl(group).toNumber(),
|
||||
)
|
||||
const accountValue = toUiDecimalsForQuote(
|
||||
mangoAccount.getEquity(group).toNumber()
|
||||
mangoAccount.getEquity(group).toNumber(),
|
||||
)
|
||||
const freeCollateral = toUiDecimalsForQuote(
|
||||
mangoAccount.getCollateralValue(group).toNumber()
|
||||
mangoAccount.getCollateralValue(group).toNumber(),
|
||||
)
|
||||
const health = mangoAccount.getHealthRatioUi(group, HealthType.maint)
|
||||
return [accountPnl, accountValue, freeCollateral, health]
|
||||
|
@ -53,7 +53,7 @@ const MangoAccountSummary = () => {
|
|||
const leverage = useMemo(() => {
|
||||
if (!group || !mangoAccount) return 0
|
||||
const assetsValue = toUiDecimalsForQuote(
|
||||
mangoAccount.getAssetsValue(group).toNumber()
|
||||
mangoAccount.getAssetsValue(group).toNumber(),
|
||||
)
|
||||
|
||||
if (isNaN(assetsValue / accountValue)) {
|
||||
|
|
|
@ -63,7 +63,7 @@ const MarketsHealthTable = ({
|
|||
const { asset, contribution, isAsset } = cont
|
||||
const market = group.getSerum3MarketByName(asset)
|
||||
const bank = group.banksMapByTokenIndex.get(
|
||||
market.baseTokenIndex
|
||||
market.baseTokenIndex,
|
||||
)?.[0]
|
||||
|
||||
let initAssetWeight = 0
|
||||
|
@ -155,7 +155,7 @@ const MarketsHealthTable = ({
|
|||
const { asset, contribution, isAsset } = cont
|
||||
const market = group.getSerum3MarketByName(asset)
|
||||
const bank = group.banksMapByTokenIndex.get(
|
||||
market.baseTokenIndex
|
||||
market.baseTokenIndex,
|
||||
)?.[0]
|
||||
|
||||
let initAssetWeight = 0
|
||||
|
|
|
@ -19,7 +19,7 @@ const PerpTradeDetails = ({ activity }: { activity: PerpTradeActivity }) => {
|
|||
const { mangoAccountAddress } = useMangoAccount()
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0]
|
||||
EXPLORERS[0],
|
||||
)
|
||||
const {
|
||||
maker,
|
||||
|
|
|
@ -44,7 +44,7 @@ const BorrowPage = () => {
|
|||
}
|
||||
const [animationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
|
||||
const filteredBanks = useMemo(() => {
|
||||
|
@ -58,7 +58,7 @@ const BorrowPage = () => {
|
|||
if (!filteredBanks.length) return 0
|
||||
return filteredBanks.reduce(
|
||||
(a, c) => a + Math.abs(c.borrowedAmount) * c.bank.uiPrice,
|
||||
0
|
||||
0,
|
||||
)
|
||||
}, [filteredBanks])
|
||||
|
||||
|
@ -75,7 +75,7 @@ const BorrowPage = () => {
|
|||
group,
|
||||
usdcBank,
|
||||
mangoAccount,
|
||||
true
|
||||
true,
|
||||
).toNumber()
|
||||
|
||||
if (borrowValue) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import TokenLogo from '@components/shared/TokenLogo'
|
|||
|
||||
export const getAvailableToBorrow = (
|
||||
bankWithBal: BankWithBalance,
|
||||
group: Group
|
||||
group: Group,
|
||||
) => {
|
||||
const { balance, bank, maxBorrow } = bankWithBal
|
||||
const { mint, mintDecimals, minVaultToDepositsRatio } = bankWithBal.bank
|
||||
|
@ -40,7 +40,7 @@ export const getAvailableToBorrow = (
|
|||
|
||||
const available = Decimal.min(
|
||||
availableAccountBorrow.toFixed(bank.mintDecimals),
|
||||
Decimal.max(0, availableVaultBalance.toFixed(mintDecimals))
|
||||
Decimal.max(0, availableVaultBalance.toFixed(mintDecimals)),
|
||||
)
|
||||
return available
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ const YourBorrowsTable = ({ banks }: { banks: BankWithBalance[] }) => {
|
|||
setSelectedToken(token)
|
||||
action === 'borrow' ? setShowBorrowModal(true) : setShowRepayModal(true)
|
||||
},
|
||||
[]
|
||||
[],
|
||||
)
|
||||
|
||||
return (
|
||||
|
|
|
@ -17,7 +17,7 @@ const ChatForm = ({
|
|||
const validateMessageText = useCallback(async (text: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://www.purgomalum.com/service/json?text=${text}&fill_char=*`
|
||||
`https://www.purgomalum.com/service/json?text=${text}&fill_char=*`,
|
||||
)
|
||||
const profanityCheck = await response.json()
|
||||
|
||||
|
@ -45,7 +45,7 @@ const ChatForm = ({
|
|||
setLatestMessages(newMessages)
|
||||
setMessageText('')
|
||||
},
|
||||
[messageText, messages, publicKey, validateMessageText, setLatestMessages]
|
||||
[messageText, messages, publicKey, validateMessageText, setLatestMessages],
|
||||
)
|
||||
|
||||
const callbackRef = useCallback((inputElement: HTMLInputElement) => {
|
||||
|
|
|
@ -17,7 +17,7 @@ const GovernanceDelegate = () => {
|
|||
const getCurrentVotingPower = GovernanceStore((s) => s.getCurrentVotingPower)
|
||||
|
||||
const [selectedDelegatePk, setSelectedDelegatePk] = useLocalStorageState(
|
||||
`${publicKey?.toBase58()}${GOVERNANCE_DELEGATE_KEY}`
|
||||
`${publicKey?.toBase58()}${GOVERNANCE_DELEGATE_KEY}`,
|
||||
)
|
||||
const currentDelegate = delegates
|
||||
.find((x) => x.pubkey.toBase58() === selectedDelegatePk)
|
||||
|
|
|
@ -90,7 +90,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
const [baseTokens, quoteTokens] = useMemo(() => {
|
||||
if (!group) return [[], []]
|
||||
const allTokens = [...group.banksMapByName.keys()].sort((a, b) =>
|
||||
a.localeCompare(b)
|
||||
a.localeCompare(b),
|
||||
)
|
||||
return [
|
||||
allTokens.filter((t) => t !== quoteToken),
|
||||
|
@ -152,7 +152,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
}
|
||||
return invalidFields
|
||||
},
|
||||
[t]
|
||||
[t],
|
||||
)
|
||||
const handlePropose = useCallback(async () => {
|
||||
const invalidFields = isFormValid(advForm)
|
||||
|
@ -189,7 +189,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
advForm.proposalDescription,
|
||||
index,
|
||||
proposalTx,
|
||||
vsrClient!
|
||||
vsrClient!,
|
||||
)
|
||||
setProposalPk(proposalAddress.toBase58())
|
||||
setCurrentView(VIEWS.SUCCESS)
|
||||
|
@ -255,7 +255,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
baseBank.uiPrice,
|
||||
quoteBank.uiPrice,
|
||||
baseBank.mintDecimals,
|
||||
quoteBank.mintDecimals
|
||||
quoteBank.mintDecimals,
|
||||
)
|
||||
}
|
||||
return {
|
||||
|
@ -289,7 +289,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
{t('market-pair')}{' '}
|
||||
{baseToken && quoteToken
|
||||
? `- ${formatTokenSymbol(baseToken)}/${formatTokenSymbol(
|
||||
quoteToken
|
||||
quoteToken,
|
||||
)}`
|
||||
: null}
|
||||
</h2>
|
||||
|
@ -506,7 +506,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleSetAdvForm(
|
||||
'openBookMarketExternalPk',
|
||||
e.target.value
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
@ -549,7 +549,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleSetAdvForm(
|
||||
'proposalDescription',
|
||||
e.target.value
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -128,7 +128,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
? governances[MANGO_DAO_WALLET_GOVERNANCE.toBase58()].account.config
|
||||
.minCommunityTokensToCreateProposal
|
||||
: new BN(0),
|
||||
[governances]
|
||||
[governances],
|
||||
) as BN
|
||||
const mintVoterWeightNumber = governances
|
||||
? fmtTokenAmount(minVoterWeight, MANGO_MINT_DECIMALS)
|
||||
|
@ -139,7 +139,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
baseTokenPrice,
|
||||
quoteBank.uiPrice,
|
||||
currentTokenInfo.decimals,
|
||||
quoteBank.mintDecimals
|
||||
quoteBank.mintDecimals,
|
||||
)
|
||||
}
|
||||
return {
|
||||
|
@ -190,7 +190,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
new BN(index).toArrayLike(Buffer, 'le', 2),
|
||||
new BN(bankNum).toArrayLike(Buffer, 'le', 4),
|
||||
],
|
||||
client.programId
|
||||
client.programId,
|
||||
)
|
||||
setAdvForm({
|
||||
...advForm,
|
||||
|
@ -210,7 +210,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
})
|
||||
setLoadingListingParams(false)
|
||||
},
|
||||
[advForm, client.programId, connection, group, mint, proposals]
|
||||
[advForm, client.programId, connection, group, mint, proposals],
|
||||
)
|
||||
|
||||
const handleGetRoutesWithFixedArgs = useCallback(
|
||||
|
@ -229,10 +229,10 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
mode,
|
||||
FEE,
|
||||
walletForCheck,
|
||||
'JUPITER'
|
||||
'JUPITER',
|
||||
)
|
||||
},
|
||||
[wallet.publicKey]
|
||||
[wallet.publicKey],
|
||||
)
|
||||
|
||||
const handleLiqudityCheck = useCallback(
|
||||
|
@ -256,7 +256,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
(acc: { amount: string; priceImpactPct: number }[], val) => {
|
||||
if (val.swapMode === 'ExactIn') {
|
||||
const exactOutRoute = bestRoutesSwaps.find(
|
||||
(x) => x.amount === val.amount && x.swapMode === 'ExactOut'
|
||||
(x) => x.amount === val.amount && x.swapMode === 'ExactOut',
|
||||
)
|
||||
acc.push({
|
||||
amount: val.amount.toString(),
|
||||
|
@ -267,14 +267,14 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
}
|
||||
return acc
|
||||
},
|
||||
[]
|
||||
[],
|
||||
)
|
||||
|
||||
const midTierCheck = averageSwaps.find(
|
||||
(x) => x.amount === TWENTY_K_USDC_BASE
|
||||
(x) => x.amount === TWENTY_K_USDC_BASE,
|
||||
)
|
||||
const indexForTierFromSwaps = averageSwaps.findIndex(
|
||||
(x) => x?.priceImpactPct && x?.priceImpactPct * 100 < 1
|
||||
(x) => x?.priceImpactPct && x?.priceImpactPct * 100 < 1,
|
||||
)
|
||||
const tier =
|
||||
indexForTierFromSwaps > -1
|
||||
|
@ -285,8 +285,8 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
|
||||
handleGetPoolParams(
|
||||
swaps.find(
|
||||
(x) => x.bestRoute!.amount.toString() === TWENTY_K_USDC_BASE
|
||||
)!.routes
|
||||
(x) => x.bestRoute!.amount.toString() === TWENTY_K_USDC_BASE,
|
||||
)!.routes,
|
||||
)
|
||||
return tier
|
||||
} catch (e) {
|
||||
|
@ -297,7 +297,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
})
|
||||
}
|
||||
},
|
||||
[t, handleGetRoutesWithFixedArgs]
|
||||
[t, handleGetRoutesWithFixedArgs],
|
||||
)
|
||||
|
||||
const handleGetPoolParams = (routes: never[] | RouteInfo[]) => {
|
||||
|
@ -378,7 +378,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
}
|
||||
return invalidFields
|
||||
},
|
||||
[t]
|
||||
[t],
|
||||
)
|
||||
|
||||
const propose = useCallback(async () => {
|
||||
|
@ -405,7 +405,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
group!.publicKey.toBuffer(),
|
||||
new PublicKey(advForm.mintPk).toBuffer(),
|
||||
],
|
||||
client.programId
|
||||
client.programId,
|
||||
)
|
||||
|
||||
const proposalTx = []
|
||||
|
@ -436,7 +436,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
Number(tierPreset.liquidationFee),
|
||||
Number(tierPreset.minVaultToDepositsRatio),
|
||||
new BN(tierPreset.netBorrowLimitWindowSizeTs),
|
||||
new BN(tierPreset.netBorrowLimitPerWindowQuote)
|
||||
new BN(tierPreset.netBorrowLimitPerWindowQuote),
|
||||
)
|
||||
.accounts({
|
||||
admin: MANGO_DAO_WALLET,
|
||||
|
@ -474,7 +474,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
false,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
)
|
||||
.accounts({
|
||||
oracle: new PublicKey(advForm.oraclePk),
|
||||
|
@ -531,7 +531,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
advForm.proposalDescription,
|
||||
advForm.tokenIndex,
|
||||
proposalTx,
|
||||
vsrClient
|
||||
vsrClient,
|
||||
)
|
||||
setProposalPk(proposalAddress.toBase58())
|
||||
} catch (e) {
|
||||
|
@ -648,7 +648,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
<p>{t('mint')}</p>
|
||||
<p className="flex items-center">
|
||||
{abbreviateAddress(
|
||||
new PublicKey(currentTokenInfo?.address)
|
||||
new PublicKey(currentTokenInfo?.address),
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -739,7 +739,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleSetAdvForm(
|
||||
'openBookMarketExternalPk',
|
||||
e.target.value
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
@ -801,7 +801,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleSetAdvForm(
|
||||
'openBookProgram',
|
||||
e.target.value
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
@ -842,7 +842,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleSetAdvForm(
|
||||
'proposalTitle',
|
||||
e.target.value
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
@ -866,7 +866,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
handleSetAdvForm(
|
||||
'proposalDescription',
|
||||
e.target.value
|
||||
e.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -23,7 +23,7 @@ const OnBoarding = ({ minVotes }: { minVotes?: BN }) => {
|
|||
? new BN(
|
||||
governances[
|
||||
MANGO_DAO_WALLET_GOVERNANCE.toBase58()
|
||||
].account.config.minCommunityTokensToCreateProposal.toString()
|
||||
].account.config.minCommunityTokensToCreateProposal.toString(),
|
||||
)
|
||||
: new BN(0)
|
||||
const mintVoterWeightNumber = governances
|
||||
|
@ -50,7 +50,7 @@ const OnBoarding = ({ minVotes }: { minVotes?: BN }) => {
|
|||
</>
|
||||
}
|
||||
desc={`${t('on-boarding-deposit-info')} ${t(
|
||||
'on-boarding-description-1'
|
||||
'on-boarding-description-1',
|
||||
)}`}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -58,7 +58,7 @@ const ProposalCard = ({
|
|||
const [voteType, setVoteType] = useState<VoteKind | undefined>(undefined)
|
||||
|
||||
const [voteRecordAddress, setVoteRecordAddress] = useState<PublicKey | null>(
|
||||
null
|
||||
null,
|
||||
)
|
||||
const [isVoteCast, setIsVoteCast] = useState(false)
|
||||
const [description, setDescription] = useState('')
|
||||
|
@ -73,7 +73,7 @@ const ProposalCard = ({
|
|||
setProcessedVoteType(
|
||||
voteType === VoteKind.Approve
|
||||
? PROCESSED_VOTE_TYPE.APPROVE
|
||||
: PROCESSED_VOTE_TYPE.DENY
|
||||
: PROCESSED_VOTE_TYPE.DENY,
|
||||
)
|
||||
try {
|
||||
await castVote(
|
||||
|
@ -83,7 +83,7 @@ const ProposalCard = ({
|
|||
voter.tokenOwnerRecord!,
|
||||
voteType,
|
||||
vsrClient!,
|
||||
client
|
||||
client,
|
||||
)
|
||||
await updateProposals(proposal.pubkey)
|
||||
} catch (e) {
|
||||
|
@ -106,7 +106,7 @@ const ProposalCard = ({
|
|||
proposal,
|
||||
voter.tokenOwnerRecord!,
|
||||
client,
|
||||
voteRecordAddress!
|
||||
voteRecordAddress!,
|
||||
)
|
||||
await updateProposals(proposal.pubkey)
|
||||
} catch (e) {
|
||||
|
@ -140,14 +140,14 @@ const ProposalCard = ({
|
|||
const voteRecordAddress = await getVoteRecordAddress(
|
||||
MANGO_GOVERNANCE_PROGRAM,
|
||||
proposal.pubkey,
|
||||
voter.tokenOwnerRecord!.pubkey!
|
||||
voter.tokenOwnerRecord!.pubkey!,
|
||||
)
|
||||
setVoteRecordAddress(voteRecordAddress)
|
||||
try {
|
||||
const governanceAccount = await getGovernanceAccount(
|
||||
connection,
|
||||
voteRecordAddress,
|
||||
VoteRecord
|
||||
VoteRecord,
|
||||
)
|
||||
setIsVoteCast(true)
|
||||
setVoteType(governanceAccount.account.vote?.voteType)
|
||||
|
|
|
@ -89,7 +89,7 @@ const Vote = () => {
|
|||
proposal={x}
|
||||
mangoMint={mangoMint}
|
||||
></ProposalCard>
|
||||
)
|
||||
),
|
||||
)
|
||||
) : (
|
||||
<div className="flex h-56 items-center justify-center rounded-lg border border-th-bkg-3 p-6">
|
||||
|
|
|
@ -26,7 +26,7 @@ const QuorumProgress = ({ governance, proposal, communityMint }: Props) => {
|
|||
realm &&
|
||||
getMintMaxVoteWeight(
|
||||
communityMint,
|
||||
realm.account.config.communityMintMaxVoteWeightSource
|
||||
realm.account.config.communityMintMaxVoteWeightSource,
|
||||
)
|
||||
|
||||
const minimumYesVotes =
|
||||
|
@ -35,7 +35,7 @@ const QuorumProgress = ({ governance, proposal, communityMint }: Props) => {
|
|||
|
||||
const yesVoteCount = fmtTokenAmount(
|
||||
new BN(proposal.account.getYesVoteCount().toString()),
|
||||
communityMint.decimals
|
||||
communityMint.decimals,
|
||||
)
|
||||
|
||||
const rawYesVotesRequired = minimumYesVotes - yesVoteCount
|
||||
|
|
|
@ -15,11 +15,11 @@ const VoteResults = ({ proposal, communityMint }: VoteResultsProps) => {
|
|||
|
||||
const yesVoteCount = fmtTokenAmount(
|
||||
proposal.getYesVoteCount() as BN,
|
||||
communityMint.decimals
|
||||
communityMint.decimals,
|
||||
)
|
||||
const noVoteCount = fmtTokenAmount(
|
||||
proposal.getNoVoteCount() as BN,
|
||||
communityMint.decimals
|
||||
communityMint.decimals,
|
||||
)
|
||||
const totalVoteCount = yesVoteCount + noVoteCount
|
||||
const getRelativeVoteCount = (voteCount: number) =>
|
||||
|
|
|
@ -23,7 +23,7 @@ export interface LeaderboardRes {
|
|||
type DaysToShow = '1DAY' | '1WEEK' | 'ALLTIME'
|
||||
|
||||
const isLeaderboard = (
|
||||
response: null | EmptyObject | LeaderboardRes[]
|
||||
response: null | EmptyObject | LeaderboardRes[],
|
||||
): response is LeaderboardRes[] => {
|
||||
if (response && Array.isArray(response)) {
|
||||
return true
|
||||
|
@ -33,10 +33,10 @@ const isLeaderboard = (
|
|||
|
||||
const fetchLeaderboard = async (
|
||||
daysToShow: DaysToShow,
|
||||
offset = 0
|
||||
offset = 0,
|
||||
): Promise<Array<LeaderboardRes>> => {
|
||||
const data = await fetch(
|
||||
`${MANGO_DATA_API_URL}/leaderboard-pnl?over_period=${daysToShow}&offset=${offset}`
|
||||
`${MANGO_DATA_API_URL}/leaderboard-pnl?over_period=${daysToShow}&offset=${offset}`,
|
||||
)
|
||||
const parsedData: null | EmptyObject | LeaderboardRes[] = await data.json()
|
||||
|
||||
|
@ -63,7 +63,7 @@ const LeaderboardPage = () => {
|
|||
refetchOnWindowFocus: false,
|
||||
keepPreviousData: true,
|
||||
getNextPageParam: (_lastPage, pages) => pages.length * 20,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const leaderboardData = useMemo(() => {
|
||||
|
|
|
@ -27,11 +27,11 @@ const CloseAccountModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
const mangoAccount = mangoStore((s) => s.mangoAccount)
|
||||
const perpPositions = mangoStore((s) => s.mangoAccount.perpPositions)
|
||||
const openPerpPositions = Object.values(perpPositions).filter((p) =>
|
||||
p.basePositionLots.toNumber()
|
||||
p.basePositionLots.toNumber(),
|
||||
)
|
||||
const group = mangoStore.getState().group
|
||||
const unsettledBalances = Object.values(mangoAccount.spotBalances).filter(
|
||||
(x) => x.unsettled && x.unsettled > 0
|
||||
(x) => x.unsettled && x.unsettled > 0,
|
||||
)
|
||||
const unsettledPerpPositions = useUnsettledPerpPositions()
|
||||
const [hasBorrows, setHasBorrows] = useState(false)
|
||||
|
@ -49,7 +49,7 @@ const CloseAccountModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
const tx = await client.emptyAndCloseMangoAccount(group, mangoAccount)
|
||||
if (tx) {
|
||||
const newMangoAccounts = mangoAccounts.filter(
|
||||
(ma) => !ma.publicKey.equals(mangoAccount.publicKey)
|
||||
(ma) => !ma.publicKey.equals(mangoAccount.publicKey),
|
||||
)
|
||||
let newCurrentAccount: MangoAccount
|
||||
if (newMangoAccounts[0]) {
|
||||
|
@ -99,7 +99,7 @@ const CloseAccountModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
.filter((token: TokenPosition) =>
|
||||
token
|
||||
.balance(group.getFirstBankByTokenIndex(token.tokenIndex))
|
||||
.isNeg()
|
||||
.isNeg(),
|
||||
).length
|
||||
) {
|
||||
setHasBorrows(true)
|
||||
|
@ -137,8 +137,8 @@ const CloseAccountModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
mangoAccount && group
|
||||
? formatCurrencyValue(
|
||||
toUiDecimalsForQuote(
|
||||
mangoAccount!.current!.getEquity(group)
|
||||
)
|
||||
mangoAccount!.current!.getEquity(group),
|
||||
),
|
||||
)
|
||||
: 0,
|
||||
})}
|
||||
|
|
|
@ -157,11 +157,11 @@ const CreateOpenbookMarketModal = ({
|
|||
const getMinLamportsToCreateMarket = async () => {
|
||||
const accountsSpace = 84522 + MARKET_STATE_LAYOUT_V2.span
|
||||
const minLamports = await connection.getMinimumBalanceForRentExemption(
|
||||
accountsSpace
|
||||
accountsSpace,
|
||||
)
|
||||
setSolNeededToCreateMarket(
|
||||
Math.round((minLamports / LAMPORTS_PER_SOL + Number.EPSILON) * 100) /
|
||||
100
|
||||
100,
|
||||
)
|
||||
}
|
||||
getMinLamportsToCreateMarket()
|
||||
|
|
|
@ -135,7 +135,7 @@ const CreateSwitchboardOracleModal = ({
|
|||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}),
|
||||
).finish(),
|
||||
},
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ const CreateSwitchboardOracleModal = ({
|
|||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}),
|
||||
).finish(),
|
||||
},
|
||||
],
|
||||
|
|
|
@ -22,7 +22,7 @@ const DelegateModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
const [delegateAddress, setDelegateAddress] = useState(
|
||||
mangoAccount?.delegate?.toString() !== DEFAULT_DELEGATE
|
||||
? mangoAccount!.delegate.toString()
|
||||
: ''
|
||||
: '',
|
||||
)
|
||||
|
||||
const handleDelegateAccount = async (address: string) => {
|
||||
|
@ -44,7 +44,7 @@ const DelegateModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
group,
|
||||
mangoAccount,
|
||||
undefined,
|
||||
delegateAddress ? new PublicKey(address) : undefined
|
||||
delegateAddress ? new PublicKey(address) : undefined,
|
||||
)
|
||||
onClose()
|
||||
notify({
|
||||
|
@ -82,7 +82,7 @@ const DelegateModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
<InlineNotification
|
||||
type="info"
|
||||
desc={`Account is delegated to ${abbreviateAddress(
|
||||
mangoAccount.delegate
|
||||
mangoAccount.delegate,
|
||||
)}`}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -117,11 +117,11 @@ const MangoAccountsListModal = ({
|
|||
acc = mangoAccount
|
||||
}
|
||||
const accountValue = toUiDecimalsForQuote(
|
||||
Number(acc.getEquity(group!))
|
||||
Number(acc.getEquity(group!)),
|
||||
).toFixed(2)
|
||||
const maintHealth = acc.getHealthRatioUi(
|
||||
group!,
|
||||
HealthType.maint
|
||||
HealthType.maint,
|
||||
)
|
||||
return (
|
||||
<div
|
||||
|
@ -207,7 +207,7 @@ const MangoAccountsListModal = ({
|
|||
acc,
|
||||
t('copy-address-success', {
|
||||
pk: abbreviateAddress(acc.publicKey),
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
hideBg
|
||||
|
|
|
@ -51,12 +51,12 @@ const ModifyTvOrderModal = ({
|
|||
const { t } = useTranslation(['common', 'trade'])
|
||||
const [modifiedOrderPrice, setModifiedOrderPrice] = useState(price)
|
||||
const [modifiedOrderSize, setModifiedOrderSize] = useState(
|
||||
order.size.toString()
|
||||
order.size.toString(),
|
||||
)
|
||||
const { baseSymbol, selectedMarket, serumOrPerpMarket } = useSelectedMarket()
|
||||
const [savedCheckboxSettings] = useLocalStorageState(
|
||||
TRADE_CHECKBOXES_KEY,
|
||||
DEFAULT_CHECKBOX_SETTINGS
|
||||
DEFAULT_CHECKBOX_SETTINGS,
|
||||
)
|
||||
|
||||
const tickDecimals = useMemo(() => {
|
||||
|
@ -99,13 +99,13 @@ const ModifyTvOrderModal = ({
|
|||
Date.now(),
|
||||
PerpOrderType.limit,
|
||||
undefined,
|
||||
undefined
|
||||
undefined,
|
||||
)
|
||||
} else {
|
||||
const marketPk = findSerum3MarketPkInOpenOrders(o)
|
||||
if (!marketPk) return
|
||||
const market = group.getSerum3MarketByExternalMarket(
|
||||
new PublicKey(marketPk)
|
||||
new PublicKey(marketPk),
|
||||
)
|
||||
tx = await client.modifySerum3Order(
|
||||
group,
|
||||
|
@ -118,7 +118,7 @@ const ModifyTvOrderModal = ({
|
|||
Serum3SelfTradeBehavior.decrementTake,
|
||||
Serum3OrderType.limit,
|
||||
Date.now(),
|
||||
10
|
||||
10,
|
||||
)
|
||||
}
|
||||
actions.fetchOpenOrders()
|
||||
|
@ -139,7 +139,7 @@ const ModifyTvOrderModal = ({
|
|||
})
|
||||
}
|
||||
},
|
||||
[findSerum3MarketPkInOpenOrders, modifiedOrderPrice, modifiedOrderSize]
|
||||
[findSerum3MarketPkInOpenOrders, modifiedOrderPrice, modifiedOrderSize],
|
||||
)
|
||||
|
||||
return selectedMarket ? (
|
||||
|
|
|
@ -129,7 +129,7 @@ const SharePositionModal = ({
|
|||
<p className="ml-2 font-mono text-base text-white">
|
||||
{formatNumericValue(
|
||||
entryPrice,
|
||||
getDecimalCount(market.tickSize)
|
||||
getDecimalCount(market.tickSize),
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -140,7 +140,7 @@ const SharePositionModal = ({
|
|||
<p className="ml-2 font-mono text-base text-white">
|
||||
{formatNumericValue(
|
||||
market.uiPrice,
|
||||
getDecimalCount(market.tickSize)
|
||||
getDecimalCount(market.tickSize),
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -26,11 +26,11 @@ const TradeVolumeAlertModal = ({ isOpen, onClose }: ModalProps) => {
|
|||
const { t } = useTranslation(['common', 'trade'])
|
||||
const [soundSettings, setSoundSettings] = useLocalStorageState(
|
||||
SOUND_SETTINGS_KEY,
|
||||
INITIAL_SOUND_SETTINGS
|
||||
INITIAL_SOUND_SETTINGS,
|
||||
)
|
||||
const [alertSettings, setAlertSettings] = useLocalStorageState(
|
||||
TRADE_VOLUME_ALERT_KEY,
|
||||
DEFAULT_VOLUME_ALERT_SETTINGS
|
||||
DEFAULT_VOLUME_ALERT_SETTINGS,
|
||||
)
|
||||
const [formValues, setFormValues] = useState(alertSettings)
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ const UserSetupModal = ({
|
|||
const banks = useBanksWithBalances('walletBalance')
|
||||
const [, setAcceptTerms] = useLocalStorageState(ACCEPT_TERMS_KEY, '')
|
||||
const [walletsToDisplay, setWalletstoDisplay] = useState<'default' | 'all'>(
|
||||
'default'
|
||||
'default',
|
||||
)
|
||||
|
||||
const walletsDisplayed = useMemo(() => {
|
||||
|
@ -78,7 +78,7 @@ const UserSetupModal = ({
|
|||
const detectedWallets = wallets.filter(
|
||||
(w) =>
|
||||
w.readyState === WalletReadyState.Installed ||
|
||||
w.readyState === WalletReadyState.Loadable
|
||||
w.readyState === WalletReadyState.Loadable,
|
||||
)
|
||||
|
||||
if (walletsToDisplay === 'default') {
|
||||
|
@ -107,7 +107,7 @@ const UserSetupModal = ({
|
|||
group,
|
||||
0,
|
||||
accountName || 'Account 1',
|
||||
16 // tokenCount
|
||||
16, // tokenCount
|
||||
)
|
||||
actions.fetchMangoAccounts(publicKey)
|
||||
if (tx) {
|
||||
|
@ -147,7 +147,7 @@ const UserSetupModal = ({
|
|||
group,
|
||||
mangoAccount,
|
||||
bank.mint,
|
||||
parseFloat(depositAmount)
|
||||
parseFloat(depositAmount),
|
||||
)
|
||||
notify({
|
||||
title: 'Transaction confirmed',
|
||||
|
@ -197,7 +197,7 @@ const UserSetupModal = ({
|
|||
const setMax = useCallback(() => {
|
||||
const max = new Decimal(tokenMax.amount).toDecimalPlaces(
|
||||
tokenMax.decimals,
|
||||
Decimal.ROUND_FLOOR
|
||||
Decimal.ROUND_FLOOR,
|
||||
)
|
||||
setDepositAmount(max.toString())
|
||||
setSizePercentage('100')
|
||||
|
@ -212,7 +212,7 @@ const UserSetupModal = ({
|
|||
.toDecimalPlaces(tokenMax.decimals, Decimal.ROUND_FLOOR)
|
||||
setDepositAmount(amount.toString())
|
||||
},
|
||||
[tokenMax]
|
||||
[tokenMax],
|
||||
)
|
||||
|
||||
const handleNextStep = () => {
|
||||
|
@ -456,7 +456,7 @@ const UserSetupModal = ({
|
|||
value={depositAmount}
|
||||
onValueChange={(e: NumberFormatValues) => {
|
||||
setDepositAmount(
|
||||
!Number.isNaN(Number(e.value)) ? e.value : ''
|
||||
!Number.isNaN(Number(e.value)) ? e.value : '',
|
||||
)
|
||||
}}
|
||||
isAllowed={withValueLimit}
|
||||
|
|
|
@ -22,7 +22,7 @@ import { notify } from 'utils/notifications'
|
|||
|
||||
export const createSolanaMessage = (
|
||||
wallet: WalletContextState,
|
||||
setCookie: (wallet: string, token: string) => void
|
||||
setCookie: (wallet: string, token: string) => void,
|
||||
) => {
|
||||
const payload = new Payload()
|
||||
payload.domain = window.location.host
|
||||
|
@ -121,7 +121,7 @@ const NotificationsDrawer = ({
|
|||
})
|
||||
}
|
||||
},
|
||||
[NOTIFICATION_API, headers]
|
||||
[NOTIFICATION_API, headers],
|
||||
)
|
||||
|
||||
const remove = useCallback(
|
||||
|
@ -136,7 +136,7 @@ const NotificationsDrawer = ({
|
|||
body: JSON.stringify({
|
||||
ids: ids,
|
||||
}),
|
||||
}
|
||||
},
|
||||
)
|
||||
const body = await resp.json()
|
||||
const error = body.error
|
||||
|
@ -158,7 +158,7 @@ const NotificationsDrawer = ({
|
|||
}
|
||||
setIsRemoving(false)
|
||||
},
|
||||
[NOTIFICATION_API, headers]
|
||||
[NOTIFICATION_API, headers],
|
||||
)
|
||||
|
||||
// Mark all notifications as seen when the inbox is opened
|
||||
|
@ -241,7 +241,7 @@ const NotificationsDrawer = ({
|
|||
<CalendarIcon className="mr-1 h-3.5 w-3.5" />
|
||||
<p className="text-xs">
|
||||
{dayjs(notification.createdAt).format(
|
||||
'DD MMM YYYY, h:mma'
|
||||
'DD MMM YYYY, h:mma',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -39,7 +39,7 @@ const TransactionNotificationList = () => {
|
|||
const notEnoughSoLMessage = t('deposit-more-sol')
|
||||
const [notificationPosition] = useLocalStorageState(
|
||||
NOTIFICATION_POSITION_KEY,
|
||||
'bottom-left'
|
||||
'bottom-left',
|
||||
)
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const { maxSolDeposit } = useSolBalance()
|
||||
|
@ -49,10 +49,10 @@ const TransactionNotificationList = () => {
|
|||
useEffect(() => {
|
||||
if (transactionNotifications.length) {
|
||||
const customErrorNotification = transactionNotifications.find(
|
||||
(n) => n.description && n.description.includes('"Custom":1')
|
||||
(n) => n.description && n.description.includes('"Custom":1'),
|
||||
)
|
||||
const notEnoughSolNotification = transactionNotifications.find(
|
||||
(n) => n.title && n.title.includes(notEnoughSoLMessage)
|
||||
(n) => n.title && n.title.includes(notEnoughSoLMessage),
|
||||
)
|
||||
|
||||
if (
|
||||
|
@ -125,11 +125,11 @@ const TransactionNotification = ({
|
|||
}) => {
|
||||
const [notificationPosition] = useLocalStorageState(
|
||||
NOTIFICATION_POSITION_KEY,
|
||||
'Bottom-Left'
|
||||
'Bottom-Left',
|
||||
)
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0]
|
||||
EXPLORERS[0],
|
||||
)
|
||||
const { type, title, description, txid, show, id } = notification
|
||||
|
||||
|
@ -151,7 +151,7 @@ const TransactionNotification = ({
|
|||
if ((type === 'error' || type === 'success') && txid) {
|
||||
setMangoStore((s) => {
|
||||
const newNotifications = s.transactionNotifications.map((n) =>
|
||||
n.txid === txid && n.type === 'confirm' ? { ...n, show: false } : n
|
||||
n.txid === txid && n.type === 'confirm' ? { ...n, show: false } : n,
|
||||
)
|
||||
s.transactionNotifications = newNotifications
|
||||
})
|
||||
|
@ -161,7 +161,7 @@ const TransactionNotification = ({
|
|||
const hideNotification = useCallback(() => {
|
||||
setMangoStore((s) => {
|
||||
const newNotifications = s.transactionNotifications.map((n) =>
|
||||
n.id === id ? { ...n, show: false } : n
|
||||
n.id === id ? { ...n, show: false } : n,
|
||||
)
|
||||
s.transactionNotifications = newNotifications
|
||||
})
|
||||
|
|
|
@ -73,7 +73,7 @@ const EditNftProfilePic = ({ onClose }: { onClose: () => void }) => {
|
|||
}
|
||||
const response = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/profile-details`,
|
||||
requestOptions
|
||||
requestOptions,
|
||||
)
|
||||
if (response.status === 200) {
|
||||
await actions.fetchProfileDetails(publicKey.toString())
|
||||
|
@ -119,7 +119,7 @@ const EditNftProfilePic = ({ onClose }: { onClose: () => void }) => {
|
|||
}
|
||||
const response = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/profile-details`,
|
||||
requestOptions
|
||||
requestOptions,
|
||||
)
|
||||
if (response.status === 200) {
|
||||
await actions.fetchProfileDetails(publicKey.toString())
|
||||
|
|
|
@ -31,7 +31,7 @@ const EditProfileForm = ({
|
|||
const profile = mangoStore((s) => s.profile.details)
|
||||
const { publicKey, signMessage } = useWallet()
|
||||
const [profileName, setProfileName] = useState(
|
||||
startCase(profile?.profile_name) || ''
|
||||
startCase(profile?.profile_name) || '',
|
||||
)
|
||||
const [inputError, setInputError] = useState('')
|
||||
const [loadUniquenessCheck, setLoadUniquenessCheck] = useState(false)
|
||||
|
@ -43,7 +43,7 @@ const EditProfileForm = ({
|
|||
try {
|
||||
setLoadUniquenessCheck(true)
|
||||
const response = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/check-profile-name-unique?profile-name=${name}`
|
||||
`${MANGO_DATA_API_URL}/user-data/check-profile-name-unique?profile-name=${name}`,
|
||||
)
|
||||
const uniquenessCheck = await response.json()
|
||||
|
||||
|
@ -105,7 +105,7 @@ const EditProfileForm = ({
|
|||
}
|
||||
const response = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/profile-details`,
|
||||
requestOptions
|
||||
requestOptions,
|
||||
)
|
||||
if (response.status === 200) {
|
||||
setLoadUpdateProfile(false)
|
||||
|
|
|
@ -54,7 +54,7 @@ const Leaderboards = ({
|
|||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const isLoading =
|
||||
|
@ -96,7 +96,7 @@ const Leaderboards = ({
|
|||
rewardsLeaderboardData.map(
|
||||
(wallet: RewardsLeaderboardItem, i: number) => (
|
||||
<LeaderboardCard rank={i + 1} key={i} wallet={wallet} />
|
||||
)
|
||||
),
|
||||
)
|
||||
) : (
|
||||
<div className="flex justify-center rounded-lg border border-th-bkg-3 p-8">
|
||||
|
|
|
@ -66,7 +66,7 @@ export const tiers = ['seed', 'mango', 'whale', 'bot']
|
|||
const fetchRewardsPoints = async (walletPk: string | undefined) => {
|
||||
try {
|
||||
const data = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/campaign-total-points-wallet?wallet-pk=${walletPk}`
|
||||
`${MANGO_DATA_API_URL}/user-data/campaign-total-points-wallet?wallet-pk=${walletPk}`,
|
||||
)
|
||||
const res = await data.json()
|
||||
return res
|
||||
|
@ -78,7 +78,7 @@ const fetchRewardsPoints = async (walletPk: string | undefined) => {
|
|||
export const fetchLeaderboard = async (tier: string | undefined) => {
|
||||
try {
|
||||
const data = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/campaign-leaderboard?tier=${tier}`
|
||||
`${MANGO_DATA_API_URL}/user-data/campaign-leaderboard?tier=${tier}`,
|
||||
)
|
||||
const res = await data.json()
|
||||
return res
|
||||
|
@ -195,7 +195,7 @@ const Season = ({
|
|||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!wallet?.adapter,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const {
|
||||
|
@ -210,7 +210,7 @@ const Season = ({
|
|||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -41,7 +41,7 @@ const SearchPage = () => {
|
|||
try {
|
||||
setLoading(true)
|
||||
const response = await fetch(
|
||||
`${MANGO_DATA_API_URL}/user-data/profile-search?search-string=${searchString}&search-method=${searchType}`
|
||||
`${MANGO_DATA_API_URL}/user-data/profile-search?search-string=${searchString}&search-method=${searchType}`,
|
||||
)
|
||||
const data = await response.json()
|
||||
setSearchResults(data)
|
||||
|
@ -115,7 +115,7 @@ const SearchPage = () => {
|
|||
<MangoAccountItem item={r} type={searchType} />
|
||||
) : (
|
||||
<WalletItem item={r} />
|
||||
)
|
||||
),
|
||||
)
|
||||
) : showNoResults ? (
|
||||
<div className="flex flex-col items-center rounded-md border border-th-bkg-3 p-4">
|
||||
|
|
|
@ -13,7 +13,7 @@ const AnimationSettings = () => {
|
|||
const { t } = useTranslation(['common', 'settings'])
|
||||
const [animationSettings, setAnimationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
|
||||
const handleToggleAnimationSetting = (settingName: string) => {
|
||||
|
|
|
@ -63,21 +63,21 @@ const DisplaySettings = () => {
|
|||
const { theme, setTheme } = useTheme()
|
||||
const [savedLanguage, setSavedLanguage] = useLocalStorageState(
|
||||
'language',
|
||||
'en'
|
||||
'en',
|
||||
)
|
||||
const router = useRouter()
|
||||
const { pathname, asPath, query } = router
|
||||
const [notificationPosition, setNotificationPosition] = useLocalStorageState(
|
||||
NOTIFICATION_POSITION_KEY,
|
||||
'bottom-left'
|
||||
'bottom-left',
|
||||
)
|
||||
const [tradeFormUi, setTradeFormUi] = useLocalStorageState(
|
||||
SIZE_INPUT_UI_KEY,
|
||||
'slider'
|
||||
'slider',
|
||||
)
|
||||
const [tradeChartUi, setTradeChartUi] = useLocalStorageState(
|
||||
TRADE_CHART_UI_KEY,
|
||||
'trading-view'
|
||||
'trading-view',
|
||||
)
|
||||
const [, setTradeLayout] = useLocalStorageState(TRADE_LAYOUT_KEY, 'chartLeft')
|
||||
|
||||
|
@ -87,7 +87,7 @@ const DisplaySettings = () => {
|
|||
router.push({ pathname, query }, asPath, { locale: l })
|
||||
dayjs.locale(l == 'zh_tw' ? 'zh-tw' : l)
|
||||
},
|
||||
[router, pathname, query, asPath, setSavedLanguage]
|
||||
[router, pathname, query, asPath, setSavedLanguage],
|
||||
)
|
||||
|
||||
return (
|
||||
|
|
|
@ -120,7 +120,7 @@ const HotKeysSettings = () => {
|
|||
{Object.entries(options).map((e) => {
|
||||
return e[1]
|
||||
? `${e[0] !== 'margin' ? ', ' : ''}${t(
|
||||
`trade:${e[0]}`
|
||||
`trade:${e[0]}`,
|
||||
)}`
|
||||
: ''
|
||||
})}
|
||||
|
|
|
@ -49,7 +49,7 @@ const NotificationSettings = () => {
|
|||
onChange={() =>
|
||||
handleSettingChange(
|
||||
'fillsNotifications',
|
||||
!data?.fillsNotifications
|
||||
!data?.fillsNotifications,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -15,7 +15,7 @@ const PreferredExplorerSettings = () => {
|
|||
const { t } = useTranslation('settings')
|
||||
const [preferredExplorer, setPreferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0]
|
||||
EXPLORERS[0],
|
||||
)
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -50,11 +50,11 @@ const RpcSettings = () => {
|
|||
const [showCustomForm, setShowCustomForm] = useState(false)
|
||||
const [rpcEndpointProvider, setRpcEndpointProvider] = useLocalStorageState(
|
||||
RPC_PROVIDER_KEY,
|
||||
RPC_URLS[0].value
|
||||
RPC_URLS[0].value,
|
||||
)
|
||||
const [storedPriorityFee, setStoredPriorityFee] = useLocalStorageState(
|
||||
PRIORITY_FEE_KEY,
|
||||
DEFAULT_PRIORITY_FEE.value
|
||||
DEFAULT_PRIORITY_FEE.value,
|
||||
)
|
||||
const [storedUseOrderbookFeed, setStoredUseOrderbookFeed] =
|
||||
useLocalStorageState(USE_ORDERBOOK_FEED_KEY, true)
|
||||
|
@ -77,7 +77,7 @@ const RpcSettings = () => {
|
|||
|
||||
const handleSetEndpointProvider = (provider: string) => {
|
||||
const endpointProvider = RPC_URLS.find(
|
||||
(node) => node.label === provider
|
||||
(node) => node.label === provider,
|
||||
) || { label: 'Custom', value: rpcEndpointProvider }
|
||||
setRpcEndpointProvider(endpointProvider.value)
|
||||
if (provider !== 'Custom') {
|
||||
|
@ -96,7 +96,7 @@ const RpcSettings = () => {
|
|||
}
|
||||
}
|
||||
},
|
||||
[setStoredPriorityFee, actions, wallet]
|
||||
[setStoredPriorityFee, actions, wallet],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -14,7 +14,7 @@ const SoundSettings = () => {
|
|||
const { t } = useTranslation(['common', 'settings'])
|
||||
const [soundSettings, setSoundSettings] = useLocalStorageState(
|
||||
SOUND_SETTINGS_KEY,
|
||||
INITIAL_SOUND_SETTINGS
|
||||
INITIAL_SOUND_SETTINGS,
|
||||
)
|
||||
|
||||
const handleToggleSoundSetting = (settingName: string) => {
|
||||
|
|
|
@ -293,7 +293,7 @@ const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
|||
let tickDecimals: number
|
||||
if (selectedMarket instanceof Serum3Market) {
|
||||
const market = group.getSerum3ExternalMarket(
|
||||
selectedMarket.serumMarketExternal
|
||||
selectedMarket.serumMarketExternal,
|
||||
)
|
||||
minOrderDecimals = getDecimalCount(market.minOrderSize)
|
||||
tickDecimals = getDecimalCount(market.tickSize)
|
||||
|
@ -306,7 +306,7 @@ const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
|||
const floorBalance = floorToDecimal(balance, tickDecimals).toNumber()
|
||||
const baseSize = floorToDecimal(
|
||||
floorBalance / price,
|
||||
minOrderDecimals
|
||||
minOrderDecimals,
|
||||
).toNumber()
|
||||
const quoteSize = floorToDecimal(baseSize * price, tickDecimals)
|
||||
set((s) => {
|
||||
|
@ -322,7 +322,7 @@ const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
|||
})
|
||||
}
|
||||
},
|
||||
[selectedMarket]
|
||||
[selectedMarket],
|
||||
)
|
||||
|
||||
const handleSwapFormBalanceClick = useCallback(
|
||||
|
@ -356,7 +356,7 @@ const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
|||
})
|
||||
}
|
||||
},
|
||||
[bank]
|
||||
[bank],
|
||||
)
|
||||
|
||||
const balance = bank.balance
|
||||
|
@ -393,7 +393,7 @@ const Balance = ({ bank }: { bank: BankWithBalance }) => {
|
|||
className="font-normal underline underline-offset-2 md:underline-offset-4 md:hover:no-underline"
|
||||
onClick={() =>
|
||||
handleSwapFormBalanceClick(
|
||||
Number(floorToDecimal(balance, tokenBank.mintDecimals))
|
||||
Number(floorToDecimal(balance, tokenBank.mintDecimals)),
|
||||
)
|
||||
}
|
||||
>
|
||||
|
|
|
@ -100,7 +100,7 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
const { theme } = useTheme()
|
||||
const [animationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
|
||||
const handleMouseMove = (coords: any) => {
|
||||
|
@ -134,7 +134,7 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
if (filteredData.length) {
|
||||
if (mouseData) {
|
||||
const index = filteredData.findIndex(
|
||||
(d: any) => d[xKey] === mouseData[xKey]
|
||||
(d: any) => d[xKey] === mouseData[xKey],
|
||||
)
|
||||
const change =
|
||||
index >= 0 ? filteredData[index][yKey] - filteredData[0][yKey] : 0
|
||||
|
@ -216,7 +216,7 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
mouseData[yKey] < 0 ? '-' : ''
|
||||
}${prefix}${formatNumericValue(
|
||||
Math.abs(mouseData[yKey]),
|
||||
yDecimals
|
||||
yDecimals,
|
||||
)}${suffix}`}
|
||||
/>
|
||||
) : (
|
||||
|
@ -249,7 +249,7 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
{dayjs(mouseData[xKey]).format(
|
||||
tooltipDateFormat
|
||||
? tooltipDateFormat
|
||||
: 'DD MMM YY, h:mma'
|
||||
: 'DD MMM YY, h:mma',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -273,9 +273,9 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
: ''
|
||||
}${prefix}${formatNumericValue(
|
||||
Math.abs(
|
||||
filteredData[filteredData.length - 1][yKey]
|
||||
filteredData[filteredData.length - 1][yKey],
|
||||
),
|
||||
yDecimals
|
||||
yDecimals,
|
||||
)}${suffix}`}
|
||||
/>
|
||||
) : (
|
||||
|
@ -308,11 +308,11 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
} text-th-fgd-4`}
|
||||
>
|
||||
{dayjs(
|
||||
filteredData[filteredData.length - 1][xKey]
|
||||
filteredData[filteredData.length - 1][xKey],
|
||||
).format(
|
||||
tooltipDateFormat
|
||||
? tooltipDateFormat
|
||||
: 'DD MMM YY, h:mma'
|
||||
: 'DD MMM YY, h:mma',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -341,7 +341,7 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
<linearGradient
|
||||
id={`gradientArea-${title?.replace(
|
||||
/[^a-zA-Z]/g,
|
||||
''
|
||||
'',
|
||||
)}`}
|
||||
x1="0"
|
||||
y1={flipGradientCoords ? '1' : '0'}
|
||||
|
@ -380,7 +380,7 @@ const DetailedAreaOrBarChart: FunctionComponent<
|
|||
strokeWidth={1.5}
|
||||
fill={`url(#gradientArea-${title?.replace(
|
||||
/[^a-zA-Z]/g,
|
||||
''
|
||||
'',
|
||||
)})`}
|
||||
/>
|
||||
<XAxis
|
||||
|
|
|
@ -11,7 +11,7 @@ const FavoriteMarketButton = ({
|
|||
}) => {
|
||||
const [favoriteMarkets, setFavoriteMarkets] = useLocalStorageState<string[]>(
|
||||
FAVORITE_MARKETS_KEY,
|
||||
[]
|
||||
[],
|
||||
)
|
||||
|
||||
const addToFavorites = (marketName: string) => {
|
||||
|
@ -24,7 +24,7 @@ const FavoriteMarketButton = ({
|
|||
}
|
||||
|
||||
return favoriteMarkets.find(
|
||||
(marketName: string) => marketName === market.name
|
||||
(marketName: string) => marketName === market.name,
|
||||
) ? (
|
||||
<button
|
||||
className="flex items-center justify-center text-th-active focus-visible:text-th-fgd-4 md:hover:text-th-fgd-3"
|
||||
|
|
|
@ -15,7 +15,7 @@ const SuccessParticles = () => {
|
|||
const set = mangoStore((s) => s.set)
|
||||
const [animationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
|
||||
const tokenLogo = useMemo(() => {
|
||||
|
@ -70,7 +70,7 @@ const SuccessParticles = () => {
|
|||
set((s) => {
|
||||
s.successAnimation.swap = false
|
||||
}),
|
||||
8000
|
||||
8000,
|
||||
)
|
||||
}
|
||||
if (showForTrade) {
|
||||
|
@ -79,7 +79,7 @@ const SuccessParticles = () => {
|
|||
set((s) => {
|
||||
s.successAnimation.trade = false
|
||||
}),
|
||||
8000
|
||||
8000,
|
||||
)
|
||||
}
|
||||
}, [showForSwap, showForTrade])
|
||||
|
|
|
@ -62,7 +62,7 @@ export const TrBody = forwardRef<HTMLTableRowElement, TrBodyProps>(
|
|||
{children}
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
TrBody.displayName = 'TrBody'
|
||||
|
|
|
@ -22,7 +22,7 @@ const TokenLogo = ({
|
|||
let jupiterLogoURI
|
||||
if (mangoTokens?.length) {
|
||||
jupiterLogoURI = mangoTokens.find(
|
||||
(t) => t.address === bank?.mint.toString()
|
||||
(t) => t.address === bank?.mint.toString(),
|
||||
)?.logoURI
|
||||
}
|
||||
return jupiterLogoURI
|
||||
|
|
|
@ -26,7 +26,7 @@ const TokenVaultWarnings = ({
|
|||
const maxWithdraw = getMaxWithdrawForBank(group, bank, mangoAccount)
|
||||
const maxBorrow = mangoAccount.getMaxWithdrawWithBorrowForTokenUi(
|
||||
group,
|
||||
bank.mint
|
||||
bank.mint,
|
||||
)
|
||||
|
||||
return [maxWithdraw, maxBorrow]
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
|
|||
|
||||
export default function useDebounce<T>(
|
||||
value: T,
|
||||
delay: number
|
||||
delay: number,
|
||||
): [T, (value: T) => void] {
|
||||
// State and setters for debounced value
|
||||
const [debouncedValue, setDebouncedValue] = useState(value)
|
||||
|
@ -19,7 +19,7 @@ export default function useDebounce<T>(
|
|||
clearTimeout(handler)
|
||||
}
|
||||
},
|
||||
[value, delay] // Only re-call effect if value or delay changes
|
||||
[value, delay], // Only re-call effect if value or delay changes
|
||||
)
|
||||
return [debouncedValue, setDebouncedValue]
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { useRef, useEffect } from 'react'
|
|||
export default function useInterval(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
callback: (...args: any[]) => any,
|
||||
delay: number
|
||||
delay: number,
|
||||
) {
|
||||
const savedCallback = useRef<() => void>()
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ const AverageFundingChart = ({
|
|||
|
||||
const groupByHourlyInterval = (
|
||||
data: PerpStatsItem[],
|
||||
intervalDurationHours: number
|
||||
intervalDurationHours: number,
|
||||
) => {
|
||||
const intervalMillis = intervalDurationHours * 60 * 60 * 1000
|
||||
const groupedData = []
|
||||
|
|
|
@ -39,15 +39,15 @@ const MangoPerpStatsCharts = () => {
|
|||
const data = perpStats.reduce(
|
||||
(a: PerpStatsData, c: PerpStatsItem) => {
|
||||
const hasDateFee = a.feeValues.find(
|
||||
(d: FeeValueItem) => d.date === c.date_hour
|
||||
(d: FeeValueItem) => d.date === c.date_hour,
|
||||
)
|
||||
|
||||
const hasDateOpenInterest = a.openInterestValues.find(
|
||||
(d: OiValueItem) => d.date === c.date_hour
|
||||
(d: OiValueItem) => d.date === c.date_hour,
|
||||
)
|
||||
|
||||
const hasDateVolume = a.volumeValues.find(
|
||||
(d: VolumeValueItem) => d.date === c.date_hour
|
||||
(d: VolumeValueItem) => d.date === c.date_hour,
|
||||
)
|
||||
|
||||
if (!hasDateFee) {
|
||||
|
@ -66,7 +66,7 @@ const MangoPerpStatsCharts = () => {
|
|||
})
|
||||
} else {
|
||||
hasDateOpenInterest.openInterest += Math.floor(
|
||||
c.open_interest * c.price
|
||||
c.open_interest * c.price,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -81,19 +81,19 @@ const MangoPerpStatsCharts = () => {
|
|||
|
||||
return a
|
||||
},
|
||||
{ feeValues: [], openInterestValues: [], volumeValues: [] }
|
||||
{ feeValues: [], openInterestValues: [], volumeValues: [] },
|
||||
)
|
||||
|
||||
const { feeValues, openInterestValues, volumeValues } = data
|
||||
|
||||
const sortedFeeValues = feeValues.sort(
|
||||
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()
|
||||
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime(),
|
||||
)
|
||||
const sortedOpenInterestValues = openInterestValues.sort(
|
||||
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()
|
||||
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime(),
|
||||
)
|
||||
const sortedVolumeValues = volumeValues.sort(
|
||||
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()
|
||||
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime(),
|
||||
)
|
||||
|
||||
return [sortedFeeValues, sortedOpenInterestValues, sortedVolumeValues]
|
||||
|
|
|
@ -28,7 +28,7 @@ import { DAILY_SECONDS } from 'utils/constants'
|
|||
|
||||
export const getOneDayPerpStats = (
|
||||
stats: PerpStatsItem[] | null,
|
||||
marketName: string
|
||||
marketName: string,
|
||||
) => {
|
||||
return stats
|
||||
? stats
|
||||
|
@ -46,7 +46,7 @@ export const getOneDayPerpStats = (
|
|||
|
||||
export const goToPerpMarketDetails = (
|
||||
market: PerpMarket,
|
||||
router: NextRouter
|
||||
router: NextRouter,
|
||||
) => {
|
||||
const query = { ...router.query, ['market']: market.name }
|
||||
router.push({ pathname: router.pathname, query })
|
||||
|
@ -107,14 +107,14 @@ const PerpMarketsOverviewTable = () => {
|
|||
let fundingRateApr
|
||||
if (rate.isSuccess) {
|
||||
const marketRate = rate?.data?.find(
|
||||
(r) => r.market_index === market.perpMarketIndex
|
||||
(r) => r.market_index === market.perpMarketIndex,
|
||||
)
|
||||
if (marketRate) {
|
||||
fundingRate = formatFunding.format(
|
||||
marketRate.funding_rate_hourly
|
||||
marketRate.funding_rate_hourly,
|
||||
)
|
||||
fundingRateApr = formatFunding.format(
|
||||
marketRate.funding_rate_hourly * 8760
|
||||
marketRate.funding_rate_hourly * 8760,
|
||||
)
|
||||
} else {
|
||||
fundingRate = '–'
|
||||
|
@ -190,9 +190,9 @@ const PerpMarketsOverviewTable = () => {
|
|||
<FormatNumericValue
|
||||
value={group.toUiPrice(
|
||||
I80F48.fromNumber(
|
||||
market.stablePriceModel.stablePrice
|
||||
market.stablePriceModel.stablePrice,
|
||||
),
|
||||
market.baseDecimals
|
||||
market.baseDecimals,
|
||||
)}
|
||||
isUsd
|
||||
/>
|
||||
|
@ -260,7 +260,7 @@ const PerpMarketsOverviewTable = () => {
|
|||
<p className="text-th-fgd-4">
|
||||
$
|
||||
{numberCompacter.format(
|
||||
openInterest * market.uiPrice
|
||||
openInterest * market.uiPrice,
|
||||
)}
|
||||
</p>
|
||||
</>
|
||||
|
@ -328,12 +328,12 @@ const MobilePerpMarketItem = ({ market }: { market: PerpMarket }) => {
|
|||
let fundingRateApr: string
|
||||
if (rate.isSuccess) {
|
||||
const marketRate = rate?.data?.find(
|
||||
(r) => r.market_index === market.perpMarketIndex
|
||||
(r) => r.market_index === market.perpMarketIndex,
|
||||
)
|
||||
if (marketRate) {
|
||||
fundingRate = formatFunding.format(marketRate.funding_rate_hourly)
|
||||
fundingRateApr = formatFunding.format(
|
||||
marketRate.funding_rate_hourly * 8760
|
||||
marketRate.funding_rate_hourly * 8760,
|
||||
)
|
||||
} else {
|
||||
fundingRate = '–'
|
||||
|
|
|
@ -41,7 +41,7 @@ const PerpPositionsStatsTable = ({
|
|||
<tbody>
|
||||
{positions.map(({ account, perpPosition, mangoAccount }, i) => {
|
||||
const market = group.getPerpMarketByMarketIndex(
|
||||
perpPosition.marketIndex
|
||||
perpPosition.marketIndex,
|
||||
)
|
||||
const basePosition = perpPosition.getBasePositionUi(market)
|
||||
|
||||
|
@ -49,7 +49,7 @@ const PerpPositionsStatsTable = ({
|
|||
|
||||
const floorBasePosition = floorToDecimal(
|
||||
basePosition,
|
||||
getDecimalCount(market.minOrderSize)
|
||||
getDecimalCount(market.minOrderSize),
|
||||
).toNumber()
|
||||
|
||||
const isLong = basePosition > 0
|
||||
|
@ -179,7 +179,7 @@ const PerpPositionsStatsTable = ({
|
|||
<div className="border-b border-th-bkg-3">
|
||||
{positions.map(({ account, perpPosition, mangoAccount }) => {
|
||||
const market = group.getPerpMarketByMarketIndex(
|
||||
perpPosition.marketIndex
|
||||
perpPosition.marketIndex,
|
||||
)
|
||||
const basePosition = perpPosition.getBasePositionUi(market)
|
||||
|
||||
|
@ -187,7 +187,7 @@ const PerpPositionsStatsTable = ({
|
|||
|
||||
const floorBasePosition = floorToDecimal(
|
||||
basePosition,
|
||||
getDecimalCount(market.minOrderSize)
|
||||
getDecimalCount(market.minOrderSize),
|
||||
).toNumber()
|
||||
|
||||
const isLong = basePosition > 0
|
||||
|
|
|
@ -40,7 +40,7 @@ const SpotMarketsTable = () => {
|
|||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
return (
|
||||
|
@ -62,30 +62,30 @@ const SpotMarketsTable = () => {
|
|||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((mkt) => {
|
||||
const baseBank = group?.getFirstBankByTokenIndex(
|
||||
mkt.baseTokenIndex
|
||||
mkt.baseTokenIndex,
|
||||
)
|
||||
const quoteBank = group?.getFirstBankByTokenIndex(
|
||||
mkt.quoteTokenIndex
|
||||
mkt.quoteTokenIndex,
|
||||
)
|
||||
const market = group?.getSerum3ExternalMarket(
|
||||
mkt.serumMarketExternal
|
||||
mkt.serumMarketExternal,
|
||||
)
|
||||
let price
|
||||
if (baseBank && market && quoteBank) {
|
||||
price = floorToDecimal(
|
||||
baseBank.uiPrice / quoteBank.uiPrice,
|
||||
getDecimalCount(market.tickSize)
|
||||
getDecimalCount(market.tickSize),
|
||||
).toNumber()
|
||||
}
|
||||
let tickerData: TickerData | undefined
|
||||
if (spotVolumeData && spotVolumeData.length) {
|
||||
tickerData = spotVolumeData.find(
|
||||
(m: TickerData) => m.ticker_id === mkt.name
|
||||
(m: TickerData) => m.ticker_id === mkt.name,
|
||||
)
|
||||
}
|
||||
|
||||
const birdeyeData = birdeyePrices.find(
|
||||
(m) => m.mint === mkt.serumMarketExternal.toString()
|
||||
(m) => m.mint === mkt.serumMarketExternal.toString(),
|
||||
)
|
||||
|
||||
const birdeyeChange =
|
||||
|
@ -163,7 +163,7 @@ const SpotMarketsTable = () => {
|
|||
{tickerData ? (
|
||||
<span>
|
||||
{numberCompacter.format(
|
||||
parseFloat(tickerData.target_volume)
|
||||
parseFloat(tickerData.target_volume),
|
||||
)}{' '}
|
||||
<span className="font-body text-th-fgd-4">
|
||||
{quoteBank?.name}
|
||||
|
@ -222,14 +222,14 @@ const MobileSpotMarketItem = ({
|
|||
if (!baseBank || !quoteBank || !serumMarket) return 0
|
||||
return floorToDecimal(
|
||||
baseBank.uiPrice / quoteBank.uiPrice,
|
||||
getDecimalCount(serumMarket.tickSize)
|
||||
getDecimalCount(serumMarket.tickSize),
|
||||
).toNumber()
|
||||
}, [baseBank, quoteBank, serumMarket])
|
||||
|
||||
const birdeyeData = useMemo(() => {
|
||||
if (!loadingPrices) {
|
||||
return birdeyePrices.find(
|
||||
(m) => m.mint === market.serumMarketExternal.toString()
|
||||
(m) => m.mint === market.serumMarketExternal.toString(),
|
||||
)
|
||||
}
|
||||
return null
|
||||
|
@ -254,7 +254,7 @@ const MobileSpotMarketItem = ({
|
|||
let tickerData: TickerData | undefined
|
||||
if (spotVolumeData && spotVolumeData.length) {
|
||||
tickerData = spotVolumeData.find(
|
||||
(m: TickerData) => m.ticker_id === market.name
|
||||
(m: TickerData) => m.ticker_id === market.name,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ const MobileSpotMarketItem = ({
|
|||
{tickerData ? (
|
||||
<span>
|
||||
{numberCompacter.format(
|
||||
parseFloat(tickerData.target_volume)
|
||||
parseFloat(tickerData.target_volume),
|
||||
)}{' '}
|
||||
<span className="font-body text-th-fgd-4">
|
||||
{quoteBank?.name}
|
||||
|
|
|
@ -19,7 +19,7 @@ const StatsPage = () => {
|
|||
const actions = mangoStore.getState().actions
|
||||
const perpStats = mangoStore((s) => s.perpStats.data)
|
||||
const perpPositionsStatsNotLoaded = mangoStore(
|
||||
(s) => s.perpStats.positions.initialLoad
|
||||
(s) => s.perpStats.positions.initialLoad,
|
||||
)
|
||||
const { group } = useMangoGroup()
|
||||
const { width } = useViewport()
|
||||
|
|
|
@ -98,7 +98,7 @@ const TokenDetailsTable = () => {
|
|||
const [oracleProvider, oracleLinkPath] = getOracleProvider(bank)
|
||||
|
||||
const mintInfo = group.mintInfosMapByMint.get(
|
||||
bank.mint.toString()
|
||||
bank.mint.toString(),
|
||||
)
|
||||
|
||||
return (
|
||||
|
@ -131,7 +131,7 @@ const TokenDetailsTable = () => {
|
|||
<Td>
|
||||
<p className="text-right">
|
||||
{(100 * bank.loanOriginationFeeRate.toNumber()).toFixed(
|
||||
2
|
||||
2,
|
||||
)}
|
||||
%
|
||||
</p>
|
||||
|
@ -262,7 +262,7 @@ const TokenDetailsTable = () => {
|
|||
</Tooltip>
|
||||
<p className="font-mono text-th-fgd-1">
|
||||
{(bank.liquidationFee.toNumber() * 100).toFixed(
|
||||
2
|
||||
2,
|
||||
)}
|
||||
%
|
||||
</p>
|
||||
|
|
|
@ -84,11 +84,11 @@ const TokenOverviewTable = () => {
|
|||
deposits * bank.minVaultToDepositsRatio
|
||||
const available = Decimal.max(
|
||||
0,
|
||||
availableVaultBalance.toFixed(bank.mintDecimals)
|
||||
availableVaultBalance.toFixed(bank.mintDecimals),
|
||||
)
|
||||
const feesEarned = toUiDecimals(
|
||||
bank.collectedFeesNative,
|
||||
bank.mintDecimals
|
||||
bank.mintDecimals,
|
||||
)
|
||||
|
||||
return (
|
||||
|
@ -201,11 +201,11 @@ const TokenOverviewTable = () => {
|
|||
deposits * bank.minVaultToDepositsRatio
|
||||
const available = Decimal.max(
|
||||
0,
|
||||
availableVaultBalance.toFixed(bank.mintDecimals)
|
||||
availableVaultBalance.toFixed(bank.mintDecimals),
|
||||
)
|
||||
const feesEarned = toUiDecimals(
|
||||
bank.collectedFeesNative,
|
||||
bank.mintDecimals
|
||||
bank.mintDecimals,
|
||||
)
|
||||
return (
|
||||
<Disclosure key={bank.name}>
|
||||
|
|
|
@ -39,7 +39,7 @@ const TokenStatsCharts = () => {
|
|||
a +
|
||||
c.bank.uiPrice *
|
||||
toUiDecimals(c.bank.collectedFeesNative, c.bank.mintDecimals),
|
||||
0
|
||||
0,
|
||||
),
|
||||
]
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ const RoutesModal = ({
|
|||
{
|
||||
jupiterTokens.find(
|
||||
(item) =>
|
||||
item?.address === r?.outputMint?.toString()
|
||||
item?.address === r?.outputMint?.toString(),
|
||||
)?.symbol
|
||||
}
|
||||
</span>
|
||||
|
|
|
@ -121,14 +121,14 @@ const SwapForm = () => {
|
|||
}
|
||||
})
|
||||
},
|
||||
[]
|
||||
[],
|
||||
)
|
||||
|
||||
const setAmountFromSlider = useCallback(
|
||||
(amount: string) => {
|
||||
setAmountInFormValue(amount, true)
|
||||
},
|
||||
[setAmountInFormValue]
|
||||
[setAmountInFormValue],
|
||||
)
|
||||
|
||||
const setAmountOutFormValue = useCallback((amountOut: string) => {
|
||||
|
@ -149,7 +149,7 @@ const SwapForm = () => {
|
|||
}
|
||||
setAmountOutFormValue(borrowAmount.toString())
|
||||
},
|
||||
[setAmountOutFormValue]
|
||||
[setAmountOutFormValue],
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -192,7 +192,7 @@ const SwapForm = () => {
|
|||
}
|
||||
setAmountInFormValue(e.value)
|
||||
},
|
||||
[swapMode, setAmountInFormValue]
|
||||
[swapMode, setAmountInFormValue],
|
||||
)
|
||||
|
||||
const handleAmountOutChange = useCallback(
|
||||
|
@ -205,7 +205,7 @@ const SwapForm = () => {
|
|||
}
|
||||
setAmountOutFormValue(e.value)
|
||||
},
|
||||
[swapMode, setAmountOutFormValue]
|
||||
[swapMode, setAmountOutFormValue],
|
||||
)
|
||||
|
||||
const handleTokenInSelect = useCallback((mintAddress: string) => {
|
||||
|
@ -242,10 +242,10 @@ const SwapForm = () => {
|
|||
s.swap.outputBank = inputBank
|
||||
})
|
||||
setAnimateSwitchArrow(
|
||||
(prevanimateSwitchArrow) => prevanimateSwitchArrow + 1
|
||||
(prevanimateSwitchArrow) => prevanimateSwitchArrow + 1,
|
||||
)
|
||||
},
|
||||
[setAmountInFormValue]
|
||||
[setAmountInFormValue],
|
||||
)
|
||||
|
||||
const maintProjectedHealth = useMemo(() => {
|
||||
|
@ -272,7 +272,7 @@ const SwapForm = () => {
|
|||
uiTokenAmount: amountOutAsDecimal.toNumber(),
|
||||
},
|
||||
],
|
||||
HealthType.maint
|
||||
HealthType.maint,
|
||||
)
|
||||
return simulatedHealthRatio > 100
|
||||
? 100
|
||||
|
@ -401,7 +401,7 @@ const SwapForm = () => {
|
|||
<span className="absolute right-3 bottom-1.5 text-xxs text-th-fgd-4">
|
||||
{inputBank
|
||||
? formatCurrencyValue(
|
||||
inputBank.uiPrice * Number(amountInFormValue)
|
||||
inputBank.uiPrice * Number(amountInFormValue),
|
||||
)
|
||||
: '–'}
|
||||
</span>
|
||||
|
@ -434,8 +434,8 @@ const SwapForm = () => {
|
|||
onClick={() =>
|
||||
setBorrowAmountOut(
|
||||
outputTokenBalanceBorrow.toFixed(
|
||||
outputBank?.mintDecimals || 9
|
||||
)
|
||||
outputBank?.mintDecimals || 9,
|
||||
),
|
||||
)
|
||||
}
|
||||
value={outputTokenBalanceBorrow}
|
||||
|
@ -476,7 +476,7 @@ const SwapForm = () => {
|
|||
<span className="absolute right-3 bottom-1.5 text-xxs text-th-fgd-4">
|
||||
{outputBank
|
||||
? formatCurrencyValue(
|
||||
outputBank.uiPrice * Number(amountOutFormValue)
|
||||
outputBank.uiPrice * Number(amountOutFormValue),
|
||||
)
|
||||
: '–'}
|
||||
</span>
|
||||
|
|
|
@ -166,7 +166,7 @@ const SwapFormTokenList = ({
|
|||
new PublicKey(token.address),
|
||||
outputBank.mint,
|
||||
group,
|
||||
useMargin
|
||||
useMargin,
|
||||
)
|
||||
return { ...token, ...max }
|
||||
})
|
||||
|
@ -174,7 +174,7 @@ const SwapFormTokenList = ({
|
|||
.sort((a, b) =>
|
||||
useMargin
|
||||
? Number(b.amountWithBorrow) - Number(a.amountWithBorrow)
|
||||
: Number(b.amount) - Number(a.amount)
|
||||
: Number(b.amount) - Number(a.amount),
|
||||
)
|
||||
|
||||
return filteredSortedTokens
|
||||
|
|
|
@ -36,7 +36,7 @@ const SwapHistoryTable = () => {
|
|||
const showTableView = width ? width > breakpoints.md : false
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
PREFERRED_EXPLORER_KEY,
|
||||
EXPLORERS[0]
|
||||
EXPLORERS[0],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -56,7 +56,7 @@ const SwapHistoryTable = () => {
|
|||
actions.fetchSwapHistory(
|
||||
mangoAccountAddress,
|
||||
0,
|
||||
offset + PAGINATION_PAGE_LENGTH
|
||||
offset + PAGINATION_PAGE_LENGTH,
|
||||
)
|
||||
}, [actions, offset, mangoAccountAddress])
|
||||
|
||||
|
@ -196,7 +196,7 @@ const SwapHistoryTable = () => {
|
|||
<div className="flex items-center justify-end">
|
||||
<Tooltip
|
||||
content={`View on ${t(
|
||||
`settings:${preferredExplorer.name}`
|
||||
`settings:${preferredExplorer.name}`,
|
||||
)}`}
|
||||
placement="top-end"
|
||||
>
|
||||
|
|
|
@ -19,7 +19,7 @@ const SwapPage = () => {
|
|||
const actions = mangoStore((s) => s.actions)
|
||||
const [showSwapIntro, setShowSwapIntro] = useLocalStorage(
|
||||
SHOW_SWAP_INTRO_MODAL,
|
||||
true
|
||||
true,
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -59,17 +59,17 @@ type JupiterRouteInfoProps = {
|
|||
|
||||
const deserializeJupiterIxAndAlt = async (
|
||||
connection: Connection,
|
||||
swapTransaction: string
|
||||
swapTransaction: string,
|
||||
): Promise<[TransactionInstruction[], AddressLookupTableAccount[]]> => {
|
||||
const parsedSwapTransaction = VersionedTransaction.deserialize(
|
||||
Buffer.from(swapTransaction, 'base64')
|
||||
Buffer.from(swapTransaction, 'base64'),
|
||||
)
|
||||
const message = parsedSwapTransaction.message
|
||||
// const lookups = message.addressTableLookups
|
||||
const addressLookupTablesResponses = await Promise.all(
|
||||
message.addressTableLookups.map((alt) =>
|
||||
connection.getAddressLookupTable(alt.accountKey)
|
||||
)
|
||||
connection.getAddressLookupTable(alt.accountKey),
|
||||
),
|
||||
)
|
||||
const addressLookupTables: AddressLookupTableAccount[] =
|
||||
addressLookupTablesResponses
|
||||
|
@ -87,7 +87,7 @@ const prepareMangoRouterInstructions = async (
|
|||
selectedRoute: RouteInfo,
|
||||
inputMint: PublicKey,
|
||||
outputMint: PublicKey,
|
||||
userPublicKey: PublicKey
|
||||
userPublicKey: PublicKey,
|
||||
): Promise<[TransactionInstruction[], AddressLookupTableAccount[]]> => {
|
||||
if (!selectedRoute || !selectedRoute.mints || !selectedRoute.instructions) {
|
||||
return [[], []]
|
||||
|
@ -97,8 +97,8 @@ const prepareMangoRouterInstructions = async (
|
|||
...selectedRoute.mints.filter(
|
||||
(routeMint) =>
|
||||
!mintsToFilterOut.find((filterOutMint) =>
|
||||
filterOutMint.equals(routeMint)
|
||||
)
|
||||
filterOutMint.equals(routeMint),
|
||||
),
|
||||
),
|
||||
]
|
||||
const additionalInstructions = []
|
||||
|
@ -106,7 +106,7 @@ const prepareMangoRouterInstructions = async (
|
|||
const ix = await createAssociatedTokenAccountIdempotentInstruction(
|
||||
userPublicKey,
|
||||
userPublicKey,
|
||||
mint
|
||||
mint,
|
||||
)
|
||||
additionalInstructions.push(ix)
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ export const fetchJupiterTransaction = async (
|
|||
userPublicKey: PublicKey,
|
||||
slippage: number,
|
||||
inputMint: PublicKey,
|
||||
outputMint: PublicKey
|
||||
outputMint: PublicKey,
|
||||
): Promise<[TransactionInstruction[], AddressLookupTableAccount[]]> => {
|
||||
const transactions = await (
|
||||
await fetch('https://quote-api.jup.ag/v4/swap', {
|
||||
|
@ -148,7 +148,7 @@ export const fetchJupiterTransaction = async (
|
|||
|
||||
const [ixs, alts] = await deserializeJupiterIxAndAlt(
|
||||
connection,
|
||||
swapTransaction
|
||||
swapTransaction,
|
||||
)
|
||||
|
||||
const isSetupIx = (pk: PublicKey): boolean =>
|
||||
|
@ -202,14 +202,14 @@ const SwapReviewRouteInfo = ({
|
|||
const outputBank = mangoStore((s) => s.swap.outputBank)
|
||||
const [soundSettings] = useLocalStorageState(
|
||||
SOUND_SETTINGS_KEY,
|
||||
INITIAL_SOUND_SETTINGS
|
||||
INITIAL_SOUND_SETTINGS,
|
||||
)
|
||||
const focusRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
const amountOut = useMemo(() => {
|
||||
if (!selectedRoute || !outputTokenInfo) return
|
||||
return new Decimal(selectedRoute.outAmount.toString()).div(
|
||||
10 ** outputTokenInfo.decimals
|
||||
10 ** outputTokenInfo.decimals,
|
||||
)
|
||||
}, [selectedRoute, outputTokenInfo])
|
||||
|
||||
|
@ -228,7 +228,7 @@ const SwapReviewRouteInfo = ({
|
|||
if (inputId && outputId) {
|
||||
try {
|
||||
const results = await fetch(
|
||||
`https://api.coingecko.com/api/v3/simple/price?ids=${inputId},${outputId}&vs_currencies=usd`
|
||||
`https://api.coingecko.com/api/v3/simple/price?ids=${inputId},${outputId}&vs_currencies=usd`,
|
||||
)
|
||||
const json = await results.json()
|
||||
if (json[inputId]?.usd && json[outputId]?.usd) {
|
||||
|
@ -275,7 +275,7 @@ const SwapReviewRouteInfo = ({
|
|||
selectedRoute,
|
||||
inputBank.mint,
|
||||
outputBank.mint,
|
||||
mangoAccount.owner
|
||||
mangoAccount.owner,
|
||||
)
|
||||
: await fetchJupiterTransaction(
|
||||
connection,
|
||||
|
@ -283,7 +283,7 @@ const SwapReviewRouteInfo = ({
|
|||
wallet.publicKey,
|
||||
slippage,
|
||||
inputBank.mint,
|
||||
outputBank.mint
|
||||
outputBank.mint,
|
||||
)
|
||||
|
||||
try {
|
||||
|
@ -358,8 +358,8 @@ const SwapReviewRouteInfo = ({
|
|||
.div(amountOut)
|
||||
.minus(
|
||||
new Decimal(coingeckoPrices?.outputCoingeckoPrice).div(
|
||||
coingeckoPrices?.inputCoingeckoPrice
|
||||
)
|
||||
coingeckoPrices?.inputCoingeckoPrice,
|
||||
),
|
||||
)
|
||||
.div(amountIn.div(amountOut))
|
||||
.mul(100)
|
||||
|
@ -540,7 +540,7 @@ const SwapReviewRouteInfo = ({
|
|||
token: inputTokenInfo?.symbol,
|
||||
rate: formatNumericValue(
|
||||
inputBank!.getBorrowRateUi(),
|
||||
2
|
||||
2,
|
||||
),
|
||||
})
|
||||
: t('swap:tooltip-borrow-no-balance', {
|
||||
|
@ -548,7 +548,7 @@ const SwapReviewRouteInfo = ({
|
|||
token: inputTokenInfo?.symbol,
|
||||
rate: formatNumericValue(
|
||||
inputBank!.getBorrowRateUi(),
|
||||
2
|
||||
2,
|
||||
),
|
||||
})
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ const SwapReviewRouteInfo = ({
|
|||
) : (
|
||||
selectedRoute?.marketInfos.map((info, index) => {
|
||||
const feeToken = jupiterTokens.find(
|
||||
(item) => item?.address === info.lpFee?.mint
|
||||
(item) => item?.address === info.lpFee?.mint,
|
||||
)
|
||||
return (
|
||||
<div className="flex justify-between" key={index}>
|
||||
|
@ -690,7 +690,7 @@ const SwapReviewRouteInfo = ({
|
|||
undefined,
|
||||
{
|
||||
maximumSignificantDigits: 2,
|
||||
}
|
||||
},
|
||||
)}
|
||||
%)
|
||||
</p>
|
||||
|
|
|
@ -102,7 +102,7 @@ interface ExtendedReferenceDotProps extends ReferenceDotProps {
|
|||
flipPrices: boolean
|
||||
mouseEnter: (
|
||||
swap: SwapHistoryItem | undefined,
|
||||
coingeckoPrice: string | number | undefined
|
||||
coingeckoPrice: string | number | undefined,
|
||||
) => void
|
||||
mouseLeave: MouseEventHandler
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ const SwapHistoryArrows = (props: ExtendedReferenceDotProps) => {
|
|||
mouseLeave,
|
||||
} = props
|
||||
const swapDetails = swapHistory.find(
|
||||
(swap) => dayjs(swap.block_datetime).unix() * 1000 === x
|
||||
(swap) => dayjs(swap.block_datetime).unix() * 1000 === x,
|
||||
)
|
||||
const side =
|
||||
swapDetails?.swap_in_symbol === swapMarketName.split('/')[0]
|
||||
|
@ -186,7 +186,7 @@ const SwapTokenChart = () => {
|
|||
const { theme } = useTheme()
|
||||
const [animationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
const swapHistory = mangoStore((s) => s.mangoAccount.swapHistory.data)
|
||||
const loadSwapHistory = mangoStore((s) => s.mangoAccount.swapHistory.loading)
|
||||
|
@ -200,7 +200,7 @@ const SwapTokenChart = () => {
|
|||
const handleSwapMouseEnter = useCallback(
|
||||
(
|
||||
swap: SwapHistoryItem | undefined,
|
||||
coingeckoPrice: string | number | undefined
|
||||
coingeckoPrice: string | number | undefined,
|
||||
) => {
|
||||
if (swap) {
|
||||
setSwapTooltipData(swap)
|
||||
|
@ -209,7 +209,7 @@ const SwapTokenChart = () => {
|
|||
setSwapTooltipCoingeckoPrice(coingeckoPrice)
|
||||
}
|
||||
},
|
||||
[setSwapTooltipData, setSwapTooltipCoingeckoPrice]
|
||||
[setSwapTooltipData, setSwapTooltipCoingeckoPrice],
|
||||
)
|
||||
|
||||
const handleSwapMouseLeave = useCallback(() => {
|
||||
|
@ -302,9 +302,9 @@ const SwapTokenChart = () => {
|
|||
return (
|
||||
<>
|
||||
<p className="text-center text-th-fgd-2">{`${t(
|
||||
side
|
||||
side,
|
||||
)} ${amount} ${symbol} at ${formatNumericValue(
|
||||
price
|
||||
price,
|
||||
)} ${priceSymbol} for ${formatCurrencyValue(value)}`}</p>
|
||||
{coingeckoPercentageDifference ? (
|
||||
<p
|
||||
|
@ -321,7 +321,7 @@ const SwapTokenChart = () => {
|
|||
</>
|
||||
)
|
||||
},
|
||||
[flipPrices, swapMarketName, swapTooltipCoingeckoPrice]
|
||||
[flipPrices, swapMarketName, swapTooltipCoingeckoPrice],
|
||||
)
|
||||
|
||||
const {
|
||||
|
@ -336,7 +336,7 @@ const SwapTokenChart = () => {
|
|||
staleTime: 1000 * 60 * 1,
|
||||
enabled: !!baseTokenId && !!quoteTokenId,
|
||||
refetchOnWindowFocus: false,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const coingeckoData = useMemo(() => {
|
||||
|
@ -371,7 +371,7 @@ const SwapTokenChart = () => {
|
|||
.filter(
|
||||
(swap) =>
|
||||
chartSymbols.includes(swap.swap_in_symbol) &&
|
||||
chartSymbols.includes(swap.swap_out_symbol)
|
||||
chartSymbols.includes(swap.swap_out_symbol),
|
||||
)
|
||||
.map((val) => dayjs(val.block_datetime).unix() * 1000)
|
||||
}, [swapHistory, loadSwapHistory, inputBank, outputBank])
|
||||
|
@ -408,7 +408,7 @@ const SwapTokenChart = () => {
|
|||
const maxTime = coingeckoData[coingeckoData.length - 1].time
|
||||
if (swapHistoryPoints.length && showSwaps) {
|
||||
const swapPoints = swapHistoryPoints.filter(
|
||||
(point) => point.time >= minTime && point.time <= maxTime
|
||||
(point) => point.time >= minTime && point.time <= maxTime,
|
||||
)
|
||||
return coingeckoData.concat(swapPoints).sort((a, b) => a.time - b.time)
|
||||
} else return coingeckoData
|
||||
|
@ -420,7 +420,7 @@ const SwapTokenChart = () => {
|
|||
setMouseData(coords.activePayload[0].payload)
|
||||
}
|
||||
},
|
||||
[setMouseData]
|
||||
[setMouseData],
|
||||
)
|
||||
|
||||
const handleMouseLeave = useCallback(() => {
|
||||
|
@ -524,7 +524,7 @@ const SwapTokenChart = () => {
|
|||
width={35}
|
||||
play
|
||||
numbers={formatNumericValue(
|
||||
chartData[chartData.length - 1].price
|
||||
chartData[chartData.length - 1].price,
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
|
@ -540,7 +540,7 @@ const SwapTokenChart = () => {
|
|||
</div>
|
||||
<p className="text-sm text-th-fgd-4">
|
||||
{dayjs(chartData[chartData.length - 1].time).format(
|
||||
'DD MMM YY, h:mma'
|
||||
'DD MMM YY, h:mma',
|
||||
)}
|
||||
</p>
|
||||
</>
|
||||
|
|
|
@ -11,10 +11,10 @@ const useJupiterSwapData = () => {
|
|||
if (inputBank && outputBank) {
|
||||
return [
|
||||
mangoTokens?.find(
|
||||
(item) => item?.address === inputBank.mint.toString() || ''
|
||||
(item) => item?.address === inputBank.mint.toString() || '',
|
||||
),
|
||||
mangoTokens?.find(
|
||||
(item) => item?.address === outputBank.mint.toString() || ''
|
||||
(item) => item?.address === outputBank.mint.toString() || '',
|
||||
),
|
||||
]
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ const fetchJupiterRoutes = async (
|
|||
amount = 0,
|
||||
slippage = 50,
|
||||
swapMode = 'ExactIn',
|
||||
feeBps = 0
|
||||
feeBps = 0,
|
||||
) => {
|
||||
{
|
||||
const paramsString = new URLSearchParams({
|
||||
|
@ -40,7 +40,7 @@ const fetchJupiterRoutes = async (
|
|||
}).toString()
|
||||
|
||||
const response = await fetch(
|
||||
`https://quote-api.jup.ag/v4/quote?${paramsString}`
|
||||
`https://quote-api.jup.ag/v4/quote?${paramsString}`,
|
||||
)
|
||||
|
||||
const res = await response.json()
|
||||
|
@ -60,7 +60,7 @@ const fetchMangoRoutes = async (
|
|||
slippage = 50,
|
||||
swapMode = 'ExactIn',
|
||||
feeBps = 0,
|
||||
wallet = PublicKey.default.toBase58()
|
||||
wallet = PublicKey.default.toBase58(),
|
||||
) => {
|
||||
{
|
||||
const defaultOtherAmount =
|
||||
|
@ -118,7 +118,7 @@ export const handleGetRoutes = async (
|
|||
swapMode = 'ExactIn',
|
||||
feeBps = 0,
|
||||
wallet: string | undefined | null,
|
||||
mode: SwapModes = 'ALL'
|
||||
mode: SwapModes = 'ALL',
|
||||
) => {
|
||||
try {
|
||||
wallet ||= PublicKey.default.toBase58()
|
||||
|
@ -129,7 +129,7 @@ export const handleGetRoutes = async (
|
|||
slippage,
|
||||
swapMode,
|
||||
feeBps,
|
||||
wallet
|
||||
wallet,
|
||||
)
|
||||
const jupiterRoute = fetchJupiterRoutes(
|
||||
inputMint,
|
||||
|
@ -137,7 +137,7 @@ export const handleGetRoutes = async (
|
|||
amount,
|
||||
slippage,
|
||||
swapMode,
|
||||
feeBps
|
||||
feeBps,
|
||||
)
|
||||
|
||||
const routes = []
|
||||
|
@ -166,7 +166,7 @@ export const handleGetRoutes = async (
|
|||
).sort((a, b) =>
|
||||
swapMode === 'ExactIn'
|
||||
? Number(b.bestRoute.outAmount) - Number(a.bestRoute.outAmount)
|
||||
: Number(a.bestRoute.inAmount) - Number(b.bestRoute.inAmount)
|
||||
: Number(a.bestRoute.inAmount) - Number(b.bestRoute.inAmount),
|
||||
)
|
||||
return {
|
||||
routes: sortedByBiggestOutAmount[0].routes,
|
||||
|
@ -227,7 +227,7 @@ const useQuoteRoutes = ({
|
|||
swapMode,
|
||||
0,
|
||||
wallet,
|
||||
mode
|
||||
mode,
|
||||
),
|
||||
{
|
||||
cacheTime: 1000 * 60,
|
||||
|
@ -235,7 +235,7 @@ const useQuoteRoutes = ({
|
|||
enabled: enabled ? enabled() : amount ? true : false,
|
||||
refetchInterval: 20000,
|
||||
retry: 3,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
return amount
|
||||
|
|
|
@ -11,13 +11,13 @@ export const getMaxWithdrawForBank = (
|
|||
group: Group,
|
||||
bank: Bank,
|
||||
mangoAccount: MangoAccount,
|
||||
allowBorrow = false
|
||||
allowBorrow = false,
|
||||
): Decimal => {
|
||||
const accountBalance = mangoAccount.getTokenBalanceUi(bank)
|
||||
const vaultBalance = group.getTokenVaultBalanceByMintUi(bank.mint)
|
||||
const maxBorrow = mangoAccount.getMaxWithdrawWithBorrowForTokenUi(
|
||||
group,
|
||||
bank.mint
|
||||
bank.mint,
|
||||
)
|
||||
const maxWithdraw = allowBorrow
|
||||
? Decimal.min(vaultBalance, maxBorrow)
|
||||
|
@ -32,7 +32,7 @@ export const getTokenInMax = (
|
|||
inputMint: PublicKey,
|
||||
outputMint: PublicKey,
|
||||
group: Group,
|
||||
useMargin: boolean
|
||||
useMargin: boolean,
|
||||
) => {
|
||||
const inputBank = group.getFirstBankByMint(inputMint)
|
||||
const outputBank = group.getFirstBankByMint(outputMint)
|
||||
|
@ -49,11 +49,11 @@ export const getTokenInMax = (
|
|||
const outputReduceOnly = outputBank.areDepositsReduceOnly()
|
||||
|
||||
const inputTokenBalance = new Decimal(
|
||||
mangoAccount.getTokenBalanceUi(inputBank)
|
||||
mangoAccount.getTokenBalanceUi(inputBank),
|
||||
)
|
||||
|
||||
const outputTokenBalance = new Decimal(
|
||||
mangoAccount.getTokenBalanceUi(outputBank)
|
||||
mangoAccount.getTokenBalanceUi(outputBank),
|
||||
)
|
||||
|
||||
const maxAmountWithoutMargin =
|
||||
|
@ -65,7 +65,7 @@ export const getTokenInMax = (
|
|||
const rawMaxUiAmountWithBorrow = mangoAccount.getMaxSourceUiForTokenSwap(
|
||||
group,
|
||||
inputBank.mint,
|
||||
outputBank.mint
|
||||
outputBank.mint,
|
||||
)
|
||||
|
||||
const maxUiAmountWithBorrow =
|
||||
|
@ -79,19 +79,19 @@ export const getTokenInMax = (
|
|||
group
|
||||
.getTokenVaultBalanceByMintUi(inputBank.mint)
|
||||
.toFixed(inputBank.mintDecimals),
|
||||
inputBank.mintDecimals
|
||||
inputBank.mintDecimals,
|
||||
)
|
||||
|
||||
const maxAmount = useMargin
|
||||
? Decimal.min(
|
||||
maxAmountWithoutMargin,
|
||||
inputBankVaultBalance,
|
||||
maxUiAmountWithBorrow
|
||||
maxUiAmountWithBorrow,
|
||||
)
|
||||
: Decimal.min(
|
||||
maxAmountWithoutMargin,
|
||||
inputBankVaultBalance,
|
||||
maxUiAmountWithBorrow
|
||||
maxUiAmountWithBorrow,
|
||||
)
|
||||
|
||||
const maxAmountWithBorrow = inputReduceOnly
|
||||
|
@ -125,7 +125,7 @@ export const useTokenMax = (useMargin = true): TokenMaxResults => {
|
|||
inputBank.mint,
|
||||
outputBank.mint,
|
||||
group,
|
||||
useMargin
|
||||
useMargin,
|
||||
)
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
@ -28,7 +28,7 @@ const ActionPanel = ({ bank }: { bank: Bank }) => {
|
|||
const handleTrade = () => {
|
||||
const set = mangoStore.getState().set
|
||||
const market = serumMarkets.find(
|
||||
(m) => m.baseTokenIndex === bank?.tokenIndex
|
||||
(m) => m.baseTokenIndex === bank?.tokenIndex,
|
||||
)
|
||||
if (market) {
|
||||
set((state) => {
|
||||
|
|
|
@ -39,7 +39,7 @@ const ChartTabs = ({ bank }: { bank: Bank }) => {
|
|||
}
|
||||
return a.sort(
|
||||
(a, b) =>
|
||||
new Date(a.date_hour).getTime() - new Date(b.date_hour).getTime()
|
||||
new Date(a.date_hour).getTime() - new Date(b.date_hour).getTime(),
|
||||
)
|
||||
}, [])
|
||||
}, [tokenStats, bank])
|
||||
|
|
|
@ -41,7 +41,7 @@ interface BirdeyeResponse {
|
|||
|
||||
const fetchBirdeyePrices = async (
|
||||
daysToShow: string,
|
||||
mint: string
|
||||
mint: string,
|
||||
): Promise<BirdeyePriceResponse[] | []> => {
|
||||
const interval = daysToShow === '1' ? '30m' : daysToShow === '7' ? '1H' : '4H'
|
||||
const queryEnd = Math.floor(Date.now() / 1000)
|
||||
|
@ -81,7 +81,7 @@ const CoingeckoStats = ({
|
|||
retry: 3,
|
||||
enabled: !!bank,
|
||||
refetchOnWindowFocus: false,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const {
|
||||
|
|
|
@ -56,7 +56,7 @@ const fetchTokenInfo = async (tokenId: string | undefined) => {
|
|||
if (!tokenId) return
|
||||
const response = await fetch(
|
||||
`https://api.coingecko.com/api/v3/coins/${tokenId}?localization=false&tickers=false&developer_data=false&sparkline=false&community_data=false
|
||||
`
|
||||
`,
|
||||
)
|
||||
const data = await response.json()
|
||||
return data
|
||||
|
@ -71,7 +71,7 @@ const TokenPage = () => {
|
|||
const { mangoTokens } = useJupiterMints()
|
||||
const [animationSettings] = useLocalStorageState(
|
||||
ANIMATION_SETTINGS_KEY,
|
||||
INITIAL_ANIMATION_SETTINGS
|
||||
INITIAL_ANIMATION_SETTINGS,
|
||||
)
|
||||
|
||||
const bankName = useMemo(() => {
|
||||
|
@ -118,7 +118,7 @@ const TokenPage = () => {
|
|||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!coingeckoId,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const { high_24h, low_24h, price_change_percentage_24h } =
|
||||
|
|
|
@ -115,20 +115,20 @@ const TokenParams = ({ bank }: { bank: Bank }) => {
|
|||
<p className="font-mono text-th-fgd-2">
|
||||
{bank.name === 'USDC'
|
||||
? `$${toUiDecimalsForQuote(
|
||||
bank.depositWeightScaleStartQuote
|
||||
bank.depositWeightScaleStartQuote,
|
||||
).toExponential(1)}`
|
||||
: formatCurrencyValue(
|
||||
toUiDecimalsForQuote(bank.depositWeightScaleStartQuote)
|
||||
toUiDecimalsForQuote(bank.depositWeightScaleStartQuote),
|
||||
)}
|
||||
</p>
|
||||
<span className="text-th-fgd-4">|</span>
|
||||
<p className="font-mono text-th-fgd-2">
|
||||
{bank.name === 'USDC'
|
||||
? `$${toUiDecimalsForQuote(
|
||||
bank.depositWeightScaleStartQuote
|
||||
bank.depositWeightScaleStartQuote,
|
||||
).toExponential(1)}`
|
||||
: formatCurrencyValue(
|
||||
toUiDecimalsForQuote(bank.borrowWeightScaleStartQuote)
|
||||
toUiDecimalsForQuote(bank.borrowWeightScaleStartQuote),
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -152,8 +152,8 @@ const TokenParams = ({ bank }: { bank: Bank }) => {
|
|||
<p className="font-mono text-th-fgd-2">
|
||||
{formatCurrencyValue(
|
||||
toUiDecimalsForQuote(
|
||||
I80F48.fromI64(bank.netBorrowsInWindow).mul(bank.price)
|
||||
)
|
||||
I80F48.fromI64(bank.netBorrowsInWindow).mul(bank.price),
|
||||
),
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -165,7 +165,7 @@ const TokenParams = ({ bank }: { bank: Bank }) => {
|
|||
</Tooltip>
|
||||
<p className="font-mono text-th-fgd-2">
|
||||
{formatCurrencyValue(
|
||||
toUiDecimals(bank.netBorrowLimitPerWindowQuote, 6)
|
||||
toUiDecimals(bank.netBorrowLimitPerWindowQuote, 6),
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -31,17 +31,17 @@ const fetchTopTokenAccounts = async (tokenIndex: number) => {
|
|||
try {
|
||||
const promises = [
|
||||
fetch(
|
||||
`${MANGO_DATA_API_URL}/leaderboard-token-deposits?token-index=${tokenIndex}`
|
||||
`${MANGO_DATA_API_URL}/leaderboard-token-deposits?token-index=${tokenIndex}`,
|
||||
),
|
||||
fetch(
|
||||
`${MANGO_DATA_API_URL}/leaderboard-token-borrows?token-index=${tokenIndex}`
|
||||
`${MANGO_DATA_API_URL}/leaderboard-token-borrows?token-index=${tokenIndex}`,
|
||||
),
|
||||
]
|
||||
const [depositsResponse, borrowsResponse] = await Promise.all(promises)
|
||||
|
||||
const [depositsData, borrowsData]: [
|
||||
TopDepositorBorrower[],
|
||||
TopDepositorBorrower[]
|
||||
TopDepositorBorrower[],
|
||||
] = await Promise.all([depositsResponse.json(), borrowsResponse.json()])
|
||||
|
||||
// const depositorProfilesResponse = await Promise.all(
|
||||
|
@ -93,7 +93,7 @@ const TopTokenAccounts = ({ bank }: { bank: Bank }) => {
|
|||
staleTime: 1000 * 60,
|
||||
retry: 3,
|
||||
refetchOnWindowFocus: false,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const topAccountsData = data ? data : [[], []]
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue