add fee estimation to governance instructions
This commit is contained in:
parent
99c7d20bea
commit
35715084ba
|
@ -78,6 +78,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
const [quoteToken, setQuoteToken] = useState<null | string>(null)
|
||||
const [loadingMarketProps, setLoadingMarketProps] = useState(false)
|
||||
const [proposing, setProposing] = useState(false)
|
||||
const fee = mangoStore((s) => s.priorityFee)
|
||||
const [marketPk, setMarketPk] = useState('')
|
||||
const [currentView, setCurrentView] = useState(VIEWS.BASE_TOKEN)
|
||||
const [createOpenbookMarketModal, setCreateOpenbookMarket] = useState(false)
|
||||
|
@ -199,6 +200,7 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
index,
|
||||
proposalTx,
|
||||
vsrClient!,
|
||||
fee,
|
||||
)
|
||||
setProposalPk(proposalAddress.toBase58())
|
||||
setCurrentView(VIEWS.SUCCESS)
|
||||
|
@ -442,7 +444,9 @@ const ListMarket = ({ goBack }: { goBack: () => void }) => {
|
|||
<div className="mt-2 flex items-center justify-between">
|
||||
<p>{t('price-tick')}</p>
|
||||
<p className="text-th-fgd-2">
|
||||
{tradingParams.priceIncrement}
|
||||
{tradingParams.priceIncrement <= 1e-9
|
||||
? '1e-8'
|
||||
: tradingParams.priceIncrement.toString()}
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
|
|
|
@ -101,6 +101,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
const vsrClient = GovernanceStore((s) => s.vsrClient)
|
||||
const governances = GovernanceStore((s) => s.governances)
|
||||
const loadingRealm = GovernanceStore((s) => s.loadingRealm)
|
||||
const fee = mangoStore((s) => s.priorityFee)
|
||||
const loadingVoter = GovernanceStore((s) => s.loadingVoter)
|
||||
const proposals = GovernanceStore((s) => s.proposals)
|
||||
const getCurrentVotingPower = GovernanceStore((s) => s.getCurrentVotingPower)
|
||||
|
@ -590,6 +591,7 @@ const ListToken = ({ goBack }: { goBack: () => void }) => {
|
|||
advForm.tokenIndex,
|
||||
proposalTx,
|
||||
vsrClient,
|
||||
fee,
|
||||
)
|
||||
setProposalPk(proposalAddress.toBase58())
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import mangoStore, { CLUSTER } from '@store/mangoStore'
|
||||
import { ModalProps } from '../../types/modal'
|
||||
import Modal from '../shared/Modal'
|
||||
import { OPENBOOK_PROGRAM_ID } from '@blockworks-foundation/mango-v4'
|
||||
import {
|
||||
OPENBOOK_PROGRAM_ID,
|
||||
createComputeBudgetIx,
|
||||
} from '@blockworks-foundation/mango-v4'
|
||||
import { ChangeEvent, useEffect, useState } from 'react'
|
||||
import Label from '@components/forms/Label'
|
||||
import Input from '@components/forms/Input'
|
||||
|
@ -65,6 +68,7 @@ const CreateOpenbookMarketModal = ({
|
|||
}: ModalProps & CreateOpenbookMarketModalProps) => {
|
||||
const { t } = useTranslation(['governance'])
|
||||
const connection = mangoStore((s) => s.connection)
|
||||
const fee = mangoStore((s) => s.priorityFee)
|
||||
const { connect, signAllTransactions, connected, publicKey } = useWallet()
|
||||
|
||||
const [form, setForm] = useState({ ...defaultFormValues })
|
||||
|
@ -105,6 +109,7 @@ const CreateOpenbookMarketModal = ({
|
|||
const latestBlockhash = await connection.getLatestBlockhash('confirmed')
|
||||
for (const chunk of txChunks) {
|
||||
const tx = new Transaction()
|
||||
tx.add(createComputeBudgetIx(fee))
|
||||
tx.add(...chunk.instructions)
|
||||
tx.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight
|
||||
tx.recentBlockhash = latestBlockhash.blockhash
|
||||
|
|
|
@ -20,6 +20,7 @@ import { useCallback, useState } from 'react'
|
|||
import Loading from '@components/shared/Loading'
|
||||
import { WhirlpoolContext, buildWhirlpoolClient } from '@orca-so/whirlpools-sdk'
|
||||
import { LIQUIDITY_STATE_LAYOUT_V4 } from '@raydium-io/raydium-sdk'
|
||||
import { createComputeBudgetIx } from '@blockworks-foundation/mango-v4'
|
||||
|
||||
const poolAddressError = 'no-pool-address-found'
|
||||
|
||||
|
@ -56,6 +57,7 @@ const CreateSwitchboardOracleModal = ({
|
|||
}: RaydiumProps | OrcaProps) => {
|
||||
const { t } = useTranslation(['governance'])
|
||||
const connection = mangoStore((s) => s.connection)
|
||||
const fee = mangoStore((s) => s.priorityFee)
|
||||
const wallet = useWallet()
|
||||
const quoteTokenName = 'USD'
|
||||
const pythUsdOracle = 'Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD'
|
||||
|
@ -330,6 +332,7 @@ const CreateSwitchboardOracleModal = ({
|
|||
for (const chunk of txChunks) {
|
||||
const tx = new Transaction()
|
||||
const singers = [...chunk.flatMap((x) => x.signers)]
|
||||
tx.add(createComputeBudgetIx(fee))
|
||||
tx.add(...chunk.flatMap((x) => x.ixns))
|
||||
tx.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight
|
||||
tx.recentBlockhash = latestBlockhash.blockhash
|
||||
|
|
|
@ -52,6 +52,7 @@ const DashboardSuggestedValues = ({
|
|||
//do not deconstruct wallet is used for anchor to sign
|
||||
const wallet = useWallet()
|
||||
const connection = mangoStore((s) => s.connection)
|
||||
const fee = mangoStore((s) => s.priorityFee)
|
||||
const voter = GovernanceStore((s) => s.voter)
|
||||
const vsrClient = GovernanceStore((s) => s.vsrClient)
|
||||
const proposals = GovernanceStore((s) => s.proposals)
|
||||
|
@ -259,6 +260,7 @@ const DashboardSuggestedValues = ({
|
|||
index,
|
||||
proposalTx,
|
||||
vsrClient!,
|
||||
fee,
|
||||
)
|
||||
window.open(
|
||||
`https://dao.mango.markets/dao/MNGO/proposal/${proposalAddress.toBase58()}`,
|
||||
|
|
|
@ -36,6 +36,7 @@ import { TelemetryEvents } from 'utils/telemetry'
|
|||
import { Prize, getClaimsAsPrizes } from './RewardsComponents'
|
||||
import { notify } from 'utils/notifications'
|
||||
import { sleep } from 'utils'
|
||||
import { createComputeBudgetIx } from '@blockworks-foundation/mango-v4'
|
||||
|
||||
const CLAIM_BUTTON_CLASSES =
|
||||
'raised-button group mx-auto block h-12 px-6 pt-1 font-rewards text-xl after:rounded-lg focus:outline-none lg:h-14'
|
||||
|
@ -84,6 +85,7 @@ const ClaimPage = () => {
|
|||
|
||||
const { client } = mangoStore()
|
||||
const { publicKey } = useWallet()
|
||||
const fee = mangoStore((s) => s.priorityFee)
|
||||
const { data: seasonData } = useCurrentSeason()
|
||||
const currentSeason = seasonData?.season_id
|
||||
const previousSeason = currentSeason ? currentSeason - 1 : null
|
||||
|
@ -227,7 +229,10 @@ const ClaimPage = () => {
|
|||
}
|
||||
chunk(claimIxes, 2).map((x) =>
|
||||
transactionInstructions.push({
|
||||
instructionsSet: x,
|
||||
instructionsSet: [
|
||||
new TransactionInstructionWithSigners(createComputeBudgetIx(fee)),
|
||||
...x,
|
||||
],
|
||||
sequenceType: SequenceType.Parallel,
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -1178,10 +1178,11 @@ const mangoStore = create<MangoStore>()(
|
|||
if (!altKeys) return
|
||||
|
||||
const addresses = sampleSize(altKeys, MAX_PRIORITY_FEE_KEYS)
|
||||
console.log(addresses)
|
||||
const fees = await connection.getRecentPrioritizationFees({
|
||||
lockedWritableAccounts: addresses,
|
||||
})
|
||||
|
||||
console.log(fees)
|
||||
if (fees.length < 1) return
|
||||
|
||||
// get max priority fee per slot (and sort by slot from old to new)
|
||||
|
|
|
@ -23,6 +23,7 @@ import { MANGO_MINT } from 'utils/constants'
|
|||
import { MANGO_GOVERNANCE_PROGRAM, MANGO_REALM_PK } from '../constants'
|
||||
import { VsrClient } from '../voteStakeRegistryClient'
|
||||
import { updateVoterWeightRecord } from './updateVoteWeightRecord'
|
||||
import { createComputeBudgetIx } from '@blockworks-foundation/mango-v4'
|
||||
|
||||
export const createProposal = async (
|
||||
connection: Connection,
|
||||
|
@ -34,6 +35,7 @@ export const createProposal = async (
|
|||
proposalIndex: number,
|
||||
proposalInstructions: TransactionInstruction[],
|
||||
client: VsrClient,
|
||||
fee: number,
|
||||
) => {
|
||||
const instructions: TransactionInstruction[] = []
|
||||
const walletPk = wallet.publicKey!
|
||||
|
@ -132,6 +134,7 @@ export const createProposal = async (
|
|||
const latestBlockhash = await connection.getLatestBlockhash('confirmed')
|
||||
for (const chunk of txChunks) {
|
||||
const tx = new Transaction()
|
||||
tx.add(createComputeBudgetIx(fee))
|
||||
tx.add(...chunk)
|
||||
tx.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight
|
||||
tx.recentBlockhash = latestBlockhash.blockhash
|
||||
|
|
Loading…
Reference in New Issue