#
MarketFacet
Inherits: Modifiers, ReentrancyGuard
Trade entity tokens
This should only be called through an entity, never directly by an EOA
#
Functions
#
cancelOffer
Cancel offer #_offerId
. This will cancel the offer so that it's no longer active.
This function can be frontrun: In the scenario where a user wants to cancel an unfavorable market offer, an attacker can potentially monitor and identify that the user has called this method, determine that filling this market offer is profitable, and as a result call executeLimitOffer with a higher gas price to have their transaction filled before the user can have cancelOffer filled. The most ideal situation for the user is to not have placed the unfavorable market offer in the first place since an attacker can always monitor our marketplace and potentially identify profitable market offers. Our UI will aide users in not placing market offers that are obviously unfavorable to the user and/or seem like mistake orders. In the event that a user needs to cancel an offer, it is recommended to use Flashbots in order to privately send your transaction so an attack cannot be triggered from monitoring the mempool for calls to cancelOffer. A user is recommended to change their RPC endpoint to point to https://rpc.flashbots.net when calling cancelOffer. We will add additional documentation to aide our users in this process. More information on using Flashbots: https://docs.flashbots.net/flashbots-protect/rpc/quick-start/
function cancelOffer(uint256 _offerId)
external
notLocked(msg.sig)
nonReentrant
assertPrivilege(LibObject._getParentFromAddress(msg.sender), LC.GROUP_CANCEL_OFFER);
Parameters
#
executeLimitOffer
Execute a limit offer.
function executeLimitOffer(bytes32 _sellToken, uint256 _sellAmount, bytes32 _buyToken, uint256 _buyAmount)
external
notLocked(msg.sig)
nonReentrant
assertPrivilege(LibObject._getParentFromAddress(msg.sender), LC.GROUP_EXECUTE_LIMIT_OFFER)
returns (uint256 offerId_, uint256 buyTokenCommissionsPaid_, uint256 sellTokenCommissionsPaid_);
Parameters
Returns
#
getLastOfferId
Get last created offer.
function getLastOfferId() external view returns (uint256);
Returns
#
getBestOfferId
Get current best offer for given token pair.
This means finding the highest sellToken-per-buyToken price, i.e. price = sellToken / buyToken
function getBestOfferId(bytes32 _sellToken, bytes32 _buyToken) external view returns (uint256);
Parameters
Returns
#
getOffer
Get the details of the offer #_offerId
function getOffer(uint256 _offerId) external view returns (MarketInfo memory _offerState);
Parameters
Returns
#
isActiveOffer
Check if the offer #_offerId
is active or not.
function isActiveOffer(uint256 _offerId) external view returns (bool);
Parameters
Returns
#
calculateTradingFees
Calculate the trading fees based on a buy amount.
function calculateTradingFees(bytes32 _buyerId, bytes32 _sellToken, bytes32 _buyToken, uint256 _buyAmount)
external
view
returns (uint256 totalFees_, uint256 totalBP_);
Parameters
Returns
#
getMakerBP
Get the maker commission basis points.
function getMakerBP() external view returns (uint16);
Returns
#
objectMinimumSell
Get the minimum amount of tokens that can be sold on the market.
function objectMinimumSell(bytes32 _objectId) external view returns (uint256);
Parameters
#
setMinimumSell
Set the minimum amount of tokens that can be sold on the market.
function setMinimumSell(bytes32 _objectId, uint256 _minimumSell)
external
assertPrivilege(LibAdmin._getSystemId(), LC.GROUP_SYSTEM_MANAGERS);
Parameters