Skip to content

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

Open
wants to merge 10 commits into
base: epic/svm-client
Choose a base branch
from

Conversation

bmzig
Copy link
Contributor

@bmzig bmzig commented Apr 10, 2025

This should implement the relayFeeCalculator (and by extension, the gasPriceOracle) for svm. It will contain some other utilities which are used by those structures.

@bmzig bmzig changed the base branch from master to epic/svm-client April 11, 2025 18:22
bmzig added 6 commits April 11, 2025 13:26
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
Signed-off-by: bennett <[email protected]>
@bmzig bmzig changed the title [wip] feat: relayFeeCalculator & gasPriceOracle feat: Solana relayFeeCalculator and gasPriceOracle Apr 16, 2025
@bmzig
Copy link
Contributor Author

bmzig commented Apr 16, 2025

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 fillRelayInstruction.

@bmzig bmzig marked this pull request as ready for review April 16, 2025 18:56
* @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> {
Copy link
Contributor Author

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));
Copy link
Contributor Author

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.

@bmzig
Copy link
Contributor Author

bmzig commented Apr 17, 2025

I'm now getting both reasonable gas price estimations and reasonable compute unit estimations.

@bmzig bmzig requested review from nicholaspai, dohaki and pxrl April 17, 2025 17:27
Signed-off-by: bennett <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant