CRYPTO NEWS

ERC20 token, override functions but state variable do not update as expected

I am trying to implement and test an ERC20 token by inheriting from ERC20.sol from OpenZeppelin. I want most of the functions to be by default from OpenZeppelin but I also want to overrride some of them. For example, I have overriden increaseAllowance with the below code with the goal not to call approve in increaseAllowance to avoid front running.

function increaseAllowance(address spender, uint256 addedValue) public override returns (bool) {     require(spender != address(0), "KToken: transfer to the zero address");          _allowances[msg.sender][spender] += addedValue;      emit Approval(msg.sender, spender, _allowances[msg.sender][spender]);     return true; } 

When I test this function the _allowances state variable is not updated as expected. It keeps the value it had before and it is not increased by addedValue.

This is the test that I am running.

it("account1 should be able to increase allowance to account2", async () => {    const kateToken = await deploy(accounts);            // transfer 1000 tokens to account1 FROM owner        await kateToken.transfer(accounts[1], toWei('1000'), {from: accounts[0]});    // approve 50 tokens FROM account1 TO account2   await kateToken.approve(accounts[2], toWei('50'), {from: accounts[1]});    let allowanceToAccountBEFORE = fromWei(await kateToken.allowance(accounts[1], accounts[2]));                   // attempt to increase allowance to account2 by 150 tokens   let increaseAllowanceProccess = await kateToken.increaseAllowance(accounts[2], toWei('150'), {from: accounts[1]});    // get allowance of account2 converted from string to number so as to make calcs in asserts   let allowanceToAccountAFTER = parseInt(fromWei(await kateToken.allowance(accounts[1], accounts[2])));            assert.equal(increaseAllowanceProccess.receipt.status, true, `proccess to increase allowance did not succeed`);   assert.equal(allowanceToAccountBEFORE, allowanceToAccountAFTER-150, `allowance of account2 is not increased by 150 tokens`); 

});

If I comment my code and increaseAllowance is called by OpenZeppelin’s the test runs with success.

If not, allowance is not updated by 150 tokens, it remains 50 which was set by approve. But the strange thing is that I get the Approval Event (emited with only the addedValue), I can get the tx receipt with status true.

Do I have any logical or other issue that I can not get?

Is _allowances state variable from my contract different than _allowances state variable from OpenZeppelin’s ERC20 Contract which I am inheriting from?

By the way, I have also implemented the same code by inheriting from IERC20 with no issues and succesful testing, and I can not understand why this does not work with ERC20.

Thank you in advance!

Decline In Ethereum Futures On CME Suggests Institutional Investors Are Still Bearish

Institutional investors have been bearish toward Ethereum for a while now. There have been outflows rocking the digital asset until it ended its 11-week streak with inflows for last week. However, this does not mean that positive sentiment had returned entirely to the cryptocurrency once more. The numbers on the CME show that institutional investors::Listen

Institutional investors have been bearish toward Ethereum for a while now. There have been outflows rocking the digital asset until it ended its 11-week streak with inflows for last week. However, this does not mean that positive sentiment had returned entirely to the cryptocurrency once more. The numbers on the CME show that institutional investors remain wary and even bearish toward the second-largest cryptocurrency in the market. 

Ethereum Falls Into The Negative

The Ether futures on the CME have been trading on a negative basis lately, which basically means they are trading below spot. This has caused the Ether Futures on the come to decline to the lowest they have ever been since inception. 

The Ether-denominated open interest on the CME had previously claimed a new all-time high back in April. But since then, has continued to decline, with more drops recorded over the last weekend. This has spelled a bad streak for the month of June.

Related Reading | Outflows Rock Bitcoin As Institutional Investors Pull The Plug, More Downside Coming?

As the month draws to a close, the three-month Ether basis has now decoupled from bitcoin and has been trading below spot, which had been recorded on June 23rd. Hence marking the first time that the Ether basis would ever decline so low.

ETH futures on CME in decline | Source: Arcane Research

Asset managers have now moved to a predominantly bearish stand following this. It has been recorded that they have been net short on Ethereum since mid-June when it stood at $37 million. This number has since dropped but only slightly to be resting at the $32 million that was recorded last week. The Ether futures basis is now sitting at a -2.33% while bitcoin remains at 0.63%.

ETH Struggles To Hold $1,000

The bearish sentiment towards Ethereum has not been relegated to just institutional investors alone. The spot markets are also feeling the heat as sell-offs have resumed. In light of this, the digital asset has had a hard time holding the $1,000 level.

ETH struggles to hold above $1,000 | Source: ETHUSD on TradingView.com

This level is significant for Ethereum due to the fact that there is support mounting here. However, it is a very critical technical level given that if the price were to decline below this point, resistance would quickly build up around it. Any support below $1,000 is incredibly weak, so a dip from here would likely see the price touch $800 before there is any recovery.

Related Reading | Ethereum Plugs 11-Week Bleed, why $1,500 May Be On The Horizon

Ethereum is now trading firmly below its 20-day moving average which has wiped out all hopes for a bullish recovery in the short term. Additionally, as the 3AC liquidation comes into focus, the implications for digital assets such as ETH remain very negative.

Featured image from Admiral Markets, charts from Arcane Research and TradingView.com

Follow Best Owie on Twitter for market insights, updates, and the occasional funny tweet…

ERC20 token, override functions but state variable do not update as expected

Shopping cart
There are no products in the cart!
Continue shopping
0