-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Solana relayFeeCalculator and gasPriceOracle #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: epic/svm-client
Are you sure you want to change the base?
Conversation
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
I can confirm that the gas price oracle is giving reasonable estimates for priority fees/base fees (assuming that the fill transaction only requires a single signature). The relay fee calculator simulation is still failing somewhere in the fill instruction, and I haven't figured out if this is an issue with how the instruction is being created or if I am just testing with relay data values that would cause the SvmSpoke to revert, but even if it is incorrect, this should at most require a small change in |
* @param extraSeed An optional extra seed. Defaults to 0. | ||
* @returns The PDA for the State account. | ||
*/ | ||
export async function getStatePda(programId: string, extraSeed = 0): Promise<Address> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally just copied the format for these functions from #978
const recentPriorityFees = await provider.getRecentPrioritizationFees(instructionAddresses).send(); | ||
|
||
const nonzeroPrioritizationFees = recentPriorityFees.map((value) => value.prioritizationFee).filter((fee) => fee > 0); | ||
const totalPrioritizationFees = nonzeroPrioritizationFees.reduce((acc, fee) => acc + fee, BigInt(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am definitely open for ideas on how to optimize the priority fee calculation. I can get nonzero priority fees for the most part, presumably since TOKEN_PROGRAM_ADDRESS
is one of the instructionAddresses
, but a lot of slots suggest a priority fee of zero for one reason for another, and this RPC by default will query 100 slots, so it's possible under this method that we obtain a prioritization fee which is dominated by data from older slots.
Signed-off-by: bennett <[email protected]>
I'm now getting both reasonable gas price estimations and reasonable compute unit estimations. |
Signed-off-by: bennett <[email protected]>
This should implement the relayFeeCalculator (and by extension, the gasPriceOracle) for svm. It will contain some other utilities which are used by those structures.