Contract 0xaD67C3bF4673F1238e330256a4E1225B9418E6C0

 
Txn Hash
Method
Block
From
To
Value
0xc5b5706445e5e8cbd2602317ca58e867a8ea98d772e87e2e8a9d89fca52001ee0x60806040120201282021-03-11 23:04:31573 days 12 hrs agoStabilize Finance: Deployer 2 IN  Create: StabinolSpentETHOracle0 Ether0.07302939145
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StabinolSpentETHOracle

Compiler Version
v0.6.6+commit.6c089d02

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion, GNU GPLv3 license
/**
 *Submitted for verification at Etherscan.io on 2021-03-11
*/

// Spent ETH Oracle for Stabinol
// This oracle collects eth data from various whitelisted data sources to generate a database of eth spent data for users
// The ETH spent data will be used by the Stabinol Claimer to determine how much cashback to reward to STOL LP holders
// 
// Governace can update whitelisted addresses, change eth spent balances per user and update the iteration of the oracle (which resets all balances to 0)

pragma solidity =0.6.6;

contract StabinolSpentETHOracle {

    address public governance;
    uint256 private _globalIteration; // This resets all the balances back to 0
    
    mapping(address => UserInfo) private allUsersInfo;
    mapping(address => bool) private providers; // This will be a list of all providers eligible
    
    event GovernanceUpdated(address _add);
    event ProviderAdded(address _add);
    event ProviderRemoved(address _add);
    event NewIteration(uint256 _iter);
    event UserETHSpentUpdated(address _updater, address _user, uint256 _amount);
    
    // Structs
    struct UserInfo {
        uint256 ethSpent; // The amount of eth spent since last claim
        uint256 iteration; // The iteration version of the user
    }

    constructor() public {
        governance = msg.sender;
    }
    
    modifier onlyGovernance() {
        require(governance == msg.sender, "Ownable: caller is not the owner");
        _;
    }
    
    function getCurrentIteration() external view returns (uint256) {
        return _globalIteration;
    }
    
    function getUserETHSpent(address _add) external view returns (uint256) {
        if(allUsersInfo[_add].iteration < _globalIteration){
            return 0; // The user is on an old iteration of this oracle
        }else{
            return allUsersInfo[_add].ethSpent; // Get the eth septn
        }
    }
    
    function getUserIteration(address _add) external view returns (uint256) {
        return allUsersInfo[_add].iteration;
    }
    
    function isAddressProvider(address _add) public view returns (bool) {
        return providers[_add];
    }
    
    // Write functions
    // Whitelisted contracts can call this oracle to update the amount the user spent to perform a call
    function addUserETHSpent(address _add, uint256 _ethback) external returns (bool) {
        if(isAddressProvider(msg.sender) == false){
            return false; // Don't revert, just return false instead
        }
        if(allUsersInfo[_add].iteration < _globalIteration){
            allUsersInfo[_add].iteration = _globalIteration;
            allUsersInfo[_add].ethSpent = 0;
        }
        allUsersInfo[_add].ethSpent = allUsersInfo[_add].ethSpent + _ethback; // Overflow is ok
        emit UserETHSpentUpdated(msg.sender, _add, _ethback); // Create an event
        return true; // This function will never revert so safe to be integrated
    }
    
    // Governance functions
    function updateGovernanceAddress(address _add) external onlyGovernance {
        require(_add != address(0), "Can't set to 0 address");
        governance = _add;
        emit GovernanceUpdated(_add);
    }
    
    function governanceUpdateUserETHSpent(address _add, uint256 amount) external onlyGovernance {
        // Governance can update users balances manually in case of errors
        allUsersInfo[_add].iteration = _globalIteration; // Set to the current iteration
        allUsersInfo[_add].ethSpent = amount;
    }
    
    function governanceAddToProviders(address _add) external onlyGovernance {
        providers[_add] = true;
        emit ProviderAdded(_add);
    }
    
    function governanceRemoveFromProviders(address _add) external onlyGovernance {
        providers[_add] = false;
        emit ProviderRemoved(_add);
    }
    
    function governanceNewIteration() external onlyGovernance {
        // This will reset all ETH spends back to zero
        _globalIteration = _globalIteration + 1;
        emit NewIteration(_globalIteration);
    }
    
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_add","type":"address"}],"name":"GovernanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_iter","type":"uint256"}],"name":"NewIteration","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_add","type":"address"}],"name":"ProviderAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_add","type":"address"}],"name":"ProviderRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_updater","type":"address"},{"indexed":false,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"UserETHSpentUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"_add","type":"address"},{"internalType":"uint256","name":"_ethback","type":"uint256"}],"name":"addUserETHSpent","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCurrentIteration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"getUserETHSpent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"getUserIteration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"governanceAddToProviders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"governanceNewIteration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"governanceRemoveFromProviders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"governanceUpdateUserETHSpent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"isAddressProvider","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_add","type":"address"}],"name":"updateGovernanceAddress","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50600080546001600160a01b031916331790556107c5806100326000396000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c80636faabf5f11610081578063b90d89301161005b578063b90d89301461020c578063ca15efd114610232578063da9dfa0a1461023a576100c9565b80636faabf5f146101a6578063a3f98823146101c0578063b7a5116e146101e6576100c9565b80633b3fa241116100b25780633b3fa2411461011c5780634a5db28c1461015c5780635aa6e67514610182576100c9565b806306348f3e146100ce5780630c7fc7c3146100f6575b600080fd5b6100f4600480360360208110156100e457600080fd5b50356001600160a01b0316610266565b005b6100f46004803603602081101561010c57600080fd5b50356001600160a01b031661031d565b6101486004803603604081101561013257600080fd5b506001600160a01b0381351690602001356103d7565b604080519115158252519081900360200190f35b6101486004803603602081101561017257600080fd5b50356001600160a01b03166104a3565b61018a6104c5565b604080516001600160a01b039092168252519081900360200190f35b6101ae6104d4565b60408051918252519081900360200190f35b6101ae600480360360208110156101d657600080fd5b50356001600160a01b03166104da565b6101ae600480360360208110156101fc57600080fd5b50356001600160a01b0316610527565b6100f46004803603602081101561022257600080fd5b50356001600160a01b0316610545565b6100f461066b565b6100f46004803603604081101561025057600080fd5b506001600160a01b038135169060200135610708565b6000546001600160a01b031633146102c5576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116600081815260036020908152604091829020805460ff19169055815192835290517f1589f8555933761a3cff8aa925061be3b46e2dd43f621322ab611d300f62b1d99281900390910190a150565b6000546001600160a01b0316331461037c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116600081815260036020908152604091829020805460ff19166001179055815192835290517fae9c2c6481964847714ce58f65a7f6dcc41d0d8394449bacdf161b5920c4744a9281900390910190a150565b60006103e2336104a3565b6103ee5750600061049d565b600180546001600160a01b038516600090815260026020526040902090910154101561043a57600180546001600160a01b03851660009081526002602052604081209283019190915590555b6001600160a01b038316600081815260026020908152604091829020805486019055815133815290810192909252818101849052517f27c0b38d54c0fe7cc1e3d5df15b1359be59cb43a10e706959eac8f5d6d1ee73d9181900360600190a15060015b92915050565b6001600160a01b03811660009081526003602052604090205460ff165b919050565b6000546001600160a01b031681565b60015490565b600180546001600160a01b0383166000908152600260205260408120909201541015610508575060006104c0565b506001600160a01b0381166000908152600260205260409020546104c0565b6001600160a01b031660009081526002602052604090206001015490565b6000546001600160a01b031633146105a4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166105ff576040805162461bcd60e51b815260206004820152601660248201527f43616e27742073657420746f2030206164647265737300000000000000000000604482015290519081900360640190fd5b600080546001600160a01b0383167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915560408051918252517f9d3e522e1e47a2f6009739342b9cc7b252a1888154e843ab55ee1c81745795ab9181900360200190a150565b6000546001600160a01b031633146106ca576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001805481019081905560408051918252517f5897baeb88942cacf61155dbb84caf33542aeca607ce229e604a28ce18cdc7c59181900360200190a1565b6000546001600160a01b03163314610767576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600180546001600160a01b03909316600090815260026020526040902090810192909255905556fea26469706673582212201aa70f0a0ca89292817796e16e5d13956e9fe6f15721be6cbff91b7a39c8a11264736f6c63430006060033

Deployed ByteCode Sourcemap

466:3607:0:-:0;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;466:3607:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;3678:156:0;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;3678:156:0;-1:-1:-1;;;;;3678:156:0;;:::i;:::-;;3518:148;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;3518:148:0;-1:-1:-1;;;;;3518:148:0;;:::i;2265:665::-;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;;;;;;2265:665:0;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;2015:109;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;2015:109:0;-1:-1:-1;;;;;2015:109:0;;:::i;507:25::-;;;:::i;:::-;;;;-1:-1:-1;;;;;507:25:0;;;;;;;;;;;;;;1437:105;;;:::i;:::-;;;;;;;;;;;;;;;;1554:311;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1554:311:0;-1:-1:-1;;;;;1554:311:0;;:::i;1877:126::-;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;1877:126:0;-1:-1:-1;;;;;1877:126:0;;:::i;2971:210::-;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;2971:210:0;-1:-1:-1;;;;;2971:210:0;;:::i;3846:218::-;;;:::i;3193:313::-;;;;;;15:2:-1;10:3;7:11;4:2;;;31:1;28;21:12;4:2;-1:-1;;;;;;3193:313:0;;;;;;;;:::i;3678:156::-;1344:10;;-1:-1:-1;;;;;1344:10:0;1358;1344:24;1336:69;;;;;-1:-1:-1;;;1336:69:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3766:15:0;::::1;3784:5;3766:15:::0;;;:9:::1;:15;::::0;;;;;;;;:23;;-1:-1:-1;;3766:23:0::1;::::0;;3805:21;;;;;;;::::1;::::0;;;;;;;;::::1;3678:156:::0;:::o;3518:148::-;1344:10;;-1:-1:-1;;;;;1344:10:0;1358;1344:24;1336:69;;;;;-1:-1:-1;;;1336:69:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3601:15:0;::::1;;::::0;;;:9:::1;:15;::::0;;;;;;;;:22;;-1:-1:-1;;3601:22:0::1;3619:4;3601:22;::::0;;3639:19;;;;;;;::::1;::::0;;;;;;;;::::1;3518:148:::0;:::o;2265:665::-;2340:4;2360:29;2378:10;2360:17;:29::i;:::-;2357:124;;-1:-1:-1;2421:5:0;2414:12;;2357:124;2525:16;;;-1:-1:-1;;;;;2494:18:0;;;;;;:12;:18;;;;;:28;;;;:47;2491:171;;;2588:16;;;-1:-1:-1;;;;;2557:18:0;;;;;;:12;:18;;;;;:28;;;:47;;;;2619:31;;2491:171;-1:-1:-1;;;;;2702:18:0;;;;;;:12;:18;;;;;;;;;:27;;:38;;2672:68;;2774:47;;2794:10;2774:47;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2858:4:0;2265:665;;;;;:::o;2015:109::-;-1:-1:-1;;;;;2101:15:0;;2077:4;2101:15;;;:9;:15;;;;;;;;2015:109;;;;:::o;507:25::-;;;-1:-1:-1;;;;;507:25:0;;:::o;1437:105::-;1518:16;;1437:105;:::o;1554:311::-;1670:16;;;-1:-1:-1;;;;;1639:18:0;;1616:7;1639:18;;;:12;:18;;;;;:28;;;;:47;1636:222;;;-1:-1:-1;1709:1:0;1702:8;;1636:222;-1:-1:-1;;;;;;1798:18:0;;;;;;:12;:18;;;;;:27;1791:34;;1877:126;-1:-1:-1;;;;;1967:18:0;1940:7;1967:18;;;:12;:18;;;;;:28;;;;1877:126::o;2971:210::-;1344:10;;-1:-1:-1;;;;;1344:10:0;1358;1344:24;1336:69;;;;;-1:-1:-1;;;1336:69:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3061:18:0;::::1;3053:53;;;::::0;;-1:-1:-1;;;3053:53:0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;3117:10;:17:::0;;-1:-1:-1;;;;;3117:17:0;::::1;::::0;;;::::1;::::0;::::1;::::0;;;3150:23:::1;::::0;;;;;;::::1;::::0;;;;::::1;::::0;;::::1;2971:210:::0;:::o;3846:218::-;1344:10;;-1:-1:-1;;;;;1344:10:0;1358;1344:24;1336:69;;;;;-1:-1:-1;;;1336:69:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3990:16:::1;::::0;;:20;::::1;3971:39:::0;;;;4026:30:::1;::::0;;;;;;::::1;::::0;;;;::::1;::::0;;::::1;3846:218::o:0;3193:313::-;1344:10;;-1:-1:-1;;;;;1344:10:0;1358;1344:24;1336:69;;;;;-1:-1:-1;;;1336:69:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3403:16:::1;::::0;;-1:-1:-1;;;;;3372:18:0;;::::1;;::::0;;;:12:::1;:18;::::0;;;;:28;;::::1;:47:::0;;;;3462:36;;3193:313::o

Swarm Source

ipfs://1aa70f0a0ca89292817796e16e5d13956e9fe6f15721be6cbff91b7a39c8a112
Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.