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

Merged
merged 21 commits into from
May 8, 2025

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
@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
bmzig added 2 commits April 17, 2025 16:55
Signed-off-by: bennett <[email protected]>
): Promise<Address<string>> {
const [associatedToken] = await getProgramDerivedAddress({
programAddress: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,
seeds: [owner.toBuffer(), SvmAddress.from(tokenProgramId).toBuffer(), mint.toBuffer()],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the user of Buffer here a hangover from the contracts implementation? Seeds in Kit have to conform to type Seed = ReadonlyUint8Array | string;, so it should be OK to pass strings in; I think this should work:

Suggested change
seeds: [owner.toBuffer(), SvmAddress.from(tokenProgramId).toBuffer(), mint.toBuffer()],
seeds: [owner.toAddress(), tokenProgramId, mint.toAddress()],

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'm actually not too sure how the string encoding is supposed to work here, but each character is treated as a byte, so passing in a string here will have getProgramDerivedAddress interpret the input as 66 byte strings, not 32 bytes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, .toAddress() would be completely wrong. The kit readme has an example on how to supply the seeds correctly: https://github.com/anza-xyz/kit/blob/0bfe90b1c1e1c1a2dd90c46408c7cab995692f7b/packages/addresses/README.md#getprogramderivedaddress

@bmzig bmzig requested a review from pxrl May 7, 2025 20:51
@bmzig bmzig merged commit 0146d3c into epic/svm-client May 8, 2025
4 checks passed
@bmzig bmzig deleted the bz/relayFeeSol branch May 8, 2025 15:52
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.

2 participants