// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.25;
interface IERC20 {
/// @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`).
event Transfer(address indexed from, address indexed to, uint256 value);
/// @dev Emitted when the allowance of a `spender` for an `owner` is set, where `value`
/// is the new allowance.
event Approval(address indexed owner, address indexed spender, uint256 value);
/// @notice Returns the amount of tokens in existence.
function totalSupply() external view returns (uint256);
/// @notice Returns the amount of tokens owned by `account`.
function balanceOf(address account) external view returns (uint256);
/// @notice Moves `amount` tokens from the caller's account to `to`.
function transfer(address to, uint256 amount) external returns (bool);
/// @notice Returns the remaining number of tokens that `spender` is allowed
/// to spend on behalf of `owner`
function allowance(address owner, address spender) external view returns (uint256);
/// @notice Sets `amount` as the allowance of `spender` over the caller's tokens.
/// @dev Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
function approve(address spender, uint256 amount) external returns (bool);
/// @notice Moves `amount` tokens from `from` to `to` using the allowance mechanism.
/// `amount` is then deducted from the caller's allowance.
function transferFrom(address from, address to, uint256 amount) external returns (bool);
/// @notice Returns the name of the token.
function name() external view returns (string memory);
/// @notice Returns the symbol of the token.
function symbol() external view returns (string memory);
/// @notice Returns the decimals places of the token.
function decimals() external view returns (uint8);
}
/// @dev Interface of the ERC20 standard as defined in the EIP.
/// @dev This includes the optional name, symbol, and decimals metadata.
interface JoinLike {
function deposit(uint256,address) external;
function redeem(uint256,address,address) external;
}
/**
* @notice Actions for migrating from DAI/sDAI to USDS/sUSDS.
* @dev Also contains 1 downgrade path from USDS to DAI for convenience.
*/
contract MigrationActions {
IERC20 public immutable usds;
JoinLike public immutable Staking;
event Stakings(address usr,uint amount);
event UnStaking(address usr,uint amount);
constructor( address _usds,address StakingAddress ) {
usds = IERC20(_usds);
Staking = JoinLike(StakingAddress);
usds.approve(StakingAddress, type(uint256).max);
}
function StakeErc20 (address receiver,uint amount)public {
usds.transferFrom(receiver, address(this), amount);
Staking.deposit(amount,address(this));
emit Stakings(receiver,amount);
}
function UnstakeErc20 (address receiver,uint amount)public {
Staking.redeem(amount,address(this),address(this));
usds.transfer(receiver, amount);
emit UnStaking(receiver,amount);
}
}
{
"compilationTarget": {
"MigrationActions.sol": "MigrationActions"
},
"evmVersion": "cancun",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_usds","type":"address"},{"internalType":"address","name":"StakingAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"usr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Stakings","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"usr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnStaking","type":"event"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StakeErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"Staking","outputs":[{"internalType":"contract JoinLike","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnstakeErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usds","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"}]