ETH Price: $3,080.04 (-0.94%)
Gas: 3 Gwei

Transaction Decoder

Block:
14405574 at Mar-17-2022 06:20:23 PM +UTC
Transaction Fee:
0.00780755599142628 ETH $24.05
Gas Used:
117,835 Gas / 66.258378168 Gwei

Emitted Events:

155 MultiSigWalletWithDailyLimit.Confirmation( sender=[Sender] 0xfe2321d7dfa492dfc39330e8b85e7c49161e7f98, transactionId=96 )
156 AdminUpgradeabilityProxy.0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0( 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0, 0x000000000000000000000000a847dc227d3f3e86fa01406279c1e88cb6950c3a, 0x000000000000000000000000223592a191ecfc7fdc38a9256c3bd96e771539a9 )
157 MultiSigWalletWithDailyLimit.Execution( transactionId=96 )

Account State Difference:

  Address   Before After State Difference Code
0x1B228a74...d96Dca2ea
(Flexpool.io)
5,368.367359981937980285 Eth5,368.367536734437980285 Eth0.0001767525
0xa847dc22...cb6950c3A
0xfe2321D7...9161e7F98
(Ampleforth Governance: Deployer)
1.228936339448912341 Eth
Nonce: 1199
1.221128783457486061 Eth
Nonce: 1200
0.00780755599142628

Execution Trace

MultiSigWalletWithDailyLimit.confirmTransaction( transactionId=96 )
  • AdminUpgradeabilityProxy.f2fde38b( )
    • UFragmentsPolicy.transferOwnership( newOwner=0x223592a191ECfC7FDC38a9256c3BD96E771539A9 )
      File 1 of 3: MultiSigWalletWithDailyLimit
      contract Factory {
      
          /*
           *  Events
           */
          event ContractInstantiation(address sender, address instantiation);
      
          /*
           *  Storage
           */
          mapping(address => bool) public isInstantiation;
          mapping(address => address[]) public instantiations;
      
          /*
           * Public functions
           */
          /// @dev Returns number of instantiations by creator.
          /// @param creator Contract creator.
          /// @return Returns number of instantiations by creator.
          function getInstantiationCount(address creator)
              public
              constant
              returns (uint)
          {
              return instantiations[creator].length;
          }
      
          /*
           * Internal functions
           */
          /// @dev Registers contract in factory registry.
          /// @param instantiation Address of contract instantiation.
          function register(address instantiation)
              internal
          {
              isInstantiation[instantiation] = true;
              instantiations[msg.sender].push(instantiation);
              ContractInstantiation(msg.sender, instantiation);
          }
      }
      
      /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
      /// @author Stefan George - <[email protected]>
      contract MultiSigWallet {
      
          /*
           *  Events
           */
          event Confirmation(address indexed sender, uint indexed transactionId);
          event Revocation(address indexed sender, uint indexed transactionId);
          event Submission(uint indexed transactionId);
          event Execution(uint indexed transactionId);
          event ExecutionFailure(uint indexed transactionId);
          event Deposit(address indexed sender, uint value);
          event OwnerAddition(address indexed owner);
          event OwnerRemoval(address indexed owner);
          event RequirementChange(uint required);
      
          /*
           *  Constants
           */
          uint constant public MAX_OWNER_COUNT = 50;
      
          /*
           *  Storage
           */
          mapping (uint => Transaction) public transactions;
          mapping (uint => mapping (address => bool)) public confirmations;
          mapping (address => bool) public isOwner;
          address[] public owners;
          uint public required;
          uint public transactionCount;
      
          struct Transaction {
              address destination;
              uint value;
              bytes data;
              bool executed;
          }
      
          /*
           *  Modifiers
           */
          modifier onlyWallet() {
              require(msg.sender == address(this));
              _;
          }
      
          modifier ownerDoesNotExist(address owner) {
              require(!isOwner[owner]);
              _;
          }
      
          modifier ownerExists(address owner) {
              require(isOwner[owner]);
              _;
          }
      
          modifier transactionExists(uint transactionId) {
              require(transactions[transactionId].destination != 0);
              _;
          }
      
          modifier confirmed(uint transactionId, address owner) {
              require(confirmations[transactionId][owner]);
              _;
          }
      
          modifier notConfirmed(uint transactionId, address owner) {
              require(!confirmations[transactionId][owner]);
              _;
          }
      
          modifier notExecuted(uint transactionId) {
              require(!transactions[transactionId].executed);
              _;
          }
      
          modifier notNull(address _address) {
              require(_address != 0);
              _;
          }
      
          modifier validRequirement(uint ownerCount, uint _required) {
              require(ownerCount <= MAX_OWNER_COUNT
                  && _required <= ownerCount
                  && _required != 0
                  && ownerCount != 0);
              _;
          }
      
          /// @dev Fallback function allows to deposit ether.
          function()
              payable
          {
              if (msg.value > 0)
                  Deposit(msg.sender, msg.value);
          }
      
          /*
           * Public functions
           */
          /// @dev Contract constructor sets initial owners and required number of confirmations.
          /// @param _owners List of initial owners.
          /// @param _required Number of required confirmations.
          function MultiSigWallet(address[] _owners, uint _required)
              public
              validRequirement(_owners.length, _required)
          {
              for (uint i=0; i<_owners.length; i++) {
                  require(!isOwner[_owners[i]] && _owners[i] != 0);
                  isOwner[_owners[i]] = true;
              }
              owners = _owners;
              required = _required;
          }
      
          /// @dev Allows to add a new owner. Transaction has to be sent by wallet.
          /// @param owner Address of new owner.
          function addOwner(address owner)
              public
              onlyWallet
              ownerDoesNotExist(owner)
              notNull(owner)
              validRequirement(owners.length + 1, required)
          {
              isOwner[owner] = true;
              owners.push(owner);
              OwnerAddition(owner);
          }
      
          /// @dev Allows to remove an owner. Transaction has to be sent by wallet.
          /// @param owner Address of owner.
          function removeOwner(address owner)
              public
              onlyWallet
              ownerExists(owner)
          {
              isOwner[owner] = false;
              for (uint i=0; i<owners.length - 1; i++)
                  if (owners[i] == owner) {
                      owners[i] = owners[owners.length - 1];
                      break;
                  }
              owners.length -= 1;
              if (required > owners.length)
                  changeRequirement(owners.length);
              OwnerRemoval(owner);
          }
      
          /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
          /// @param owner Address of owner to be replaced.
          /// @param newOwner Address of new owner.
          function replaceOwner(address owner, address newOwner)
              public
              onlyWallet
              ownerExists(owner)
              ownerDoesNotExist(newOwner)
          {
              for (uint i=0; i<owners.length; i++)
                  if (owners[i] == owner) {
                      owners[i] = newOwner;
                      break;
                  }
              isOwner[owner] = false;
              isOwner[newOwner] = true;
              OwnerRemoval(owner);
              OwnerAddition(newOwner);
          }
      
          /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
          /// @param _required Number of required confirmations.
          function changeRequirement(uint _required)
              public
              onlyWallet
              validRequirement(owners.length, _required)
          {
              required = _required;
              RequirementChange(_required);
          }
      
          /// @dev Allows an owner to submit and confirm a transaction.
          /// @param destination Transaction target address.
          /// @param value Transaction ether value.
          /// @param data Transaction data payload.
          /// @return Returns transaction ID.
          function submitTransaction(address destination, uint value, bytes data)
              public
              returns (uint transactionId)
          {
              transactionId = addTransaction(destination, value, data);
              confirmTransaction(transactionId);
          }
      
          /// @dev Allows an owner to confirm a transaction.
          /// @param transactionId Transaction ID.
          function confirmTransaction(uint transactionId)
              public
              ownerExists(msg.sender)
              transactionExists(transactionId)
              notConfirmed(transactionId, msg.sender)
          {
              confirmations[transactionId][msg.sender] = true;
              Confirmation(msg.sender, transactionId);
              executeTransaction(transactionId);
          }
      
          /// @dev Allows an owner to revoke a confirmation for a transaction.
          /// @param transactionId Transaction ID.
          function revokeConfirmation(uint transactionId)
              public
              ownerExists(msg.sender)
              confirmed(transactionId, msg.sender)
              notExecuted(transactionId)
          {
              confirmations[transactionId][msg.sender] = false;
              Revocation(msg.sender, transactionId);
          }
      
          /// @dev Allows anyone to execute a confirmed transaction.
          /// @param transactionId Transaction ID.
          function executeTransaction(uint transactionId)
              public
              ownerExists(msg.sender)
              confirmed(transactionId, msg.sender)
              notExecuted(transactionId)
          {
              if (isConfirmed(transactionId)) {
                  Transaction storage txn = transactions[transactionId];
                  txn.executed = true;
                  if (txn.destination.call.value(txn.value)(txn.data))
                      Execution(transactionId);
                  else {
                      ExecutionFailure(transactionId);
                      txn.executed = false;
                  }
              }
          }
      
          /// @dev Returns the confirmation status of a transaction.
          /// @param transactionId Transaction ID.
          /// @return Confirmation status.
          function isConfirmed(uint transactionId)
              public
              constant
              returns (bool)
          {
              uint count = 0;
              for (uint i=0; i<owners.length; i++) {
                  if (confirmations[transactionId][owners[i]])
                      count += 1;
                  if (count == required)
                      return true;
              }
          }
      
          /*
           * Internal functions
           */
          /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
          /// @param destination Transaction target address.
          /// @param value Transaction ether value.
          /// @param data Transaction data payload.
          /// @return Returns transaction ID.
          function addTransaction(address destination, uint value, bytes data)
              internal
              notNull(destination)
              returns (uint transactionId)
          {
              transactionId = transactionCount;
              transactions[transactionId] = Transaction({
                  destination: destination,
                  value: value,
                  data: data,
                  executed: false
              });
              transactionCount += 1;
              Submission(transactionId);
          }
      
          /*
           * Web3 call functions
           */
          /// @dev Returns number of confirmations of a transaction.
          /// @param transactionId Transaction ID.
          /// @return Number of confirmations.
          function getConfirmationCount(uint transactionId)
              public
              constant
              returns (uint count)
          {
              for (uint i=0; i<owners.length; i++)
                  if (confirmations[transactionId][owners[i]])
                      count += 1;
          }
      
          /// @dev Returns total number of transactions after filers are applied.
          /// @param pending Include pending transactions.
          /// @param executed Include executed transactions.
          /// @return Total number of transactions after filters are applied.
          function getTransactionCount(bool pending, bool executed)
              public
              constant
              returns (uint count)
          {
              for (uint i=0; i<transactionCount; i++)
                  if (   pending && !transactions[i].executed
                      || executed && transactions[i].executed)
                      count += 1;
          }
      
          /// @dev Returns list of owners.
          /// @return List of owner addresses.
          function getOwners()
              public
              constant
              returns (address[])
          {
              return owners;
          }
      
          /// @dev Returns array with owner addresses, which confirmed transaction.
          /// @param transactionId Transaction ID.
          /// @return Returns array of owner addresses.
          function getConfirmations(uint transactionId)
              public
              constant
              returns (address[] _confirmations)
          {
              address[] memory confirmationsTemp = new address[](owners.length);
              uint count = 0;
              uint i;
              for (i=0; i<owners.length; i++)
                  if (confirmations[transactionId][owners[i]]) {
                      confirmationsTemp[count] = owners[i];
                      count += 1;
                  }
              _confirmations = new address[](count);
              for (i=0; i<count; i++)
                  _confirmations[i] = confirmationsTemp[i];
          }
      
          /// @dev Returns list of transaction IDs in defined range.
          /// @param from Index start position of transaction array.
          /// @param to Index end position of transaction array.
          /// @param pending Include pending transactions.
          /// @param executed Include executed transactions.
          /// @return Returns array of transaction IDs.
          function getTransactionIds(uint from, uint to, bool pending, bool executed)
              public
              constant
              returns (uint[] _transactionIds)
          {
              uint[] memory transactionIdsTemp = new uint[](transactionCount);
              uint count = 0;
              uint i;
              for (i=0; i<transactionCount; i++)
                  if (   pending && !transactions[i].executed
                      || executed && transactions[i].executed)
                  {
                      transactionIdsTemp[count] = i;
                      count += 1;
                  }
              _transactionIds = new uint[](to - from);
              for (i=from; i<to; i++)
                  _transactionIds[i - from] = transactionIdsTemp[i];
          }
      }
      
      /// @title Multisignature wallet with daily limit - Allows an owner to withdraw a daily limit without multisig.
      /// @author Stefan George - <[email protected]>
      contract MultiSigWalletWithDailyLimit is MultiSigWallet {
      
          /*
           *  Events
           */
          event DailyLimitChange(uint dailyLimit);
      
          /*
           *  Storage
           */
          uint public dailyLimit;
          uint public lastDay;
          uint public spentToday;
      
          /*
           * Public functions
           */
          /// @dev Contract constructor sets initial owners, required number of confirmations and daily withdraw limit.
          /// @param _owners List of initial owners.
          /// @param _required Number of required confirmations.
          /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis.
          function MultiSigWalletWithDailyLimit(address[] _owners, uint _required, uint _dailyLimit)
              public
              MultiSigWallet(_owners, _required)
          {
              dailyLimit = _dailyLimit;
          }
      
          /// @dev Allows to change the daily limit. Transaction has to be sent by wallet.
          /// @param _dailyLimit Amount in wei.
          function changeDailyLimit(uint _dailyLimit)
              public
              onlyWallet
          {
              dailyLimit = _dailyLimit;
              DailyLimitChange(_dailyLimit);
          }
      
          /// @dev Allows anyone to execute a confirmed transaction or ether withdraws until daily limit is reached.
          /// @param transactionId Transaction ID.
          function executeTransaction(uint transactionId)
              public
              ownerExists(msg.sender)
              confirmed(transactionId, msg.sender)
              notExecuted(transactionId)
          {
              Transaction storage txn = transactions[transactionId];
              bool _confirmed = isConfirmed(transactionId);
              if (_confirmed || txn.data.length == 0 && isUnderLimit(txn.value)) {
                  txn.executed = true;
                  if (!_confirmed)
                      spentToday += txn.value;
                  if (txn.destination.call.value(txn.value)(txn.data))
                      Execution(transactionId);
                  else {
                      ExecutionFailure(transactionId);
                      txn.executed = false;
                      if (!_confirmed)
                          spentToday -= txn.value;
                  }
              }
          }
      
          /*
           * Internal functions
           */
          /// @dev Returns if amount is within daily limit and resets spentToday after one day.
          /// @param amount Amount to withdraw.
          /// @return Returns if amount is under daily limit.
          function isUnderLimit(uint amount)
              internal
              returns (bool)
          {
              if (now > lastDay + 24 hours) {
                  lastDay = now;
                  spentToday = 0;
              }
              if (spentToday + amount > dailyLimit || spentToday + amount < spentToday)
                  return false;
              return true;
          }
      
          /*
           * Web3 call functions
           */
          /// @dev Returns maximum withdraw amount.
          /// @return Returns amount.
          function calcMaxWithdraw()
              public
              constant
              returns (uint)
          {
              if (now > lastDay + 24 hours)
                  return dailyLimit;
              if (dailyLimit < spentToday)
                  return 0;
              return dailyLimit - spentToday;
          }
      }

      File 2 of 3: AdminUpgradeabilityProxy
      // File: zos-lib/contracts/upgradeability/Proxy.sol
      
      pragma solidity ^0.5.0;
      
      /**
       * @title Proxy
       * @dev Implements delegation of calls to other contracts, with proper
       * forwarding of return values and bubbling of failures.
       * It defines a fallback function that delegates all calls to the address
       * returned by the abstract _implementation() internal function.
       */
      contract Proxy {
        /**
         * @dev Fallback function.
         * Implemented entirely in `_fallback`.
         */
        function () payable external {
          _fallback();
        }
      
        /**
         * @return The Address of the implementation.
         */
        function _implementation() internal view returns (address);
      
        /**
         * @dev Delegates execution to an implementation contract.
         * This is a low level function that doesn't return to its internal call site.
         * It will return to the external caller whatever the implementation returns.
         * @param implementation Address to delegate.
         */
        function _delegate(address implementation) internal {
          assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize)
      
            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
      
            // Copy the returned data.
            returndatacopy(0, 0, returndatasize)
      
            switch result
            // delegatecall returns 0 on error.
            case 0 { revert(0, returndatasize) }
            default { return(0, returndatasize) }
          }
        }
      
        /**
         * @dev Function that is run as the first thing in the fallback function.
         * Can be redefined in derived contracts to add functionality.
         * Redefinitions must call super._willFallback().
         */
        function _willFallback() internal {
        }
      
        /**
         * @dev fallback implementation.
         * Extracted to enable manual triggering.
         */
        function _fallback() internal {
          _willFallback();
          _delegate(_implementation());
        }
      }
      
      // File: zos-lib/contracts/utils/Address.sol
      
      pragma solidity ^0.5.0;
      
      /**
       * Utility library of inline functions on addresses
       *
       * Source https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-solidity/v2.1.3/contracts/utils/Address.sol
       * This contract is copied here and renamed from the original to avoid clashes in the compiled artifacts
       * when the user imports a zos-lib contract (that transitively causes this contract to be compiled and added to the
       * build/artifacts folder) as well as the vanilla Address implementation from an openzeppelin version.
       */
      library ZOSLibAddress {
          /**
           * Returns whether the target address is a contract
           * @dev This function will return false if invoked during the constructor of a contract,
           * as the code is not actually created until after the constructor finishes.
           * @param account address of the account to check
           * @return whether the target address is a contract
           */
          function isContract(address account) internal view returns (bool) {
              uint256 size;
              // XXX Currently there is no better way to check if there is a contract in an address
              // than to check the size of the code at that address.
              // See https://ethereum.stackexchange.com/a/14016/36603
              // for more details about how this works.
              // TODO Check this again before the Serenity release, because all addresses will be
              // contracts then.
              // solhint-disable-next-line no-inline-assembly
              assembly { size := extcodesize(account) }
              return size > 0;
          }
      }
      
      // File: zos-lib/contracts/upgradeability/BaseUpgradeabilityProxy.sol
      
      pragma solidity ^0.5.0;
      
      
      
      /**
       * @title BaseUpgradeabilityProxy
       * @dev This contract implements a proxy that allows to change the
       * implementation address to which it will delegate.
       * Such a change is called an implementation upgrade.
       */
      contract BaseUpgradeabilityProxy is Proxy {
        /**
         * @dev Emitted when the implementation is upgraded.
         * @param implementation Address of the new implementation.
         */
        event Upgraded(address indexed implementation);
      
        /**
         * @dev Storage slot with the address of the current implementation.
         * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is
         * validated in the constructor.
         */
        bytes32 internal constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
      
        /**
         * @dev Returns the current implementation.
         * @return Address of the current implementation
         */
        function _implementation() internal view returns (address impl) {
          bytes32 slot = IMPLEMENTATION_SLOT;
          assembly {
            impl := sload(slot)
          }
        }
      
        /**
         * @dev Upgrades the proxy to a new implementation.
         * @param newImplementation Address of the new implementation.
         */
        function _upgradeTo(address newImplementation) internal {
          _setImplementation(newImplementation);
          emit Upgraded(newImplementation);
        }
      
        /**
         * @dev Sets the implementation address of the proxy.
         * @param newImplementation Address of the new implementation.
         */
        function _setImplementation(address newImplementation) internal {
          require(ZOSLibAddress.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
      
          bytes32 slot = IMPLEMENTATION_SLOT;
      
          assembly {
            sstore(slot, newImplementation)
          }
        }
      }
      
      // File: zos-lib/contracts/upgradeability/UpgradeabilityProxy.sol
      
      pragma solidity ^0.5.0;
      
      
      /**
       * @title UpgradeabilityProxy
       * @dev Extends BaseUpgradeabilityProxy with a constructor for initializing
       * implementation and init data.
       */
      contract UpgradeabilityProxy is BaseUpgradeabilityProxy {
        /**
         * @dev Contract constructor.
         * @param _logic Address of the initial implementation.
         * @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
         * It should include the signature and the parameters of the function to be called, as described in
         * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
         * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
         */
        constructor(address _logic, bytes memory _data) public payable {
          assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
          _setImplementation(_logic);
          if(_data.length > 0) {
            (bool success,) = _logic.delegatecall(_data);
            require(success);
          }
        }  
      }
      
      // File: zos-lib/contracts/upgradeability/BaseAdminUpgradeabilityProxy.sol
      
      pragma solidity ^0.5.0;
      
      
      /**
       * @title BaseAdminUpgradeabilityProxy
       * @dev This contract combines an upgradeability proxy with an authorization
       * mechanism for administrative tasks.
       * All external functions in this contract must be guarded by the
       * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity
       * feature proposal that would enable this to be done automatically.
       */
      contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy {
        /**
         * @dev Emitted when the administration has been transferred.
         * @param previousAdmin Address of the previous admin.
         * @param newAdmin Address of the new admin.
         */
        event AdminChanged(address previousAdmin, address newAdmin);
      
        /**
         * @dev Storage slot with the admin of the contract.
         * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is
         * validated in the constructor.
         */
        bytes32 internal constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b;
      
        /**
         * @dev Modifier to check whether the `msg.sender` is the admin.
         * If it is, it will run the function. Otherwise, it will delegate the call
         * to the implementation.
         */
        modifier ifAdmin() {
          if (msg.sender == _admin()) {
            _;
          } else {
            _fallback();
          }
        }
      
        /**
         * @return The address of the proxy admin.
         */
        function admin() external ifAdmin returns (address) {
          return _admin();
        }
      
        /**
         * @return The address of the implementation.
         */
        function implementation() external ifAdmin returns (address) {
          return _implementation();
        }
      
        /**
         * @dev Changes the admin of the proxy.
         * Only the current admin can call this function.
         * @param newAdmin Address to transfer proxy administration to.
         */
        function changeAdmin(address newAdmin) external ifAdmin {
          require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
          emit AdminChanged(_admin(), newAdmin);
          _setAdmin(newAdmin);
        }
      
        /**
         * @dev Upgrade the backing implementation of the proxy.
         * Only the admin can call this function.
         * @param newImplementation Address of the new implementation.
         */
        function upgradeTo(address newImplementation) external ifAdmin {
          _upgradeTo(newImplementation);
        }
      
        /**
         * @dev Upgrade the backing implementation of the proxy and call a function
         * on the new implementation.
         * This is useful to initialize the proxied contract.
         * @param newImplementation Address of the new implementation.
         * @param data Data to send as msg.data in the low level call.
         * It should include the signature and the parameters of the function to be called, as described in
         * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
         */
        function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin {
          _upgradeTo(newImplementation);
          (bool success,) = newImplementation.delegatecall(data);
          require(success);
        }
      
        /**
         * @return The admin slot.
         */
        function _admin() internal view returns (address adm) {
          bytes32 slot = ADMIN_SLOT;
          assembly {
            adm := sload(slot)
          }
        }
      
        /**
         * @dev Sets the address of the proxy admin.
         * @param newAdmin Address of the new proxy admin.
         */
        function _setAdmin(address newAdmin) internal {
          bytes32 slot = ADMIN_SLOT;
      
          assembly {
            sstore(slot, newAdmin)
          }
        }
      
        /**
         * @dev Only fall back when the sender is not the admin.
         */
        function _willFallback() internal {
          require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
          super._willFallback();
        }
      }
      
      // File: zos-lib/contracts/upgradeability/AdminUpgradeabilityProxy.sol
      
      pragma solidity ^0.5.0;
      
      
      /**
       * @title AdminUpgradeabilityProxy
       * @dev Extends from BaseAdminUpgradeabilityProxy with a constructor for 
       * initializing the implementation, admin, and init data.
       */
      contract AdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, UpgradeabilityProxy {
        /**
         * Contract constructor.
         * @param _logic address of the initial implementation.
         * @param _admin Address of the proxy administrator.
         * @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
         * It should include the signature and the parameters of the function to be called, as described in
         * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
         * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
         */
        constructor(address _logic, address _admin, bytes memory _data) UpgradeabilityProxy(_logic, _data) public payable {
          assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin"));
          _setAdmin(_admin);
        }
      }

      File 3 of 3: UFragmentsPolicy
      pragma solidity 0.7.6;
      import "./_external/SafeMath.sol";
      import "./_external/Ownable.sol";
      import "./lib/SafeMathInt.sol";
      import "./lib/UInt256Lib.sol";
      interface IUFragments {
          function totalSupply() external view returns (uint256);
          function rebase(uint256 epoch, int256 supplyDelta) external returns (uint256);
      }
      interface IOracle {
          function getData() external returns (uint256, bool);
      }
      /**
       * @title uFragments Monetary Supply Policy
       * @dev This is an implementation of the uFragments Ideal Money protocol.
       *      uFragments operates symmetrically on expansion and contraction. It will both split and
       *      combine coins to maintain a stable unit price.
       *
       *      This component regulates the token supply of the uFragments ERC20 token in response to
       *      market oracles.
       */
      contract UFragmentsPolicy is Ownable {
          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
          );
          IUFragments public uFrags;
          // 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(type(int256).max) / 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
           */
          function rebase() external onlyOrchestrator {
              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;
              bool cpiValid;
              (cpi, cpiValid) = cpiOracle.getData();
              require(cpiValid);
              uint256 targetRate = cpi.mul(10**DECIMALS).div(baseCpi);
              uint256 exchangeRate;
              bool rateValid;
              (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 && uFrags.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {
                  supplyDelta = (MAX_SUPPLY.sub(uFrags.totalSupply())).toInt256Safe();
              }
              uint256 supplyAfterRebase = uFrags.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_;
          }
          /**
           * @notice A multi-chain AMPL interface method. The Ampleforth monetary policy contract
           *         on the base-chain and XC-AmpleController contracts on the satellite-chains
           *         implement this method. It atomically returns two values:
           *         what the current contract believes to be,
           *         the globalAmpleforthEpoch and globalAMPLSupply.
           * @return globalAmpleforthEpoch The current epoch number.
           * @return globalAMPLSupply The total supply at the current epoch.
           */
          function globalAmpleforthEpochAndAMPLSupply() external view returns (uint256, uint256) {
              return (epoch, uFrags.totalSupply());
          }
          /**
           * @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(
              address owner_,
              IUFragments uFrags_,
              uint256 baseCpi_
          ) public initializer {
              Ownable.initialize(owner_);
              // 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;
              uFrags = uFrags_;
              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) internal view returns (int256) {
              if (withinDeviationThreshold(rate, targetRate)) {
                  return 0;
              }
              // supplyDelta = totalSupply * (rate - targetRate) / targetRate
              int256 targetRateSigned = targetRate.toInt256Safe();
              return
                  uFrags.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)
              internal
              view
              returns (bool)
          {
              uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold).div(10**DECIMALS);
              return
                  (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) ||
                  (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold);
          }
      }
      pragma solidity 0.7.6;
      /**
       * @title SafeMath
       * @dev Math operations with safety checks that revert on error
       */
      library SafeMath {
          /**
           * @dev Multiplies two numbers, reverts on overflow.
           */
          function mul(uint256 a, uint256 b) internal pure returns (uint256) {
              // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
              // benefit is lost if 'b' is also tested.
              // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
              if (a == 0) {
                  return 0;
              }
              uint256 c = a * b;
              require(c / a == b);
              return c;
          }
          /**
           * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
           */
          function div(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b > 0); // Solidity only automatically asserts when dividing by 0
              uint256 c = a / b;
              // assert(a == b * c + a % b); // There is no case in which this doesn't hold
              return c;
          }
          /**
           * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
           */
          function sub(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b <= a);
              uint256 c = a - b;
              return c;
          }
          /**
           * @dev Adds two numbers, reverts on overflow.
           */
          function add(uint256 a, uint256 b) internal pure returns (uint256) {
              uint256 c = a + b;
              require(c >= a);
              return c;
          }
          /**
           * @dev Divides two numbers and returns the remainder (unsigned integer modulo),
           * reverts when dividing by zero.
           */
          function mod(uint256 a, uint256 b) internal pure returns (uint256) {
              require(b != 0);
              return a % b;
          }
      }
      pragma solidity 0.7.6;
      import "./Initializable.sol";
      /**
       * @title Ownable
       * @dev The Ownable contract has an owner address, and provides basic authorization control
       * functions, this simplifies the implementation of "user permissions".
       */
      contract Ownable is Initializable {
          address private _owner;
          event OwnershipRenounced(address indexed previousOwner);
          event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
          /**
           * @dev The Ownable constructor sets the original `owner` of the contract to the sender
           * account.
           */
          function initialize(address sender) public virtual initializer {
              _owner = sender;
          }
          /**
           * @return the address of the owner.
           */
          function owner() public view returns (address) {
              return _owner;
          }
          /**
           * @dev Throws if called by any account other than the owner.
           */
          modifier onlyOwner() {
              require(isOwner());
              _;
          }
          /**
           * @return true if `msg.sender` is the owner of the contract.
           */
          function isOwner() public view returns (bool) {
              return msg.sender == _owner;
          }
          /**
           * @dev Allows the current owner to relinquish control of the contract.
           * @notice Renouncing to ownership will leave the contract without an owner.
           * It will not be possible to call the functions with the `onlyOwner`
           * modifier anymore.
           */
          function renounceOwnership() public onlyOwner {
              emit OwnershipRenounced(_owner);
              _owner = address(0);
          }
          /**
           * @dev Allows the current owner to transfer control of the contract to a newOwner.
           * @param newOwner The address to transfer ownership to.
           */
          function transferOwnership(address newOwner) public onlyOwner {
              _transferOwnership(newOwner);
          }
          /**
           * @dev Transfers control of the contract to a newOwner.
           * @param newOwner The address to transfer ownership to.
           */
          function _transferOwnership(address newOwner) internal {
              require(newOwner != address(0));
              emit OwnershipTransferred(_owner, newOwner);
              _owner = newOwner;
          }
          uint256[50] private ______gap;
      }
      /*
      MIT License
      Copyright (c) 2018 requestnetwork
      Copyright (c) 2018 Fragments, Inc.
      Permission is hereby granted, free of charge, to any person obtaining a copy
      of this software and associated documentation files (the "Software"), to deal
      in the Software without restriction, including without limitation the rights
      to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      copies of the Software, and to permit persons to whom the Software is
      furnished to do so, subject to the following conditions:
      The above copyright notice and this permission notice shall be included in all
      copies or substantial portions of the Software.
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      SOFTWARE.
      */
      pragma solidity 0.7.6;
      /**
       * @title SafeMathInt
       * @dev Math operations for int256 with overflow safety checks.
       */
      library SafeMathInt {
          int256 private constant MIN_INT256 = int256(1) << 255;
          int256 private constant MAX_INT256 = ~(int256(1) << 255);
          /**
           * @dev Multiplies two int256 variables and fails on overflow.
           */
          function mul(int256 a, int256 b) internal pure returns (int256) {
              int256 c = a * b;
              // Detect overflow when multiplying MIN_INT256 with -1
              require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
              require((b == 0) || (c / b == a));
              return c;
          }
          /**
           * @dev Division of two int256 variables and fails on overflow.
           */
          function div(int256 a, int256 b) internal pure returns (int256) {
              // Prevent overflow when dividing MIN_INT256 by -1
              require(b != -1 || a != MIN_INT256);
              // Solidity already throws when dividing by 0.
              return a / b;
          }
          /**
           * @dev Subtracts two int256 variables and fails on overflow.
           */
          function sub(int256 a, int256 b) internal pure returns (int256) {
              int256 c = a - b;
              require((b >= 0 && c <= a) || (b < 0 && c > a));
              return c;
          }
          /**
           * @dev Adds two int256 variables and fails on overflow.
           */
          function add(int256 a, int256 b) internal pure returns (int256) {
              int256 c = a + b;
              require((b >= 0 && c >= a) || (b < 0 && c < a));
              return c;
          }
          /**
           * @dev Converts to absolute value, and fails on overflow.
           */
          function abs(int256 a) internal pure returns (int256) {
              require(a != MIN_INT256);
              return a < 0 ? -a : a;
          }
      }
      pragma solidity 0.7.6;
      /**
       * @title Various utilities useful for uint256.
       */
      library UInt256Lib {
          uint256 private constant MAX_INT256 = ~(uint256(1) << 255);
          /**
           * @dev Safely converts a uint256 to an int256.
           */
          function toInt256Safe(uint256 a) internal pure returns (int256) {
              require(a <= MAX_INT256);
              return int256(a);
          }
      }
      pragma solidity 0.7.6;
      /**
       * @title Initializable
       *
       * @dev Helper contract to support initializer functions. To use it, replace
       * the constructor with a function that has the `initializer` modifier.
       * WARNING: Unlike constructors, initializer functions must be manually
       * invoked. This applies both to deploying an Initializable contract, as well
       * as extending an Initializable contract via inheritance.
       * WARNING: When used with inheritance, manual care must be taken to not invoke
       * a parent initializer twice, or ensure that all initializers are idempotent,
       * because this is not dealt with automatically as with constructors.
       */
      contract Initializable {
          /**
           * @dev Indicates that the contract has been initialized.
           */
          bool private initialized;
          /**
           * @dev Indicates that the contract is in the process of being initialized.
           */
          bool private initializing;
          /**
           * @dev Modifier to use in the initializer function of a contract.
           */
          modifier initializer() {
              require(
                  initializing || isConstructor() || !initialized,
                  "Contract instance has already been initialized"
              );
              bool wasInitializing = initializing;
              initializing = true;
              initialized = true;
              _;
              initializing = wasInitializing;
          }
          /// @dev Returns true if and only if the function is running in the constructor
          function isConstructor() private view returns (bool) {
              // extcodesize checks the size of the code stored in an address, and
              // address returns the current address. Since the code is still not
              // deployed when running a constructor, any checks on its code size will
              // yield zero, making it an effective way to detect if a contract is
              // under construction or not.
              // MINOR CHANGE HERE:
              // previous code
              // uint256 cs;
              // assembly { cs := extcodesize(address) }
              // return cs == 0;
              // current code
              address _self = address(this);
              uint256 cs;
              assembly {
                  cs := extcodesize(_self)
              }
              return cs == 0;
          }
          // Reserved storage space to allow for layout changes in the future.
          uint256[50] private ______gap;
      }