fix: all your codebase belongs to us (#492)
This commit is contained in:
parent
574dedec23
commit
5bf46d4da0
@ -145,7 +145,7 @@ export default function Index(props: Props) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[baseCurrency.decimals, markets],
|
[markets],
|
||||||
)
|
)
|
||||||
|
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import classNames from 'classnames'
|
||||||
|
|
||||||
import { VerticalThreeLine } from 'components/Icons'
|
import { VerticalThreeLine } from 'components/Icons'
|
||||||
import { formatValue } from 'utils/formatters'
|
import { formatValue } from 'utils/formatters'
|
||||||
|
|
||||||
@ -19,7 +21,7 @@ function InputOverlay({ max, value, marginThreshold }: Props) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className={className.marksWrapper}
|
className='absolute flex-1 flex w-full justify-evenly bg-no-repeat top-[8.5px] pointer-events-none pt-[2.5px] pb-[2.5px] rounded-lg'
|
||||||
style={{
|
style={{
|
||||||
backgroundImage:
|
backgroundImage:
|
||||||
'linear-gradient(270deg, rgba(255, 97, 141, 0.89) 0%, rgba(66, 58, 70, 0.05) 100%)',
|
'linear-gradient(270deg, rgba(255, 97, 141, 0.89) 0%, rgba(66, 58, 70, 0.05) 100%)',
|
||||||
@ -27,16 +29,16 @@ function InputOverlay({ max, value, marginThreshold }: Props) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Array.from(Array(9).keys()).map((i) => (
|
{Array.from(Array(9).keys()).map((i) => (
|
||||||
<div key={`mark-${i}`} className={className.mark} />
|
<div key={`mark-${i}`} className='w-1 h-1 bg-black rounded-full bg-opacity-30' />
|
||||||
))}
|
))}
|
||||||
{marginThreshold !== undefined && (
|
{marginThreshold !== undefined && (
|
||||||
<div
|
<div
|
||||||
key='margin-mark'
|
key='margin-mark'
|
||||||
className={className.marginMarkContainer}
|
className='absolute w-[33px] flex justify-center'
|
||||||
style={{ left: `calc(${markPosPercent}% - ${markPadRight}px)` }}
|
style={{ left: `calc(${markPosPercent}% - ${markPadRight}px)` }}
|
||||||
>
|
>
|
||||||
<div className={className.marginMark} />
|
<div className='w-1 h-1 bg-white rounded-full' />
|
||||||
<div className={className.marginMarkOverlay}>
|
<div className='absolute top-2.5 flex-col text-xs w-[33px] items-center flex'>
|
||||||
<VerticalThreeLine className='h-2 w-[1px]' />
|
<VerticalThreeLine className='h-2 w-[1px]' />
|
||||||
<div className={!hasPastMarginThreshold ? 'opacity-50' : 'opacity-100'}>Margin</div>
|
<div className={!hasPastMarginThreshold ? 'opacity-50' : 'opacity-100'}>Margin</div>
|
||||||
</div>
|
</div>
|
||||||
@ -44,7 +46,12 @@ function InputOverlay({ max, value, marginThreshold }: Props) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={className.inputThumbOverlay}
|
className={classNames(
|
||||||
|
'w-[33px] h-4 absolute text-[10px] top-[5px]',
|
||||||
|
'pointer-events-none text-center font-bold',
|
||||||
|
'bg-pink shadow-md border-b-0 border-1',
|
||||||
|
'border-solid rounded-sm backdrop-blur-sm border-white/10',
|
||||||
|
)}
|
||||||
style={{ left: `calc(${thumbPosPercent}% - ${thumbPadRight}px)` }}
|
style={{ left: `calc(${thumbPosPercent}% - ${thumbPadRight}px)` }}
|
||||||
>
|
>
|
||||||
{formatValue(value, { maxDecimals: 2, abbreviated: true, rounded: true })}
|
{formatValue(value, { maxDecimals: 2, abbreviated: true, rounded: true })}
|
||||||
@ -53,19 +60,4 @@ function InputOverlay({ max, value, marginThreshold }: Props) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = {
|
|
||||||
inputThumbOverlay: `
|
|
||||||
w-[33px] h-4 absolute text-[10px] top-[5px]
|
|
||||||
pointer-events-none text-center font-bold
|
|
||||||
bg-pink shadow-md border-b-0 border-1
|
|
||||||
border-solid rounded-sm backdrop-blur-sm border-white/10
|
|
||||||
`,
|
|
||||||
mark: `w-1 h-1 bg-black rounded-full bg-opacity-30`,
|
|
||||||
marginMark: `w-1 h-1 bg-white rounded-full`,
|
|
||||||
marginMarkContainer: 'absolute w-[33px] flex justify-center',
|
|
||||||
marginMarkOverlay: 'absolute top-2.5 flex-col text-xs w-[33px] items-center flex',
|
|
||||||
marksWrapper: `absolute flex-1 flex w-full justify-evenly bg-no-repeat
|
|
||||||
top-[8.5px] pointer-events-none pt-[2.5px] pb-[2.5px] rounded-lg`,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default InputOverlay
|
export default InputOverlay
|
||||||
|
@ -29,13 +29,21 @@ function RangeInput(props: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(className.containerDefault, wrapperClassName, {
|
className={classNames(
|
||||||
[className.disabled]: disabled,
|
'relative min-h-3 w-full transition-opacity',
|
||||||
})}
|
wrapperClassName,
|
||||||
|
disabled && 'pointer-events-none opacity-50',
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<div className={className.inputWrapper}>
|
<div className='relative h-[30px]'>
|
||||||
<input
|
<input
|
||||||
className={className.input}
|
className={classNames(
|
||||||
|
'relative w-full appearance-none bg-transparent hover:cursor-pointer',
|
||||||
|
'[&::-webkit-slider-runnable-track]:bg-white [&::-webkit-slider-runnable-track]:bg-opacity-20 [&::-webkit-slider-runnable-track]:h-[9px] [&::-webkit-slider-runnable-track]:rounded-lg',
|
||||||
|
'[&::-moz-range-track]:bg-white [&::-moz-range-track]:bg-opacity-20 [&::-moz-range-track]:h-1 [&::-moz-range-track]:pb-[5px] [&::-moz-range-track]:rounded-lg',
|
||||||
|
'[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:-mt-1 [&::-webkit-slider-thumb]:w-[33px] [&::-webkit-slider-thumb]:h-4',
|
||||||
|
'[&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:opacity-0 [&::-moz-range-thumb]:w-[33px] [&::-moz-range-thumb]:h-4',
|
||||||
|
)}
|
||||||
type='range'
|
type='range'
|
||||||
value={value.toFixed(2)}
|
value={value.toFixed(2)}
|
||||||
step={max / 101}
|
step={max / 101}
|
||||||
@ -46,7 +54,7 @@ function RangeInput(props: Props) {
|
|||||||
/>
|
/>
|
||||||
<InputOverlay max={max} marginThreshold={marginThreshold} value={value} />
|
<InputOverlay max={max} marginThreshold={marginThreshold} value={value} />
|
||||||
</div>
|
</div>
|
||||||
<div className={className.legendWrapper}>
|
<div className={'flex w-full justify-between text-xs text-opacity-50 text-white font-bold'}>
|
||||||
<span>{markPosPercent > LEFT_MARGIN ? 0 : ''}</span>
|
<span>{markPosPercent > LEFT_MARGIN ? 0 : ''}</span>
|
||||||
<span>{max.toFixed(2)}</span>
|
<span>{max.toFixed(2)}</span>
|
||||||
</div>
|
</div>
|
||||||
@ -54,35 +62,4 @@ function RangeInput(props: Props) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = {
|
|
||||||
containerDefault: 'relative min-h-3 w-full transition-opacity',
|
|
||||||
disabled: 'pointer-events-none opacity-50',
|
|
||||||
legendWrapper: 'flex w-full justify-between text-xs text-opacity-50 text-white font-bold',
|
|
||||||
inputWrapper: 'relative h-[30px]',
|
|
||||||
input: `
|
|
||||||
relative w-full appearance-none bg-transparent hover:cursor-pointer
|
|
||||||
|
|
||||||
[&::-webkit-slider-runnable-track]:bg-white
|
|
||||||
[&::-webkit-slider-runnable-track]:bg-opacity-20
|
|
||||||
[&::-webkit-slider-runnable-track]:h-[9px]
|
|
||||||
[&::-webkit-slider-runnable-track]:rounded-lg
|
|
||||||
|
|
||||||
[&::-moz-range-track]:bg-white
|
|
||||||
[&::-moz-range-track]:bg-opacity-20
|
|
||||||
[&::-moz-range-track]:h-1
|
|
||||||
[&::-moz-range-track]:pb-[5px]
|
|
||||||
[&::-moz-range-track]:rounded-lg
|
|
||||||
|
|
||||||
[&::-webkit-slider-thumb]:appearance-none
|
|
||||||
[&::-webkit-slider-thumb]:-mt-1
|
|
||||||
[&::-webkit-slider-thumb]:w-[33px]
|
|
||||||
[&::-webkit-slider-thumb]:h-4
|
|
||||||
|
|
||||||
[&::-moz-range-thumb]:appearance-none
|
|
||||||
[&::-moz-range-thumb]:opacity-0
|
|
||||||
[&::-moz-range-thumb]:w-[33px]
|
|
||||||
[&::-moz-range-thumb]:h-4
|
|
||||||
`,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default RangeInput
|
export default RangeInput
|
||||||
|
@ -22,8 +22,10 @@ export default function AccountDetailsCard() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const tabs = (
|
const tabs = (
|
||||||
<div className={className.tabWrapper}>
|
<div className='flex items-center w-full pt-4 pl-4 font-semibold bg-white/10'>
|
||||||
<div className={className.tab}>Balances</div>
|
<div className='flex flex-row pb-3 mr-4 border-b-2 border-solid select-none hover:cursor-pointer border-pink'>
|
||||||
|
Balances
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,8 +41,3 @@ export default function AccountDetailsCard() {
|
|||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = {
|
|
||||||
tabWrapper: 'flex w-full items-center bg-white/10 pt-4 pl-4 font-semibold',
|
|
||||||
tab: 'mr-4 pb-3 hover:cursor-pointer select-none flex flex-row border-b-2 border-pink border-solid',
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import classNames from 'classnames'
|
|
||||||
import { useCallback, useMemo } from 'react'
|
import { useCallback, useMemo } from 'react'
|
||||||
|
|
||||||
|
import DisplayCurrency from 'components/DisplayCurrency'
|
||||||
import NumberInput from 'components/NumberInput'
|
import NumberInput from 'components/NumberInput'
|
||||||
import { formatValue } from 'utils/formatters'
|
import { BNCoin } from 'types/classes/BNCoin'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
label?: string
|
label?: string
|
||||||
@ -11,7 +11,6 @@ interface Props {
|
|||||||
amount: BigNumber
|
amount: BigNumber
|
||||||
disabled: boolean
|
disabled: boolean
|
||||||
maxButtonLabel: string
|
maxButtonLabel: string
|
||||||
assetUSDValue: BigNumber
|
|
||||||
amountValueText?: string
|
amountValueText?: string
|
||||||
containerClassName?: string
|
containerClassName?: string
|
||||||
setAmount: (amount: BigNumber) => void
|
setAmount: (amount: BigNumber) => void
|
||||||
@ -27,7 +26,6 @@ export default function AssetAmountInput(props: Props) {
|
|||||||
asset,
|
asset,
|
||||||
disabled,
|
disabled,
|
||||||
setAmount,
|
setAmount,
|
||||||
assetUSDValue,
|
|
||||||
maxButtonLabel,
|
maxButtonLabel,
|
||||||
containerClassName,
|
containerClassName,
|
||||||
onFocus,
|
onFocus,
|
||||||
@ -44,14 +42,14 @@ export default function AssetAmountInput(props: Props) {
|
|||||||
}, [asset.decimals, max])
|
}, [asset.decimals, max])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(className.container, containerClassName)}>
|
<div className={containerClassName}>
|
||||||
<label>
|
<label>
|
||||||
{label}
|
{label}
|
||||||
<div className={className.inputWrapper}>
|
<div className='flex flex-1 flex-row py-3 border-[1px] border-white border-opacity-20 rounded bg-white bg-opacity-5 pl-3 pr-2 mt-2'>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
asset={asset}
|
asset={asset}
|
||||||
amount={amount}
|
amount={amount}
|
||||||
className={className.input}
|
className='border-none bg-transparent outline-none flex-1 !text-left'
|
||||||
maxDecimals={asset.decimals}
|
maxDecimals={asset.decimals}
|
||||||
max={max}
|
max={max}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
@ -61,33 +59,22 @@ export default function AssetAmountInput(props: Props) {
|
|||||||
/>
|
/>
|
||||||
<span>{asset.symbol}</span>
|
<span>{asset.symbol}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className={className.footer}>
|
<div className='flex flex-row flex-1'>
|
||||||
<div className={className.maxButtonWrapper}>
|
<div className='flex flex-row flex-1 mt-2'>
|
||||||
<span className={className.maxButtonLabel}>{maxButtonLabel}</span>
|
<span className='text-xs font-bold'>{maxButtonLabel}</span>
|
||||||
<span className={className.maxValue}>{maxValue}</span>
|
<span className='mx-1 text-xs font-bold text-white text-opacity-60'>{maxValue}</span>
|
||||||
<div className={className.maxButton} onClick={handleMaxClick}>
|
<div
|
||||||
|
className='hover:cursor-pointer select-none bg-white bg-opacity-20 text-2xs !leading-3 font-bold py-0.5 px-1.5 rounded'
|
||||||
|
onClick={handleMaxClick}
|
||||||
|
>
|
||||||
MAX
|
MAX
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={className.assetValue}>
|
<div className='mt-2 text-xs text-white text-opacity-60'>
|
||||||
{formatValue(assetUSDValue.toString(), { prefix: '~ $', minDecimals: 2 })}
|
<DisplayCurrency coin={BNCoin.fromDenomAndBigNumber(asset.denom, amount)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = {
|
|
||||||
container: '',
|
|
||||||
inputWrapper:
|
|
||||||
'flex flex-1 flex-row py-3 border-[1px] border-white border-opacity-20 rounded bg-white bg-opacity-5 pl-3 pr-2 mt-2',
|
|
||||||
input: 'border-none bg-transparent outline-none flex-1 !text-left',
|
|
||||||
footer: 'flex flex-1 flex-row',
|
|
||||||
maxButtonWrapper: 'flex flex-1 flex-row mt-2',
|
|
||||||
maxButtonLabel: 'font-bold text-xs',
|
|
||||||
maxValue: 'font-bold text-xs text-white text-opacity-60 mx-1',
|
|
||||||
maxButton:
|
|
||||||
'hover:cursor-pointer select-none bg-white bg-opacity-20 text-2xs !leading-3 font-bold py-0.5 px-1.5 rounded',
|
|
||||||
assetValue: 'text-xs text-white text-opacity-60 mt-2',
|
|
||||||
}
|
|
||||||
|
@ -16,13 +16,14 @@ export default function OrderTypeSelector(props: Props) {
|
|||||||
const { selected, onChange } = props
|
const { selected, onChange } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className.wrapper}>
|
<div className='flex flex-row flex-1 px-3 pt-4'>
|
||||||
{ORDER_TYPE_TABS.map((tab) => {
|
{ORDER_TYPE_TABS.map((tab) => {
|
||||||
const isSelected = tab.type === selected
|
const isSelected = tab.type === selected
|
||||||
const classes = classNames(className.tab, {
|
const classes = classNames(
|
||||||
[className.selectedTab]: isSelected,
|
'mr-4 pb-2 hover:cursor-pointer select-none flex flex-row',
|
||||||
[className.disabledTab]: tab.isDisabled,
|
isSelected && 'border-b-2 border-pink border-solid',
|
||||||
})
|
tab.isDisabled && 'opacity-20 pointer-events-none',
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConditionalWrapper
|
<ConditionalWrapper
|
||||||
@ -36,7 +37,7 @@ export default function OrderTypeSelector(props: Props) {
|
|||||||
>
|
>
|
||||||
<div onClick={() => onChange(tab.type)} className={classes}>
|
<div onClick={() => onChange(tab.type)} className={classes}>
|
||||||
{tab.type}
|
{tab.type}
|
||||||
{tab.isDisabled && <InfoCircle className={className.infoCircle} />}
|
{tab.isDisabled && <InfoCircle className='w-4 h-4 mt-1 ml-2' />}
|
||||||
</div>
|
</div>
|
||||||
</ConditionalWrapper>
|
</ConditionalWrapper>
|
||||||
)
|
)
|
||||||
@ -44,11 +45,3 @@ export default function OrderTypeSelector(props: Props) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = {
|
|
||||||
wrapper: 'flex flex-1 flex-row px-3 pt-4',
|
|
||||||
tab: 'mr-4 pb-2 hover:cursor-pointer select-none flex flex-row',
|
|
||||||
selectedTab: 'border-b-2 border-pink border-solid',
|
|
||||||
disabledTab: 'opacity-20 pointer-events-none',
|
|
||||||
infoCircle: 'w-4 h-4 ml-2 mt-1',
|
|
||||||
}
|
|
||||||
|
@ -49,18 +49,25 @@ export default function TradeSummary(props: Props) {
|
|||||||
[buyAsset.symbol, routes],
|
[buyAsset.symbol, routes],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const infoLineClasses = 'flex flex-row justify-between flex-1 mb-1 text-xs text-white'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(containerClassName, className.container)}>
|
<div
|
||||||
<div className={className.summaryWrapper}>
|
className={classNames(
|
||||||
<span className={className.title}>Summary</span>
|
containerClassName,
|
||||||
<div className={className.infoLine}>
|
'flex flex-1 flex-col bg-white bg-opacity-5 rounded border-[1px] border-white border-opacity-20',
|
||||||
<span className={className.infoLineLabel}>Fees</span>
|
)}
|
||||||
|
>
|
||||||
|
<div className='flex flex-col flex-1 m-3'>
|
||||||
|
<span className='mb-2 text-xs font-bold'>Summary</span>
|
||||||
|
<div className={infoLineClasses}>
|
||||||
|
<span className='opacity-40'>Fees</span>
|
||||||
<span>{formatAmountWithSymbol(estimatedFee.amount[0])}</span>
|
<span>{formatAmountWithSymbol(estimatedFee.amount[0])}</span>
|
||||||
</div>
|
</div>
|
||||||
{isMargin && (
|
{isMargin && (
|
||||||
<>
|
<>
|
||||||
<div className={className.infoLine}>
|
<div className={infoLineClasses}>
|
||||||
<span className={className.infoLineLabel}>Borrowing</span>
|
<span className='opacity-40'>Borrowing</span>
|
||||||
<FormattedNumber
|
<FormattedNumber
|
||||||
amount={borrowAmount.toNumber()}
|
amount={borrowAmount.toNumber()}
|
||||||
options={{
|
options={{
|
||||||
@ -74,15 +81,15 @@ export default function TradeSummary(props: Props) {
|
|||||||
animate
|
animate
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={className.infoLine}>
|
<div className={infoLineClasses}>
|
||||||
<span className={className.infoLineLabel}>Borrow rate</span>
|
<span className='opacity-40'>Borrow rate</span>
|
||||||
<span>{formatPercent(borrowRate || 0)}</span>
|
<span>{formatPercent(borrowRate || 0)}</span>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={className.infoLine}>
|
<div className={infoLineClasses}>
|
||||||
<span className={className.infoLineLabel}>Route</span>
|
<span className='opacity-40'>Route</span>
|
||||||
<span>{parsedRoutes}</span>
|
<span>{parsedRoutes}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -98,12 +105,3 @@ export default function TradeSummary(props: Props) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = {
|
|
||||||
container:
|
|
||||||
'flex flex-1 flex-col bg-white bg-opacity-5 rounded border-[1px] border-white border-opacity-20 ',
|
|
||||||
title: 'text-xs font-bold mb-2',
|
|
||||||
summaryWrapper: 'flex flex-1 flex-col m-3',
|
|
||||||
infoLine: 'flex flex-1 flex-row text-xs text-white justify-between mb-1',
|
|
||||||
infoLineLabel: 'opacity-40',
|
|
||||||
}
|
|
||||||
|
@ -27,7 +27,7 @@ import { BNCoin } from 'types/classes/BNCoin'
|
|||||||
import { byDenom } from 'utils/array'
|
import { byDenom } from 'utils/array'
|
||||||
import { defaultFee } from 'utils/constants'
|
import { defaultFee } from 'utils/constants'
|
||||||
import { getCapLeftWithBuffer } from 'utils/generic'
|
import { getCapLeftWithBuffer } from 'utils/generic'
|
||||||
import { BN, asyncThrottle } from 'utils/helpers'
|
import { asyncThrottle, BN } from 'utils/helpers'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
buyAsset: Asset
|
buyAsset: Asset
|
||||||
@ -138,24 +138,6 @@ export default function SwapForm(props: Props) {
|
|||||||
return maxBuyableAmountEstimation.multipliedBy(marginRatio)
|
return maxBuyableAmountEstimation.multipliedBy(marginRatio)
|
||||||
}, [marginRatio, maxBuyableAmountEstimation])
|
}, [marginRatio, maxBuyableAmountEstimation])
|
||||||
|
|
||||||
const [buyAssetValue, sellAssetValue] = useMemo(() => {
|
|
||||||
const buyAssetPrice = prices.find(byDenom(buyAsset.denom))?.amount ?? BN_ZERO
|
|
||||||
const sellAssetPrice = prices.find(byDenom(sellAsset.denom))?.amount ?? BN_ZERO
|
|
||||||
|
|
||||||
return [
|
|
||||||
buyAssetPrice.multipliedBy(buyAssetAmount.shiftedBy(-buyAsset.decimals)),
|
|
||||||
sellAssetPrice.multipliedBy(sellAssetAmount.shiftedBy(-sellAsset.decimals)),
|
|
||||||
]
|
|
||||||
}, [
|
|
||||||
prices,
|
|
||||||
buyAsset.denom,
|
|
||||||
buyAsset.decimals,
|
|
||||||
sellAsset.denom,
|
|
||||||
sellAsset.decimals,
|
|
||||||
buyAssetAmount,
|
|
||||||
sellAssetAmount,
|
|
||||||
])
|
|
||||||
|
|
||||||
const swapTx = useMemo(() => {
|
const swapTx = useMemo(() => {
|
||||||
const borrowCoin = sellAssetAmount.isGreaterThan(sellSideMarginThreshold)
|
const borrowCoin = sellAssetAmount.isGreaterThan(sellSideMarginThreshold)
|
||||||
? BNCoin.fromDenomAndBigNumber(
|
? BNCoin.fromDenomAndBigNumber(
|
||||||
@ -262,7 +244,6 @@ export default function SwapForm(props: Props) {
|
|||||||
amount={buyAssetAmount}
|
amount={buyAssetAmount}
|
||||||
setAmount={onChangeBuyAmount}
|
setAmount={onChangeBuyAmount}
|
||||||
asset={buyAsset}
|
asset={buyAsset}
|
||||||
assetUSDValue={buyAssetValue}
|
|
||||||
maxButtonLabel='Max Amount:'
|
maxButtonLabel='Max Amount:'
|
||||||
disabled={isConfirming}
|
disabled={isConfirming}
|
||||||
/>
|
/>
|
||||||
@ -286,7 +267,6 @@ export default function SwapForm(props: Props) {
|
|||||||
max={maxSellAmount}
|
max={maxSellAmount}
|
||||||
amount={sellAssetAmount}
|
amount={sellAssetAmount}
|
||||||
setAmount={onChangeSellAmount}
|
setAmount={onChangeSellAmount}
|
||||||
assetUSDValue={sellAssetValue}
|
|
||||||
asset={sellAsset}
|
asset={sellAsset}
|
||||||
maxButtonLabel='Balance:'
|
maxButtonLabel='Balance:'
|
||||||
disabled={isConfirming}
|
disabled={isConfirming}
|
||||||
|
Loading…
Reference in New Issue
Block a user