fix contributed srm bug

This commit is contained in:
Tyler Shipe 2021-04-13 20:41:28 -04:00
parent 8b418dbe5f
commit de620e9a3f
2 changed files with 6 additions and 10 deletions

View File

@ -4,18 +4,14 @@ import useMangoStore from '../stores/useMangoStore'
import useMarketList from './useMarketList'
const getOrderBookAccounts = (market, accountInfos) => {
const bidBuffer = Buffer.from(
accountInfos[market._decoded.bids.toString()].data
)
const askBuffer = Buffer.from(
accountInfos[market._decoded.asks.toString()].data
)
const bidData = accountInfos[market._decoded.bids.toString()]?.data
const askData = accountInfos[market._decoded.asks.toString()]?.data
return {
bidOrderBook:
market && bidBuffer ? Orderbook.decode(market, bidBuffer) : null,
market && bidData ? Orderbook.decode(market, Buffer.from(bidData)) : null,
askOrderBook:
market && askBuffer ? Orderbook.decode(market, askBuffer) : null,
market && askData ? Orderbook.decode(market, Buffer.from(askData)) : null,
}
}

View File

@ -196,12 +196,12 @@ const useMangoStore = create<MangoStore>((set, get) => ({
)
if (usersMangoSrmAccounts.length) {
set((state) => {
state.selectedMangoGroup.srmAccountsForOwner = usersMangoSrmAccounts
state.wallet.srmAccountsForOwner = usersMangoSrmAccounts
const totalSrmDeposits = usersMangoSrmAccounts.reduce(
(prev, cur) => prev + cur.amount,
0
)
state.selectedMangoGroup.contributedSrm = nativeToUi(
state.wallet.contributedSrm = nativeToUi(
totalSrmDeposits,
SRM_DECIMALS
)