Account Trade Limit 🏅

This project implements an Account Abstraction wallet contract with multiple unique features: swap & trade size limit, multicall, and meta-transaction via paymaster.

0
2

Challenges

👛🪄 Account Abstraction & Security

Pool 6,500 ETH

Account Abstraction wallet with extensional features trade limit, multicall, and meta-transaction vastly improves the user experience, user retention, and security in the use of wallet for ordinary/new users because of the reasons below. ● Trade limit - Token whitelist protects users from unknown scammy tokens. - Max size per trade prevents users from unintentionally trading a big amount of tokens by a mistake. - Daily Trading Limit discourages users to take too much risk by trading too much. ● Multicall - Multicall gives users an easy and flexible experience, e.g. bypassing an approval transaction and combining it with a transaction that the user actually wants to execute. This functionality is expected to vastly increase user retention. ●Paymaster Paymaster gives users an option not to own ETH which is a native token on zkSync. Instead, it allows for either a gasless experience or gas payment in an accepted ERC20 token. In the case of this implementation, after the deployment of the Account contract, the user, a signer of the account, doesn't have to transfer his/her ETH to the account address but can send any preferable ERC20. With the token, the account can transact by using the token as a gas token. Additionally, one of the suggested ideas in the description on the BuidlBox challenge page is "Safe Transaction training wheels: create safe and curated experience with limits on trading size, margin and assets, or certain types of transactions based on expertise.", which is exactly what the project implemented, not to mention that the addition of a paymaster to the project is also optionally suggested. Given the reasons explained above, I believe that this project is qualified for the challenge of "Account Abstraction & Security".

Project details

No video added

Account Trade Limit & Swap Module

Modules serve as peripheral helpers and give them extensional functionalities and protective limitations. This project has a module called SwapModule that allows accounts to swap tokens on AMM DEX with limitations such as token whitelist, the daily trade size limit, and maximum size per trade. This module is recommended for non-veteran users who ought to trade crypto assets as conservatively as possible.

SwapModule

  • SwapModuleUniV2 is an executor, delegatecalled from Account and executes swap methods on an UniswapV2's router contract.

  • SwapModuleBase is a base for executors, being in charge of all the validations logic and storing variables.

The rationale for deploying SwapModuleBase separately is that 1) with delegatecall, variables stored in SwapModuleUniV2 can't be read and used for validation logics, and 2) SwapModuleBase should serve as a single base for multiple executors since SwapModule can integrate multiple DEXs by deploying new executors contracts.

GasPond(Paymaster)

Contract: GasPond.sol

A Paymaster contract called GasPond allows both free transactions and gas payments in ERC20 for accounts. GasPond also supports accounts' transactions via modules such as SwapModule if enabled.

Sponsor Model

GasPond employs the sponsor model instead of the general paymaster model, meaning that the deployer/owner of the GasPond contract isn't a "paymaster" who compensates gas costs and accepts ERC20 gas payments. Rather, GasPond is a Paymaster-as-a-Service: any individual and project can become a sponsor on GasPond to sponsor users with easy registration, ETH deposit, and configurations.

This model could drastically reduce the cost of providing meta-transactions so that crypto services can improve the UX of their products more easily. Additionally, users don't have to rely on multiple different paymaster contracts where vulnerabilities and malicious bugs might exist.

An example of the use of GasPond for a project

A project called XYZinc becomes a sponsor on GasPond, aiming to increase trading activities and awareness of their native token XYZ. As such, for purchases of XYZ tokens on DEXs supported by SwapModule, it accepts gas payments paid in XYZ with a 50% discount.

Multicall

Account inherits Multicall contract that allows the account to perform both call and delegatecall in the same transaction. It also supports call/delegatecall to module contracts so that the account can combine any arbitrary logic in modules with methods in external contracts.

For example, 1) approve tx to an ERC20 token 2) swap tx via SwapModule.