feat: integrate pyth_sponsor_rule — sponsor Pyth fees#40
Merged
JustaLiang merged 6 commits intomainfrom Apr 17, 2026
Merged
Conversation
Default trading path now uses PythSponsor to pay Pyth price update fees instead of splitting from tx.gas. The sponsor Fund hot-potato is created before Hermes fetch, split for each feed update, then reimbursed onto the TradingRequest (adding PythSponsorRule witness). - Add pyth_sponsor_rule to codegen pipeline and constants - Add pythSponsorRulePackageId / pythSponsorId to WaterXConfig - Modify buildPythPriceUpdateCalls to accept optional sponsorFund - New addPriceFeeds default: sponsor-paid Hermes+Pyth update - selfPayPyth param opts out to legacy gas-paid path - Add reimburseSponsorFund helper (utils/sponsor.ts) - Thread sponsorFund through all trading builders and user functions - Remove updatePythPrice:true from e2e tests (default sponsor covers it) - Add xStock markets to lifecycle e2e test coverage Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- fetchSimulatedUsdPricesForBases falls back to per-base simulates when batch TX fails (DEEP's broken aggregator no longer blocks all markets) - Add per-base price guard in trading-negative and prd-product-coverage - Fix cancelOrder test: use scaled triggerPrice + wildcard orderTypeTag - Adjust BTC e2ePtb sizes to match on-chain position (size=588) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…iceFeeds - buildResolveSize now uses trading::resolve_size (takes collateralPriceResult) instead of deprecated trading::resize - Export addPriceFeeds for test helpers and custom PTB construction - Simplify simulate-resize-size helper to use addPriceFeeds Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Exact max leverage (positive) and max+1 (negative) now use leverage-only path with on-chain resolve_size — no approxPrice off-chain estimate. Removed unused fetchSimulatedUsdPricesForBases import from prd tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Withdraws nearly all collateral from existing positions — verifies on-chain err_exceed_max_leverage (104) abort when remaining collateral would push effective leverage above market max. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Guard against undefined prices[base] (e.g. DEEP broken aggregator) in scratchSimulateOpenApproxOracle — prevents NaN→BigInt crash in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PythSponsorto pay Pyth price update fees (notx.splitCoins(tx.gas, ...))selfPayPythparam on all trading builders to opt out and pay from gaspyth_sponsor_rulepackage (testnet deployed)reimburseSponsorFund()addsPythSponsorRulewitness toTradingRequestbefore executeupdatePythPrice: truefrom e2e tests — default sponsor path covers itTest plan
pnpm typecheckpassespnpm lintpassesupdatePythPrice: trueremoved — default sponsor path works🤖 Generated with Claude Code