// SPDX-License-Identifier: AGPL-3.0-or-later
/// UsdsJoin.sol -- Usds adapter
// Copyright (C) 2018 Rain <rainbreak@riseup.net>
// Copyright (C) 2023 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.8.21;
interface UsdsLike {
function burn(address,uint256) external;
function mint(address,uint256) external;
}
interface VatLike {
function move(address,address,uint256) external;
}
contract UsdsJoin {
VatLike public immutable vat; // CDP Engine
UsdsLike public immutable usds; // Stablecoin Token
uint256 constant RAY = 10 ** 27;
// --- Events ---
event Join(address indexed caller, address indexed usr, uint256 wad);
event Exit(address indexed caller, address indexed usr, uint256 wad);
constructor(address vat_, address usds_) {
vat = VatLike(vat_);
usds = UsdsLike(usds_);
}
function join(address usr, uint256 wad) external {
vat.move(address(this), usr, RAY * wad);
usds.burn(msg.sender, wad);
emit Join(msg.sender, usr, wad);
}
function exit(address usr, uint256 wad) external {
vat.move(msg.sender, address(this), RAY * wad);
usds.mint(usr, wad);
emit Exit(msg.sender, usr, wad);
}
// To fully cover daiJoin abi
function dai() external view returns (address) {
return address(usds);
}
}
{
"compilationTarget": {
"src/UsdsJoin.sol": "UsdsJoin"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
":@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
":ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
":dss-interfaces/=lib/token-tests/lib/dss-test/lib/dss-interfaces/src/",
":dss-test/=lib/token-tests/lib/dss-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
":forge-std/=lib/openzeppelin-foundry-upgrades/lib/forge-std/src/",
":openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
":openzeppelin-contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
":openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
":solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/",
":token-tests/=lib/token-tests/src/"
]
}
[{"inputs":[{"internalType":"address","name":"vat_","type":"address"},{"internalType":"address","name":"usds_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"usr","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Exit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"usr","type":"address"},{"indexed":false,"internalType":"uint256","name":"wad","type":"uint256"}],"name":"Join","type":"event"},{"inputs":[],"name":"dai","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"usr","type":"address"},{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"join","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usds","outputs":[{"internalType":"contract UsdsLike","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vat","outputs":[{"internalType":"contract VatLike","name":"","type":"address"}],"stateMutability":"view","type":"function"}]