add settle borrow instruction to deposit transaction
This commit is contained in:
parent
7d26ec8fac
commit
861eb34a76
|
@ -9,6 +9,7 @@ import useMarket from '../hooks/useMarket'
|
|||
import { ElementTitle } from './styles'
|
||||
import { InformationCircleIcon } from '@heroicons/react/outline'
|
||||
import Tooltip from './Tooltip'
|
||||
import { sleep } from '../utils'
|
||||
|
||||
const BalancesTable = () => {
|
||||
const balances = useBalances()
|
||||
|
@ -33,6 +34,7 @@ const BalancesTable = () => {
|
|||
markets,
|
||||
wallet
|
||||
)
|
||||
await sleep(250)
|
||||
actions.fetchMarginAccounts()
|
||||
} catch (e) {
|
||||
console.warn('Error settling all:', e)
|
||||
|
|
|
@ -62,12 +62,12 @@ const DepositSrmModal = ({ isOpen, onClose }) => {
|
|||
? mangoSrmAccountsForOwner[0].publicKey
|
||||
: undefined
|
||||
)
|
||||
.then((_mangoSrmAcct: PublicKey) => {
|
||||
.then(async (_mangoSrmAcct: PublicKey) => {
|
||||
setSubmitting(false)
|
||||
actions.fetchMangoSrmAccounts()
|
||||
actions.fetchWalletBalances()
|
||||
actions.fetchMangoGroup()
|
||||
onClose()
|
||||
await actions.fetchWalletBalances()
|
||||
await actions.fetchMangoSrmAccounts()
|
||||
await actions.fetchMangoGroup()
|
||||
})
|
||||
.catch((err) => {
|
||||
setSubmitting(false)
|
||||
|
|
|
@ -55,10 +55,10 @@ const WithdrawModal = ({ isOpen, onClose }) => {
|
|||
walletSrmAccount.publicKey,
|
||||
Number(inputAmount)
|
||||
)
|
||||
.then((_transSig: string) => {
|
||||
.then(async (_transSig: string) => {
|
||||
setSubmitting(false)
|
||||
onClose()
|
||||
actions.fetchWalletBalances()
|
||||
await actions.fetchWalletBalances()
|
||||
actions.fetchMangoSrmAccounts()
|
||||
actions.fetchMangoGroup()
|
||||
})
|
||||
|
|
|
@ -140,6 +140,23 @@ export async function deposit(
|
|||
|
||||
const transaction = new Transaction()
|
||||
transaction.add(instruction)
|
||||
|
||||
// settle borrow
|
||||
const settleKeys = [
|
||||
{ isSigner: false, isWritable: true, pubkey: mangoGroup.publicKey },
|
||||
{ isSigner: false, isWritable: true, pubkey: marginAccount.publicKey },
|
||||
{ isSigner: true, isWritable: false, pubkey: wallet.publicKey },
|
||||
{ isSigner: false, isWritable: false, pubkey: SYSVAR_CLOCK_PUBKEY },
|
||||
]
|
||||
const setttleBorrowsData = encodeMangoInstruction({
|
||||
SettleBorrow: { tokenIndex: new BN(tokenIndex), quantity: nativeQuantity },
|
||||
})
|
||||
const settleBorrowsInstruction = new TransactionInstruction({
|
||||
keys: settleKeys,
|
||||
data: setttleBorrowsData,
|
||||
programId,
|
||||
})
|
||||
transaction.add(settleBorrowsInstruction)
|
||||
const signers = []
|
||||
|
||||
const functionName = 'Deposit'
|
||||
|
|
Loading…
Reference in New Issue