github

IMP

ERC 1524

A hybrid token standard merging ERC-20 with ERC-721, with native swap.

Github Repository (Coming soon)

receive() external payable {

require(tradingEnable, "Trading not enable");

uint256 token_amount

= (balanceOf[address(this)] * msg.value)

/ (address(this).balance + msg.value);

_transfer(address(this), msg.sender, token_amount);


emit Swap(msg.sender, msg.value,0,0,token_amount);

}


function getAmountOut(uint256 value, bool _buy)

public view returns(uint256) {

(uint256 reserveETH, uint256 reserveToken) = getReserves();

if (_buy) {

return (value * reserveToken) / (reserveETH + value);

} else {

return (value * reserveETH) / (reserveToken + value);

}

}


function addLiquidity() external payable onlyOwner {

emit LiquidityAdded(msg.value);

}


function _transfer(

address from,

address to,

uint256 amount

) internal returns (bool) {

uint256 balanceBeforeSender = balanceOf[from];

uint256 balanceBeforeReceiver = balanceOf[to];

balanceOf[from] -= amount;

unchecked {

balanceOf[to] += amount;

}

if (!whitelist[from]) {

uint256 tokens_to_burn = (balanceBeforeSender / unit)

- (balanceOf[from] / unit);

for (uint256 i = 0; i < tokens_to_burn; i++) {

_burn(from);

}

}

if (!whitelist[to]) {

uint256 tokens_to_mint = (balanceOf[to] / unit) -

(balanceBeforeReceiver / unit);

for (uint256 i = 0; i < tokens_to_mint; i++) {

_mint(to);

}

}

emit ERC20Transfer(from, to, amount);

return true;

}