use new placePerpOrder market order type when closing pos
This commit is contained in:
parent
1c04018f65
commit
9cb4ccf519
|
@ -42,16 +42,16 @@ const MarketCloseModal: FunctionComponent<MarketCloseModalProps> = ({
|
|||
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
|
||||
const { askInfo, bidInfo } = useMangoStore.getState().selectedMarket
|
||||
const wallet = useMangoStore.getState().wallet.current
|
||||
const connection = useMangoStore.getState().connection.current
|
||||
|
||||
if (!wallet || !mangoGroup || !mangoAccount) return
|
||||
setSubmitting(true)
|
||||
|
||||
try {
|
||||
const reloadedMangoAccount = await mangoAccount.reload(connection)
|
||||
const perpAccount = reloadedMangoAccount.perpAccounts[marketIndex]
|
||||
const perpAccount = mangoAccount.perpAccounts[marketIndex]
|
||||
const side = perpAccount.basePosition.gt(ZERO_BN) ? 'sell' : 'buy'
|
||||
const size = Math.abs(market.baseLotsToNumber(perpAccount.basePosition))
|
||||
// send a large size to ensure we are reducing the entire position
|
||||
const size =
|
||||
Math.abs(market.baseLotsToNumber(perpAccount.basePosition)) * 2
|
||||
|
||||
const orderPrice = calculateTradePrice(
|
||||
'Market',
|
||||
|
@ -78,9 +78,10 @@ const MarketCloseModal: FunctionComponent<MarketCloseModalProps> = ({
|
|||
side,
|
||||
orderPrice,
|
||||
size,
|
||||
'ioc',
|
||||
0,
|
||||
side === 'buy' ? askInfo : bidInfo
|
||||
'market',
|
||||
0, // client order id
|
||||
side === 'buy' ? askInfo : bidInfo,
|
||||
true // reduce only
|
||||
)
|
||||
await sleep(500)
|
||||
actions.reloadMangoAccount()
|
||||
|
|
22
yarn.lock
22
yarn.lock
|
@ -997,8 +997,9 @@
|
|||
|
||||
"@blockworks-foundation/mango-client@git+https://github.com/blockworks-foundation/mango-client-v3.git#dd/marketorder":
|
||||
version "3.0.24"
|
||||
resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#4cc24f3aec295ee93490eff2352bf98412927fc4"
|
||||
resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#dc1b328947d47186997b03a7465ff4d5c26bbe76"
|
||||
dependencies:
|
||||
"@project-serum/anchor" "^0.16.2"
|
||||
"@project-serum/serum" "0.13.55"
|
||||
"@project-serum/sol-wallet-adapter" "^0.2.0"
|
||||
"@solana/spl-token" "^0.1.6"
|
||||
|
@ -1883,14 +1884,14 @@
|
|||
integrity sha512-XmdEOrKQ8a1Y/yxQFOMbC47G/V2VDO1GvMRnl4O75M4GW/abC5tnfzadQYkqEveqRM1dEJGFFegfPNA2vvx2iw==
|
||||
|
||||
"@types/node@*":
|
||||
version "16.10.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.2.tgz#5764ca9aa94470adb4e1185fe2e9f19458992b2e"
|
||||
integrity sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==
|
||||
version "16.10.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.3.tgz#7a8f2838603ea314d1d22bb3171d899e15c57bd5"
|
||||
integrity sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==
|
||||
|
||||
"@types/node@^12.12.54":
|
||||
version "12.20.27"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.27.tgz#4141fcad57c332a120591de883e26fe4bb14aaea"
|
||||
integrity sha512-qZdePUDSLAZRXXV234bLBEUM0nAQjoxbcSwp1rqSMUe1rZ47mwU6OjciR/JvF1Oo8mc0ys6GE0ks0HGgqAZoGg==
|
||||
version "12.20.28"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.28.tgz#4b20048c6052b5f51a8d5e0d2acbf63d5a17e1e2"
|
||||
integrity sha512-cBw8gzxUPYX+/5lugXIPksioBSbE42k0fZ39p+4yRzfYjN6++eq9kAPdlY9qm+MXyfbk9EmvCYAYRn380sF46w==
|
||||
|
||||
"@types/node@^14.14.25":
|
||||
version "14.17.3"
|
||||
|
@ -2542,16 +2543,11 @@ bindings@^1.3.0:
|
|||
dependencies:
|
||||
file-uri-to-path "1.0.0"
|
||||
|
||||
bn.js@5.1.3, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9, bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.1, bn.js@^5.1.2:
|
||||
bn.js@5.1.3, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9, bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.1, bn.js@^5.1.2, bn.js@^5.2.0:
|
||||
version "5.1.3"
|
||||
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b"
|
||||
integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==
|
||||
|
||||
bn.js@^5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002"
|
||||
integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==
|
||||
|
||||
boolbase@^1.0.0, boolbase@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
|
||||
|
|
Loading…
Reference in New Issue