Address Details
contract

0xF7a5D241Ac3d884BeBB5Da76385Aa962c799F23E

Contract Name
Liquidator
Creator
0xd3c2ab–ffc681 at 0xbc9c8e–92ba90
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
101 Transactions
Transfers
0 Transfers
Gas Used
12,771,952
Last Balance Update
18137401
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Liquidator




Optimization enabled
true
Compiler version
v0.8.16+commit.07a7930e




Optimization runs
800
EVM Version
london




Verified at
2023-03-01T06:54:42.317529Z

contracts/core/Liquidator.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../access/Governable.sol";
import "../interfaces/IDex.sol";
import "../interfaces/IOracle.sol";

contract Liquidator is Governable {
    address public immutable dex;
    address public immutable oracle;

    mapping(address => bool) public isKeeper;

    event SetKeeper(address keeper, bool isActive);

    modifier onlyKeeper() {
        require(isKeeper[msg.sender], "Liquidator: !keeper");
        _;
    }

    constructor(address _dex, address _oracle) {
        dex = _dex;
        oracle = _oracle;
    }

    function liquidateWithPrices(
        uint256[] memory productIds,
        uint256[] memory prices,
        bytes32[] calldata positionKeys
    ) external onlyKeeper {
        IOracle(oracle).setPrices(productIds, prices);
        IDex(dex).liquidatePositions(positionKeys);
    }

    function setKeeper(address _account, bool _isActive) external onlyGov {
        isKeeper[_account] = _isActive;
        emit SetKeeper(_account, _isActive);
    }
}
        

/contracts/access/Governable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract Governable {
    address public gov;

    event SetGov(address indexed newGov);

    constructor() {
        gov = msg.sender;
    }

    modifier onlyGov() {
        require(msg.sender == gov, "Governable: forbidden");
        _;
    }

    function setGov(address _gov) external onlyGov {
        gov = _gov;
        emit SetGov(_gov);
    }
}
          

/contracts/interfaces/IDex.sol

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IDex {
    function stakeVaultToCompound(address user, uint256 amount) external;

    function openPosition(
        address user,
        uint256 productId,
        bool isLong,
        uint256 margin,
        uint256 leverage
    ) external;

    function validateOpenPositionRequirements(
        uint256 margin,
        uint256 leverage,
        uint256 productId
    ) external view;

    function closePosition(
        address user,
        uint256 productId,
        bool isLong,
        uint256 margin
    ) external;

    function liquidatePositions(bytes32[] calldata positionKeys) external;

    function distributeVaultReward() external returns (uint256);

    function distributeStakingReward() external returns (uint256);

    function getVaultShares() external view returns (uint256);

    function getStakeShares(address user) external view returns (uint256);

    function getPositionLeverage(
        address account,
        uint256 productId,
        bool isLong
    ) external view returns (uint256);

    function minMargin() external view returns (uint256);

    function totalProducts() external view returns (uint256);

    function getTradeFee(
        uint256 margin,
        uint256 leverage,
        uint256 productId
    ) external view returns (uint256);

    function getPendingVaultReward() external view returns (uint256);

    function getPendingStakingReward() external view returns (uint256);
}
          

/contracts/interfaces/IOracle.sol

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IOracle {
    function getPrice(uint256 productId) external view returns (uint256);

    function getPrice(uint256 productId, bool isLong) external view returns (uint256);

    function setPrices(uint256[] memory productIds, uint256[] memory prices) external;
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_dex","internalType":"address"},{"type":"address","name":"_oracle","internalType":"address"}]},{"type":"event","name":"SetGov","inputs":[{"type":"address","name":"newGov","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetKeeper","inputs":[{"type":"address","name":"keeper","internalType":"address","indexed":false},{"type":"bool","name":"isActive","internalType":"bool","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"dex","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"gov","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isKeeper","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"liquidateWithPrices","inputs":[{"type":"uint256[]","name":"productIds","internalType":"uint256[]"},{"type":"uint256[]","name":"prices","internalType":"uint256[]"},{"type":"bytes32[]","name":"positionKeys","internalType":"bytes32[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"oracle","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setGov","inputs":[{"type":"address","name":"_gov","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setKeeper","inputs":[{"type":"address","name":"_account","internalType":"address"},{"type":"bool","name":"_isActive","internalType":"bool"}]}]
              

Contract Creation Code

0x60c060405234801561001057600080fd5b506040516107fd3803806107fd83398101604081905261002f91610074565b600080546001600160a01b031916331790556001600160a01b039182166080521660a0526100a7565b80516001600160a01b038116811461006f57600080fd5b919050565b6000806040838503121561008757600080fd5b61009083610058565b915061009e60208401610058565b90509250929050565b60805160a0516107246100d96000396000818161011101526101e901526000818160b7015261026701526107246000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c80637dc0d1d01161005b5780637dc0d1d01461010c57806382fb5aab14610133578063cfad57a214610148578063d1b9e8531461015b57600080fd5b806312d43a5114610082578063692058c2146100b25780636ba42aaa146100d9575b600080fd5b600054610095906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100957f000000000000000000000000000000000000000000000000000000000000000081565b6100fc6100e736600461046b565b60016020526000908152604090205460ff1681565b60405190151581526020016100a9565b6100957f000000000000000000000000000000000000000000000000000000000000000081565b61014661014136600461053e565b61016e565b005b61014661015636600461046b565b6102d8565b6101466101693660046105f7565b610392565b3360009081526001602052604090205460ff166101d25760405162461bcd60e51b815260206004820152601360248201527f4c697175696461746f723a20216b65657065720000000000000000000000000060448201526064015b60405180910390fd5b604051630682f55760e51b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d05eaae090610220908790879060040161066e565b600060405180830381600087803b15801561023a57600080fd5b505af115801561024e573d6000803e3d6000fd5b505060405163180981eb60e31b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063c04c0f5891506102a0908590859060040161069c565b600060405180830381600087803b1580156102ba57600080fd5b505af11580156102ce573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146103325760405162461bcd60e51b815260206004820152601560248201527f476f7665726e61626c653a20666f7262696464656e000000000000000000000060448201526064016101c9565b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117825560405190917f91a8c1cc2d4a3bb60738481947a00cbb9899c822916694cf8bb1d68172fdcd5491a250565b6000546001600160a01b031633146103ec5760405162461bcd60e51b815260206004820152601560248201527f476f7665726e61626c653a20666f7262696464656e000000000000000000000060448201526064016101c9565b6001600160a01b038216600081815260016020908152604091829020805460ff19168515159081179091558251938452908301527f8c2ff6748f99f65f4ebf8a1e973a289bad216c4d5b20fda1940d9e01118ae42a910160405180910390a15050565b80356001600160a01b038116811461046657600080fd5b919050565b60006020828403121561047d57600080fd5b6104868261044f565b9392505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126104b457600080fd5b8135602067ffffffffffffffff808311156104d1576104d161048d565b8260051b604051601f19603f830116810181811084821117156104f6576104f661048d565b60405293845285810183019383810192508785111561051457600080fd5b83870191505b848210156105335781358352918301919083019061051a565b979650505050505050565b6000806000806060858703121561055457600080fd5b843567ffffffffffffffff8082111561056c57600080fd5b610578888389016104a3565b9550602087013591508082111561058e57600080fd5b61059a888389016104a3565b945060408701359150808211156105b057600080fd5b818701915087601f8301126105c457600080fd5b8135818111156105d357600080fd5b8860208260051b85010111156105e857600080fd5b95989497505060200194505050565b6000806040838503121561060a57600080fd5b6106138361044f565b91506020830135801515811461062857600080fd5b809150509250929050565b600081518084526020808501945080840160005b8381101561066357815187529582019590820190600101610647565b509495945050505050565b6040815260006106816040830185610633565b82810360208401526106938185610633565b95945050505050565b6020815281602082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156106d557600080fd5b8260051b8085604085013791909101604001939250505056fea264697066735822122005c8252609e227b9fbb7140a24540f30db8e6dad0357d17a12eb81e59fb7272a64736f6c634300081000330000000000000000000000009b6869733e4b2d1db6c1183dd7008136f6fa553c000000000000000000000000137de6b9f0b91f4ede8ffecec41cd91341ae5472

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80637dc0d1d01161005b5780637dc0d1d01461010c57806382fb5aab14610133578063cfad57a214610148578063d1b9e8531461015b57600080fd5b806312d43a5114610082578063692058c2146100b25780636ba42aaa146100d9575b600080fd5b600054610095906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100957f0000000000000000000000009b6869733e4b2d1db6c1183dd7008136f6fa553c81565b6100fc6100e736600461046b565b60016020526000908152604090205460ff1681565b60405190151581526020016100a9565b6100957f000000000000000000000000137de6b9f0b91f4ede8ffecec41cd91341ae547281565b61014661014136600461053e565b61016e565b005b61014661015636600461046b565b6102d8565b6101466101693660046105f7565b610392565b3360009081526001602052604090205460ff166101d25760405162461bcd60e51b815260206004820152601360248201527f4c697175696461746f723a20216b65657065720000000000000000000000000060448201526064015b60405180910390fd5b604051630682f55760e51b81526001600160a01b037f000000000000000000000000137de6b9f0b91f4ede8ffecec41cd91341ae5472169063d05eaae090610220908790879060040161066e565b600060405180830381600087803b15801561023a57600080fd5b505af115801561024e573d6000803e3d6000fd5b505060405163180981eb60e31b81526001600160a01b037f0000000000000000000000009b6869733e4b2d1db6c1183dd7008136f6fa553c16925063c04c0f5891506102a0908590859060040161069c565b600060405180830381600087803b1580156102ba57600080fd5b505af11580156102ce573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146103325760405162461bcd60e51b815260206004820152601560248201527f476f7665726e61626c653a20666f7262696464656e000000000000000000000060448201526064016101c9565b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117825560405190917f91a8c1cc2d4a3bb60738481947a00cbb9899c822916694cf8bb1d68172fdcd5491a250565b6000546001600160a01b031633146103ec5760405162461bcd60e51b815260206004820152601560248201527f476f7665726e61626c653a20666f7262696464656e000000000000000000000060448201526064016101c9565b6001600160a01b038216600081815260016020908152604091829020805460ff19168515159081179091558251938452908301527f8c2ff6748f99f65f4ebf8a1e973a289bad216c4d5b20fda1940d9e01118ae42a910160405180910390a15050565b80356001600160a01b038116811461046657600080fd5b919050565b60006020828403121561047d57600080fd5b6104868261044f565b9392505050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126104b457600080fd5b8135602067ffffffffffffffff808311156104d1576104d161048d565b8260051b604051601f19603f830116810181811084821117156104f6576104f661048d565b60405293845285810183019383810192508785111561051457600080fd5b83870191505b848210156105335781358352918301919083019061051a565b979650505050505050565b6000806000806060858703121561055457600080fd5b843567ffffffffffffffff8082111561056c57600080fd5b610578888389016104a3565b9550602087013591508082111561058e57600080fd5b61059a888389016104a3565b945060408701359150808211156105b057600080fd5b818701915087601f8301126105c457600080fd5b8135818111156105d357600080fd5b8860208260051b85010111156105e857600080fd5b95989497505060200194505050565b6000806040838503121561060a57600080fd5b6106138361044f565b91506020830135801515811461062857600080fd5b809150509250929050565b600081518084526020808501945080840160005b8381101561066357815187529582019590820190600101610647565b509495945050505050565b6040815260006106816040830185610633565b82810360208401526106938185610633565b95945050505050565b6020815281602082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156106d557600080fd5b8260051b8085604085013791909101604001939250505056fea264697066735822122005c8252609e227b9fbb7140a24540f30db8e6dad0357d17a12eb81e59fb7272a64736f6c63430008100033