Skip to content

[evm, sdk, simplex]: add SimplexPaymaster#768

Open
royvardhan wants to merge 3 commits intomainfrom
roy/simplex-paymaster
Open

[evm, sdk, simplex]: add SimplexPaymaster#768
royvardhan wants to merge 3 commits intomainfrom
roy/simplex-paymaster

Conversation

@royvardhan
Copy link
Copy Markdown
Collaborator

@royvardhan royvardhan commented Apr 10, 2026

Contract: Added SimplexPaymaster.sol — onchain ERC-4337 v0.8 paymaster accepting USDC/USDT via Chainlink oracles, with PERMIT and APPROVE modes. Deployed on Base and BSC for testing.

Deployment: Added DeploySimplexPaymaster.s.sol and paymaster config entries to config.mainnet.toml.

SDK: Replaced Circle paymaster with self-contained buildPaymasterData() — auto-selects token by balance, auto-detects permit support, falls back to capped approval for non-permit tokens (BSC).

Simplex: DelegationService now delegates via bundler UserOp with paymaster paying gas — solver needs zero native tokens. Falls back to direct tx.

function _executePermit(PackedUserOperation calldata userOp) internal {
bytes calldata data = userOp.paymasterData();
// Minimum length: 1 + 20 + 32 + 32 + 1 + 32 + 32 = 150
require(data.length >= 150, "SimplexPaymaster: permit data too short");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't we just use equalto?

Suggested change
require(data.length >= 150, "SimplexPaymaster: permit data too short");
require(data.length == 150, "SimplexPaymaster: permit data too short");


// ── Oracle helpers ───────────────────────────────────────────────

/// @dev Fetch price from a Chainlink feed, normalized to 8 decimals.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why normalize 8 instead of 18 decimals

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The oracle already returns the price in 8 decimals.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think 18 decimals is better since we'll still have to do some math with native token gas

const paymasterAndData = packPaymasterAndData(pm)

// 3. Get gas prices from bundler
const gasPriceResult = await this.sendBundlerRpc<{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would fail when they use the alchemy bundler which is now our default bundler

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should support both alchemy and pimlico

@Wizdave97
Copy link
Copy Markdown
Member

@royvardhan let's default to the circle paymaster when it's available and when the user has USDC balance. Our custom paymaster should only be used in cases where there's no circle paymaster or the user

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