Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xe08cb5E24862eA86328295D5E5c08972203C20D8
Balance 0 ETH
Nonce 1
Code Size 8238 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8238 bytes
0x608060405234801561001057600080fd5b50600436106101215760003560e01c8063959ac484116100ad578063d663159411610071578063d663159414610478578063daddce52146104ac578063e11746391461051a578063f4b9fa751461055c578063fc2b8cc31461059057610121565b8063959ac4841461031c5780639c52a7f11461034a578063a81de4f81461038e578063bf353dbb146103d2578063d4e8be831461042a57610121565b806359ac371b116100f457806359ac371b1461021457806361e86cad1461025857806365fae35e1461029a5780637bd2bea7146102de5780638035f0ce1461031257610121565b806304bda26214610126578063131519811461015a578063344cbc681461018e578063453638ce146101bc575b600080fd5b61012e61059a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101626105c0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101ba600480360360208110156101a457600080fd5b81019080803590602001909291905050506105e6565b005b6101fe600480360360208110156101d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106a6565b6040518082815260200191505060405180910390f35b6102566004803603602081101561022a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506106be565b005b6102846004803603602081101561026e57600080fd5b81019080803590602001909291905050506107e0565b6040518082815260200191505060405180910390f35b6102dc600480360360208110156102b057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108e3565b005b6102e6610a04565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61031a610a28565b005b6103486004803603602081101561033257600080fd5b8101908080359060200190929190505050610af4565b005b61038c6004803603602081101561036057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b00565b005b6103d0600480360360208110156103a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c21565b005b610414600480360360208110156103e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d42565b6040518082815260200191505060405180910390f35b6104766004803603604081101561044057600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d5a565b005b610480611585565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610518600480360360608110156104c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506115ab565b005b6105466004803603602081101561053057600080fd5b8101908080359060200190929190505050611759565b6040518082815260200191505060405180910390f35b610564611859565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61059861187d565b005b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461069a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f52776153776170496e707574436f6e64756974322f6e6f742d6d61746500000081525060200191505060405180910390fd5b6106a3816119fd565b50565b60016020528060005260406000206000915090505481565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610755576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f106023913960400191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f04942e12b9e2310f85c952df158815306377bb9f797dc3677d03be357427c53b60405160405180910390a250565b60008061080d837f000000000000000000000000000000000000000000000000000000e8d4a51000611c07565b90506000670de0b6b3a76400006108c683600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663568d4b6f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561088657600080fd5b505afa15801561089a573d6000803e3d6000fd5b505050506040513d60208110156108b057600080fd5b8101908080519060200190929190505050611c07565b816108cd57fe5b0490506108da8282611c9c565b92505050919050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541461097a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f106023913960400191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a6060405160405180910390a250565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b610af27f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610ab257600080fd5b505afa158015610ac6573d6000803e3d6000fd5b505050506040513d6020811015610adc57600080fd5b8101908080519060200190929190505050611d1f565b565b610afd81611d1f565b50565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610b97576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f106023913960400191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b60405160405180910390a250565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610cb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f106023913960400191505060405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fe25de3b40ce055247fe4ef6c00f96c8c3b6530536701ba1c48296b30b4bb0d9560405160405180910390a250565b60006020528060005260406000206000915090505481565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610df1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f106023913960400191505060405180910390fd5b7f71756974546f0000000000000000000000000000000000000000000000000000821415610e5f5780600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611533565b7f746f000000000000000000000000000000000000000000000000000000000000821415610ecd5780600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611532565b7f70736d00000000000000000000000000000000000000000000000000000000008214156114e0577f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1663f4b9fa756040518163ffffffff1660e01b815260040160206040518083038186803b158015610f7257600080fd5b505afa158015610f86573d6000803e3d6000fd5b505050506040513d6020811015610f9c57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1614611019576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611f856026913960400191505060405180910390fd5b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff166301664f666040518163ffffffff1660e01b815260040160206040518083038186803b15801561109657600080fd5b505afa1580156110aa573d6000803e3d6000fd5b505050506040513d60208110156110c057600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16637bd2bea76040518163ffffffff1660e01b815260040160206040518083038186803b15801561111657600080fd5b505afa15801561112a573d6000803e3d6000fd5b505050506040513d602081101561114057600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16146111bd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611f336026913960400191505060405180910390fd5b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166301664f666040518163ffffffff1660e01b815260040160206040518083038186803b15801561126157600080fd5b505afa158015611275573d6000803e3d6000fd5b505050506040513d602081101561128b57600080fd5b810190808051906020019092919050505060006040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156112f157600080fd5b505af1158015611305573d6000803e3d6000fd5b505050506040513d602081101561131b57600080fd5b8101908080519060200190929190505050507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff1663095ea7b38273ffffffffffffffffffffffffffffffffffffffff166301664f666040518163ffffffff1660e01b815260040160206040518083038186803b1580156113af57600080fd5b505afa1580156113c3573d6000803e3d6000fd5b505050506040513d60208110156113d957600080fd5b81019080805190602001909291905050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561145e57600080fd5b505af1158015611472573d6000803e3d6000fd5b505050506040513d602081101561148857600080fd5b81019080805190602001909291905050505080600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611531565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180611fd26027913960400191505060405180910390fd5b5b5b817f8fef588b5fc1afbf5b2f06c1a435d513f208da2e6704c3d8f0e0ec91167066ba82604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a25050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414611642576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611f106023913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156116b357600080fd5b505af11580156116c7573d6000803e3d6000fd5b505050506040513d60208110156116dd57600080fd5b8101908080519060200190929190505050508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f3336d8973868f7727fbbf287f4fd9fb0237fe2696b301f8a46c563cb46d7b419836040518082815260200191505060405180910390a3505050565b6000611838611812670de0b6b3a7640000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663568d4b6f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156117d257600080fd5b505afa1580156117e6573d6000803e3d6000fd5b505050506040513d60208110156117fc57600080fd5b8101908080519060200190929190505050611c9c565b7f000000000000000000000000000000000000000000000000000000e8d4a51000611c07565b61184a83670de0b6b3a7640000611c07565b8161185157fe5b049050919050565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b60018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414611931576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f52776153776170496e707574436f6e64756974322f6e6f742d6d61746500000081525060200191505060405180910390fd5b6119fb7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156119bb57600080fd5b505afa1580156119cf573d6000803e3d6000fd5b505050506040513d60208110156119e557600080fd5b81019080805190602001909291905050506119fd565b565b600073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611aa5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180611f59602c913960400191505060405180910390fd5b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4873ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611b5857600080fd5b505af1158015611b6c573d6000803e3d6000fd5b505050506040513d6020811015611b8257600080fd5b810190808051906020019092919050505050600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fc81bfec1ac9d038698c3b15fc900dafbff3af4b9f26062f895dd08a676ec78ae826040518082815260200191505060405180910390a250565b600080821480611c245750828283850292508281611c2157fe5b04145b611c96576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f4d6174682f6d756c2d6f766572666c6f7700000000000000000000000000000081525060200191505060405180910390fd5b92915050565b6000828284039150811115611d19576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f4d6174682f7375622d6f766572666c6f7700000000000000000000000000000081525060200191505060405180910390fd5b92915050565b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611dc7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526027815260200180611fab6027913960400191505060405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166395991276600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015611e7c57600080fd5b505af1158015611e90573d6000803e3d6000fd5b50505050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fdf8180823cf670d41db21fa54ef9909b0bd724c931fbd55fe1fcbdc655ea2fb0611ef7836107e0565b6040518082815260200191505060405180910390a25056fe52776153776170496e707574436f6e64756974322f6e6f742d617574686f72697a656452776153776170496e707574436f6e64756974322f77726f6e672d67656d2d666f722d70736d52776153776170496e707574436f6e64756974322f696e76616c69642d717569742d746f2d6164647265737352776153776170496e707574436f6e64756974322f77726f6e672d6461692d666f722d70736d52776153776170496e707574436f6e64756974322f696e76616c69642d746f2d6164647265737352776153776170496e707574436f6e64756974322f756e7265636f676e697365642d706172616da2646970667358221220f3b1194106e9b11810dcdc7fa00415a0e250bc8c0cd56a58204c3b6ca9fccf7164736f6c634300060c0033

Verified Source Code Partial Match

Compiler: v0.6.12+commit.27d51765 EVM: istanbul Optimization: No
GemAbstract.sol 16 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.12;

// A base ERC-20 abstract class
// https://eips.ethereum.org/EIPS/eip-20
interface GemAbstract {
    function totalSupply() external view returns (uint256);
    function balanceOf(address) external view returns (uint256);
    function allowance(address, address) external view returns (uint256);
    function approve(address, uint256) external returns (bool);
    function transfer(address, uint256) external returns (bool);
    function transferFrom(address, address, uint256) external returns (bool);
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
}
DaiAbstract.sol 28 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.12;

// https://github.com/makerdao/dss/blob/master/src/dai.sol
interface DaiAbstract {
    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;
}
PsmAbstract.sol 22 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.12;

// https://github.com/makerdao/dss-psm/blob/master/src/psm.sol
interface PsmAbstract {
    function wards(address) external view returns (uint256);
    function rely(address) external;
    function deny(address) external;
    function vat() external view returns (address);
    function gemJoin() external view returns (address);
    function dai() external view returns (address);
    function daiJoin() external view returns (address);
    function ilk() external view returns (bytes32);
    function vow() external view returns (address);
    function tin() external view returns (uint256);
    function tout() external view returns (uint256);
    function file(bytes32 what, uint256 data) external;
    function hope(address) external;
    function nope(address) external;
    function sellGem(address usr, uint256 gemAmt) external;
    function buyGem(address usr, uint256 gemAmt) external;
}
GemJoinAbstract.sol 17 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.12;

// https://github.com/makerdao/dss/blob/master/src/join.sol
interface GemJoinAbstract {
    function wards(address) external view returns (uint256);
    function rely(address) external;
    function deny(address) external;
    function vat() external view returns (address);
    function ilk() external view returns (bytes32);
    function gem() external view returns (address);
    function dec() external view returns (uint256);
    function live() external view returns (uint256);
    function cage() external;
    function join(address, uint256) external;
    function exit(address, uint256) external;
}
RwaSwapInputConduit2.sol 332 lines
// SPDX-FileCopyrightText: © 2021 Lev Livnev <[email protected]>
// SPDX-FileCopyrightText: © 2022 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// 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 {GemAbstract} from "dss-interfaces/ERC/GemAbstract.sol";
import {DaiAbstract} from "dss-interfaces/dss/DaiAbstract.sol";
import {PsmAbstract} from "dss-interfaces/dss/PsmAbstract.sol";
import {GemJoinAbstract} from "dss-interfaces/dss/GemJoinAbstract.sol";

/**
 * @author Lev Livnev <[email protected]>
 * @author Nazar Duchak <[email protected]>
 * @title An Input Conduit for real-world assets (RWA).
 * @dev This contract differs from the original [RwaInputConduit](https://github.com/makerdao/MIP21-RWA-Example/blob/fce06885ff89d10bf630710d4f6089c5bba94b4d/src/RwaConduit.sol#L20-L39):
 *  - Requires DAI, GEM and PSM addresses in the constructor.
 *      - DAI and GEM are immutable, PSM can be replaced as long as it uses the same DAI and GEM.
 *  - The caller of `push()` is not required to hold MakerDAO governance tokens.
 *  - The `push()` method is permissionless.
 *  - The `push()` method swaps entire GEM balance to DAI using PSM.
 *  - The `push(uint256)` method swaps specified amount of GEM to DAI using PSM.
 *  - The `quit()` method allows moving outstanding GEM balance to `quitTo`. It can be called only by `mate`d addresses.
 *  - The `quit(uint256)` method allows moving the specified amount of GEM balance to `quitTo`. It can be called only by `mate`d addresses.
 *  - The `file(bytes32, address)` method allows updating `quitTo`, `to`, `psm` addresses. It can be called only by the admin.
 */
contract RwaSwapInputConduit2 {
    /// @notice PSM GEM token contract address.
    GemAbstract public immutable gem;
    /// @notice DAI token contract address.
    DaiAbstract public immutable dai;
    /// @dev DAI/GEM resolution difference.
    uint256 private immutable to18ConversionFactor;

    /// @notice Addresses with admin access on this contract. `wards[usr]`
    mapping(address => uint256) public wards;
    /// @notice Addresses with quit access on this contract. `may[usr]`
    mapping(address => uint256) public may;

    /// @notice PSM contract address.
    PsmAbstract public psm;
    /// @notice Recipient address for DAI.
    address public to;
    /// @notice Destination address for GEM after calling `quit`.
    address public quitTo;

    /**
     * @notice `usr` was granted admin access.
     * @param usr The user address.
     */
    event Rely(address indexed usr);
    /**
     * @notice `usr` admin access was revoked.
     * @param usr The user address.
     */
    event Deny(address indexed usr);
    /**
     * @notice `usr` was granted push access.
     * @param usr The user address.
     */
    event Mate(address indexed usr);
    /**
     * @notice `usr` push access was revoked.
     * @param usr The user address.
     */
    event Hate(address indexed usr);
    /**
     * @notice `wad` amount of Dai was pushed to `to`.
     * @param to Recipient address for DAI.
     * @param wad The amount of DAI.
     */
    event Push(address indexed to, uint256 wad);
    /**
     * @notice A contract parameter was updated.
     * @param what The changed parameter name. Currently the supported values are: "quitTo", "to", "psm".
     * @param data The new value of the parameter.
     */
    event File(bytes32 indexed what, address data);
    /**
     * @notice The conduit outstanding GEM balance was flushed out to `quitTo`.
     * @param quitTo The quitTo address.
     * @param wad The amount of GEM flushed out.
     */
    event Quit(address indexed quitTo, uint256 wad);
    /**
     * @notice `amt` outstanding `token` balance was flushed out to `usr`.
     * @param token The token address.
     * @param usr The destination address.
     * @param amt The amount of `token` flushed out.
     */
    event Yank(address indexed token, address indexed usr, uint256 amt);

    modifier auth() {
        require(wards[msg.sender] == 1, "RwaSwapInputConduit2/not-authorized");
        _;
    }

    modifier onlyMate() {
        require(may[msg.sender] == 1, "RwaSwapInputConduit2/not-mate");
        _;
    }

    /**
     * @notice Defines addresses and gives `msg.sender` admin access.
     * @param _psm PSM contract address.
     * @param _dai DAI contract address.
     * @param _gem GEM contract address.
     * @param _to RwaUrn contract address.
     */
    constructor(
        address _dai,
        address _gem,
        address _psm,
        address _to
    ) public {
        require(_to != address(0), "RwaSwapInputConduit2/invalid-to-address");
        require(PsmAbstract(_psm).dai() == _dai, "RwaSwapInputConduit2/wrong-dai-for-psm");
        require(GemJoinAbstract(PsmAbstract(_psm).gemJoin()).gem() == _gem, "RwaSwapInputConduit2/wrong-gem-for-psm");

        // We assume that DAI will alway have 18 decimals
        to18ConversionFactor = 10**_sub(18, GemAbstract(_gem).decimals());

        psm = PsmAbstract(_psm);
        dai = DaiAbstract(_dai);
        gem = GemAbstract(_gem);

        to = _to;

        // Give unlimited approval to PSM gemjoin
        GemAbstract(_gem).approve(address(psm.gemJoin()), type(uint256).max);

        wards[msg.sender] = 1;
        emit Rely(msg.sender);
    }

    /*//////////////////////////////////
               Authorization
    //////////////////////////////////*/

    /**
     * @notice Grants `usr` admin access to this contract.
     * @param usr The user address.
     */
    function rely(address usr) external auth {
        wards[usr] = 1;
        emit Rely(usr);
    }

    /**
     * @notice Revokes `usr` admin access from this contract.
     * @param usr The user address.
     */
    function deny(address usr) external auth {
        wards[usr] = 0;
        emit Deny(usr);
    }

    /**
     * @notice Grants `usr` push access to this contract.
     * @param usr The user address.
     */
    function mate(address usr) external auth {
        may[usr] = 1;
        emit Mate(usr);
    }

    /**
     * @notice Revokes `usr` push access from this contract.
     * @param usr The user address.
     */
    function hate(address usr) external auth {
        may[usr] = 0;
        emit Hate(usr);
    }

    /*//////////////////////////////////
               Administration
    //////////////////////////////////*/

    /**
     * @notice Updates a contract parameter.
     * @dev `to` and `quitTo` can be set to `address(0)` to disable `push` and `quit` respectively.
     * @param what The changed parameter name. `"to", "quitTo", "psm"`
     * @param data The new value of the parameter.
     */
    function file(bytes32 what, address data) external auth {
        if (what == "quitTo") {
            quitTo = data;
        } else if (what == "to") {
            to = data;
        } else if (what == "psm") {
            require(PsmAbstract(data).dai() == address(dai), "RwaSwapInputConduit2/wrong-dai-for-psm");
            require(
                GemJoinAbstract(PsmAbstract(data).gemJoin()).gem() == address(gem),
                "RwaSwapInputConduit2/wrong-gem-for-psm"
            );

            // Revoke approval for the old PSM gemjoin
            gem.approve(address(psm.gemJoin()), 0);
            // Give unlimited approval to the new PSM gemjoin
            gem.approve(address(PsmAbstract(data).gemJoin()), type(uint256).max);

            psm = PsmAbstract(data);
        } else {
            revert("RwaSwapInputConduit2/unrecognised-param");
        }

        emit File(what, data);
    }

    /*//////////////////////////////////
               Operations
    //////////////////////////////////*/

    /**
     * @notice Swaps the GEM balance of this contract into DAI through the PSM and push it into the recipient address.
     */
    function push() external {
        _doPush(gem.balanceOf(address(this)));
    }

    /**
     * @notice Swaps the specified amount of GEM into DAI through the PSM and push it into the recipient address.
     * @param amt Gem amount.
     */
    function push(uint256 amt) external {
        _doPush(amt);
    }

    /**
     * @notice Flushes out any GEM balance to `quitTo` address.
     * @dev `msg.sender` must have received push access through `mate()`.
     */
    function quit() external onlyMate {
        _doQuit(gem.balanceOf(address(this)));
    }

    /**
     * @notice Flushes out the specified amount of GEM balance to `quitTo` address.
     * @dev `msg.sender` must have received push access through `mate()`.
     * @param amt Gem amount.
     */
    function quit(uint256 amt) external onlyMate {
        _doQuit(amt);
    }

    /**
     * @notice Flushes out `amt` of `token` sitting in this contract to `usr` address.
     * @dev Can only be called by the admin.
     * @param token Token address.
     * @param usr Destination address.
     * @param amt Token amount.
     */
    function yank(
        address token,
        address usr,
        uint256 amt
    ) external auth {
        GemAbstract(token).transfer(usr, amt);
        emit Yank(token, usr, amt);
    }

    /**
     * @notice Calculates the amount of DAI received for swapping `amt` of GEM.
     * @param amt GEM amount.
     * @return wad Expected DAI amount.
     */
    function expectedDaiWad(uint256 amt) public view returns (uint256 wad) {
        uint256 amt18 = _mul(amt, to18ConversionFactor);
        uint256 fee = _mul(amt18, psm.tin()) / WAD;
        return _sub(amt18, fee);
    }

    /**
     * @notice Calculates the required amount of GEM to get `wad` amount of DAI.
     * @param wad DAI amount.
     * @return amt Required GEM amount.
     */
    function requiredGemAmt(uint256 wad) external view returns (uint256 amt) {
        return _mul(wad, WAD) / _mul(_sub(WAD, psm.tin()), to18ConversionFactor);
    }

    /**
     * @notice Swaps the specified amount of GEM into DAI through the PSM and push it into the recipient address.
     * @dev If `to` is set to `address(0)`, if effectively means this methos is currently disabled.
     * @param amt GEM amount.
     */
    function _doPush(uint256 amt) internal {
        require(to != address(0), "RwaSwapInputConduit2/invalid-to-address");

        psm.sellGem(to, amt);
        emit Push(to, expectedDaiWad(amt));
    }

    /**
     * @notice Flushes out the specified amount of GEM to the `quitTo` address.
     * @dev If `quitTo` is set to `address(0)`, if effectively means this method is currently disabled.
     * @param amt GEM amount.
     */
    function _doQuit(uint256 amt) internal {
        require(quitTo != address(0), "RwaSwapInputConduit2/invalid-quit-to-address");

        gem.transfer(quitTo, amt);
        emit Quit(quitTo, amt);
    }

    /*//////////////////////////////////
                    Math
    //////////////////////////////////*/

    uint256 internal constant WAD = 10**18;

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

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

Read Contract

dai 0xf4b9fa75 → address
expectedDaiWad 0x61e86cad → uint256
gem 0x7bd2bea7 → address
may 0x453638ce → uint256
psm 0x04bda262 → address
quitTo 0xd6631594 → address
requiredGemAmt 0xe1174639 → uint256
to 0x13151981 → address
wards 0xbf353dbb → uint256

Write Contract 10 functions

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

deny 0x9c52a7f1
address usr
file 0xd4e8be83
bytes32 what
address data
hate 0x59ac371b
address usr
mate 0xa81de4f8
address usr
push 0x8035f0ce
No parameters
push 0x959ac484
uint256 amt
quit 0x344cbc68
uint256 amt
quit 0xfc2b8cc3
No parameters
rely 0x65fae35e
address usr
yank 0xdaddce52
address token
address usr
uint256 amt

Recent Transactions

No transactions found for this address