Skip to content

Commit

Permalink
add ERC20Amplifier source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakuhito committed Oct 2, 2024
1 parent e9c8873 commit de2c0e3
Showing 5 changed files with 63 additions and 57 deletions.
19 changes: 0 additions & 19 deletions script/Counter.s.sol

This file was deleted.

14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

39 changes: 39 additions & 0 deletions src/ERC20Amplifier.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT
/* yak tracks all over the place */
pragma solidity 0.8.23;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

event Deposit(address indexed sender, uint256 originalTokenAmount);
event Withdraw(address indexed receiver, uint256 originalTokenAmount);

contract ERC20Amplifier is ERC20 {
address public originalToken;
uint256 public amplification;

constructor(address _originalToken, uint256 _amplification, string memory _name, string memory _symbol)
ERC20(_name, _symbol)
{
originalToken = _originalToken;
amplification = _amplification;
}

function deposit(uint256 _originalTokenAmount) public {
require(_originalTokenAmount > 0, "!gt0");

_mint(msg.sender, _originalTokenAmount * amplification);
IERC20(originalToken).transferFrom(msg.sender, address(this), _originalTokenAmount);

emit Deposit(msg.sender, _originalTokenAmount);
}

function withdraw(uint256 _originalTokenAmount) external {
require(_originalTokenAmount > 0, "!gt0");

_burn(msg.sender, _originalTokenAmount * amplification);
IERC20(originalToken).transfer(msg.sender, _originalTokenAmount);

emit Withdraw(msg.sender, _originalTokenAmount);
}
}
24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

24 changes: 24 additions & 0 deletions test/ERC20Amplifier.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// // SPDX-License-Identifier: UNLICENSED
// pragma solidity ^0.8.13;

// import {Test, console} from "forge-std/Test.sol";
// import {Counter} from "../src/Counter.sol";

// contract CounterTest is Test {
// Counter public counter;

// function setUp() public {
// counter = new Counter();
// counter.setNumber(0);
// }

// function test_Increment() public {
// counter.increment();
// assertEq(counter.number(), 1);
// }

// function testFuzz_SetNumber(uint256 x) public {
// counter.setNumber(x);
// assertEq(counter.number(), x);
// }
// }

0 comments on commit de2c0e3

Please sign in to comment.