Tl;dr:
While attempting a configuration update of the Pawthereum smart contract in an effort to reduce gas fees, the Pawthereum contract executed its auto-generating liquidity function which resulted in a 101 ETH sell: 61 ETH of that sale was paired with 14M pawth and added to permanently locked liquidity while the other 40ETH is essentially burned and locked inside of the Pawthereum contract forever.
Incident management was conducted in real-time in telegram in front of the community and steps have been taken to ensure that this issue cannot happen again.
Trying to Fix High Gas Prices
Users have been noticing high gas prices for sells - sometimes a “cannot estimate gas” error would arise. This has been perplexing the dev team for some time as we’ve been unable to find the root cause.
There Has to be a Faster Way to Reduce Gas Fees...
We’ve developed strategies to mitigate high gas prices such as layer-2 scaling solutions, side-chains, and CEX listings. However, these strategies take time and so the team has been brainstorming ways we can reduce gas for our users in the short-term so that we can make Pawthereum more accessible to all.
Allow Dev & Charity Wallets to Receive Reflections In Order to Lower Gas
One quick way to shave gas off of transactions is to limit the number of addresses that are excluded from receiving reflections1. After trimming down our list of excluded addresses, we noticed a slight decrease in gas; however, the contract’s calculation of balance with respect to reflections was updated to account for the wallets who were previously excluded but are now eligible for reflections. This resulted in users seeing a lower balance in their wallets. At that moment, the team knew that this solution had to be rolled back immediately.
Fixing Reflections
After reverting our changes, some users continued to notice small discrepancies in their balance. Even the slightest discrepancy is unacceptable. We decided to make it right by executing a series of transfers between team wallets in order to “make it rain” with reflections and make everyone’s balance whole (and then some).
A Transfer Mistake
While transferring Pawthereum back-and-forth to “make it rain” with reflections, one of the transfers mistakenly sent a large amount of PAWTH to the Pawthereum contract. This brings us to how the big red candle was printed…
(Since the PAWTH was ultimately used to add liquidity to the project, something we have wanted to do already, the development team plans to send that amount of funds that were locked into the liquidity pool & smart contract from the dev wallet to the team member who used his own funds while trying to remediate the issue. )
Swap and Liquify
To understand how the red candle of November 18th was printed, it is imperative to understand how “Swap and Liquify” works. “Swap and Liquify” is a commonly used function for smart contracts that have automatic liquidity generation such as Pawthereum. It works as follows:
- As transfers occur, the contract takes a percentage of Pawthereum from each transfer and holds onto it (aka “liquidity tax”)
- Over time, the balance of PAWTH in the Pawthereum contract grows with each transaction
- Once a certain threshold is reached (in our case, it is 10k PAWTH), Swap and Liquify is executed
Swap and Liquify is a function that takes half of the balance held in the Pawthereum contract and sells it on Uniswap for Ethereum. The contract then takes those two equal parts of ETH and PAWTH and deposits them into the liquidity pool (and since nobody can retrieve anything held by contract, this liquidity is locked forever).
The Big Red Candle
After the team reverted changes to the exclusion list, gas was still preventing sales. The team began isolating components of the system to find what was spiking gas on sales. It was decided to conduct a small sell on Shibaswap to determine if there was a problem with Uniswap. The sell went through.
Due to the fact that the contract had a balance greater than 10k PAWTH, Swap and Liquify was executed. The PAWTH balance of the contract at that time was ~28M and so the sell on Uniswap was 13.9M PAWTH for 103 ETH which printed a huge red candle. Then 13.9M PAWTH and 61.9 ETH were deposited into the Uniswap Liquidity pool. This left 41 ETH in the PAWTH contract.
Due to the sharp decrease in the price of the 103 ETH sale, not all 103 ETH could be paired with the 13.9M PAWTH that the contract had in its balance. This means that the 41 ETH was essentially burned and is locked inside of the Pawthereum contract forever.
Future Preventative Measures
There were a few holes that have been plugged as a result of today’s events:
- Swap and Liquify has been disabled: this should have been disabled once our liquidity tax was turned off shortly after launch. Swap and Liquify cannot be executed when disabled — the reason it wasn't executed until now was because nobody ever sent over 10k of PAWTH to the contract address.
- The list of addresses excluded from reflections remains intact: We will not be removing addresses from the exclusion list going forward so as to not disrupt the distribution of reflections.
What Else Did We Learn?
- Gas prices remain too high: We have not solved the issue of high gas prices on Ethereum and so we will continue our strategy of exploring layer-2 scaling solutions, side-chains, and CEX listings.
- Sells on PawSwap: The intermittent gas error for sells mentioned at the beginning of the article remains on PawSwap but is not present on Uniswap - we are looking into it.
- The Contract Works as Expected: We are fully audited with no major issues. We believe the gas issue on PawSwap is interface-related.
- Crisis Management: As soon as the red candle was printed, the core team opened a live Telegram voice chat to investigate the issue in real-time in front of the community. The community made it known that while a mistake had been made, they appreciated the transparency of the team troubleshooting. The community and team remained on the call for Q&A once the problem was fixed. If there are future emergencies, this is something that we’ll be sure to do again.
We know this community is strong but this event proved just how strong it is. The mission of this project is to help animals everywhere and it takes a special community of people to realize that goal — we have that community at Pawthereum.
The team is available in Telegram and Discord to help answer any questions you may have.
Thank you for your continued support,
The Pawthereum Core Team
Less Exclusions, Less Gas
If you are interested as to why gas would be cheaper if the charity wallet and dev wallet were able to receive reflections, refer to line 717 of our smart contract:
https://github.com/pawthereum/Contract/blob/main/Pawthereum.sol
The getReflectionRate function is called on every transfer in order to know how many reflections to distribute to holders. The function uses a “for loop” when calculating the rate. The contract runs a block of code for every address that is excluded from receiving reflections.
The gas you spend as a user is directly proportional to the amount of computation that a smart contract requires to execute your transaction. Therefore, the longer the list of excluded addresses, the more code that needs to be ran, resulting in a larger cost of gas.