Let's get rid of transactions for approving/revoking tokens

3 351
Avatar for SmartBCH
1 year ago

Even as a DEFI beginner, you may already find SEP20 token's approving transactions are annoying: if you want to add liquidity to the CATS/FLEXUSD pool, you must send one transaction for approving CATS and another transaction for approving FLEXUSD, before you can finally deposit your CATS and FLEXUSD tokens into a DEX pool.

When you get more knowledge and experience on the risks and exploits in the DEFI world, you are aware that approving tokens to a contract is a dangerous operation. And then you find some utilities such as revoke.cash and approval-tracker to revoke your allowance to the contracts, which are annoying tasks, too.

When a cautious DEFI user interacts with a suspicious contract, she follows such a process: approve the necessary token allowances, call the suspicious contract, and finally revoke the remained allowances (if any). It is very tedious that this process needs at least three transactions (more transactions are needed when more tokens need to be approved). But it is worthwhile because she never worries about the approved allowances after this process.

You may wonder: why can't all these tasks be automated? People just click the wallet once and it will automatically send the transactions one by one. Well, even with such a feature, users still have to wait for several transactions to be broadcasted and then executed on-chain. The delay and waiting are still annoying.

A better solution is making the chain itself add a new feature to help out. And it's just what smartBCH is going to do: a feature named "EOA Delegator" is planned to be added in the next hardfork upgrade, i.e., the sha-gate upgrade.

EOA is short for Externally Owned Account, i.e., an account controlled by a private key. EOA delegators are smart contracts to which EOAs can delegatecall.

What is delegatecall? It means that whatever the bytecode in an EOA delegator does, it acts as if the EOA (instead of the contract) does it. For example, if the bytecode calls a SEP20 tokens approve method, the result is the same as the EOA calls the approve method and sets the allowance for some smart contract to spend from the EOA's balance.

Currently, no EVM-compatible chain allows an EOA to send a transaction that delegatecalls a smart contract. This will be changed in smartBCH's next upgrade. After that, smartBCH will take a specialized smart contract as the EOA delegator. Whenever they are used as the target of a transaction (called by EOAs), they execute as if they are delegatecalled.

The EOA delegator has been already opensourced. They help EOA to automate such a process: 1) approve one or more tokens; 2) call a contract to do the desired job; 3) revoke any remained allowance. With EOA delegators, you can act as a cautious DEFI user easily. We welcome comments and reviews on them.

EOA delegator's technical detail is described in SEP103. If you have any suggestions or ideas on it, please reach out to us through telegram, GitHub, or email.

28
$ 29.87
$ 21.54 from @TheRandomRewarder
$ 5.00 from @bitcoincashautist
$ 1.00 from @nyusternie
+ 10
Avatar for SmartBCH
1 year ago

Comments

What a good article I invite you to read my most recent article that is very interesting, https://read.cash/@themastergamer/meet-the-pregnant-woman-in-and-out-of-wedlock-b1d5fbfb

$ 0.00
1 year ago

a feature named "EOA Delegator" is planned to be added in the next hardfork upgrade, i.e., the sha-gate upgrade

what work is being performed by the smartbch team to extend the current sha-gate contract to support the new functionality being added on May 15th? the github repo was least updated 8mos ago.

what updates/upgrades are you planning during the "sha-gate" hard fork to extend the functionality of the contract?

any eta as to when this will be ready for testnet?

thanks for all your hard work 🙏 😁

$ 0.00
1 year ago

Great news! Thanks for always making it better

$ 0.00
1 year ago