sei-protocol / sei-chain

Apache License 2.0
2.7k stars 805 forks source link

Allow infinite approves on ERC20 Pointer #1708

Closed jewei1997 closed 4 months ago

jewei1997 commented 4 months ago

Describe your changes and provide context

Currently, our pointer contracts don't allow for approval amounts larger than uint128 max int. This is because CW20s only support uint128 while the ERC20 standard has uint256s. This discrepancy could cause issues since "infinite" approvals is commonly used for ERC20s where people just approve uint256 max int and infinite approves currently don't work. As a "fix", if someone tries to approve an amount larger than uint128 max int, we will just approve uint128 max int. This will allow infinite approves to basically have the intended affect on the CW20 side but since all balances and transfers on the CW20 side are uint128, this shouldn't create any "less" approval than is expected.

Testing performed to validate your change

hardhat tests + existing tests.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 60.38%. Comparing base (e8e4b3b) to head (ff23411). Report is 62 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1708/graphs/tree.svg?width=650&height=150&src=pr&token=DG7ZZJ3PVV&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol)](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1708?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol) ```diff @@ Coverage Diff @@ ## main #1708 +/- ## ========================================== - Coverage 61.64% 60.38% -1.27% ========================================== Files 365 369 +4 Lines 26178 27035 +857 ========================================== + Hits 16138 16325 +187 - Misses 8967 9598 +631 - Partials 1073 1112 +39 ``` [see 12 files with indirect coverage changes](https://app.codecov.io/gh/sei-protocol/sei-chain/pull/1708/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sei-protocol)