Skip to content

Estimate Sui gas budget dynamically via dry-run#1058

Merged
0xh3rman merged 8 commits intomainfrom
feature/sui-dynamic-gas-budget
Apr 7, 2026
Merged

Estimate Sui gas budget dynamically via dry-run#1058
0xh3rman merged 8 commits intomainfrom
feature/sui-dynamic-gas-budget

Conversation

@0xh3rman
Copy link
Copy Markdown
Collaborator

@0xh3rman 0xh3rman commented Apr 6, 2026

Replace the static 25M gas budget with actual estimation using dry-run simulation. Build transactions with a placeholder budget, dry-run to get real gas costs, then rebuild with the correct budget. Pre-built transactions (Swap/Generic) skip the rebuild.

Test:

  • Send SUI
  • Send USDC
  • Swap SUI <> USDC
  • Stake / Unstake
  • Wallet Connect x Cetus

…value

Replace the static 25M gas budget with actual estimation using dry-run simulation.
Build transactions with a placeholder budget, dry-run to get real gas costs, then
rebuild with the correct budget. Pre-built transactions (Swap/Generic) skip the rebuild.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Sui gas budget calculation and transaction building logic, transitioning from a hardcoded gas budget to a dynamic estimation approach using dry runs. Key changes include updating the SuiRpc enum to support optional gas prices and refactoring encoding functions into internal builder patterns. Review feedback identifies a compilation error in preload.rs regarding field access and a potential arithmetic underflow in the gas budget calculation.

Comment thread crates/gem_sui/src/provider/preload.rs
Comment thread crates/gem_sui/src/gas_budget.rs Outdated
Comment thread crates/gem_sui/src/models/transaction.rs Outdated
Comment thread crates/gem_sui/src/provider/preload.rs
Comment thread crates/gem_sui/src/provider/preload.rs Outdated
Comment thread crates/gem_sui/src/gas_budget.rs Outdated
@0xh3rman 0xh3rman merged commit 55e9e03 into main Apr 7, 2026
4 checks passed
@0xh3rman 0xh3rman deleted the feature/sui-dynamic-gas-budget branch April 7, 2026 07:06
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