Skip to content
Verified contractExactAGPL-3.0-or-later

RwaJar

Address0x3bcf5dc52a7ebe6426ac7aabb2600239b912c4fb
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.6.12

 

Same code

1 more contract

 

Details

Compiler
solc 0.6.12+commit.27d51765
Language
solidity
Optimization
Yes, 200 runs
EVM version
istanbul
License
AGPL-3.0-or-later
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
23,274,910
Creation transaction
0x7f2aa62953…bfb25a31e5

src/jars/RwaJar.sol

// Copyright (C) 2022 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/>.

// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.6.12;

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

/**
 * @author Henrique Barcelos <[email protected]>
 * @title RwaJar: Facility to allow stability fee payments into the Surplus Buffer.
 * @dev Users can either send Usdd directly to this conract or approve it to pull Usdd from their wallet.
 */
contract RwaJar {
    /// @notice The UsddJoin adapter from MCD.
    UsddJoinAbstract public immutable usddJoin;
    /// @notice The Usdd token.
    UsddAbstract public immutable usdd;
    /// @notice The vow address.
    address public immutable vow;
    /**
     * @notice Emitted whenever Usdd is sent to the `vow`.
     * @param usr The origin of the funds.
     * @param wad The amount of Usdd sent.
     */
    event Toss(address indexed usr, uint256 wad);

    /**
     * @dev The Usdd address is obtained from the UsddJoin contract.
     * @param usddJoin_ The usddJoin from MCD.
     * @param vow_ System treasury
     */
    constructor(address usddJoin_, address vow_) public {
        // UsddJoin and Usdd are meant to be immutable, so we can store them.
        usddJoin = UsddJoinAbstract(usddJoin_);
        usdd = UsddAbstract(UsddJoinAbstract(usddJoin_).usdd());

        vow = vow_;

        UsddAbstract(UsddJoinAbstract(usddJoin_).usdd()).approve(usddJoin_, type(uint256).max);
    }

    /**
     * @notice Transfers any outstanding Usdd balance in this contract to the `vow`.
     * @dev Reverts if there Usdd balance of this contract is zero.
     * @dev This effectively burns ERC-20 Usdd and credits it to the internal Usdd balance of the `vow` in the Vat.
     */
    function void() external {
        uint256 balance = usdd.balanceOf(address(this));
        require(balance > 0, "RwaJar/already-empty");

        usddJoin.join(vow, balance);

        emit Toss(address(this), balance);
    }

    /**
     * @notice Pulls `wad` amount of Usdd from the sender's wallet into the `vow`.
     * @dev Requires `msg.sender` to have previously `approve`d this contract to spend at least `wad` Usdd.
     * @dev This effectively burns ERC-20 Usdd and credits it to the internal Usdd balance of the `vow` in the Vat.
     * @param wad The amount of Usdd.
     */
    function toss(uint256 wad) external {
        usdd.transferFrom(msg.sender, address(this), wad);
        usddJoin.join(vow, wad);

        emit Toss(msg.sender, wad);
    }
}

src/interfaces/dss/UsddAbstract.sol

// 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;
}

src/interfaces/dss/UsddJoinAbstract.sol

// 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;
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "istanbul",
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "usdd/=lib/usddv2-contracts/src/",
    "ds-math/=lib/ds-math/src/",
    "ds-token/=lib/ds-token/src/",
    "ds-value/=lib/ds-value/src/",
    "psm/=lib/psm/src/",
    "forward-proxy/=lib/forward-proxy/src/",
    "ds-auth/=lib/usddv2-contracts/lib/ds-auth/src/",
    "ds-note/=lib/ds-value/lib/ds-thing/lib/ds-note/src/",
    "ds-test/=lib/psm/lib/ds-test/src/",
    "ds-thing/=lib/ds-value/lib/ds-thing/src/",
    "dss-interfaces/=lib/psm/lib/dss-interfaces/src/",
    "erc4626-tests/=lib/usddv2-contracts/lib/erc4626-tests/",
    "usddv2-contracts/=lib/usddv2-contracts/",
    "usddv2/=lib/psm/lib/usddv2/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.