Skip to content

Commit ac47ad0

Browse files
authored
updated to now use 1e18 divided (#153)
1 parent ae1cd60 commit ac47ad0

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/module/token/minting/ClaimableERC20.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ contract ClaimableERC20 is
194194

195195
_validateClaimCondition(_to, _amount, _params.currency, _params.pricePerUnit, _params.recipientAllowlistProof);
196196

197-
_distributeMintPrice(msg.sender, _params.currency, _amount * _params.pricePerUnit);
197+
_distributeMintPrice(msg.sender, _params.currency, (_amount * _params.pricePerUnit) / 1e18);
198198
}
199199

200200
/// @notice Callback function for the ERC20Core.mint function.
@@ -213,7 +213,7 @@ contract ClaimableERC20 is
213213

214214
_validateClaimSignatureParams(_params, _to, _amount);
215215

216-
_distributeMintPrice(msg.sender, _params.currency, _amount * _params.pricePerUnit);
216+
_distributeMintPrice(msg.sender, _params.currency, (_amount * _params.pricePerUnit) / 1e18);
217217
}
218218

219219
/// @dev Called by a Core into an Module during the installation of the Module.

src/module/token/minting/MintableERC20.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ contract MintableERC20 is
153153
MintSignatureParamsERC20 memory _params = abi.decode(_data, (MintSignatureParamsERC20));
154154

155155
_mintWithSignatureERC20(_params);
156-
_distributeMintPrice(msg.sender, _params.currency, _amount * _params.pricePerUnit);
156+
_distributeMintPrice(msg.sender, _params.currency, (_amount * _params.pricePerUnit) / 1e18);
157157
}
158158

159159
/// @dev Called by a Core into an Module during the installation of the Module.

test/module/minting/ClaimableERC20.t.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ contract ClaimableERC20Test is Test {
234234
assertEq(saleRecipient.balance, 0);
235235

236236
vm.prank(tokenRecipient);
237-
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
237+
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
238238
tokenRecipient, amount, abi.encode(claimRequest), sig
239239
);
240240

241241
// Check minted balance
242242
assertEq(core.balanceOf(address(0x123)), amount);
243243

244-
uint256 salePrice = amount * claimRequest.pricePerUnit;
244+
uint256 salePrice = (amount * claimRequest.pricePerUnit) / 1e18;
245245
assertEq(tokenRecipient.balance, balBefore - salePrice);
246246
assertEq(saleRecipient.balance, salePrice);
247247
}
@@ -289,14 +289,14 @@ contract ClaimableERC20Test is Test {
289289
);
290290

291291
vm.prank(tokenRecipient);
292-
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
292+
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
293293
tokenRecipient, amount, abi.encode(claimRequest), sig
294294
);
295295

296296
// Check minted balance
297297
assertEq(core.balanceOf(tokenRecipient), amount);
298298

299-
uint256 salePrice = amount * claimRequest.pricePerUnit;
299+
uint256 salePrice = (amount * claimRequest.pricePerUnit) / 1e18;
300300
assertEq(tokenRecipient.balance, balBefore - salePrice);
301301
assertEq(saleRecipient.balance, salePrice);
302302
}
@@ -347,7 +347,7 @@ contract ClaimableERC20Test is Test {
347347
tokenRecipient, amount, abi.encode(claimRequest), sig
348348
);
349349

350-
uint256 salePrice = amount * condition.pricePerUnit;
350+
uint256 salePrice = (amount * condition.pricePerUnit) / 1e18;
351351

352352
vm.prank(tokenRecipient);
353353
currency.approve(address(core), salePrice);
@@ -356,7 +356,7 @@ contract ClaimableERC20Test is Test {
356356
core.mintWithSignature(tokenRecipient, amount, abi.encode(claimRequest), sig);
357357

358358
// Check minted balance
359-
assertEq(core.balanceOf(address(0x123)), amount);
359+
assertEq(core.balanceOf(tokenRecipient), amount);
360360

361361
assertEq(currency.balanceOf(tokenRecipient), balBefore - salePrice);
362362
assertEq(currency.balanceOf(saleRecipient), salePrice);
@@ -494,7 +494,7 @@ contract ClaimableERC20Test is Test {
494494
bytes memory sig = signMintRequest(claimRequest, permissionedActorPrivateKey);
495495

496496
vm.prank(tokenRecipient);
497-
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
497+
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
498498
tokenRecipient, amount, abi.encode(claimRequest), sig
499499
);
500500
assertEq(core.balanceOf(tokenRecipient), amount);
@@ -711,7 +711,7 @@ contract ClaimableERC20Test is Test {
711711

712712
vm.prank(tokenRecipient);
713713
vm.expectRevert(abi.encodeWithSelector(ClaimableERC20.ClaimableMaxMintPerWalletExceeded.selector));
714-
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
714+
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
715715
tokenRecipient, amount, abi.encode(claimRequest), sig
716716
);
717717
}

test/module/minting/MintableERC20.t.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ contract MintableERC20Test is Test {
164164
assertEq(saleRecipient.balance, 0);
165165

166166
vm.prank(tokenRecipient);
167-
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
167+
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
168168
tokenRecipient, amount, abi.encode(mintRequest), sig
169169
);
170170

171171
// Check minted balance
172172
assertEq(core.balanceOf(address(0x123)), amount);
173173

174-
uint256 salePrice = amount * mintRequest.pricePerUnit;
174+
uint256 salePrice = (amount * mintRequest.pricePerUnit) / 1e18;
175175
assertEq(tokenRecipient.balance, balBefore - salePrice);
176176
assertEq(saleRecipient.balance, salePrice);
177177
}
@@ -190,7 +190,7 @@ contract MintableERC20Test is Test {
190190

191191
vm.prank(tokenRecipient);
192192
vm.expectRevert();
193-
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
193+
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
194194
tokenRecipient, amount, abi.encode(bytes("random mixer")), sig
195195
);
196196
}
@@ -209,7 +209,7 @@ contract MintableERC20Test is Test {
209209

210210
vm.prank(tokenRecipient);
211211
vm.expectRevert(abi.encodeWithSelector(MintableERC20.MintableRequestOutOfTimeWindow.selector));
212-
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
212+
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
213213
tokenRecipient, amount, abi.encode(mintRequest), sig
214214
);
215215
}
@@ -230,7 +230,7 @@ contract MintableERC20Test is Test {
230230

231231
vm.prank(tokenRecipient);
232232
vm.expectRevert(abi.encodeWithSelector(MintableERC20.MintableRequestOutOfTimeWindow.selector));
233-
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
233+
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
234234
tokenRecipient, amount, abi.encode(mintRequest), sig
235235
);
236236
}
@@ -248,7 +248,7 @@ contract MintableERC20Test is Test {
248248
bytes memory sig = signMintSignatureParams(mintRequest, permissionedActorPrivateKey);
249249

250250
vm.prank(tokenRecipient);
251-
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
251+
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
252252
tokenRecipient, amount, abi.encode(mintRequest), sig
253253
);
254254
assertEq(core.balanceOf(tokenRecipient), amount);
@@ -276,7 +276,7 @@ contract MintableERC20Test is Test {
276276

277277
vm.prank(tokenRecipient);
278278
vm.expectRevert(abi.encodeWithSelector(MintableERC20.MintableSignatureMintUnauthorized.selector));
279-
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
279+
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
280280
tokenRecipient, amount, abi.encode(mintRequest), sig
281281
);
282282
}

0 commit comments

Comments
 (0)