add settle all spot markets to balances

This commit is contained in:
Tyler Shipe 2021-06-24 18:15:23 -04:00
parent 619295d2e0
commit e9cdeb8a08
2 changed files with 8 additions and 17 deletions

View File

@ -1,37 +1,28 @@
import { useBalances } from '../hooks/useBalances'
import useMangoStore from '../stores/useMangoStore'
// import { settleAll } from '../utils/mango'
import useConnection from '../hooks/useConnection'
import useMangoStore, { mangoClient } from '../stores/useMangoStore'
import Button from '../components/Button'
import { notify } from '../utils/notifications'
import { Table, Thead, Tbody, Tr, Th, Td } from 'react-super-responsive-table'
import { InformationCircleIcon } from '@heroicons/react/outline'
import Tooltip from './Tooltip'
import { sleep } from '../utils'
import { PublicKey } from '@solana/web3.js'
import { Market } from '@project-serum/serum'
const BalancesTable = () => {
const balances = useBalances()
const { programId, connection } = useConnection()
const actions = useMangoStore((s) => s.actions)
async function handleSettleAll() {
const markets = Object.values(
useMangoStore.getState().selectedMangoGroup.markets
)
const mangoAccount = useMangoStore.getState().selectedMangoAccount.current
const mangoGroup = useMangoStore.getState().selectedMangoGroup.current
const markets = useMangoStore.getState().selectedMangoGroup.markets
const wallet = useMangoStore.getState().wallet.current
try {
// await settleAll(
// connection,
// new PublicKey(programId),
// mangoGroup,
// mangoAccount,
// markets,
// wallet
// )
const spotMarkets = Object.values(markets).filter(
(mkt) => mkt instanceof Market
) as Market[]
await mangoClient.settleAll(mangoGroup, mangoAccount, spotMarkets, wallet)
await sleep(250)
actions.fetchMangoAccounts()
} catch (e) {

View File

@ -988,7 +988,7 @@
"@blockworks-foundation/mango-client@git+https://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:x-oauth-basic@github.com/blockworks-foundation/mango-client-v3.git":
version "3.0.1"
resolved "git+https://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:x-oauth-basic@github.com/blockworks-foundation/mango-client-v3.git#c749b362dec7c2f60de1154d7167c0f6032d6999"
resolved "git+https://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:x-oauth-basic@github.com/blockworks-foundation/mango-client-v3.git#36bd0f0de7b531c6d7ff8cc491146ad3368a0214"
dependencies:
"@project-serum/serum" "^0.13.38"
"@project-serum/sol-wallet-adapter" "^0.2.0"