zkSync Era transaction fee adapter

zkSync Era was rolled out for a while, currently seems we only have zkSync Lite transaction fee adapter, add adapter for zkSync Era is necessary.

The adapter is using rpc method “zks-estimatefee” to check transaction fee.

And based on documentation “https://era.zksync.io/docs/dev/developer-guides/transactions/fee-model.html#refunds”, the fee normally is over estimated, it will refund the sender, the actual fee will be less than estimation, so add a method to estimate the real cost considering refund(normally there will be more than 40% refund)

The adapter: zkSync Era Transaction Fees Adapter - CryptoStats

Could someone help to put it in l2-fee collection?

Hello, thanks for your work on this!

I lead data & analytics at Matter Labs. I can’t offer a timeline, but we are working on a method to more accurately account for the refund in tx fee estimation. I will write the adapter when that is done, but I would recommend holding off on any other attempted implementations until then.

I’ve seen refunds be anywhere from 30-90%, so even an assumption of 40% could offer quite incorrect estimations.

I have created an adapter for zkSync Era that uses historical data to calculate average refund percentages for each of the three transaction types. While refund amounts can be highly variable when considering all transactions, they are quite similar when repeating the same transaction (ETH Transfer, USDC Transfer, SyncSwap Trade, etc).

The average refund amount is applied to the transaction fee estimate returned from the zk_estimateFee method. Data used to calculate the following refund averages are from March 24, 2023 to June 12, 2023.

Refund Amounts:
- ETH Transfer = 49%
- ERC20 Transfer = 56%
- ERC20 Swap = 64%

Having trouble posting the raw link without it getting flagged as spam.

~https://cryptostats.community/discover/adapter/QmQaVjioHBsGbmznvDUwrpr7z2rbVdZr6cKzFn4tkZB7Dx

This one is now live :slight_smile: