Skip to content

Commit

Permalink
fix: NonexistentOffer | OfferAlreadyExists error
Browse files Browse the repository at this point in the history
  • Loading branch information
jusikXL committed Aug 7, 2024
1 parent aa8033b commit d816854
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions contracts/protocol/OtcMarketAcceptOffer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,24 @@ abstract contract OtcMarketAcceptOffer is IOtcMarketAcceptOffer, OtcMarketCore {
_validateAcceptOffer(_params); // revert
Offer storage offer = offers[_params.offerId];


if (offer.dstEid != offer.srcEid) {
(bytes memory payload, bytes memory options) = _buildAcceptOfferMsgAndOptions(
_dstBuyerAddress,
offer.srcEid,
_params
); // revert
fee = _quote(offer.srcEid, payload, options, _payInLzToken);
}else{
fee = MessagingFee(0,0);
} else {
fee = MessagingFee(0, 0);
}

acceptOfferReceipt = _toDstAmount(_params.srcAmountSD, offer.exchangeRateSD, offer.dstTokenAddress.toAddress()); // revert
}

function _validateAcceptOffer(AcceptOfferParams calldata _params) internal view virtual {
Offer storage offer = offers[_params.offerId];

if (offer.srcAmountSD == 0) {
if (offer.exchangeRateSD == 0) {
revert NonexistentOffer(_params.offerId);
}
if (eid != offer.dstEid) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocol/OtcMarketCancelOffer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract contract OtcMarketCancelOffer is IOtcMarketCancelOffer, OtcMarketCore {
function _validateCancelOffer(bytes32 _srcSellerAddress, bytes32 _offerId) internal view virtual {
Offer storage offer = offers[_offerId];

if (offer.srcAmountSD == 0) {
if (offer.exchangeRateSD == 0) {
revert NonexistentOffer(_offerId);
}
if (eid != offer.srcEid) {
Expand Down
6 changes: 3 additions & 3 deletions contracts/protocol/OtcMarketCreateOffer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract contract OtcMarketCreateOffer is IOtcMarketCreateOffer, OtcMarketCore {
_params.dstTokenAddress,
_params.exchangeRateSD
);
if (offers[offerId].srcAmountSD != 0) {
if (offers[offerId].exchangeRateSD != 0) {
revert OfferAlreadyExists(offerId);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ abstract contract OtcMarketCreateOffer is IOtcMarketCreateOffer, OtcMarketCore {
_params.dstTokenAddress,
_params.exchangeRateSD
);
if (offers[offerId].srcAmountSD != 0) {
if (offers[offerId].exchangeRateSD != 0) {
revert OfferAlreadyExists(offerId);
} // revert

Expand All @@ -116,7 +116,7 @@ abstract contract OtcMarketCreateOffer is IOtcMarketCreateOffer, OtcMarketCore {
); // revert

fee = _quote(_params.dstEid, payload, options, _payInLzToken);
} else{
} else {
fee = MessagingFee(0, 0);
}
createOfferReceipt = CreateOfferReceipt(offerId, srcAmountLD);
Expand Down

0 comments on commit d816854

Please sign in to comment.