IMarketplace

Git Source

Functions

createListing

This function creates a new listing and returns the resulting listing ID

This functino handles ERC20 tokens

function createListing(
    address token,
    uint256 amount,
    uint256 unitPrice,
    uint256 minFillAmount,
    uint256 deadline
)
    external
    returns (bytes32 id);

Parameters

NameTypeDescription
tokenaddressThe token being listed
amountuint256The amount to be listed
unitPriceuint256The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000
minFillAmountuint256The minimum number of tons needed to be purchased to fill this listing
deadlineuint256The block timestamp at which this listing will expire

Returns

NameTypeDescription
idbytes32The ID of the listing that was created

createListing

This function creates a new listing and returns the resulting listing ID

This function handles ERC1155 tokens

function createListing(
    address token,
    uint256 tokenId,
    uint256 amount,
    uint256 unitPrice,
    uint256 minFillAmount,
    uint256 deadline
)
    external
    returns (bytes32 id);

Parameters

NameTypeDescription
tokenaddressThe token being listed
tokenIduint256The token ID of the ERC1155 being listed
amountuint256The amount to be listed
unitPriceuint256The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000
minFillAmountuint256The minimum number of tons needed to be purchased to fill this listing
deadlineuint256The block timestamp at which this listing will expire

Returns

NameTypeDescription
idbytes32The ID of the listing that was created

updateListing

This function takes an old listing and replaces it with an updated listing

function updateListing(
    bytes32 id,
    uint256 newAmount,
    uint256 newUnitPrice,
    uint256 newMinFillAmount,
    uint256 newDeadline
)
    external;

Parameters

NameTypeDescription
idbytes32The listing ID to update
newAmountuint256The amount for the new listing
newUnitPriceuint256The unit price for the new listing
newMinFillAmountuint256The minFillAmount for the new listing
newDeadlineuint256The deadline for the new listing

cancelListing

This function cancels an existing listing

function cancelListing(bytes32 id) external;

Parameters

NameTypeDescription
idbytes32The listing ID to cancel

fillListing

This function fills an existing listing

function fillListing(
    bytes32 id,
    address listingAccount,
    address listingToken,
    uint256 listingUnitPrice,
    uint256 amount,
    uint256 maxCost
)
    external;

Parameters

NameTypeDescription
idbytes32The listing ID to update
listingAccountaddressThe account that created the listing you are filling
listingTokenaddressThe token you are swapping for
listingUnitPriceuint256The unit price per token to fill the listing
amountuint256Amount of the listing to fill
maxCostuint256Maximum cost in USDC for filling this listing

Events

ListingCreated

Emitted each time a new listing is created

event ListingCreated(
    bytes32 id,
    address account,
    address token,
    uint256 tokenId,
    uint256 price,
    uint256 amount,
    uint256 minFillAmount,
    uint256 deadline
);

Parameters

NameTypeDescription
idbytes32The resulting hashed listing ID
accountaddressThe ethereum account that created the listing
tokenaddressThe ethereum address of the token being listed
tokenIduint256
priceuint256The unit price in USDC for this listing
amountuint256The total amount of the token being listed
minFillAmountuint256The minimum amount needed to purchase to fill this listing
deadlineuint256The block timestamp at which this listing expires

ListingUpdated

Emitted every time an existing listing is updated

event ListingUpdated(
    bytes32 id,
    uint256 oldAmount,
    uint256 newAmount,
    uint256 oldUnitPrice,
    uint256 newUnitPrice,
    uint256 oldMinFillAmount,
    uint256 newMinFillAmount,
    uint256 oldDeadline,
    uint256 newDeadline
);

Parameters

NameTypeDescription
idbytes32The hashed ID of the listing to update
oldAmountuint256Remaining amount to fill before the update
newAmountuint256Remaining amount to fill after the update
oldUnitPriceuint256Unit price before the update
newUnitPriceuint256Unit price after the update
oldMinFillAmountuint256Minimum fill amount before the update
newMinFillAmountuint256Minimum fill amount after the update
oldDeadlineuint256Expiring deadline before the update
newDeadlineuint256Expiring deadline after the update

ListingCancelled

Emitted every time a listing is cancelled

event ListingCancelled(bytes32 id);

Parameters

NameTypeDescription
idbytes32The hashed ID of the listing being cancelled

ListingFilled

Emitted every time a listing is filled

event ListingFilled(bytes32 id, address account, uint256 amount, uint256 totalCost);

Parameters

NameTypeDescription
idbytes32ID of the listing being filled
accountaddressEthereum address of account filling the listing
amountuint256Amount of the listing that was filled
totalCostuint256Total cost in USDC used to fill the listing

Structs

CreditListing

Struct containing all of the detail information about a listing

struct CreditListing {
    address account;
    address token;
    uint256 originalAmount;
    uint256 remainingAmount;
    uint256 unitPrice;
    uint256 minFillAmount;
    uint256 deadline;
}

Properties

NameTypeDescription
accountaddressEthereum address of the account who owns the listing
tokenaddressEthereum address of the token being listing
originalAmountuint256Original amount of the listing
remainingAmountuint256Remaining amount that can be filled on this listing
unitPriceuint256The unit price in USDC of the listing
minFillAmountuint256The minimum amount needed to purchase in order to fill the listing
deadlineuint256The block timestamp at which this listing expires