Compare commits

...

2 Commits

Author SHA1 Message Date
Adrian Brzeziński eb3d1a08c5 fix connection 2024-04-07 15:37:38 +02:00
Adrian Brzeziński ad49d89f33 use backup rpc 2024-04-07 15:35:37 +02:00
1 changed files with 19 additions and 4 deletions

View File

@ -82,6 +82,9 @@ const MANGO_BOOST_ID = new PublicKey(
'zF2vSz6V9g1YHGmfrzsY497NJzbRr84QUrPry4bLQ25',
)
export const LITE_RPC_URL = 'https://api.mngo.cloud/lite-rpc/v1/'
const backupConnections = [new Connection(LITE_RPC_URL, 'recent')]
const GROUP_JLP = new PublicKey('AKeMSYiJekyKfwCc3CUfVNDVAiqk9FfbQVMY3G7RUZUf')
const GROUP_V1 = new PublicKey('78b8f4cGCwmZ9ysPFMWLaLTkkaYnUjwMJYStWe5RTSSX')
@ -114,12 +117,14 @@ const initMangoClient = (
opts = {
prioritizationFee: DEFAULT_PRIORITY_FEE,
fallbackOracleConfig: FALLBACK_ORACLES,
multipleConnections: backupConnections,
},
): { lst: MangoClient; jlp: MangoClient } => {
return {
lst: MangoClient.connect(provider, CLUSTER, MANGO_V4_ID['mainnet-beta'], {
prioritizationFee: opts.prioritizationFee,
fallbackOracleConfig: opts.fallbackOracleConfig,
multipleConnections: opts.multipleConnections,
idsSource: 'api',
postSendTxCallback: ({ txid }: { txid: string }) => {
notify({
@ -133,6 +138,7 @@ const initMangoClient = (
jlp: MangoClient.connect(provider, CLUSTER, MANGO_BOOST_ID, {
prioritizationFee: opts.prioritizationFee,
fallbackOracleConfig: opts.fallbackOracleConfig,
multipleConnections: opts.multipleConnections,
idsSource: 'get-program-accounts',
postSendTxCallback: ({ txid }: { txid: string }) => {
notify({
@ -326,7 +332,12 @@ const mangoStore = create<MangoStore>()(
}
const provider = new AnchorProvider(connection, emptyWallet, options)
provider.opts.skipPreflight = true
const client = initMangoClient(provider)
const priorityFee = get()?.priorityFee ?? DEFAULT_PRIORITY_FEE
const client = initMangoClient(provider, {
prioritizationFee: priorityFee,
fallbackOracleConfig: FALLBACK_ORACLES,
multipleConnections: backupConnections,
})
return {
// leverage stake
@ -760,10 +771,11 @@ const mangoStore = create<MangoStore>()(
options,
)
provider.opts.skipPreflight = true
const priorityFee = get().priorityFee ?? DEFAULT_PRIORITY_FEE
const priorityFee = get()?.priorityFee ?? DEFAULT_PRIORITY_FEE
const client = initMangoClient(provider, {
prioritizationFee: priorityFee,
fallbackOracleConfig: FALLBACK_ORACLES,
multipleConnections: backupConnections,
})
set((s) => {
@ -814,10 +826,11 @@ const mangoStore = create<MangoStore>()(
options,
)
newProvider.opts.skipPreflight = true
const priorityFee = get().priorityFee ?? DEFAULT_PRIORITY_FEE
const priorityFee = get()?.priorityFee ?? DEFAULT_PRIORITY_FEE
const newClient = initMangoClient(newProvider, {
prioritizationFee: priorityFee,
fallbackOracleConfig: FALLBACK_ORACLES,
multipleConnections: backupConnections,
})
set((state) => {
state.connection = newConnection
@ -873,9 +886,11 @@ const mangoStore = create<MangoStore>()(
const provider = client.jlp.program.provider as AnchorProvider
provider.opts.skipPreflight = true
const priorityFee = get()?.priorityFee ?? DEFAULT_PRIORITY_FEE
const newClient = initMangoClient(provider, {
prioritizationFee: feeEstimate,
prioritizationFee: priorityFee,
fallbackOracleConfig: FALLBACK_ORACLES,
multipleConnections: backupConnections,
})
set((state) => {
state.priorityFee = feeEstimate