celo-org / viem

TypeScript Interface for Ethereum
https://viem.sh
Other
0 stars 0 forks source link

Add celo gas fee estimator #4

Closed aaronmgdr closed 6 months ago

aaronmgdr commented 11 months ago

Is there an existing issue for this?

Package Version

1.0.0

Current Behavior

when using feeCurrency it is necessary to lookup gasPrice by hand as the automatic way does not factor in feeCurrency

Expected Behavior

Add a celo estimateFeesPerGas function

internally this should call eth_gasPrice with feeCurrency as a param

should return

return {
      maxFeePerGas,
      maxPriorityFeePerGas,
    } as EstimateFeesPerGasReturnType<type>   

https://github.com/wagmi-dev/viem/blob/5c95fafceffe7f399b5b5ee32119e2d78a0c8acd/src/actions/public/estimateFeesPerGas.ts#L130-L137

Steps To Reproduce

No response

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

No response

Anything else?

No response

arthurgousset commented 8 months ago

Additional context from Jean at Valora on Slack:

I noticed viem supports a custom estimateFeesPerGas per chain https://github.com/wagmi-dev/viem/blob/5c95fafceffe7f399b5b5ee32119e2d78a0c8acd/src/actions/public/estimateFeesPerGas.ts#L130-L137 Looks like this could be used to avoid having to manually call a custom function to take the feeCurrency into account like recommended here: https://docs.celo.org/developer/viem#gas-price

arthurgousset commented 8 months ago

Additiona context in viem repo:

aaronmgdr commented 7 months ago

status is that I need to see what the best design is for when you want to use a custom chain fee estimator only on certain conditions and then use standard one if not as the standard one is where the custom is called.

1 option is adding a param to say skip the custom even if it exists

2 option is to refactor inside of function to be able to reuse parts

3 would be to just duplicate the code

aaronmgdr commented 7 months ago

10

aaronmgdr commented 6 months ago

waiting on help from viem

arthurgousset commented 6 months ago

This issue is related to viem and might benefit from being done around the same time (while you have your head in viem):

shazarre commented 6 months ago

Test values from alfajores:

Symbol maxFeePerGas maxPriorityFeePerGas
CELO 8000000000n 2000000000n
cREAL 63940958968n 12788191793n
cEUR 11755155930n 2351031186n
cUSD 12672525950n 2534505190n
USDC 12672525950n 2534505190n