From 6277984325d948df8276bb2b75b56efc4f24e347 Mon Sep 17 00:00:00 2001 From: tjs Date: Thu, 9 Feb 2023 16:22:54 -0500 Subject: [PATCH] use latest client --- components/MangoProvider.tsx | 4 ++-- components/account/CreateAccountForm.tsx | 4 ++-- components/trade/UnsettledTrades.tsx | 9 ++++----- hooks/useUnsettledPerpPositions.ts | 2 +- pages/dashboard/index.tsx | 24 ------------------------ pages/dashboard/mangoaccount.tsx | 2 +- store/mangoStore.ts | 4 ++-- yarn.lock | 22 +++++++++++----------- 8 files changed, 23 insertions(+), 48 deletions(-) diff --git a/components/MangoProvider.tsx b/components/MangoProvider.tsx index a00941ed..59a19fcb 100644 --- a/components/MangoProvider.tsx +++ b/components/MangoProvider.tsx @@ -82,7 +82,7 @@ const HydrateStore = () => { mangoAccount.publicKey, decodedMangoAccount ) - await newMangoAccount.reloadAccountData(client) + await newMangoAccount.reloadSerum3OpenOrders(client) actions.fetchOpenOrders() // newMangoAccount.spotOpenOrdersAccounts = // mangoAccount.spotOpenOrdersAccounts @@ -120,7 +120,7 @@ const ReadOnlyMangoAccount = () => { const client = mangoStore.getState().client const pk = new PublicKey(ma) const readOnlyMangoAccount = await client.getMangoAccount(pk) - await readOnlyMangoAccount.reloadAccountData(client) + await readOnlyMangoAccount.reloadSerum3OpenOrders(client) await actions.fetchOpenOrders(readOnlyMangoAccount) set((state) => { state.mangoAccount.current = readOnlyMangoAccount diff --git a/components/account/CreateAccountForm.tsx b/components/account/CreateAccountForm.tsx index 8c745aa0..f0885b11 100644 --- a/components/account/CreateAccountForm.tsx +++ b/components/account/CreateAccountForm.tsx @@ -62,13 +62,13 @@ const CreateAccountForm = ({ const pk = wallet.adapter.publicKey const mangoAccounts = await client.getMangoAccountsForOwner(group, pk!) const reloadedMangoAccounts = await Promise.all( - mangoAccounts.map((ma) => ma.reloadAccountData(client)) + mangoAccounts.map((ma) => ma.reloadSerum3OpenOrders(client)) ) const newAccount = mangoAccounts.find( (acc) => acc.accountNum === newAccountNum ) if (newAccount) { - await newAccount.reloadAccountData(client) + await newAccount.reloadSerum3OpenOrders(client) set((s) => { s.mangoAccount.current = newAccount s.mangoAccounts = reloadedMangoAccounts diff --git a/components/trade/UnsettledTrades.tsx b/components/trade/UnsettledTrades.tsx index 6b8d518d..2fa5bad5 100644 --- a/components/trade/UnsettledTrades.tsx +++ b/components/trade/UnsettledTrades.tsx @@ -79,7 +79,7 @@ const UnsettledTrades = ({ try { const mangoAccounts = await client.getAllMangoAccounts(group) const perpPosition = mangoAccount.getPerpPosition(market.perpMarketIndex) - const mangoAccountPnl = perpPosition?.getEquityUi(group, market) + const mangoAccountPnl = perpPosition?.getEquityUi(market) if (mangoAccountPnl === undefined) throw new Error('Unable to get account P&L') @@ -89,9 +89,8 @@ const UnsettledTrades = ({ .map((m) => ({ mangoAccount: m, pnl: - m - ?.getPerpPosition(market.perpMarketIndex) - ?.getEquityUi(group, market) || 0, + m?.getPerpPosition(market.perpMarketIndex)?.getEquityUi(market) || + 0, })) .sort((a, b) => sign * (a.pnl - b.pnl)) @@ -199,7 +198,7 @@ const UnsettledTrades = ({ {' '} USDC diff --git a/hooks/useUnsettledPerpPositions.ts b/hooks/useUnsettledPerpPositions.ts index b826280c..e0da07f9 100644 --- a/hooks/useUnsettledPerpPositions.ts +++ b/hooks/useUnsettledPerpPositions.ts @@ -13,7 +13,7 @@ const useUnsettledPerpPositions = () => { return perpPositions.filter((p) => { const market = group?.getPerpMarketByMarketIndex(p.marketIndex) if (!market || !group) return false - return p.getUnsettledPnlUi(group, market) !== 0 + return p.getUnsettledPnlUi(market) !== 0 }) }, [mangoAccountAddress]) diff --git a/pages/dashboard/index.tsx b/pages/dashboard/index.tsx index 06284943..0c0dfe17 100644 --- a/pages/dashboard/index.tsx +++ b/pages/dashboard/index.tsx @@ -193,12 +193,6 @@ const Dashboard: NextPage = () => { label="Collected fees native" value={bank.collectedFeesNative.toNumber()} /> - { )}/ ${perpMarket.initBaseLiabWeight.toFixed(4)}`} /> - - - { /> ()( } if (newSelectedMangoAccount) { - await newSelectedMangoAccount.reloadAccountData(client) + await newSelectedMangoAccount.reloadSerum3OpenOrders(client) set((state) => { state.mangoAccount.current = newSelectedMangoAccount state.mangoAccount.initialLoad = false @@ -735,7 +735,7 @@ const mangoStore = create()( } await Promise.all( - mangoAccounts.map((ma) => ma.reloadAccountData(client)) + mangoAccounts.map((ma) => ma.reloadSerum3OpenOrders(client)) ) set((state) => { diff --git a/yarn.lock b/yarn.lock index ff3f0d68..86d7abf6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23,8 +23,8 @@ regenerator-runtime "^0.13.11" "@blockworks-foundation/mango-v4@https://github.com/blockworks-foundation/mango-v4.git#ts-client": - version "0.0.1-beta.6" - resolved "https://github.com/blockworks-foundation/mango-v4.git#2f754115d06745282b863e7a905bdb25bf85d309" + version "0.4.3" + resolved "https://github.com/blockworks-foundation/mango-v4.git#35763da947e3b15175dcee5c81633e409803b2f7" dependencies: "@project-serum/anchor" "^0.25.0" "@project-serum/serum" "^0.13.65" @@ -369,9 +369,9 @@ sha.js "^2.4.11" "@noble/ed25519@^1.7.0": - version "1.7.1" - resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.1.tgz#6899660f6fbb97798a6fbd227227c4589a454724" - integrity sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw== + version "1.7.3" + resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.3.tgz#57e1677bf6885354b466c38e2b620c62f45a7123" + integrity sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ== "@noble/hashes@^1.1.2": version "1.2.0" @@ -1509,9 +1509,9 @@ integrity sha512-evMDG1bC4rgQg4ku9tKpuMh5iBNEwNa3tf9zRHdP1qlv+1WUg44xat4IxCE14gIpZRGUUWAx2VhItCZc25NfMA== "@types/node@*": - version "18.11.18" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" - integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== + version "18.13.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850" + integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg== "@types/node@17.0.23": version "17.0.23" @@ -2313,9 +2313,9 @@ bin-links@4.0.1: write-file-atomic "^5.0.0" binance-api-node@^0.12.0: - version "0.12.2" - resolved "https://registry.yarnpkg.com/binance-api-node/-/binance-api-node-0.12.2.tgz#a7f9b8d94c2d75f64cb709d7b041b80da1e0e79d" - integrity sha512-X9zKjYhcp+smUMxmZvJdcqd22wQnD8gyjRKCmf1dno9Ft/mr9ZavtzHzjJaoXGbHbcGI2gSSg6fa8ozfT6B6Yg== + version "0.12.3" + resolved "https://registry.yarnpkg.com/binance-api-node/-/binance-api-node-0.12.3.tgz#1703282ce7ef1b52a893d7de046fd305806808f7" + integrity sha512-JMBOmcva/nlM9k0SDG3nBm2i/kSNva74jDU55j/mpoXMbb4AYP9luG1JuI5dgPvmkaKiR2A05MPI5aQiLhWTDw== dependencies: https-proxy-agent "^5.0.0" isomorphic-fetch "^3.0.0"