Merge commit '4875c77c530978a69defb89ace7e3446971e8641' into edit-orders
This commit is contained in:
commit
e12707acc6
|
@ -56,7 +56,7 @@ export const getTokenInMax = (
|
||||||
group,
|
group,
|
||||||
inputBank.mint,
|
inputBank.mint,
|
||||||
outputBank.mint,
|
outputBank.mint,
|
||||||
1
|
inputBank.uiPrice / outputBank.uiPrice
|
||||||
),
|
),
|
||||||
inputBank.mintDecimals
|
inputBank.mintDecimals
|
||||||
)
|
)
|
||||||
|
|
|
@ -313,40 +313,48 @@ const AdvancedTradeForm = () => {
|
||||||
const maintProjectedHealth = useMemo(() => {
|
const maintProjectedHealth = useMemo(() => {
|
||||||
const group = mangoStore.getState().group
|
const group = mangoStore.getState().group
|
||||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||||
if (!mangoAccount || !group || !Number(tradeForm.baseSize)) return 100
|
if (
|
||||||
|
!mangoAccount ||
|
||||||
|
!group ||
|
||||||
|
!Number.isInteger(Number(tradeForm.baseSize))
|
||||||
|
)
|
||||||
|
return 100
|
||||||
|
|
||||||
let simulatedHealthRatio = 0
|
let simulatedHealthRatio = 0
|
||||||
|
try {
|
||||||
if (selectedMarket instanceof Serum3Market) {
|
if (selectedMarket instanceof Serum3Market) {
|
||||||
simulatedHealthRatio =
|
simulatedHealthRatio =
|
||||||
tradeForm.side === 'sell'
|
tradeForm.side === 'sell'
|
||||||
? mangoAccount.simHealthRatioWithSerum3AskUiChanges(
|
? mangoAccount.simHealthRatioWithSerum3AskUiChanges(
|
||||||
group,
|
group,
|
||||||
parseFloat(tradeForm.baseSize),
|
parseFloat(tradeForm.baseSize),
|
||||||
selectedMarket.serumMarketExternal,
|
selectedMarket.serumMarketExternal,
|
||||||
HealthType.maint
|
HealthType.maint
|
||||||
)
|
)
|
||||||
: mangoAccount.simHealthRatioWithSerum3BidUiChanges(
|
: mangoAccount.simHealthRatioWithSerum3BidUiChanges(
|
||||||
group,
|
group,
|
||||||
parseFloat(tradeForm.baseSize),
|
parseFloat(tradeForm.baseSize),
|
||||||
selectedMarket.serumMarketExternal,
|
selectedMarket.serumMarketExternal,
|
||||||
HealthType.maint
|
HealthType.maint
|
||||||
)
|
)
|
||||||
} else if (selectedMarket instanceof PerpMarket) {
|
} else if (selectedMarket instanceof PerpMarket) {
|
||||||
simulatedHealthRatio =
|
simulatedHealthRatio =
|
||||||
tradeForm.side === 'sell'
|
tradeForm.side === 'sell'
|
||||||
? mangoAccount.simHealthRatioWithPerpAskUiChanges(
|
? mangoAccount.simHealthRatioWithPerpAskUiChanges(
|
||||||
group,
|
group,
|
||||||
selectedMarket.perpMarketIndex,
|
selectedMarket.perpMarketIndex,
|
||||||
parseFloat(tradeForm.baseSize),
|
parseFloat(tradeForm.baseSize),
|
||||||
parseFloat(tradeForm.price)
|
parseFloat(tradeForm.price)
|
||||||
)
|
)
|
||||||
: mangoAccount.simHealthRatioWithPerpBidUiChanges(
|
: mangoAccount.simHealthRatioWithPerpBidUiChanges(
|
||||||
group,
|
group,
|
||||||
selectedMarket.perpMarketIndex,
|
selectedMarket.perpMarketIndex,
|
||||||
parseFloat(tradeForm.baseSize),
|
parseFloat(tradeForm.baseSize),
|
||||||
parseFloat(tradeForm.price)
|
parseFloat(tradeForm.price)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Error calculating projected health: ', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
return simulatedHealthRatio > 100
|
return simulatedHealthRatio > 100
|
||||||
|
|
Loading…
Reference in New Issue