Skip to content

Commit

Permalink
decode withdraw fee mango instrucitons (#1784)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 authored Aug 21, 2023
1 parent 0bb83b6 commit c696a79
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
68 changes: 68 additions & 0 deletions components/instructions/programs/mangoV4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
coinTiersToNames,
} from '@blockworks-foundation/mango-v4-settings/lib/helpers/listingTools'
import { tryParseKey } from '@tools/validators/pubkey'
import Loading from '@components/Loading'
// import { snakeCase } from 'snake-case'
// import { sha256 } from 'js-sha256'

Expand Down Expand Up @@ -1030,6 +1031,73 @@ const instructions = () => ({
}
},
},
73195: {
name: 'Withdraw all token fees',
accounts: [
{ name: 'Group' },
{ name: 'Bank' },
{ name: 'Vault' },
{ name: 'Destination' },
],
getDataUI: async (
connection: Connection,
data: Uint8Array,
accounts: AccountMetaData[]
) => {
const group = accounts[0].pubkey
const bank = accounts[1].pubkey
const client = await getClient(connection)
const mangoGroup = await client.getGroup(group)
const mint = [...mangoGroup.banksMapByMint.values()].find(
(x) => x[0]!.publicKey.equals(bank)!
)![0]!.mint!
const tokenSymbol = tokenPriceService.getTokenInfo(mint.toBase58())
?.symbol
try {
return (
<div>
{tokenSymbol ? tokenSymbol : <Loading className="w-5"></Loading>}
</div>
)
} catch (e) {
console.log(e)
return <div>{JSON.stringify(data)}</div>
}
},
},
15219: {
name: 'Withdraw all perp fees',
accounts: [
{ name: 'Group' },
{ name: 'Perp market' },
{ name: 'Bank' },
{ name: 'Vault' },
{ name: 'Destination' },
],
getDataUI: async (
connection: Connection,
data: Uint8Array,
accounts: AccountMetaData[]
) => {
const group = accounts[0].pubkey
const perpMarket = accounts[1].pubkey
const client = await getClient(connection)
const mangoGroup = await client.getGroup(group)
const marketName = [
...mangoGroup.perpMarketsMapByName.values(),
].find((x) => x.publicKey.equals(perpMarket))?.name
try {
return (
<div>
{marketName ? marketName : <Loading className="w-5"></Loading>}
</div>
)
} catch (e) {
console.log(e)
return <div>{JSON.stringify(data)}</div>
}
},
},
19895: {
name: 'Create Mango Account',
accounts: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const WithdrawPerpFees = ({
bank.mint,
ataAddress,
form.governedAccount.extensions.transferAddress!,
form.governedAccount.extensions.transferAddress!
wallet.publicKey
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const AdminTokenWithdrawTokenFees = ({
bank.mint,
ataAddress,
form.governedAccount.extensions.transferAddress!,
form.governedAccount.extensions.transferAddress!
wallet.publicKey
)
)
}
Expand Down

1 comment on commit c696a79

@vercel
Copy link

@vercel vercel bot commented on c696a79 Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

governance-ui – ./

app.realms.today
governance-ui-git-main-solana-labs.vercel.app
governance-ui-solana-labs.vercel.app

Please sign in to comment.