Skip to content

Commit

Permalink
updated to now use 1e18 divided (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
GWSzeto authored Sep 5, 2024
1 parent ae1cd60 commit ac47ad0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/module/token/minting/ClaimableERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ contract ClaimableERC20 is

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

_distributeMintPrice(msg.sender, _params.currency, _amount * _params.pricePerUnit);
_distributeMintPrice(msg.sender, _params.currency, (_amount * _params.pricePerUnit) / 1e18);
}

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

_validateClaimSignatureParams(_params, _to, _amount);

_distributeMintPrice(msg.sender, _params.currency, _amount * _params.pricePerUnit);
_distributeMintPrice(msg.sender, _params.currency, (_amount * _params.pricePerUnit) / 1e18);
}

/// @dev Called by a Core into an Module during the installation of the Module.
Expand Down
2 changes: 1 addition & 1 deletion src/module/token/minting/MintableERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ contract MintableERC20 is
MintSignatureParamsERC20 memory _params = abi.decode(_data, (MintSignatureParamsERC20));

_mintWithSignatureERC20(_params);
_distributeMintPrice(msg.sender, _params.currency, _amount * _params.pricePerUnit);
_distributeMintPrice(msg.sender, _params.currency, (_amount * _params.pricePerUnit) / 1e18);
}

/// @dev Called by a Core into an Module during the installation of the Module.
Expand Down
16 changes: 8 additions & 8 deletions test/module/minting/ClaimableERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ contract ClaimableERC20Test is Test {
assertEq(saleRecipient.balance, 0);

vm.prank(tokenRecipient);
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
tokenRecipient, amount, abi.encode(claimRequest), sig
);

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

uint256 salePrice = amount * claimRequest.pricePerUnit;
uint256 salePrice = (amount * claimRequest.pricePerUnit) / 1e18;
assertEq(tokenRecipient.balance, balBefore - salePrice);
assertEq(saleRecipient.balance, salePrice);
}
Expand Down Expand Up @@ -289,14 +289,14 @@ contract ClaimableERC20Test is Test {
);

vm.prank(tokenRecipient);
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
tokenRecipient, amount, abi.encode(claimRequest), sig
);

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

uint256 salePrice = amount * claimRequest.pricePerUnit;
uint256 salePrice = (amount * claimRequest.pricePerUnit) / 1e18;
assertEq(tokenRecipient.balance, balBefore - salePrice);
assertEq(saleRecipient.balance, salePrice);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ contract ClaimableERC20Test is Test {
tokenRecipient, amount, abi.encode(claimRequest), sig
);

uint256 salePrice = amount * condition.pricePerUnit;
uint256 salePrice = (amount * condition.pricePerUnit) / 1e18;

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

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

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

vm.prank(tokenRecipient);
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
tokenRecipient, amount, abi.encode(claimRequest), sig
);
assertEq(core.balanceOf(tokenRecipient), amount);
Expand Down Expand Up @@ -711,7 +711,7 @@ contract ClaimableERC20Test is Test {

vm.prank(tokenRecipient);
vm.expectRevert(abi.encodeWithSelector(ClaimableERC20.ClaimableMaxMintPerWalletExceeded.selector));
core.mintWithSignature{value: amount * claimRequest.pricePerUnit}(
core.mintWithSignature{value: (amount * claimRequest.pricePerUnit) / 1e18}(
tokenRecipient, amount, abi.encode(claimRequest), sig
);
}
Expand Down
14 changes: 7 additions & 7 deletions test/module/minting/MintableERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ contract MintableERC20Test is Test {
assertEq(saleRecipient.balance, 0);

vm.prank(tokenRecipient);
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
tokenRecipient, amount, abi.encode(mintRequest), sig
);

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

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

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

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

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

vm.prank(tokenRecipient);
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
tokenRecipient, amount, abi.encode(mintRequest), sig
);
assertEq(core.balanceOf(tokenRecipient), amount);
Expand Down Expand Up @@ -276,7 +276,7 @@ contract MintableERC20Test is Test {

vm.prank(tokenRecipient);
vm.expectRevert(abi.encodeWithSelector(MintableERC20.MintableSignatureMintUnauthorized.selector));
core.mintWithSignature{value: amount * mintRequest.pricePerUnit}(
core.mintWithSignature{value: (amount * mintRequest.pricePerUnit) / 1e18}(
tokenRecipient, amount, abi.encode(mintRequest), sig
);
}
Expand Down

0 comments on commit ac47ad0

Please sign in to comment.