Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xcE355440c00014A229bbEc030A2B8f8EB45a2897
Balance 0 ETH
Nonce 1
Code Size 4509 bytes
Indexed Transactions 2 (24,424,07924,424,150)
Gas Used (indexed) 344,295
External Etherscan · Sourcify

Contract Bytecode

4509 bytes
0x608060405234801561001057600080fd5b50600436106101165760003560e01c806395991276116100a2578063c5ce281e11610071578063c5ce281e1461028e578063c78d6d2114610296578063dc4d20fa1461029e578063f582d293146102c4578063fae036d5146102cc57610116565b806395991276146101f05780639c52a7f11461021c578063a3b22fc414610242578063bf353dbb1461026857610116565b8063568d4b6f116100e9578063568d4b6f1461017457806358197a9d1461018e578063626cb3c51461019657806365fae35e1461019e5780638d7ef9bb146101c457610116565b806301664f661461011b5780630c30bc021461013f57806329ae81141461014757806336569e771461016c575b600080fd5b6101236102d4565b604080516001600160a01b039092168252519081900360200190f35b6101236102f8565b61016a6004803603604081101561015d57600080fd5b508035906020013561031c565b005b610123610470565b61017c610494565b60408051918252519081900360200190f35b61017c61049a565b6101236104a0565b61016a600480360360208110156101b457600080fd5b50356001600160a01b03166104c4565b61016a600480360360408110156101da57600080fd5b506001600160a01b038135169060200135610566565b61016a6004803603604081101561020657600080fd5b506001600160a01b038135169060200135610a05565b61016a6004803603602081101561023257600080fd5b50356001600160a01b0316610da5565b61016a6004803603602081101561025857600080fd5b50356001600160a01b0316610e46565b61017c6004803603602081101561027e57600080fd5b50356001600160a01b0316610f2d565b61017c610f3f565b610123610f63565b61016a600480360360208110156102b457600080fd5b50356001600160a01b0316610f87565b61017c611053565b61017c611059565b7f000000000000000000000000217e42ceb2eae9ecb788fdf0e31c806c531760a381565b7f0000000000000000000000004f8e5de400de08b164e7421b3ee387f461becd1a81565b33600090815260208190526040902054600114610379576040805162461bcd60e51b8152602060048201526016602482015275155cd919141cdb4bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015290519081900360640190fd5b81623a34b760e91b1415610391576001819055610436565b81631d1bdd5d60e21b14156103aa576002819055610436565b816a1cd95b1b115b98589b195960aa1b14156103ca576003819055610436565b8169189d5e515b98589b195960b21b14156103e9576004819055610436565b6040805162461bcd60e51b815260206004820152601f60248201527f5573646450736d2f66696c652d756e7265636f676e697a65642d706172616d00604482015290519081900360640190fd5b60408051828152905183917fe986e40cc8c151830d4f61050f4fb2e4add8567caad2d5f5496f9158e91fe4c7919081900360200190a25050565b7f000000000000000000000000ff77f6209239deb2c076179499f2346b0032097f81565b60015481565b60035481565b7f000000000000000000000000f085edd75c1ab4fda0c3bd49b264a4a113d06f3b81565b33600090815260208190526040902054600114610521576040805162461bcd60e51b8152602060048201526016602482015275155cd919141cdb4bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015290519081900360640190fd5b6001600160a01b03811660008181526020819052604080822060019055517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a250565b6004546001146105bd576040805162461bcd60e51b815260206004820152601760248201527f5573646450736d2f6275792d6e6f742d656e61626c6564000000000000000000604482015290519081900360640190fd5b60006105e9827f000000000000000000000000000000000000000000000000000000e8d4a5100061105f565b90506000670de0b6b3a76400006106028360025461105f565b8161060957fe5b049050600061061883836110c8565b604080516323b872dd60e01b81523360048201523060248201526044810183905290519192506001600160a01b037f0000000000000000000000004f8e5de400de08b164e7421b3ee387f461becd1a16916323b872dd916064808201926020929091908290030181600087803b15801561069157600080fd5b505af11580156106a5573d6000803e3d6000fd5b505050506040513d60208110156106bb57600080fd5b505161070e576040805162461bcd60e51b815260206004820152601760248201527f5573646450736d2f6661696c65642d7472616e73666572000000000000000000604482015290519081900360640190fd5b60408051633b4da69f60e01b81523060048201526024810183905290516001600160a01b037f000000000000000000000000983dfef6d71862d809e239845da5a959492f63b81691633b4da69f91604480830192600092919082900301818387803b15801561077c57600080fd5b505af1158015610790573d6000803e3d6000fd5b505060408051637608870360e01b81527f50534d2d555344542d41000000000000000000000000000000000000000000006004820152306024820181905260448201819052606482015260008781036084830181905260a483015291516001600160a01b037f000000000000000000000000ff77f6209239deb2c076179499f2346b0032097f1694506376088703935060c4808301939282900301818387803b15801561083c57600080fd5b505af1158015610850573d6000803e3d6000fd5b505050507f000000000000000000000000217e42ceb2eae9ecb788fdf0e31c806c531760a36001600160a01b031663ef693bed86866040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156108cb57600080fd5b505af11580156108df573d6000803e3d6000fd5b505050507f000000000000000000000000ff77f6209239deb2c076179499f2346b0032097f6001600160a01b031663bb35783b307f000000000000000000000000f085edd75c1ab4fda0c3bd49b264a4a113d06f3b61094a866b033b2e3c9fd0803ce800000061105f565b6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b1580156109a057600080fd5b505af11580156109b4573d6000803e3d6000fd5b5050604080518781526020810186905281516001600160a01b038a1694507f085d06ecf4c34b237767a31c0888e121d89546a77f186f1987c6b8715e1a8caa93509081900390910190a25050505050565b600354600114610a5c576040805162461bcd60e51b815260206004820152601860248201527f5573646450736d2f73656c6c2d6e6f742d656e61626c65640000000000000000604482015290519081900360640190fd5b6040805163d14b1e4b60e01b81523060048201526024810183905233604482015290516000916001600160a01b037f000000000000000000000000217e42ceb2eae9ecb788fdf0e31c806c531760a3169163d14b1e4b9160648082019260209290919082900301818787803b158015610ad457600080fd5b505af1158015610ae8573d6000803e3d6000fd5b505050506040513d6020811015610afe57600080fd5b505160408051637608870360e01b81527f50534d2d555344542d4100000000000000000000000000000000000000000000600482015230602482018190526044820181905260648201526084810183905260a4810183905290519192506001600160a01b037f000000000000000000000000ff77f6209239deb2c076179499f2346b0032097f169163760887039160c48082019260009290919082900301818387803b158015610bad57600080fd5b505af1158015610bc1573d6000803e3d6000fd5b505050506000670de0b6b3a7640000610bdc8360015461105f565b81610be357fe5b0490506000610bf28383611117565b90507f000000000000000000000000ff77f6209239deb2c076179499f2346b0032097f6001600160a01b031663bb35783b307f000000000000000000000000f085edd75c1ab4fda0c3bd49b264a4a113d06f3b610c5b866b033b2e3c9fd0803ce800000061105f565b6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b158015610cb157600080fd5b505af1158015610cc5573d6000803e3d6000fd5b505050507f000000000000000000000000983dfef6d71862d809e239845da5a959492f63b86001600160a01b031663ef693bed86836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015610d4057600080fd5b505af1158015610d54573d6000803e3d6000fd5b5050604080518781526020810186905281516001600160a01b038a1694507fef75f5a47cc9a929968796ceb84f19e7541617b4577f2c228ea95200e157208193509081900390910190a25050505050565b33600090815260208190526040902054600114610e02576040805162461bcd60e51b8152602060048201526016602482015275155cd919141cdb4bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015290519081900360640190fd5b6001600160a01b038116600081815260208190526040808220829055517f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b9190a250565b33600090815260208190526040902054600114610ea3576040805162461bcd60e51b8152602060048201526016602482015275155cd919141cdb4bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015290519081900360640190fd5b7f000000000000000000000000ff77f6209239deb2c076179499f2346b0032097f6001600160a01b031663a3b22fc4826040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015610f1257600080fd5b505af1158015610f26573d6000803e3d6000fd5b5050505050565b60006020819052908152604090205481565b7f50534d2d555344542d410000000000000000000000000000000000000000000081565b7f000000000000000000000000983dfef6d71862d809e239845da5a959492f63b881565b33600090815260208190526040902054600114610fe4576040805162461bcd60e51b8152602060048201526016602482015275155cd919141cdb4bdb9bdd0b585d5d1a1bdc9a5e995960521b604482015290519081900360640190fd5b7f000000000000000000000000ff77f6209239deb2c076179499f2346b0032097f6001600160a01b031663dc4d20fa826040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015610f1257600080fd5b60045481565b60025481565b600081158061107a5750508082028282828161107757fe5b04145b6110c2576040805162461bcd60e51b81526020600482015260146024820152735573646450736d2f6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b92915050565b808201828110156110c2576040805162461bcd60e51b81526020600482015260146024820152735573646450736d2f6164642d6f766572666c6f7760601b604482015290519081900360640190fd5b808203828111156110c2576040805162461bcd60e51b81526020600482015260156024820152745573646450736d2f7375622d756e646572666c6f7760581b604482015290519081900360640190fdfea26469706673582212202def53476185292d4192c06a764bd8a22a7bee0beb4aee2651ae3217c68ee93f64736f6c634300060c0033

Verified Source Code Partial Match

Compiler: v0.6.12+commit.27d51765 EVM: istanbul Optimization: Yes (200 runs)
psm7.sol 183 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2021 Dai Foundation
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.6.12;

import {UsddJoinAbstract} from "./interfaces/dss/UsddJoinAbstract.sol";
import {UsddAbstract} from "./interfaces/dss/UsddAbstract.sol";
import {VatAbstract} from "./interfaces/dss/VatAbstract.sol";

interface AuthGemJoinAbstract {
    function dec() external view returns (uint256);

    function vat() external view returns (address);

    function ilk() external view returns (bytes32);

    function join(address, uint256, address) external returns (uint256);

    function exit(address, uint256) external;
}

// USDD Peg Stability Module
contract UsddPsm7 {

    // --- Auth ---
    mapping(address => uint256) public wards;

    function rely(address usr) external auth {wards[usr] = 1;
        emit Rely(usr);}

    function deny(address usr) external auth {wards[usr] = 0;
        emit Deny(usr);}
    modifier auth {require(wards[msg.sender] == 1, "UsddPsm/not-authorized");
        _;}

    VatAbstract immutable public vat;
    AuthGemJoinAbstract immutable public gemJoin;   // Stablecoin Join adapter
    UsddAbstract immutable public usdd;             // USDD token
    UsddJoinAbstract immutable public usddJoin;     // USDD Join adapter
    bytes32 immutable public ilk;                   // Collateral type
    address immutable public vow;                   // System treasury

    uint256 immutable internal to18ConversionFactor;

    // --- State Variables ---
    uint256 public tin;         // Fee in [wad]
    uint256 public tout;        // Fee out [wad]
    uint256 public sellEnabled; // Stablecoin -> USDD enabled
    uint256 public buyEnabled;  // USDD -> Stablecoin enabled

    // --- Events ---
    event Rely(address indexed usr);
    event Deny(address indexed usr);
    event File(bytes32 indexed what, uint256 data);
    event SellGem(address indexed owner, uint256 value, uint256 fee);
    event BuyGem(address indexed owner, uint256 value, uint256 fee);

    // --- Init ---
    constructor(
        address gemJoin_,    // Stablecoin Join adapter
        address usddJoin_,   // USDD Join adapter
        address vow_         // System treasury
    ) public {
        wards[msg.sender] = 1;
        emit Rely(msg.sender);

        AuthGemJoinAbstract gemJoin__ = gemJoin = AuthGemJoinAbstract(gemJoin_);
        UsddJoinAbstract usddJoin__ = usddJoin = UsddJoinAbstract(usddJoin_);
        VatAbstract vat__ = vat = VatAbstract(address(gemJoin__.vat()));
        UsddAbstract usdd__ = usdd = UsddAbstract(address(usddJoin__.usdd()));

        ilk = gemJoin__.ilk();
        vow = vow_;

        // Handle decimals conversion
        to18ConversionFactor = 10 ** (18 - gemJoin__.dec());

        // Set initial state
        sellEnabled = 1;  // Enable by default
        buyEnabled = 1;   // Enable by default

        // Approve max amount for USDD transfers
        usdd__.approve(usddJoin_, uint256(-1));
        vat__.hope(usddJoin_);
    }

    // --- Math ---
    uint256 constant WAD = 10 ** 18;
    uint256 constant RAY = 10 ** 27;

    function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x + y) >= x, "UsddPsm/add-overflow");
    }

    function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require((z = x - y) <= x, "UsddPsm/sub-underflow");
    }

    function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
        require(y == 0 || (z = x * y) / y == x, "UsddPsm/mul-overflow");
    }

    // --- Administration ---
    function file(bytes32 what, uint256 data) external auth {
        if (what == "tin") tin = data;
        else if (what == "tout") tout = data;
        else if (what == "sellEnabled") {
            sellEnabled = data;
        }
        else if (what == "buyEnabled") {
            buyEnabled = data;
        }
        else revert("UsddPsm/file-unrecognized-param");

        emit File(what, data);
    }

    // --- Upgrade Path ---
    function hope(address usr) external auth {
        vat.hope(usr);
    }

    function nope(address usr) external auth {
        vat.nope(usr);
    }

    // --- Primary Functions ---

    // Sell gem for USDD
    function sellGem(address usr, uint256 gemAmt) external {
        require(sellEnabled == 1, "UsddPsm/sell-not-enabled");

        // Transfer gem in and mint USDD
        uint256 wad = gemJoin.join(address(this), gemAmt, msg.sender);
        vat.frob(ilk, address(this), address(this), address(this), int256(wad), int256(wad));

        uint256 fee = mul(wad, tin) / WAD;
        uint256 usddAmt = sub(wad, fee);

        // Send fee to system treasury
        vat.move(address(this), vow, mul(fee, RAY));

        // Send USDD to user
        usddJoin.exit(usr, usddAmt);

        emit SellGem(usr, gemAmt, fee);
    }

    // Buy gem with USDD
    function buyGem(address usr, uint256 gemAmt) external {
        require(buyEnabled == 1, "UsddPsm/buy-not-enabled");

        uint256 gemAmt18 = mul(gemAmt, to18ConversionFactor);
        uint256 fee = mul(gemAmt18, tout) / WAD;
        uint256 usddAmt = add(gemAmt18, fee);

        // Transfer USDD in
        require(usdd.transferFrom(msg.sender, address(this), usddAmt), "UsddPsm/failed-transfer");
        usddJoin.join(address(this), usddAmt);

        // Burn USDD and release gem
        vat.frob(ilk, address(this), address(this), address(this), - int256(gemAmt18), - int256(gemAmt18));
        gemJoin.exit(usr, gemAmt);

        // Send fee to system treasury
        vat.move(address(this), vow, mul(fee, RAY));

        emit BuyGem(usr, gemAmt, fee);
    }
}
UsddJoinAbstract.sol 15 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.12;

// https://github.com/usdd-network/usddv2-contracts/blob/main/src/dss/join.sol
interface UsddJoinAbstract {
    function wards(address) external view returns (uint256);
    function rely(address usr) external;
    function deny(address usr) external;
    function vat() external view returns (address);
    function usdd() external view returns (address);
    function live() external view returns (uint256);
    function cage() external;
    function join(address, uint256) external;
    function exit(address, uint256) external;
}
UsddAbstract.sol 28 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.12;

// https://github.com/usdd-network/usddv2-contracts/blob/main/src/dss/usdd.sol
interface UsddAbstract {
    function wards(address) external view returns (uint256);
    function rely(address) external;
    function deny(address) external;
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function version() external view returns (string memory);
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint256);
    function balanceOf(address) external view returns (uint256);
    function allowance(address, address) external view returns (uint256);
    function nonces(address) external view returns (uint256);
    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external view returns (bytes32);
    function transfer(address, uint256) external returns (bool);
    function transferFrom(address, address, uint256) external returns (bool);
    function mint(address, uint256) external;
    function burn(address, uint256) external;
    function approve(address, uint256) external returns (bool);
    function push(address, uint256) external;
    function pull(address, uint256) external;
    function move(address, address, uint256) external;
    function permit(address, address, uint256, uint256, bool, uint8, bytes32, bytes32) external;
}
VatAbstract.sol 34 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.12;

// https://github.com/usdd-network/usddv2-contracts/blob/main/src/dss/vat.sol
interface VatAbstract {
    function wards(address) external view returns (uint256);
    function rely(address) external;
    function deny(address) external;
    function can(address, address) external view returns (uint256);
    function hope(address) external;
    function nope(address) external;
    function ilks(bytes32) external view returns (uint256, uint256, uint256, uint256, uint256);
    function urns(bytes32, address) external view returns (uint256, uint256);
    function gem(bytes32, address) external view returns (uint256);
    function usdd(address) external view returns (uint256);
    function sin(address) external view returns (uint256);
    function debt() external view returns (uint256);
    function vice() external view returns (uint256);
    function Line() external view returns (uint256);
    function live() external view returns (uint256);
    function init(bytes32) external;
    function file(bytes32, uint256) external;
    function file(bytes32, bytes32, uint256) external;
    function cage() external;
    function slip(bytes32, address, int256) external;
    function flux(bytes32, address, address, uint256) external;
    function move(address, address, uint256) external;
    function frob(bytes32, address, address, address, int256, int256) external;
    function fork(bytes32, address, address, int256, int256) external;
    function grab(bytes32, address, address, address, int256, int256) external;
    function heal(uint256) external;
    function suck(address, address, uint256) external;
    function fold(bytes32, address, int256) external;
}

Read Contract

buyEnabled 0xf582d293 → uint256
gemJoin 0x01664f66 → address
ilk 0xc5ce281e → bytes32
sellEnabled 0x58197a9d → uint256
tin 0x568d4b6f → uint256
tout 0xfae036d5 → uint256
usdd 0x0c30bc02 → address
usddJoin 0xc78d6d21 → address
vat 0x36569e77 → address
vow 0x626cb3c5 → address
wards 0xbf353dbb → uint256

Write Contract 7 functions

These functions modify contract state and require a wallet transaction to execute.

buyGem 0x8d7ef9bb
address usr
uint256 gemAmt
deny 0x9c52a7f1
address usr
file 0x29ae8114
bytes32 what
uint256 data
hope 0xa3b22fc4
address usr
nope 0xdc4d20fa
address usr
rely 0x65fae35e
address usr
sellGem 0x95991276
address usr
uint256 gemAmt

Top Interactions

AddressTxnsSentReceived
0x05523957...4c67 1 1
0x44712C9f...39df 1 1

Recent Transactions

CSV
|
Hash Method Block Age From/To Value Txn Fee Type
0x07e54e52...c3f4ba 0x95991276 24,424,150 IN 0x05523957...4c67 0 ETH EIP-1559
0x73c656e1...bc3421 0x95991276 24,424,079 IN 0x44712C9f...39df 0 ETH EIP-1559