Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you deduct user ERC20 tokens when user use ERC20 tokens to pay the gas fee? #46

Open
etherCrossroads opened this issue Apr 28, 2021 · 5 comments
Assignees

Comments

@etherCrossroads
Copy link

Maybe user deposit ERC20 to specified contract firstly? Or deposit to your platform?
Or user approve ERC20 to your contract and this contract transferFrom user balance?

Your documents(https://docs.biconomy.io/guides/enable-paying-gas-in-erc20) doesn't describe this detail...

@livingrock7
Copy link

livingrock7 commented Apr 28, 2021

It's the later. approve / gasless permit and contract does transfer from based on execution gas.

Pricisely here : https://github.com/bcnmy/mexa/blob/master/contracts/6/forwarder/ERC20Forwarder.sol#L460

Besides execution gas, charge is calculated based on token price / eth price chainlink feeds.

@livingrock7
Copy link

Here is one of the technical threads

https://twitter.com/schin_tomar/status/1375477475493416961?s=21

@preston4896
Copy link

I have a similar question. What happens if a transaction involves an ERC20 transfer that happens to be the same token as req.token ? For example, a user who initially holds 10 USDC wants to make a transfer of 8 USDC, that costs 3 USDC in fees. The user would end up with 2 USDC after executing the inner txn, causing the _transferHandler to revert the txn, with a non-refundable gas cost. I was wondering if there's a good preventive measure for users to not execute such transactions, that could end up with them not being able to pay for fees?

My main concern here is that users may intentionally submit failed txns to dry out the relayer's funds. Would really appreciate some insights.

@livingrockrises
Copy link

@preston4896 since the atomicity is maintained and we do gas estimation when transaction goes through relayer infra, If it was gonna fail we don't send it to the chain and stop relay with 417 error. Besides that in the sdk there are checks in place for user balance for transfer and fees, given allowance etc. so yeah there is no on chain check on this but when it goes through relayer infra these measures even the pre flight check (token / eth price volatility) is in place

@livingrockrises
Copy link

btw we added another contract for this specific use case of transferring tokens and paying gas fees in same. It allows deployer to sponsor ETH gas fees and same time charge tokens in gas with optional premium.

https://github.com/bcnmy/mexa/blob/internal/forward-v2-RnD/contracts/6/forwarder/TransferHandlerCustom.sol

@livingrockrises livingrockrises self-assigned this Nov 2, 2021
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

No branches or pull requests

4 participants