-
-
Save zhe-t/60938c69e29276b7a9f098e1b0672c79 to your computer and use it in GitHub Desktop.
import { Connection, SendOptions } from '@solana/web3.js'; | |
export type JitoRegion = 'mainnet' | 'amsterdam' | 'frankfurt' | 'ny' | 'tokyo'; | |
export const JitoEndpoints = { | |
mainnet: 'https://mainnet.block-engine.jito.wtf/api/v1/transactions', | |
amsterdam: 'https://amsterdam.mainnet.block-engine.jito.wtf/api/v1/transactions', | |
frankfurt: 'https://frankfurt.mainnet.block-engine.jito.wtf/api/v1/transactions', | |
ny: 'https://ny.mainnet.block-engine.jito.wtf/api/v1/transactions', | |
tokyo: 'https://tokyo.mainnet.block-engine.jito.wtf/api/v1/transactions', | |
}; | |
export function getJitoEndpoint(region: JitoRegion) { | |
return JitoEndpoints[region]; | |
} | |
/** | |
* Send a transaction using Jito. This only supports sending a single transaction on mainnet only. | |
* See https://jito-labs.gitbook.io/mev/searcher-resources/json-rpc-api-reference/transactions-endpoint/sendtransaction. | |
* @param args.serialisedTx - A single transaction to be sent, in serialised form | |
* @param args.region - The region of the Jito endpoint to use | |
*/ | |
export async function sendTxUsingJito({ | |
serializedTx, | |
region = 'mainnet' | |
}: { | |
serializedTx: Uint8Array | Buffer | number[]; | |
region: JitoRegion; | |
}) { | |
let rpcEndpoint = getJitoEndpoint(region); | |
let encodedTx = bs58.encode(serializedTx); | |
let payload = { | |
jsonrpc: "2.0", | |
id: 1, | |
method: "sendTransaction", | |
params: [encodedTx] | |
}; | |
let res = await fetch(`${rpcEndpoint}?bundleOnly=true`, { | |
method: 'POST', | |
body: JSON.stringify(payload), | |
headers: { 'Content-Type': 'application/json' } | |
}); | |
let json = await res.json(); | |
if (json.error) { | |
throw new Error(json.error.message); | |
} | |
return json; | |
} |
@yanCode thats not my issue anymore I resolved that part by downgrading marginfi to 4.04. My main issue now is Iโm trying to use Jupiter quote/swaps an I get a unit8array or getting over the solana transaction size limit of 1232. I also see ppl using a custom on chain program and their transactions succeeds.
you have discord or telegram we can chat there and if you got time can assist me!
one solution i know to bypass the transaction limit is to split the oversize transaction to many, jito bundle can submit up to 5 transactions together.
but if the transaction is returned by Jupiter quote/swaps, i don't think it should be oversize. because itself can execute the swap transaction if we don't send it via jito bundle.
I also see ppl using a custom on chain program
, well, it sounds intertesting to me.
my telgram is @tszsy
I'm very familiar with MEV project and made some profits from it.
If you need help, please let me know @cool0328 in telegram.