Calling rebase function from the console results in Gas estimation error

Hi ,I have some issues.
This is my code:

function _rebase() external returns(int256){

            epoch = epoch.add(1);

            uint256 cpi = 1;

            bool cpiValid = true;

            //(cpi, cpiValid) = cpiOracle.getData();

            require(cpiValid);

            

            targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi);

            exchangeRate = 2;

            bool rateValid = true;

            //(exchangeRate, rateValid) = marketOracle.getData();

            require(rateValid);

            if (exchangeRate > MAX_RATE) {

                exchangeRate = MAX_RATE;

            }

            int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate);

            supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());

            if (supplyDelta > 0 && eUpgrade.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {

                supplyDelta = (MAX_SUPPLY.sub(eUpgrade.totalSupply())).toInt256Safe();

            }

            uint256 supplyAfterRebase = eUpgrade.rebase(epoch, supplyDelta);

            //assert(supplyAfterRebase <= MAX_SUPPLY);

            return supplyDelta;

        }

When I calling rebase function from my console I got gas estimation error like this


When i am trying to resolve i find that " uint256 supplyAfterRebase = eUpgrade.rebase(epoch, supplyDelta); "
i think due to this line i got this error.can you help me to fix this error

1 Like

I think you do not meet some requirements when call _rebase(), so you got gas estimation error, and what is the result of cpiOracle.getData() and marketOracle.getData(), or do you have deployed these contracts on the a testnet? So I can have a try by myself.

1 Like

Yes @Skyge ,I deployed my contract in rinkeby testnet and I hardcoded the value of cpiOracle.getData() and marketOracle.getData() in my _rebase() function.
when I am trying to find the solution ,I executed line by line and find that During “eUpgrade.rebase” this line only i get an gas estimation error.can you once again check that line and help me to find that solution.

1 Like

So if the key is about eUpgrade.rebase(epoch, supplyDelta);, what are the operations in it? Without more details, I can not help more.

1 Like

my Ufragmentpolicy.sol

pragma solidity >=0.6.8;

// SPDX-License-Identifier: MIT

import "./token/ERC20/ERC20.sol";

import './math/UInt256Lib.sol';

import "./Initializable.sol";

import "./ownership/Ownable.sol";

import "./math/SafeMath.sol";

import "./math/SafeMathInt.sol";

interface IOracle {

    function getData() external returns (uint256, bool);

}

 

    contract UFragmentsPolicy is OwnableUpgradeSafe {

        using SafeMath for uint256;

        using SafeMathInt for int256;

        using UInt256Lib for uint256;

        event LogRebase(

            uint256 indexed epoch,

            uint256 exchangeRate,

            uint256 cpi,

            int256 requestedSupplyAdjustment,

            uint256 timestampSec

        );

        

        ERC20UpgradeSafe public eUpgrade;

        

        // Provides the current CPI, as an 18 decimal fixed point number.

        IOracle public cpiOracle;

        // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number.

        // (eg) An oracle value of 1.5e18 it would mean 1 Ample is trading for $1.50.

        IOracle public marketOracle;

        // CPI value at the time of launch, as an 18 decimal fixed point number.

        uint256 private baseCpi;

        // If the current exchange rate is within this fractional distance from the target, no supply

        // update is performed. Fixed point number--same format as the rate.

        // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change.

        // DECIMALS Fixed point number.

        uint256 public deviationThreshold;

        // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag

        // Check setRebaseLag comments for more details.

        // Natural number, no decimal places.

        uint256 public rebaseLag;

        // More than this much time must pass between rebase operations.

        uint256 public minRebaseTimeIntervalSec;

        // Block timestamp of last rebase operation

        uint256 public lastRebaseTimestampSec;

        // The rebase window begins this many seconds into the minRebaseTimeInterval period.

        // For example if minRebaseTimeInterval is 24hrs, it represents the time of day in seconds.

        uint256 public rebaseWindowOffsetSec;

        // The length of the time window where a rebase operation is allowed to execute, in seconds.

        uint256 public rebaseWindowLengthSec;

        // The number of rebase cycles since inception

        uint256 public epoch;

        uint256 private constant DECIMALS = 18;

       

        // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256.

        // Both are 18 decimals fixed point numbers.

        uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS;

        // MAX_SUPPLY = MAX_INT256 / MAX_RATE

        uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;

        // This module orchestrates the rebase execution and downstream notification.

        address public orchestrator;

        modifier onlyOrchestrator() {

            require(msg.sender == orchestrator);

            _;

        }

        /**

        * @notice Initiates a new rebase operation, provided the minimum time period has elapsed.

        *

        * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag

        *      Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate

        *      and targetRate is CpiOracleRate / baseCpi

        */

       
            int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate);

            supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());

            if (supplyDelta > 0 && eUpgrade.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {

                supplyDelta = (MAX_SUPPLY.sub(eUpgrade.totalSupply())).toInt256Safe();

            }

            uint256 supplyAfterRebase = eUpgrade.rebase(epoch, supplyDelta);

            //assert(supplyAfterRebase <= MAX_SUPPLY);

            return supplyDelta;

        }

        

        function rebase() external {

            //require(inRebaseWindow());

            // This comparison also ensures there is no reentrancy.

           // require(lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < block.timestamp);

            // Snap the rebase time to the start of this window.

            //lastRebaseTimestampSec = block.timestamp.sub(

                //block.timestamp.mod(minRebaseTimeIntervalSec)).add(rebaseWindowOffsetSec);

            epoch = epoch.add(1);

            uint256 cpi = 1;

            bool cpiValid = true;

            //(cpi, cpiValid) = cpiOracle.getData();

            require(cpiValid);

            uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi);

            uint256 exchangeRate = 2;

            bool rateValid = true;

            //(exchangeRate, rateValid) = marketOracle.getData();

            require(rateValid);

            if (exchangeRate > MAX_RATE) {

                exchangeRate = MAX_RATE;

            }

            int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate);

            // Apply the Dampening factor.

            supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());

            if (supplyDelta > 0 && eUpgrade.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {

                supplyDelta = (MAX_SUPPLY.sub(eUpgrade.totalSupply())).toInt256Safe();

            }

            uint256 supplyAfterRebase = eUpgrade.rebase(epoch, supplyDelta);

            assert(supplyAfterRebase <= MAX_SUPPLY);

            emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, block.timestamp);

            

        }

        /**

        * @notice Sets the reference to the CPI oracle.

        * @param cpiOracle_ The address of the cpi oracle contract.

        */

      function setCpiOracle(IOracle cpiOracle_)

            external

            onlyOwner

        {

            cpiOracle = cpiOracle_;

        }

        /**

        * @notice Sets the reference to the market oracle.

        * @param marketOracle_ The address of the market oracle contract.

        */

        function setMarketOracle(IOracle marketOracle_)

            external

            onlyOwner

        {

            marketOracle = marketOracle_;

        }

        /**

        * @notice Sets the reference to the orchestrator.

        * @param orchestrator_ The address of the orchestrator contract.

        */

        function setOrchestrator(address orchestrator_)

            external

            onlyOwner

        {

            orchestrator = orchestrator_;

        }

        /**

        * @notice Sets the deviation threshold fraction. If the exchange rate given by the market

        *         oracle is within this fractional distance from the targetRate, then no supply

        *         modifications are made. DECIMALS fixed point number.

        * @param deviationThreshold_ The new exchange rate threshold fraction.

        */

        function setDeviationThreshold(uint256 deviationThreshold_)

            external

            onlyOwner

        {

            deviationThreshold = deviationThreshold_;

        }

        /**

        * @notice Sets the rebase lag parameter.

                It is used to dampen the applied supply adjustment by 1 / rebaseLag

                If the rebase lag R, equals 1, the smallest value for R, then the full supply

                correction is applied on each rebase cycle.

                If it is greater than 1, then a correction of 1/R of is applied on each rebase.

        * @param rebaseLag_ The new rebase lag parameter.

        */

       function setRebaseLag(uint256 rebaseLag_)

            external

            onlyOwner

        {

            require(rebaseLag_ > 0);

            rebaseLag = rebaseLag_;

        }

        /**

        * @notice Sets the parameters which control the timing and frequency of

        *         rebase operations.

        *         a) the minimum time period that must elapse between rebase cycles.

        *         b) the rebase window offset parameter.

        *         c) the rebase window length parameter.

        * @param minRebaseTimeIntervalSec_ More than this much time must pass between rebase

        *        operations, in seconds.

        * @param rebaseWindowOffsetSec_ The number of seconds from the beginning of

                the rebase interval, where the rebase window begins.

        * @param rebaseWindowLengthSec_ The length of the rebase window in seconds.

        */

         function setRebaseTimingParameters(

            uint256 minRebaseTimeIntervalSec_,

            uint256 rebaseWindowOffsetSec_,

            uint256 rebaseWindowLengthSec_)

            external

            onlyOwner

        {

            require(minRebaseTimeIntervalSec_ > 0);

            require(rebaseWindowOffsetSec_ < minRebaseTimeIntervalSec_);

            minRebaseTimeIntervalSec = minRebaseTimeIntervalSec_;

            rebaseWindowOffsetSec = rebaseWindowOffsetSec_;

            rebaseWindowLengthSec = rebaseWindowLengthSec_;

        }

        /**

        * @dev ZOS upgradable contract initialization method.

        *      It is called at the time of contract creation to invoke parent class initializers and

        *      initialize the contract's state variables.

        */

       function initialize(ERC20UpgradeSafe eUpgrade_, uint256 baseCpi_)

            public

            initializer

        {

            OwnableUpgradeSafe.__Ownable_init();

            // deviationThreshold = 0.05e18 = 5e16

            deviationThreshold = 5 * 10 ** (DECIMALS-2);

            rebaseLag = 30;

            minRebaseTimeIntervalSec = 1 days;

            rebaseWindowOffsetSec = 72000;  // 8PM UTC

            rebaseWindowLengthSec = 15 minutes;

            lastRebaseTimestampSec = 0;

            epoch = 0;

            eUpgrade = eUpgrade_;

            baseCpi = baseCpi_;

        }

        /**

        * @return If the latest block timestamp is within the rebase time window it, returns true.

        *         Otherwise, returns false.

        */

        function inRebaseWindow() public view returns (bool) {

            return (

                block.timestamp.mod(minRebaseTimeIntervalSec) >= rebaseWindowOffsetSec &&

                block.timestamp.mod(minRebaseTimeIntervalSec) < (rebaseWindowOffsetSec.add(rebaseWindowLengthSec))

            );

        }

        /**

        * @return Computes the total supply adjustment in response to the exchange rate

        *         and the targetRate.

        */

        function computeSupplyDelta(uint256 rate, uint256 targetRate)

            private

            view

            returns (int256)

        {

            if (withinDeviationThreshold(rate, targetRate)) {

                return 0;

            }

            // supplyDelta = totalSupply * (rate - targetRate) / targetRate

            int256 targetRateSigned = targetRate.toInt256Safe();

            return eUpgrade.totalSupply().toInt256Safe()

                .mul(rate.toInt256Safe().sub(targetRateSigned))

                .div(targetRateSigned);

        }

        /**

        * @param rate The current exchange rate, an 18 decimal fixed point number.

        * @param targetRate The target exchange rate, an 18 decimal fixed point number.

        * @return If the rate is within the deviation threshold from the target rate, returns true.

        *         Otherwise, returns false.

        */

       function withinDeviationThreshold(uint256 rate, uint256 targetRate)

            private

            view

            returns (bool)

        {

            uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold)

                .div(10 ** DECIMALS);

            return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold)

                || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold);

        }

    }

my ERC20.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0;

import "../../ownership/Ownable.sol";

import "../../math/SafeMathInt.sol";

import "../../GSN/Context.sol";

import "./IERC20.sol";

import "../../math/SafeMath.sol";

import "../../utils/Address.sol";

import "../../Initializable.sol";

/**

 * @dev Implementation of the {IERC20} interface.

 *

 * This implementation is agnostic to the way tokens are created. This means

 * that a supply mechanism has to be added in a derived contract using {_mint}.

 * For a generic mechanism see {ERC20MinterPauser}.

 *

 * TIP: For a detailed writeup see our guide

 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How

 * to implement supply mechanisms].

 *

 * We have followed general OpenZeppelin guidelines: functions revert instead

 * of returning `false` on failure. This behavior is nonetheless conventional

 * and does not conflict with the expectations of ERC20 applications.

 *

 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.

 * This allows applications to reconstruct the allowance for all accounts just

 * by listening to said events. Other implementations of the EIP may not emit

 * these events, as it isn't required by the specification.

 *

 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}

 * functions have been added to mitigate the well-known issues around setting

 * allowances. See {IERC20-approve}.

 */

contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20,OwnableUpgradeSafe {

    using SafeMath for uint256;

    using Address for address;

    using SafeMathInt for int256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;

    string private _symbol;

    uint8 private _decimals;

    address private _treasurey;

    /**

     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with

     * a default value of 18.

     *

     * To select a different value for {decimals}, use {_setupDecimals}.

     *

     * All three of these values are immutable: they can only be set once during

     * construction.

     */

    event LogRebase(uint256 indexed epoch, uint256 totalSupply);

    event LogMonetaryPolicyUpdated(address monetaryPolicy);

    // Used for authentication

    address public monetaryPolicy;

     modifier onlyMonetaryPolicy() {

        require(msg.sender == monetaryPolicy);

        _;

    }

    bool private rebasePausedDeprecated;

    bool private tokenPausedDeprecated;

    modifier validRecipient(address to) {

        require(to != address(0x0));

        require(to != address(this));

        _;

    }

    uint256 private constant DECIMALS = 9;

    uint256 private constant MAX_UINT256 = ~uint256(0);

    uint256 private constant INITIAL_FRAGMENTS_SUPPLY = 25 * 10**6 * 10**DECIMALS;

    // TOTAL_GONS is a multiple of INITIAL_FRAGMENTS_SUPPLY so that _gonsPerFragment is an integer.

    // Use the highest value that fits in a uint256 for max granularity.

    uint256 private constant TOTAL_GONS = MAX_UINT256 - (MAX_UINT256 % INITIAL_FRAGMENTS_SUPPLY);

    // MAX_SUPPLY = maximum integer < (sqrt(4*TOTAL_GONS + 1) - 1) / 2

    uint256 private constant MAX_SUPPLY = ~uint128(0);  // (2^128) - 1

    uint256 private _gonsPerFragment;

    mapping(address => uint256) private _gonBalances;

    

    mapping (address => mapping (address => uint256)) private _allowedFragments;

    function initialize()

        public

        initializer

    {

        __ERC20_init("TOKEN", "DEMO");

        _mint(msg.sender, 2500);

        OwnableUpgradeSafe.__Ownable_init();

        _treasurey = 0x49c889127848bc24C1cFaD21e0D310b960a3C124;

        

        rebasePausedDeprecated = false;

        tokenPausedDeprecated = false;

        _totalSupply = INITIAL_FRAGMENTS_SUPPLY;

        _gonBalances[msg.sender] = TOTAL_GONS;

        _gonsPerFragment = TOTAL_GONS.div(_totalSupply);

       

        emit Transfer(address(0x0), msg.sender, _totalSupply);

    }

    function setMonetaryPolicy(address monetaryPolicy_)

        external

        onlyOwner

    {

        monetaryPolicy = monetaryPolicy_;

        emit LogMonetaryPolicyUpdated(monetaryPolicy_);

    }

    /**

     * @dev Notifies Fragments contract about a new rebase cycle.

     * @param supplyDelta The number of new fragment tokens to add into circulation via expansion.

     * @return The total number of fragments after the supply adjustment.

     */

    function rebase(uint256 epoch, int256 supplyDelta)

        external

        onlyMonetaryPolicy payable

        returns (uint256)

    {

        if (supplyDelta == 0) {

            emit LogRebase(epoch, _totalSupply);

            return _totalSupply;

        }

        if (supplyDelta < 0) {

            _totalSupply = _totalSupply.sub(uint256(supplyDelta.abs()));

        } else {

            _totalSupply = _totalSupply.add(uint256(supplyDelta));

        }

        if (_totalSupply > MAX_SUPPLY) {

            _totalSupply = MAX_SUPPLY;

        }

        _gonsPerFragment = TOTAL_GONS.div(_totalSupply);

        emit LogRebase(epoch, _totalSupply);

        return _totalSupply;

    }

    function __ERC20_init(string memory name, string memory symbol) internal initializer {

        __Context_init_unchained();

        __ERC20_init_unchained(name, symbol);

    }

    function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer {

        _name = name;

        _symbol = symbol;

        _decimals = 18;

    }

    

    /**

     * @dev Returns the name of the token.

     */

    function name() public view returns (string memory) {

        return _name;

    }

    /**

     * @dev Returns the symbol of the token, usually a shorter version of the

     * name.

     */

    function symbol() public view returns (string memory) {

        return _symbol;

    }

    /**

     * @dev Returns the number of decimals used to get its user representation.

     * For example, if `decimals` equals `2`, a balance of `505` tokens should

     * be displayed to a user as `5,05` (`505 / 10 ** 2`).

     *

     * Tokens usually opt for a value of 18, imitating the relationship between

     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is

     * called.

     *

     * NOTE: This information is only used for _display_ purposes: it in

     * no way affects any of the arithmetic of the contract, including

     * {IERC20-balanceOf} and {IERC20-transfer}.

     */

    function decimals() public view returns (uint8) {

        return _decimals;

    }

    /**

     * @dev See {IERC20-totalSupply}.

     */

    function totalSupply() public view override returns (uint256) {

        return _totalSupply;

    }

    /**

     * @dev See {IERC20-balanceOf}.

     */

    function balanceOf(address account) public view override returns (uint256) {

        return _balances[account];

    }

    /**

     * @dev See {IERC20-transfer}.

     *

     * Requirements:

     *

     * - `recipient` cannot be the zero address.

     * - the caller must have a balance of at least `amount`.

     */

    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {

        _transfer(_msgSender(), recipient, amount);

        return true;

    }

    /**

     * @dev See {IERC20-allowance}.

     */

    function allowance(address owner, address spender) public view virtual override returns (uint256) {

        return _allowances[owner][spender];

    }

    /**

     * @dev See {IERC20-approve}.

     *

     * Requirements:

     *

     * - `spender` cannot be the zero address.

     */

    function approve(address spender, uint256 amount) public virtual override returns (bool) {

        _approve(_msgSender(), spender, amount);

        return true;

    }

    /**

     * @dev See {IERC20-transferFrom}.

     *

     * Emits an {Approval} event indicating the updated allowance. This is not

     * required by the EIP. See the note at the beginning of {ERC20};

     *

     * Requirements:

     * - `sender` and `recipient` cannot be the zero address.

     * - `sender` must have a balance of at least `amount`.

     * - the caller must have allowance for ``sender``'s tokens of at least

     * `amount`.

     */

    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {

        _transfer(sender, recipient, amount);

        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));

        return true;

        

    }

    /**

     * @dev Atomically increases the allowance granted to `spender` by the caller.

     *

     * This is an alternative to {approve} that can be used as a mitigation for

     * problems described in {IERC20-approve}.

     *

     * Emits an {Approval} event indicating the updated allowance.

     *

     * Requirements:

     *

     * - `spender` cannot be the zero address.

     */

    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {

        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));

        return true;

    }

    /**

     * @dev Atomically decreases the allowance granted to `spender` by the caller.

     *

     * This is an alternative to {approve} that can be used as a mitigation for

     * problems described in {IERC20-approve}.

     *

     * Emits an {Approval} event indicating the updated allowance.

     *

     * Requirements:

     *

     * - `spender` cannot be the zero address.

     * - `spender` must have allowance for the caller of at least

     * `subtractedValue`.

     */

    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {

        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));

        return true;

    }

    /**

     * @dev Moves tokens `amount` from `sender` to `recipient`.

     *

     * This is internal function is equivalent to {transfer}, and can be used to

     * e.g. implement automatic token fees, slashing mechanisms, etc.

     *

     * Emits a {Transfer} event.

     *

     * Requirements:

     *

     * - `sender` cannot be the zero address.

     * - `recipient` cannot be the zero address.

     * - `sender` must have a balance of at least `amount`.

     */

    function _transfer(address sender, address recipient, uint256 amount) internal virtual {

        require(sender != address(0), "ERC20: transfer from the zero address");

        require(recipient != address(0), "ERC20: transfer to the zero address");

        

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");

        uint256 amount1 = amount * 75/100;

        uint256 amount2 = amount * 25/100;

        _balances[recipient] = _balances[recipient].add(amount1);

        _balances[_treasurey] = _balances[_treasurey].add(amount2);

        emit Transfer(sender, recipient, amount1);

        emit Transfer(sender, _treasurey, amount2);

    }

   

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing

     * the total supply.

     *

     * Emits a {Transfer} event with `from` set to the zero address.

     *

     * Requirements

     *

     * - `to` cannot be the zero address.

     */

    function _mint(address account, uint256 amount) internal virtual {

        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);

        _balances[account] = _balances[account].add(amount);

        emit Transfer(address(0), account, amount);

    }

    /**

     * @dev Destroys `amount` tokens from `account`, reducing the

     * total supply.

     *

     * Emits a {Transfer} event with `to` set to the zero address.

     *

     * Requirements

     *

     * - `account` cannot be the zero address.

     * - `account` must have at least `amount` tokens.

     */

    function _burn(address account, uint256 amount) internal virtual {

        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");

        _totalSupply = _totalSupply.sub(amount);

        emit Transfer(account, address(0), amount);

    }

    /**

     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.

     *

     * This is internal function is equivalent to `approve`, and can be used to

     * e.g. set automatic allowances for certain subsystems, etc.

     *

     * Emits an {Approval} event.

     *

     * Requirements:

     *

     * - `owner` cannot be the zero address.

     * - `spender` cannot be the zero address.

     */

    function _approve(address owner, address spender, uint256 amount) internal virtual {

        require(owner != address(0), "ERC20: approve from the zero address");

        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;

        emit Approval(owner, spender, amount);

    }

    /**

     * @dev Sets {decimals} to a value other than the default one of 18.

     *

     * WARNING: This function should only be called from the constructor. Most

     * applications that interact with token contracts will not expect

     * {decimals} to ever change, and may work incorrectly if it does.

     */

    function _setupDecimals(uint8 decimals_) internal {

        _decimals = decimals_;

    }

    /**

     * @dev Hook that is called before any transfer of tokens. This includes

     * minting and burning.

     *

     * Calling conditions:

     *

     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens

     * will be to transferred to `to`.

     * - when `from` is zero, `amount` tokens will be minted for `to`.

     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.

     * - `from` and `to` are never both zero.

     *

     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].

     */

    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }

    uint256[44] private __gap;

}

this is my code

1 Like

ok @abcoathup .can you see the problem ?you have any solution for this

1 Like

It seems like only one check onlyMonetaryPolicy in eUpgrade.rebase(epoch, supplyDelta); And can you verify the contract on the rinkeby, cause the code you pasted is a little hard to read.

1 Like

sure @Skyge . i will send it soon

1 Like

Hi @Martina,

If you markdown your code using the following markdown it will be much easier to read.
Though verification is even better.

```

Your code goes here

```

I also noticed that the code is using local copies of what I assume is OpenZeppelin Contracts.

I recommend using OpenZeppelin Contracts Upgradeable where using OpenZeppelin Contracts with upgradeable contracts:

ok @abcoathup .I will check that

1 Like

ERC20 file code link:https://rinkeby.etherscan.io/address/0xd7bcf32806acf3e2f5836116cf9a1b700ac6b0c0
Ufragmentpolicy file code link:
https://rinkeby.etherscan.io/address/0xA57d90261eb9DA7B31E8915366A394863642B2c9

1 Like

So I should call rebase in the Ufragmentpolicy, right?

1 Like

hi @Skyge.Its working now .this error is due to monetary policy address now i give my Ufragmentpolicy address so its working now.
Thankyou so much @Skyge for your response

1 Like

That is great! Glad to help!

2 Likes