call addPerpTriggerOrder
This commit is contained in:
parent
419f7d607c
commit
207fddd242
|
@ -224,7 +224,7 @@ export default function TradeForm() {
|
|||
|
||||
const onTradeTypeChange = (tradeType) => {
|
||||
setTradeType(tradeType)
|
||||
if (isMarketOrder) {
|
||||
if (['Market', 'Trigger Market'].includes(tradeType)) {
|
||||
setIoc(true)
|
||||
if (isTriggerOrder) {
|
||||
setPrice(triggerPrice)
|
||||
|
@ -270,6 +270,12 @@ export default function TradeForm() {
|
|||
type: 'error',
|
||||
})
|
||||
return
|
||||
} else if (!triggerPrice && isTriggerOrder) {
|
||||
notify({
|
||||
title: 'Missing trigger price',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const mangoAccount = useMangoStore.getState().selectedMangoAccount.current
|
||||
|
@ -313,20 +319,37 @@ export default function TradeForm() {
|
|||
orderType
|
||||
)
|
||||
} else {
|
||||
txid = await mangoClient.placePerpOrder(
|
||||
mangoGroup,
|
||||
mangoAccount,
|
||||
mangoGroup.mangoCache,
|
||||
market,
|
||||
wallet,
|
||||
side,
|
||||
orderPrice,
|
||||
baseSize,
|
||||
tradeType === 'Market' ? 'market' : orderType,
|
||||
0,
|
||||
side === 'buy' ? askInfo : bidInfo,
|
||||
reduceOnly
|
||||
)
|
||||
if (isTriggerOrder) {
|
||||
txid = await mangoClient.addPerpTriggerOrder(
|
||||
mangoGroup,
|
||||
mangoAccount,
|
||||
market,
|
||||
wallet,
|
||||
orderType,
|
||||
side,
|
||||
orderPrice,
|
||||
baseSize,
|
||||
side === 'buy' ? 'below' : 'above', // triggerCondition
|
||||
triggerPrice,
|
||||
reduceOnly,
|
||||
0 // clientOrderId
|
||||
)
|
||||
} else {
|
||||
txid = await mangoClient.placePerpOrder(
|
||||
mangoGroup,
|
||||
mangoAccount,
|
||||
mangoGroup.mangoCache,
|
||||
market,
|
||||
wallet,
|
||||
side,
|
||||
orderPrice,
|
||||
baseSize,
|
||||
tradeType === 'Market' ? 'market' : orderType,
|
||||
0,
|
||||
side === 'buy' ? askInfo : bidInfo, // book side used for ConsumeEvents
|
||||
reduceOnly
|
||||
)
|
||||
}
|
||||
}
|
||||
notify({ title: 'Successfully placed trade', txid })
|
||||
setPrice('')
|
||||
|
|
|
@ -995,9 +995,9 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@blockworks-foundation/mango-client@git+https://github.com/blockworks-foundation/mango-client-v3.git":
|
||||
version "3.0.24"
|
||||
resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#8ba250d97aa6167ab3d9fc12eecc36edec482ce7"
|
||||
"@blockworks-foundation/mango-client@git+https://github.com/blockworks-foundation/mango-client-v3.git#dd/marketorder":
|
||||
version "3.0.23"
|
||||
resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#3fd55b5a1503b2e3b023d4b936c3b23619accd4e"
|
||||
dependencies:
|
||||
"@project-serum/serum" "0.13.55"
|
||||
"@project-serum/sol-wallet-adapter" "^0.2.0"
|
||||
|
|
Loading…
Reference in New Issue