Skip to content

feat: seed initial bond allowances in BondTreasuryPaymaster constructor#110

Merged
aliXsed merged 1 commit intomainfrom
fix/bond-treasury-initial-allowances
Apr 10, 2026
Merged

feat: seed initial bond allowances in BondTreasuryPaymaster constructor#110
aliXsed merged 1 commit intomainfrom
fix/bond-treasury-initial-allowances

Conversation

@aliXsed
Copy link
Copy Markdown
Collaborator

@aliXsed aliXsed commented Apr 10, 2026

Summary

Add initialBondAllowances[] constructor parameter to BondTreasuryPaymaster, parallel to the existing initialWhitelistedUsers[]. Each whitelisted user now receives a non-zero userBondAllowance at deploy time, eliminating the need for a separate setUserBondAllowance transaction after deployment.

Problem

Previously, the constructor whitelisted users but left their userBondAllowance at zero. A separate admin call to setUserBondAllowance() was required before any sponsored claims could work. This was both easy to forget and created a window where the user was whitelisted but unable to use sponsored bonds.

Changes

  • BondTreasuryPaymaster.sol: New uint256[] memory initialBondAllowances constructor arg (must match initialWhitelistedUsers length, enforced by ArrayLengthMismatch error). Allowances are set in the same loop that seeds the whitelist.
  • DeploySwarmUpgradeableZkSync.s.sol: Reads FLEET_OPERATOR_BOND_ALLOWANCE env var (defaults to BOND_QUOTA) and passes it to the constructor.
  • deploy_swarm_contracts_zksync.sh: Exports FLEET_OPERATOR_BOND_ALLOWANCE (defaults to BOND_QUOTA).
  • Tests: 6 new tests covering constructor-set allowances, array length mismatch reverts, zero-allowance edge case, and immediate usability post-deploy. All 83 tests pass.

Testing

forge test --match-path test/paymasters/BondTreasuryPaymaster.t.sol
# 83 tests passed, 0 failed

Add initialBondAllowances[] parameter parallel to initialWhitelistedUsers[]
so each whitelisted user gets a non-zero bond allowance at deploy time,
removing the need for a separate setUserBondAllowance tx after deployment.

- BondTreasuryPaymaster: new uint256[] initialBondAllowances constructor arg,
  ArrayLengthMismatch error if arrays differ in length
- DeploySwarmUpgradeableZkSync.s.sol: read FLEET_OPERATOR_BOND_ALLOWANCE env
  (defaults to BOND_QUOTA) and pass it to constructor
- deploy_swarm_contracts_zksync.sh: export FLEET_OPERATOR_BOND_ALLOWANCE
- Tests: 6 new tests covering constructor allowances, array mismatch reverts,
  and immediate usability; all 83 tests pass
@github-actions
Copy link
Copy Markdown

LCOV of commit 00c7f07 during checks #653

Summary coverage rate:
  lines......: 31.9% (771 of 2420 lines)
  functions..: 27.9% (105 of 377 functions)
  branches...: 37.5% (140 of 373 branches)

Files changed coverage rate:
                                                  |Lines       |Functions  |Branches    
  Filename                                        |Rate     Num|Rate    Num|Rate     Num
  ======================================================================================
  script/DeploySwarmUpgradeableZkSync.s.sol       | 0.0%     68| 0.0%     1|    -      0
  src/paymasters/BondTreasuryPaymaster.sol        | 0.0%     44| 0.0%     5| 0.0%      9
  test/paymasters/BondTreasuryPaymaster.t.sol     |16.7%     12|20.0%     5|    -      0

@aliXsed aliXsed merged commit 3cc41bd into main Apr 10, 2026
3 checks passed
@aliXsed aliXsed deleted the fix/bond-treasury-initial-allowances branch April 10, 2026 05:27
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.

1 participant