refactor(xpnts): unify all debt accounting in aPNTs#200
Open
jhfnetboy wants to merge 4 commits into
Open
Conversation
…ings (Section 8) Records all findings from Codex + local adversarial dual-track review after PR #195 merge: 2 Critical, 7 High, 8 Medium, 6 Low/Info with UUPS-upgradeable vs redeploy fix paths. Deferred to v5.4 per user decision — no code changes in this commit.
- GTokenAuthorization (EIP-3009 gasless transfers) replaces plain GToken - deploy-core: add --non-interactive flag for Sepolia/live envs to prevent forge 1.4+ broadcast prompt blocking in non-TTY environments - verify-all.sh: update GToken verification path/args for GTokenAuthorization (constructor now takes cap + factory address) - config.sepolia.json: updated with new contract addresses (2026-05-13) - verify.sepolia.contracts-5-13.md: 12/12 contracts verified on Etherscan New Sepolia addresses: GToken (GTokenAuthorization): 0xbC17B6C319561bcA805981fC2846e4678f9114Cb Registry proxy: 0x3dfeBE636eDA211E0a783308Cf0CB31892686d67 SuperPaymaster proxy: 0x506962D17AEA6E7A15fd3479D8c4E2ABBBF91112
All internal protocol debt is now recorded and settled in aPNTs. xPNTs conversions are pushed to the boundaries (burn/repay functions inside xPNTsToken itself) rather than computed at each call site. Key changes: - xPNTsToken.debts: unit changed from xPNTs → aPNTs - burnFromWithOpHash(amountAPNTs): converts to xPNTs internally (ceil) - recordDebt / recordDebtWithOpHash: accept aPNTs directly - repayDebt(amountXPNTs): converts to aPNTs before reducing debt - _update auto-repay: converts minted xPNTs to aPNTs before comparing - SuperPaymaster.configureOperator: drops exchangeRate param (rate read live from xPNTsToken.exchangeRate() at validation time) - OperatorConfig.exchangeRate field removed; ISuperPaymaster updated - validatePaymasterUserOp / dryRunValidation: rate commitment check uses IxPNTsToken(token).exchangeRate() instead of stale OperatorConfig copy - postOp: passes finalCharge (aPNTs) directly to _recordDebt (renamed) - getAvailableCredit: no longer needs rate conversion (debt is aPNTs) - Version bumps: SuperPaymaster-5.3.3, XPNTs-3.4.0 Fixes the dual-exchangeRate divergence (OperatorConfig.exchangeRate vs xPNTsToken.exchangeRate()) that could silently cause stale-rate debt recording after a community updates their token rate. Tests: 923/923 pass (0 failures)
- _update auto-repay: floor → ceil so repayXPNTs ≥ 1 when repayAPNTs > 0; invariant ceil(floor(v/r)×r) ≤ v proven safe (no over-burn) - transferFrom single-tx limit: convert xPNTs → aPNTs before comparing against maxSingleTxLimit (which is now denominated in aPNTs after refactor) - Regression test: rate=3e17, debt=3, mint=1 → debt cleared + 1 xPNT burned (old floor code burned 0, leaving protocol with cleared debt but no collateral)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
All internal protocol debt is now stored in aPNTs (not xPNTs). xPNTs conversions only happen at user-facing boundaries (burn / repay).
Key changes
xPNTsToken.solburnFromWithOpHash(amountAPNTs): converts aPNTs → xPNTs =ceil(aPNTs × rate / 1e18)before burningrecordDebt/recordDebtWithOpHash: accept aPNTs directly (no conversion)repayDebt(amountXPNTs): converts xPNTs → aPNTs =floor(xPNTs × 1e18 / rate)before reducing debt_updateauto-repay: converts minted xPNTs → aPNTs (floor), reduces debt, burnsceil(repayAPNTs × rate / 1e18)xPNTsmaxSingleTxLimitis now in aPNTs;transferFromlimit check converts xPNTs → aPNTs before comparingXPNTs-3.4.0SuperPaymaster.solconfigureOperator: drops staleexchangeRateparam; reads live rate fromxPNTsToken.exchangeRate()validatePaymasterUserOp/dryRunValidation: rate-commitment check uses live rate instead ofconfig.exchangeRatepostOp: passesfinalChargeaPNTs directly to_recordDebt(removes xPNTs conversion)getAvailableCredit:getDebt()returns aPNTs directly (no conversion needed)SuperPaymaster-5.3.3ISuperPaymaster.sol/IxPNTsToken.sol: interface updates matching the aboveBug fixes included
_updatefloor-rounding zero-burn: rate=3e17, debt=3, mint=1 → debt cleared but 0 xPNTs burnedrepayXPNTsto ceil; invariantceil(floor(v/r)×r) ≤ vproven safetransferFromsingle-tx limit compared xPNTs against aPNTs denominated limitRounding convention
burnFromWithOpHashaPNTs→xPNTsrepayDebtxPNTs→aPNTs_updatemint→aPNTs_updaterepayAPNTs→xPNTs≤ valueinvariantTest plan
forge test: 924/924 pass (was 923/923 before adding regression test)test_AutoRepay_ZeroBurn_Regression: proves ceil fix burns 1 xPNT not 0 for the PoC caseFollow-up (deferred, not in this PR)
exchangeRate()STATICCALL invalidatePaymasterUserOp— document as permissive-bundler-only or add a cached ratefeature/v5.4-credit-purchase(removes xPNTs conversion from credit purchase path)