@@ -92,7 +92,8 @@ library MarketplaceLogic {
9292 ps,
9393 poolAddressProvider
9494 );
95- _updateParams (
95+ params.ethLeft = msg .value ;
96+ _updateBuyParams (
9697 params,
9798 poolAddressProvider,
9899 marketplaceId,
@@ -101,24 +102,6 @@ library MarketplaceLogic {
101102 swapAdapter,
102103 swapPayload
103104 );
104- params.ethLeft = msg .value ;
105- params.orderInfo = IMarketplace (params.marketplace.adapter)
106- .getAskOrderInfo (payload);
107- if (params.orderInfo.isSeaport) {
108- require (
109- msg .sender == params.orderInfo.taker,
110- Errors.INVALID_ORDER_TAKER
111- );
112- } else {
113- // in LooksRare, X2Y2 we dont match orders between buyer and seller
114- // the protocol just works like an agent so taker cannot be read
115- // from orders
116- params.orderInfo.taker = msg .sender ;
117- }
118- require (
119- params.orderInfo.maker != params.orderInfo.taker,
120- Errors.MAKER_SAME_AS_TAKER
121- );
122105
123106 _depositETH (params);
124107
@@ -207,7 +190,7 @@ library MarketplaceLogic {
207190 params.ethLeft = msg .value ;
208191
209192 for (uint256 i = 0 ; i < marketplaceIds.length ; i++ ) {
210- _updateParams (
193+ _updateBuyParams (
211194 params,
212195 poolAddressProvider,
213196 marketplaceIds[i],
@@ -216,20 +199,6 @@ library MarketplaceLogic {
216199 swapAdapters[i],
217200 swapPayloads[i]
218201 );
219- params.orderInfo = IMarketplace (params.marketplace.adapter)
220- .getAskOrderInfo (payloads[i]);
221- if (params.orderInfo.isSeaport) {
222- require (
223- msg .sender == params.orderInfo.taker,
224- Errors.INVALID_ORDER_TAKER
225- );
226- } else {
227- params.orderInfo.taker = msg .sender ;
228- }
229- require (
230- params.orderInfo.maker != params.orderInfo.taker,
231- Errors.MAKER_SAME_AS_TAKER
232- );
233202
234203 // Once we encounter a listing using WETH, then we convert all our ethLeft to WETH
235204 // this also means that the parameters order is very important
@@ -265,21 +234,13 @@ library MarketplaceLogic {
265234 ps,
266235 poolAddressProvider
267236 );
268- _updateParams (
237+ _updateAcceptBidParams (
269238 params,
270239 poolAddressProvider,
271240 marketplaceId,
272241 payload,
273242 credit,
274- DataTypes.SwapAdapter (address (0 ), address (0 ), false ),
275- bytes ("" )
276- );
277- params.orderInfo = IMarketplace (params.marketplace.adapter)
278- .getBidOrderInfo (payload);
279-
280- require (
281- params.orderInfo.taker == onBehalfOf,
282- Errors.INVALID_ORDER_TAKER
243+ onBehalfOf
283244 );
284245
285246 _acceptBidWithCredit (ps, params);
@@ -296,7 +257,7 @@ library MarketplaceLogic {
296257 ps,
297258 poolAddressProvider
298259 );
299- _updateParams (
260+ _updateAcceptBidParams (
300261 params,
301262 poolAddressProvider,
302263 marketplaceId,
@@ -309,8 +270,7 @@ library MarketplaceLogic {
309270 bytes32 ("" ),
310271 bytes32 ("" )
311272 ),
312- DataTypes.SwapAdapter (address (0 ), address (0 ), false ),
313- bytes ("" )
273+ onBehalfOf
314274 );
315275 params.orderInfo = IMarketplace (params.marketplace.adapter)
316276 .getBidOrderInfo (payload);
@@ -341,14 +301,13 @@ library MarketplaceLogic {
341301 ps,
342302 poolAddressProvider
343303 );
344- _updateParams (
304+ _updateAcceptBidParams (
345305 params,
346306 poolAddressProvider,
347307 marketplaceIds[i],
348308 payloads[i],
349309 credits[i],
350- DataTypes.SwapAdapter (address (0 ), address (0 ), false ),
351- bytes ("" )
310+ onBehalfOf
352311 );
353312 params.orderInfo = IMarketplace (params.marketplace.adapter)
354313 .getBidOrderInfo (payloads[i]);
@@ -833,21 +792,59 @@ library MarketplaceLogic {
833792 .getPriceOracleSentinel ();
834793 }
835794
836- function _updateParams (
795+ function _updateBuyParams (
837796 DataTypes.ExecuteMarketplaceParams memory params ,
838797 IPoolAddressesProvider poolAddressProvider ,
839798 bytes32 marketplaceId ,
840799 bytes memory payload ,
841800 DataTypes.Credit memory credit ,
842801 DataTypes.SwapAdapter memory swapAdapter ,
843802 bytes memory swapPayload
844- ) internal {
803+ ) internal view {
845804 params.marketplaceId = marketplaceId;
846805 params.marketplace = poolAddressProvider.getMarketplace (marketplaceId);
847806 params.payload = payload;
848807 params.credit = credit;
849808 params.swapAdapter = swapAdapter;
850809 params.swapPayload = swapPayload;
810+ params.orderInfo = IMarketplace (params.marketplace.adapter)
811+ .getAskOrderInfo (payload);
812+ if (params.orderInfo.isSeaport) {
813+ require (
814+ msg .sender == params.orderInfo.taker,
815+ Errors.INVALID_ORDER_TAKER
816+ );
817+ } else {
818+ // in LooksRare, X2Y2 we dont match orders between buyer and seller
819+ // the protocol just works like an agent so taker cannot be read
820+ // from orders
821+ params.orderInfo.taker = msg .sender ;
822+ }
823+ require (
824+ params.orderInfo.maker != params.orderInfo.taker,
825+ Errors.MAKER_SAME_AS_TAKER
826+ );
827+ }
828+
829+ function _updateAcceptBidParams (
830+ DataTypes.ExecuteMarketplaceParams memory params ,
831+ IPoolAddressesProvider poolAddressProvider ,
832+ bytes32 marketplaceId ,
833+ bytes memory payload ,
834+ DataTypes.Credit memory credit ,
835+ address onBehalfOf
836+ ) internal view {
837+ params.marketplaceId = marketplaceId;
838+ params.marketplace = poolAddressProvider.getMarketplace (marketplaceId);
839+ params.payload = payload;
840+ params.credit = credit;
841+
842+ params.orderInfo = IMarketplace (params.marketplace.adapter)
843+ .getBidOrderInfo (payload);
844+ require (
845+ params.orderInfo.taker == onBehalfOf,
846+ Errors.INVALID_ORDER_TAKER
847+ );
851848 }
852849
853850 function _refundETH (uint256 ethLeft ) internal {
0 commit comments