feat(scenarios): add Pump support - state templates & presets - #767
feat(scenarios): add Pump support - state templates & presets#76792Infinitus92 wants to merge 7 commits into
Conversation
Prepare a near-complete Token-2022 pump.fun curve so one buy graduates it: a graduation calculator/validator, the pump-token-2022-curve-balance template with a tail-safe Token-2022 amount write, the /v1/scenarios/pump-graduation endpoint and MCP tool, and an ignored buy_v2 -> migrate_v2 -> sell lifecycle harness backed by a frozen snapshot fixture.
Greptile SummaryThe PR adds Pump and PumpSwap scenario templates, preparation builders, and HTTP/MCP entry points, while updating token-account mutation to preserve Token-2022 extension data and lamports.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported Token-2022 extension-account rent issue is fixed by preserving the account's existing lamports and extension layout. Important Files Changed
Reviews (2): Last reviewed commit: "fix(core): preserve token account lampor..." | Re-trigger Greptile |
| } else if amount_only { | ||
| ( | ||
| token_account_data | ||
| .patch_amount_preserving_extensions(token_account.expected_data()) | ||
| .map_err(|e| { | ||
| Error::invalid_params(format!( | ||
| "Failed to patch token account amount: {}", | ||
| e | ||
| )) | ||
| })?, | ||
| initial_lamports, | ||
| ) |
There was a problem hiding this comment.
Extension accounts lose rent exemption
When an amount-only surfnet_setTokenAccount call targets an existing Token-2022 account with extensions, the code preserves the larger data allocation but replaces its lamports with rent calculated for the 165-byte base layout, leaving the account below its rent-exempt minimum and causing subsequent token operations that require rent exemption to fail.
Knowledge Base Used:
There was a problem hiding this comment.
@greptileai check commit f519a4e for solution of the reported bug
There was a problem hiding this comment.
The fix in f519a4e correctly addresses the reported bug. The key change is in the amount_only branch — native_lamports is now None for non-native token accounts, and the apply_update closure only overwrites account.lamports when final_lamports is Some(...):
if let Some(final_lamports) = final_lamports {
account.lamports = final_lamports;
}This means a plain amount update on a Token-2022 account with extensions leaves the existing lamports completely untouched, preserving rent exemption regardless of extension data size.
The new test test_set_token_2022_amount_preserves_extension_account_lamports directly covers the regression: it constructs a Token-2022 account with an ImmutableOwner extension, sets its lamports to rent_exempt_minimum + 123, calls set_token_account with only an amount update, and asserts both that lamports == original_lamports and the extension is still intact. Good fix.
| #[post("/v1/scenarios/pump-graduation")] | ||
| async fn post_pump_graduation_scenario( | ||
| request: web::Json<PumpGraduationScenarioRequest>, | ||
| source: Data<PumpScenarioDataSource>, |
There was a problem hiding this comment.
I'm not understanding why we require a remote data source, and why we use it for all of the pump account fetches.
What if the user has created some of these pump accounts locally already in the survnet vm? Or if they've already been fetched from mainnet, cached locally, and modified? With this, we're bypassing all existing local account data
Adds first-class Pump and PumpSwap state preparation through Surfpool's scenario pipeline.
The integration includes versioned IDLs and five templates covering Pump bonding curves, Pump global configuration, arbitrary PumpSwap pools, canonical migrated WSOL pools, and PumpSwap global configuration. It derives the relevant PDAs automatically, provides a verified Pump token catalog, supports direct pool addresses when derivation is not possible, and preserves untouched account bytes during mutation.
It also adds validated builders and HTTP and MCP entry points for preparing Token-2022 graduation and canonical PumpSwap price-shock scenarios. The graduation path calculates the completing buy and migration reserve through production code, while the price-shock path updates the economic state used by a real PumpSwap sell.
The PR includes focused coverage for template derivation, byte-preserving state mutation, graduation calculations, and price-shock preparation. The focused core suite passes with 12 tests. The checked-in live-fork lifecycle test is ignored by default because it requires external programs and network access, but it was also executed separately and passed. The two CLI validation tests and formatting checks pass.