Skip to content

Commit

Permalink
πŸ‘·πŸ» πŸ”§ Fix usd per quanto to usd helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyrharper committed Feb 23, 2024
1 parent d3e3326 commit af86166
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Int128/USDPerQuantoInt128/Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function mulDecimal(USDPerQuantoInt128 x, int128 y)
}

/// @notice Multiplies usd/quanto and quanto to get usd
function mulDecimalToUSD(USDPerQuantoInt128 x, BaseInt128 y)
function mulDecimalToUSD(USDPerQuantoInt128 x, QuantoInt128 y)
pure
returns (USDInt128 result)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Int256/USDPerQuantoInt256/Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function mulDecimal(USDPerQuantoInt256 x, int256 y)
}

/// @notice Multiplies usd/quanto and quanto to get usd
function mulDecimalToUSD(USDPerQuantoInt256 x, BaseInt256 y)
function mulDecimalToUSD(USDPerQuantoInt256 x, QuantoInt256 y)
pure
returns (USDInt256 result)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Uint128/USDPerQuantoUint128/Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function mulDecimal(USDPerQuantoUint128 x, uint128 y)
}

/// @notice Multiplies usd/quanto and quanto to get usd
function mulDecimalToUSD(USDPerQuantoUint128 x, BaseUint128 y)
function mulDecimalToUSD(USDPerQuantoUint128 x, QuantoUint128 y)
pure
returns (USDUint128 result)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Uint256/USDPerQuantoUint256/Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function mulDecimal(USDPerQuantoUint256 x, uint256 y)
}

/// @notice Multiplies usd/quanto and quanto to get usd
function mulDecimalToUSD(USDPerQuantoUint256 x, BaseUint256 y)
function mulDecimalToUSD(USDPerQuantoUint256 x, QuantoUint256 y)
pure
returns (USDUint256 result)
{
Expand Down
9 changes: 4 additions & 5 deletions test/Int128/USDPerQuantoInt128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ pragma solidity >=0.8.19;
import {Test, console} from "forge-std/Test.sol";
import {
BaseQuantoPerUSDInt128,
BaseInt128,
QuantoInt128,
USDPerBaseInt128,
BaseInt128,
USDPerQuantoInt128,
USDPerQuantoInt256,
USDPerQuantoUint128,
Expand Down Expand Up @@ -310,7 +309,7 @@ contract USDPerQuantoInt128Test is Test {

function testUSDPerQuantoInt128MulDecimalToUSD() public {
USDPerQuantoInt128 x = USDPerQuantoInt128.wrap(100 ether);
BaseInt128 y = BaseInt128.wrap(200 ether);
QuantoInt128 y = QuantoInt128.wrap(200 ether);
USDInt128 result = x.mulDecimalToUSD(y);
assertEq(result.unwrap(), 20_000 ether);
}
Expand All @@ -332,10 +331,10 @@ contract USDPerQuantoInt128Test is Test {
&& (z / y != (x / 1 ether) || z / x != (y / 1 ether))
) {
vm.expectRevert();
USDPerQuantoInt128.wrap(x).mulDecimalToUSD(BaseInt128.wrap(y));
USDPerQuantoInt128.wrap(x).mulDecimalToUSD(QuantoInt128.wrap(y));
} else {
USDInt128 result =
USDPerQuantoInt128.wrap(x).mulDecimalToUSD(BaseInt128.wrap(y));
USDPerQuantoInt128.wrap(x).mulDecimalToUSD(QuantoInt128.wrap(y));
assertEq(result.unwrap(), z);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/Int256/USDPerQuantoInt256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ contract USDPerQuantoInt256Test is Test {

function testUSDPerQuantoInt256MulDecimalToUSD() public {
USDPerQuantoInt256 x = USDPerQuantoInt256.wrap(100 ether);
BaseInt256 y = BaseInt256.wrap(200 ether);
QuantoInt256 y = QuantoInt256.wrap(200 ether);
USDInt256 result = x.mulDecimalToUSD(y);
assertEq(result.unwrap(), 20_000 ether);
}
Expand All @@ -332,10 +332,10 @@ contract USDPerQuantoInt256Test is Test {
&& (z / y != (x / 1 ether) || z / x != (y / 1 ether))
) {
vm.expectRevert();
USDPerQuantoInt256.wrap(x).mulDecimalToUSD(BaseInt256.wrap(y));
USDPerQuantoInt256.wrap(x).mulDecimalToUSD(QuantoInt256.wrap(y));
} else {
USDInt256 result =
USDPerQuantoInt256.wrap(x).mulDecimalToUSD(BaseInt256.wrap(y));
USDPerQuantoInt256.wrap(x).mulDecimalToUSD(QuantoInt256.wrap(y));
assertEq(result.unwrap(), z);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/Uint128/USDPerQuantoUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ contract USDPerQuantoUint128Test is Test {

function testUSDPerQuantoUint128MulDecimalToUSD() public {
USDPerQuantoUint128 x = USDPerQuantoUint128.wrap(100 ether);
BaseUint128 y = BaseUint128.wrap(200 ether);
QuantoUint128 y = QuantoUint128.wrap(200 ether);
USDUint128 result = x.mulDecimalToUSD(y);
assertEq(result.unwrap(), 20_000 ether);
}
Expand All @@ -329,10 +329,10 @@ contract USDPerQuantoUint128Test is Test {
&& (z / y != (x / 1 ether) || z / x != (y / 1 ether))
) {
vm.expectRevert();
USDPerQuantoUint128.wrap(x).mulDecimalToUSD(BaseUint128.wrap(y));
USDPerQuantoUint128.wrap(x).mulDecimalToUSD(QuantoUint128.wrap(y));
} else {
USDUint128 result =
USDPerQuantoUint128.wrap(x).mulDecimalToUSD(BaseUint128.wrap(y));
USDPerQuantoUint128.wrap(x).mulDecimalToUSD(QuantoUint128.wrap(y));
assertEq(result.unwrap(), z);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/Uint256/USDPerQuantoUint256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ contract USDPerQuantoUint256Test is Test {

function testUSDPerQuantoUint256MulDecimalToUSD() public {
USDPerQuantoUint256 x = USDPerQuantoUint256.wrap(100 ether);
BaseUint256 y = BaseUint256.wrap(200 ether);
QuantoUint256 y = QuantoUint256.wrap(200 ether);
USDUint256 result = x.mulDecimalToUSD(y);
assertEq(result.unwrap(), 20_000 ether);
}
Expand All @@ -329,10 +329,10 @@ contract USDPerQuantoUint256Test is Test {
&& (z / y != (x / 1 ether) || z / x != (y / 1 ether))
) {
vm.expectRevert();
USDPerQuantoUint256.wrap(x).mulDecimalToUSD(BaseUint256.wrap(y));
USDPerQuantoUint256.wrap(x).mulDecimalToUSD(QuantoUint256.wrap(y));
} else {
USDUint256 result =
USDPerQuantoUint256.wrap(x).mulDecimalToUSD(BaseUint256.wrap(y));
USDPerQuantoUint256.wrap(x).mulDecimalToUSD(QuantoUint256.wrap(y));
assertEq(result.unwrap(), z);
}
}
Expand Down

0 comments on commit af86166

Please sign in to comment.