|
1 | 1 | // SPDX-License-Identifier: MIT |
2 | 2 | pragma solidity ^0.8.0; |
3 | 3 |
|
4 | | -import {EIP712Types} from '../helpers/EIP712Types.sol'; |
5 | | - |
6 | 4 | import './TestGhoBase.t.sol'; |
7 | 5 |
|
8 | 6 | contract TestGsm is TestGhoBase { |
@@ -93,6 +91,13 @@ contract TestGsm is TestGhoBase { |
93 | 91 | gsm.initialize(address(this), TREASURY, DEFAULT_GSM_USDX_EXPOSURE, address(GHO_RESERVE)); |
94 | 92 | } |
95 | 93 |
|
| 94 | + function testTypehash() public { |
| 95 | + bytes32 buyTypeHash = vm.eip712HashType('BuyAssetWithSig'); |
| 96 | + bytes32 sellTypeHash = vm.eip712HashType('SellAssetWithSig'); |
| 97 | + assertEq(buyTypeHash, GHO_GSM.BUY_ASSET_WITH_SIG_TYPEHASH(), 'Unexpected buy asset typed data hash'); |
| 98 | + assertEq(sellTypeHash, GHO_GSM.SELL_ASSET_WITH_SIG_TYPEHASH(), 'Unexpected sell asset typed data hash'); |
| 99 | + } |
| 100 | + |
96 | 101 | function testSellAssetZeroFee() public { |
97 | 102 | vm.expectEmit(true, true, false, true, address(GHO_GSM)); |
98 | 103 | emit FeeStrategyUpdated(address(GHO_GSM_FIXED_FEE_STRATEGY), address(0)); |
@@ -183,7 +188,7 @@ contract TestGsm is TestGhoBase { |
183 | 188 |
|
184 | 189 | assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce'); |
185 | 190 |
|
186 | | - bytes32 digest = _getSellTypedDataHash( |
| 191 | + bytes32 digest = _getSellAssetTypedDataHash( |
187 | 192 | EIP712Types.SellAssetWithSig({ |
188 | 193 | originator: gsmSignerAddr, |
189 | 194 | maxAmount: DEFAULT_GSM_USDX_AMOUNT, |
@@ -236,7 +241,7 @@ contract TestGsm is TestGhoBase { |
236 | 241 |
|
237 | 242 | assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce'); |
238 | 243 |
|
239 | | - bytes32 digest = _getSellTypedDataHash( |
| 244 | + bytes32 digest = _getSellAssetTypedDataHash( |
240 | 245 | EIP712Types.SellAssetWithSig({ |
241 | 246 | originator: gsmSignerAddr, |
242 | 247 | maxAmount: DEFAULT_GSM_USDX_AMOUNT, |
@@ -278,7 +283,7 @@ contract TestGsm is TestGhoBase { |
278 | 283 | function testRevertSellAssetWithSigExpiredSignature() public { |
279 | 284 | uint256 deadline = block.timestamp - 1; |
280 | 285 |
|
281 | | - bytes32 digest = _getSellTypedDataHash( |
| 286 | + bytes32 digest = _getSellAssetTypedDataHash( |
282 | 287 | EIP712Types.SellAssetWithSig({ |
283 | 288 | originator: gsmSignerAddr, |
284 | 289 | maxAmount: DEFAULT_GSM_USDX_AMOUNT, |
@@ -307,7 +312,7 @@ contract TestGsm is TestGhoBase { |
307 | 312 | function testRevertSellAssetWithSigInvalidSignature() public { |
308 | 313 | uint256 deadline = block.timestamp + 1 hours; |
309 | 314 |
|
310 | | - bytes32 digest = _getSellTypedDataHash( |
| 315 | + bytes32 digest = _getSellAssetTypedDataHash( |
311 | 316 | EIP712Types.SellAssetWithSig({ |
312 | 317 | originator: gsmSignerAddr, |
313 | 318 | maxAmount: DEFAULT_GSM_USDX_AMOUNT, |
@@ -584,7 +589,7 @@ contract TestGsm is TestGhoBase { |
584 | 589 |
|
585 | 590 | assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce'); |
586 | 591 |
|
587 | | - bytes32 digest = _getBuyTypedDataHash( |
| 592 | + bytes32 digest = _getBuyAssetTypedDataHash( |
588 | 593 | EIP712Types.BuyAssetWithSig({ |
589 | 594 | originator: gsmSignerAddr, |
590 | 595 | minAmount: DEFAULT_GSM_USDX_AMOUNT, |
@@ -652,7 +657,7 @@ contract TestGsm is TestGhoBase { |
652 | 657 |
|
653 | 658 | assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce'); |
654 | 659 |
|
655 | | - bytes32 digest = _getBuyTypedDataHash( |
| 660 | + bytes32 digest = _getBuyAssetTypedDataHash( |
656 | 661 | EIP712Types.BuyAssetWithSig({ |
657 | 662 | originator: gsmSignerAddr, |
658 | 663 | minAmount: DEFAULT_GSM_USDX_AMOUNT, |
@@ -745,7 +750,7 @@ contract TestGsm is TestGhoBase { |
745 | 750 | function testRevertBuyAssetWithSigExpiredSignature() public { |
746 | 751 | uint256 deadline = block.timestamp - 1; |
747 | 752 |
|
748 | | - bytes32 digest = _getBuyTypedDataHash( |
| 753 | + bytes32 digest = _getBuyAssetTypedDataHash( |
749 | 754 | EIP712Types.BuyAssetWithSig({ |
750 | 755 | originator: gsmSignerAddr, |
751 | 756 | minAmount: DEFAULT_GSM_USDX_AMOUNT, |
@@ -773,7 +778,7 @@ contract TestGsm is TestGhoBase { |
773 | 778 | function testRevertBuyAssetWithSigInvalidSignature() public { |
774 | 779 | uint256 deadline = block.timestamp + 1 hours; |
775 | 780 |
|
776 | | - bytes32 digest = _getBuyTypedDataHash( |
| 781 | + bytes32 digest = _getBuyAssetTypedDataHash( |
777 | 782 | EIP712Types.BuyAssetWithSig({ |
778 | 783 | originator: gsmSignerAddr, |
779 | 784 | minAmount: DEFAULT_GSM_USDX_AMOUNT, |
|
0 commit comments