Skip to content

Commit 314318d

Browse files
committed
fix: seperate listingPrice & supplyAmount
Signed-off-by: GopherJ <[email protected]>
1 parent 9fdcc53 commit 314318d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

contracts/protocol/libraries/logic/MarketplaceLogic.sol

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,11 @@ library MarketplaceLogic {
440440
MarketplaceLocalVars memory vars,
441441
address seller
442442
) internal {
443-
DataTypes.ReserveData storage reserve = ps._reserves[vars.creditToken];
444-
if (reserve.xTokenAddress == address(0)) {
443+
if (vars.supplyAmount == 0) {
445444
return;
446445
}
447446

447+
DataTypes.ReserveData storage reserve = ps._reserves[vars.creditToken];
448448
DataTypes.UserConfigurationMap storage sellerConfig = ps._usersConfig[
449449
seller
450450
];
@@ -453,8 +453,6 @@ library MarketplaceLogic {
453453

454454
reserve.updateState(reserveCache);
455455

456-
vars.supplyAmount = vars.price;
457-
458456
ValidationLogic.validateSupply(
459457
reserveCache,
460458
vars.supplyAmount,
@@ -631,11 +629,14 @@ library MarketplaceLogic {
631629
vars.isETH = params.credit.token == address(0);
632630
vars.creditToken = vars.isETH ? params.weth : params.credit.token;
633631
vars.creditAmount = params.credit.amount;
634-
vars.price = _validateAndGetPrice(params, vars);
632+
(vars.price, vars.supplyAmount) = _validateAndGetPriceAndSupplyAmount(
633+
params,
634+
vars
635+
);
635636
DataTypes.ReserveData storage reserve = ps._reserves[vars.creditToken];
636637
vars.creditXTokenAddress = reserve.xTokenAddress;
637638
require(
638-
vars.creditXTokenAddress != address(0),
639+
vars.creditAmount == 0 || vars.creditXTokenAddress != address(0),
639640
Errors.ASSET_NOT_LISTED
640641
);
641642
}
@@ -690,10 +691,10 @@ library MarketplaceLogic {
690691
);
691692
}
692693

693-
function _validateAndGetPrice(
694+
function _validateAndGetPriceAndSupplyAmount(
694695
DataTypes.ExecuteMarketplaceParams memory params,
695696
MarketplaceLocalVars memory vars
696-
) internal view returns (uint256 price) {
697+
) internal view returns (uint256 price, uint256 supplyAmount) {
697698
for (uint256 i = 0; i < params.orderInfo.consideration.length; i++) {
698699
ConsiderationItem memory item = params.orderInfo.consideration[i];
699700
require(
@@ -709,7 +710,11 @@ library MarketplaceLogic {
709710
item.token == params.credit.token,
710711
Errors.CREDIT_DOES_NOT_MATCH_ORDER
711712
);
712-
if (item.recipient == address(this)) price += item.startAmount;
713+
price += item.startAmount;
714+
715+
if (item.recipient == address(this)) {
716+
supplyAmount += item.startAmount;
717+
}
713718
}
714719
}
715720
}

0 commit comments

Comments
 (0)