Skip to content

Commit 9be2951

Browse files
committed
mint burn methods
1 parent 732e010 commit 9be2951

File tree

2 files changed

+306
-8
lines changed

2 files changed

+306
-8
lines changed

contracts/WAMPL.sol

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ contract WAMPL is ERC20, ERC20Permit {
5959
/// @notice Transfers AMPLs from {msg.sender} and mints wAMPLs.
6060
///
6161
/// @param amples The amount of AMPLs to deposit.
62-
/// @return The number of wAMPLs minted.
62+
/// @return The amount of wAMPLs minted.
6363
function deposit(uint256 amples) external returns (uint256) {
6464
uint256 wamples = _ampleToWample(amples, _queryAMPLSupply());
6565

@@ -75,7 +75,7 @@ contract WAMPL is ERC20, ERC20Permit {
7575
///
7676
/// @param to The beneficiary wallet.
7777
/// @param amples The amount of AMPLs to deposit.
78-
/// @return The number of wAMPLs minted.
78+
/// @return The amount of wAMPLs minted.
7979
function depositFor(address to, uint256 amples) external returns (uint256) {
8080
uint256 wamples = _ampleToWample(amples, _queryAMPLSupply());
8181

@@ -89,7 +89,7 @@ contract WAMPL is ERC20, ERC20Permit {
8989
/// @notice Burns wAMPLs from {msg.sender} and transfers AMPLs back.
9090
///
9191
/// @param amples The amount of AMPLs to withdraw.
92-
/// @return The number of burnt wAMPLs.
92+
/// @return The amount of burnt wAMPLs.
9393
function withdraw(uint256 amples) external returns (uint256) {
9494
uint256 wamples = _ampleToWample(amples, _queryAMPLSupply());
9595

@@ -105,7 +105,7 @@ contract WAMPL is ERC20, ERC20Permit {
105105
///
106106
/// @param to The beneficiary wallet.
107107
/// @param amples The amount of AMPLs to withdraw.
108-
/// @return The number of burnt wAMPLs.
108+
/// @return The amount of burnt wAMPLs.
109109
function withdrawTo(address to, uint256 amples) external returns (uint256) {
110110
uint256 wamples = _ampleToWample(amples, _queryAMPLSupply());
111111

@@ -118,7 +118,7 @@ contract WAMPL is ERC20, ERC20Permit {
118118

119119
/// @notice Burns all wAMPLs from {msg.sender} and transfers AMPLs back.
120120
///
121-
/// @return The number of burnt wAMPLs.
121+
/// @return The amount of burnt wAMPLs.
122122
function withdrawAll() external returns (uint256) {
123123
uint256 wamples = balanceOf(_msgSender());
124124

@@ -135,7 +135,7 @@ contract WAMPL is ERC20, ERC20Permit {
135135
/// to the specified beneficiary.
136136
///
137137
/// @param to The beneficiary wallet.
138-
/// @return The number of burnt wAMPLs.
138+
/// @return The amount of burnt wAMPLs.
139139
function withdrawAllTo(address to) external returns (uint256) {
140140
uint256 wamples = balanceOf(_msgSender());
141141

@@ -148,6 +148,66 @@ contract WAMPL is ERC20, ERC20Permit {
148148
return wamples;
149149
}
150150

151+
/// @notice Transfers AMPLs from {msg.sender} and mints wAMPLs.
152+
///
153+
/// @param wamples The amount of wAMPLs to mint.
154+
/// @return The amount of AMPLs deposited.
155+
function mint(uint256 wamples) external returns (uint256) {
156+
uint256 amples = _wampleToAmple(wamples, _queryAMPLSupply());
157+
158+
IERC20(_ampl).safeTransferFrom(_msgSender(), address(this), amples);
159+
160+
_mint(_msgSender(), wamples);
161+
162+
return amples;
163+
}
164+
165+
/// @notice Transfers AMPLs from {msg.sender} and mints wAMPLs,
166+
/// to the specified beneficiary.
167+
///
168+
/// @param to The beneficiary wallet.
169+
/// @param wamples The amount of wAMPLs to mint.
170+
/// @return The amount of AMPLs deposited.
171+
function mintTo(address to, uint256 wamples) external returns (uint256) {
172+
uint256 amples = _wampleToAmple(wamples, _queryAMPLSupply());
173+
174+
IERC20(_ampl).safeTransferFrom(_msgSender(), address(this), amples);
175+
176+
_mint(to, wamples);
177+
178+
return amples;
179+
}
180+
181+
/// @notice Burns wAMPLs from {msg.sender} and transfers AMPLs back.
182+
///
183+
/// @param wamples The amount of wAMPLs to burn.
184+
/// @return The amount of AMPLs withdrawn.
185+
function burn(uint256 wamples) external returns (uint256) {
186+
uint256 amples = _wampleToAmple(wamples, _queryAMPLSupply());
187+
188+
_burn(_msgSender(), wamples);
189+
190+
IERC20(_ampl).safeTransfer(_msgSender(), amples);
191+
192+
return amples;
193+
}
194+
195+
/// @notice Burns wAMPLs from {msg.sender} and transfers AMPLs back,
196+
/// to the specified beneficiary.
197+
///
198+
/// @param to The beneficiary wallet.
199+
/// @param wamples The amount of wAMPLs to burn.
200+
/// @return The amount of AMPLs withdrawn.
201+
function burnTo(address to, uint256 wamples) external returns (uint256) {
202+
uint256 amples = _wampleToAmple(wamples, _queryAMPLSupply());
203+
204+
_burn(_msgSender(), wamples);
205+
206+
IERC20(_ampl).safeTransfer(to, amples);
207+
208+
return amples;
209+
}
210+
151211
//--------------------------------------------------------------------------
152212
// WAMPL view methods
153213

0 commit comments

Comments
 (0)