Skip to content

Commit 6c61031

Browse files
committed
code change -- hyperdrive.safeTransferFrom
1 parent 4ce7f75 commit 6c61031

3 files changed

Lines changed: 13 additions & 41 deletions

File tree

contracts/src/interfaces/IHyperdriveMatchingEngineV2.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ interface IHyperdriveMatchingEngineV2 {
115115
/// @dev The counterparty of the trade. If left as zero, the validation
116116
/// is skipped.
117117
address counterparty;
118-
/// @dev The fee recipient of the trade. This is the address that will
119-
/// receive any excess trading fees on the match. If left as zero,
120-
/// the validation is skipped.
121-
address feeRecipient;
122118
/// @dev The Hyperdrive address where the trade will be executed.
123119
IHyperdrive hyperdrive;
124120
/// @dev The amount to be used in the trade. In the case of `OpenLong` or

contracts/src/matching/HyperdriveMatchingEngineV2.sol

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract HyperdriveMatchingEngineV2 is
3434
/// @notice The EIP712 typehash of the OrderIntent struct.
3535
bytes32 public constant ORDER_INTENT_TYPEHASH =
3636
keccak256(
37-
"OrderIntent(address trader,address counterparty,address feeRecipient,address hyperdrive,uint256 fundAmount,uint256 bondAmount,uint256 minVaultSharePrice,Options options,uint8 orderType,uint256 minMaturityTime,uint256 maxMaturityTime,uint256 expiry,bytes32 salt)"
37+
"OrderIntent(address trader,address counterparty,address hyperdrive,uint256 fundAmount,uint256 bondAmount,uint256 minVaultSharePrice,Options options,uint8 orderType,uint256 minMaturityTime,uint256 maxMaturityTime,uint256 expiry,bytes32 salt)"
3838
);
3939

4040
/// @notice The EIP712 typehash of the Options struct.
@@ -347,7 +347,6 @@ contract HyperdriveMatchingEngineV2 is
347347
/// OrderIntent({
348348
/// trader: msg.sender, // Take the user's address.
349349
/// counterparty: address(0), // Not needed for immediate fill.
350-
/// feeRecipient: address(0), // Not needed for immediate fill.
351350
/// hyperdrive: IHyperdrive(address(0)), // Not needed for immediate fill.
352351
/// fundAmount: 0, // Not needed for immediate fill.
353352
/// bondAmount: _bondAmount, // Take from the user's input.
@@ -860,7 +859,6 @@ contract HyperdriveMatchingEngineV2 is
860859
ORDER_INTENT_TYPEHASH,
861860
_order.trader,
862861
_order.counterparty,
863-
_order.feeRecipient,
864862
address(_order.hyperdrive),
865863
_order.fundAmount,
866864
_order.bondAmount,
@@ -1234,17 +1232,19 @@ contract HyperdriveMatchingEngineV2 is
12341232
);
12351233

12361234
// This contract needs to take custody of the bonds before burning.
1237-
_hyperdrive.transferFrom(
1238-
longAssetId,
1235+
_hyperdrive.safeTransferFrom(
12391236
_longOrder.trader,
12401237
address(this),
1241-
_bondMatchAmount
1238+
longAssetId,
1239+
_bondMatchAmount,
1240+
""
12421241
);
1243-
_hyperdrive.transferFrom(
1244-
shortAssetId,
1242+
_hyperdrive.safeTransferFrom(
12451243
_shortOrder.trader,
12461244
address(this),
1247-
_bondMatchAmount
1245+
shortAssetId,
1246+
_bondMatchAmount,
1247+
""
12481248
);
12491249

12501250
// Calculate minOutput and consider the potential donation to help match
@@ -1317,11 +1317,12 @@ contract HyperdriveMatchingEngineV2 is
13171317
}
13181318

13191319
// Transfer the position from the close trader to the open trader.
1320-
_hyperdrive.transferFrom(
1321-
assetId,
1320+
_hyperdrive.safeTransferFrom(
13221321
_closeOrder.trader,
13231322
_openOrder.options.destination,
1324-
_bondMatchAmount
1323+
assetId,
1324+
_bondMatchAmount,
1325+
""
13251326
);
13261327

13271328
// Transfer fund tokens from open trader to the close trader.

test/units/matching/HyperdriveMatchingEngineV2Test.t.sol

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
6868
memory longOrder = _createOrderIntent(
6969
alice,
7070
address(0),
71-
address(0),
7271
100_000e18, // fundAmount.
7372
95_000e18, // bondAmount.
7473
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -78,7 +77,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
7877
memory shortOrder = _createOrderIntent(
7978
bob,
8079
address(0),
81-
address(0),
8280
101_000e18, // fundAmount.
8381
95_000e18, // bondAmount.
8482
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -143,7 +141,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
143141
memory closeLongOrder = _createOrderIntent(
144142
alice,
145143
address(0),
146-
address(0),
147144
90_000e18, // min fund amount to receive.
148145
95_000e18, // bond amount to close.
149146
IHyperdriveMatchingEngineV2.OrderType.CloseLong
@@ -155,7 +152,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
155152
memory closeShortOrder = _createOrderIntent(
156153
bob,
157154
address(0),
158-
address(0),
159155
5_001e18, // min fund amount to receive.
160156
95_000e18, // bond amount to close.
161157
IHyperdriveMatchingEngineV2.OrderType.CloseShort
@@ -194,7 +190,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
194190
memory closeLongOrder = _createOrderIntent(
195191
alice,
196192
address(0),
197-
address(0),
198193
90_000e18,
199194
95_000e18,
200195
IHyperdriveMatchingEngineV2.OrderType.CloseLong
@@ -206,7 +201,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
206201
memory closeShortOrder = _createOrderIntent(
207202
bob,
208203
address(0),
209-
address(0),
210204
90_000e18,
211205
95_000e18,
212206
IHyperdriveMatchingEngineV2.OrderType.CloseShort
@@ -230,7 +224,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
230224
memory longOrder = _createOrderIntent(
231225
alice,
232226
address(0),
233-
address(0),
234227
1e18, // Very small fundAmount.
235228
95_000e18,
236229
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -240,7 +233,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
240233
memory shortOrder = _createOrderIntent(
241234
bob,
242235
address(0),
243-
address(0),
244236
1e18, // Very small fundAmount.
245237
95_000e18,
246238
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -264,7 +256,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
264256
memory longOrder = _createOrderIntent(
265257
alice,
266258
address(0),
267-
address(0),
268259
100_000e18,
269260
95_000e18,
270261
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -274,7 +265,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
274265
memory shortOrder = _createOrderIntent(
275266
bob,
276267
address(0),
277-
address(0),
278268
100_000e18,
279269
90_000e18, // Different but valid bond amount.
280270
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -335,7 +325,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
335325
memory closeLongOrder = _createOrderIntent(
336326
alice,
337327
address(0),
338-
address(0),
339328
100_000e18,
340329
200_000e18, // More than what alice has.
341330
IHyperdriveMatchingEngineV2.OrderType.CloseLong
@@ -347,7 +336,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
347336
memory closeShortOrder = _createOrderIntent(
348337
bob,
349338
address(0),
350-
address(0),
351339
100_000e18,
352340
200_000e18,
353341
IHyperdriveMatchingEngineV2.OrderType.CloseShort
@@ -371,7 +359,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
371359
memory longOrder = _createOrderIntent(
372360
alice,
373361
address(0),
374-
address(0),
375362
100_000e18,
376363
95_000e18,
377364
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -382,7 +369,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
382369
memory shortOrder = _createOrderIntent(
383370
bob,
384371
address(0),
385-
address(0),
386372
100_000e18,
387373
95_000e18,
388374
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -401,7 +387,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
401387
memory longOrder = _createOrderIntent(
402388
alice,
403389
address(0),
404-
address(0),
405390
100_000e18,
406391
95_000e18,
407392
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -411,7 +396,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
411396
memory shortOrder = _createOrderIntent(
412397
bob,
413398
address(0),
414-
address(0),
415399
100_000e18,
416400
95_000e18,
417401
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -434,7 +418,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
434418
memory longOrder = _createOrderIntent(
435419
alice,
436420
address(0),
437-
address(0),
438421
100_000e18,
439422
95_000e18,
440423
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -444,7 +427,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
444427
memory shortOrder = _createOrderIntent(
445428
bob,
446429
address(0),
447-
address(0),
448430
50_000e18, // Half the amount.
449431
47_500e18, // Half the bonds.
450432
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -475,7 +457,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
475457
memory longOrder = _createOrderIntent(
476458
alice,
477459
address(0),
478-
address(0),
479460
100_000e18,
480461
95_000e18,
481462
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -486,7 +467,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
486467
memory shortOrder = _createOrderIntent(
487468
bob,
488469
address(0),
489-
address(0),
490470
100_000e18,
491471
95_000e18,
492472
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -506,7 +486,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
506486
memory longOrder = _createOrderIntent(
507487
alice,
508488
address(0),
509-
address(0),
510489
100_000e18,
511490
95_000e18,
512491
IHyperdriveMatchingEngineV2.OrderType.OpenLong
@@ -516,7 +495,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
516495
memory shortOrder = _createOrderIntent(
517496
bob,
518497
address(0),
519-
address(0),
520498
100_000e18,
521499
95_000e18,
522500
IHyperdriveMatchingEngineV2.OrderType.OpenShort
@@ -535,15 +513,13 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
535513
/// @dev Creates an order intent.
536514
/// @param trader The address of the trader.
537515
/// @param counterparty The address of the counterparty.
538-
/// @param feeRecipient The address of the fee recipient.
539516
/// @param fundAmount The amount of base tokens to fund the order.
540517
/// @param bondAmount The amount of bonds to fund the order.
541518
/// @param orderType The type of the order.
542519
/// @return The order intent.
543520
function _createOrderIntent(
544521
address trader,
545522
address counterparty,
546-
address feeRecipient,
547523
uint256 fundAmount,
548524
uint256 bondAmount,
549525
IHyperdriveMatchingEngineV2.OrderType orderType
@@ -552,7 +528,6 @@ contract HyperdriveMatchingEngineV2Test is HyperdriveTest {
552528
IHyperdriveMatchingEngineV2.OrderIntent({
553529
trader: trader,
554530
counterparty: counterparty,
555-
feeRecipient: feeRecipient,
556531
hyperdrive: hyperdrive,
557532
fundAmount: fundAmount,
558533
bondAmount: bondAmount,

0 commit comments

Comments
 (0)