Open etherCrossroads opened 3 years ago
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.
Here is one of the technical threads
https://twitter.com/schin_tomar/status/1375477475493416961?s=21
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.
@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
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.
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...