IMarketplace
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
| Name | Type | Description |
|---|---|---|
token | address | The token being listed |
amount | uint256 | The amount to be listed |
unitPrice | uint256 | The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000 |
minFillAmount | uint256 | The minimum number of tons needed to be purchased to fill this listing |
deadline | uint256 | The block timestamp at which this listing will expire |
Returns
| Name | Type | Description |
|---|---|---|
id | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
token | address | The token being listed |
tokenId | uint256 | The token ID of the ERC1155 being listed |
amount | uint256 | The amount to be listed |
unitPrice | uint256 | The unit price in USDC to list. Should be provided in full form so a price of 2.5 USDC = input of 2500000 |
minFillAmount | uint256 | The minimum number of tons needed to be purchased to fill this listing |
deadline | uint256 | The block timestamp at which this listing will expire |
Returns
| Name | Type | Description |
|---|---|---|
id | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to update |
newAmount | uint256 | The amount for the new listing |
newUnitPrice | uint256 | The unit price for the new listing |
newMinFillAmount | uint256 | The minFillAmount for the new listing |
newDeadline | uint256 | The deadline for the new listing |
cancelListing
This function cancels an existing listing
function cancelListing(bytes32 id) external;
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
id | bytes32 | The listing ID to update |
listingAccount | address | The account that created the listing you are filling |
listingToken | address | The token you are swapping for |
listingUnitPrice | uint256 | The unit price per token to fill the listing |
amount | uint256 | Amount of the listing to fill |
maxCost | uint256 | Maximum 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
| Name | Type | Description |
|---|---|---|
id | bytes32 | The resulting hashed listing ID |
account | address | The ethereum account that created the listing |
token | address | The ethereum address of the token being listed |
tokenId | uint256 | |
price | uint256 | The unit price in USDC for this listing |
amount | uint256 | The total amount of the token being listed |
minFillAmount | uint256 | The minimum amount needed to purchase to fill this listing |
deadline | uint256 | The 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
| Name | Type | Description |
|---|---|---|
id | bytes32 | The hashed ID of the listing to update |
oldAmount | uint256 | Remaining amount to fill before the update |
newAmount | uint256 | Remaining amount to fill after the update |
oldUnitPrice | uint256 | Unit price before the update |
newUnitPrice | uint256 | Unit price after the update |
oldMinFillAmount | uint256 | Minimum fill amount before the update |
newMinFillAmount | uint256 | Minimum fill amount after the update |
oldDeadline | uint256 | Expiring deadline before the update |
newDeadline | uint256 | Expiring deadline after the update |
ListingCancelled
Emitted every time a listing is cancelled
event ListingCancelled(bytes32 id);
Parameters
| Name | Type | Description |
|---|---|---|
id | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
id | bytes32 | ID of the listing being filled |
account | address | Ethereum address of account filling the listing |
amount | uint256 | Amount of the listing that was filled |
totalCost | uint256 | Total 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
| Name | Type | Description |
|---|---|---|
account | address | Ethereum address of the account who owns the listing |
token | address | Ethereum address of the token being listing |
originalAmount | uint256 | Original amount of the listing |
remainingAmount | uint256 | Remaining amount that can be filled on this listing |
unitPrice | uint256 | The unit price in USDC of the listing |
minFillAmount | uint256 | The minimum amount needed to purchase in order to fill the listing |
deadline | uint256 | The block timestamp at which this listing expires |