separate try/catch for avg entry and break even on perps

This commit is contained in:
tjs 2022-03-27 13:11:00 -04:00
parent 5ea856e2b2
commit 79ebdba891
3 changed files with 15 additions and 10 deletions

View File

@ -39,19 +39,23 @@ export const collectPerpPosition = (
let avgEntryPrice = 0,
breakEvenPrice = 0
const perpTradeHistory = tradeHistory.filter(
(t) => t.marketName === marketConfig.name
)
try {
const perpTradeHistory = tradeHistory.filter(
(t) => t.marketName === marketConfig.name
)
avgEntryPrice = perpAccount
.getAverageOpenPrice(mangoAccount, perpMarket, perpTradeHistory)
.toNumber()
} catch (e) {
console.error(marketConfig.name, e)
}
try {
breakEvenPrice = perpAccount
.getBreakEvenPrice(mangoAccount, perpMarket, perpTradeHistory)
.toNumber()
} catch (e) {
// console.error(e)
console.error(marketConfig.name, e)
}
const basePosition = perpMarket?.baseLotsToNumber(perpAccount.basePosition)
@ -92,6 +96,7 @@ const usePerpPositions = () => {
const mangoCache = useMangoStore(mangoCacheSelector)
const allMarkets = useMangoStore(marketsSelector)
const tradeHistory = useMangoStore((s) => s.tradeHistory.parsed)
useEffect(() => {
if (
mangoAccount &&

View File

@ -16,7 +16,7 @@
"lint-all": "yarn lint && yarn type-check"
},
"dependencies": {
"@blockworks-foundation/mango-client": "^3.3.25",
"@blockworks-foundation/mango-client": "^3.3.26",
"@headlessui/react": "^0.0.0-insiders.2dbc38c",
"@heroicons/react": "^1.0.0",
"@jup-ag/react-hook": "^1.0.0-beta.16",

View File

@ -1001,10 +1001,10 @@
"@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0"
"@blockworks-foundation/mango-client@^3.3.25":
version "3.3.25"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-client/-/mango-client-3.3.25.tgz#7eb1dcb639c265d41436ff4809ea9b8e606b1a1c"
integrity sha512-N/jiqNWOi1X0cvOAsbaLj5N7oWWSaJIxzYe68VasS5a4FK/DpkUM0TSOGBvvrkcuFkp+t5TAzF1VcTCNPTXeOw==
"@blockworks-foundation/mango-client@^3.3.26":
version "3.3.26"
resolved "https://registry.yarnpkg.com/@blockworks-foundation/mango-client/-/mango-client-3.3.26.tgz#85bcca5c7dd077ab553d9a45ea68f8a43ee36319"
integrity sha512-aAvKX5Outlr+mwDRRmIiVfNPqxQuXaInhvIMXFUkoLNiXQnUha76lBYPissy/hMmSUuXA2jEdMPGX8eLjwG9mg==
dependencies:
"@project-serum/anchor" "^0.21.0"
"@project-serum/serum" "0.13.55"