Skip to main content Link Menu Expand (external link) Document Search Copy Copied

GOBMarket

Alejandro Garrido - Guardians of the Ball.

Guardians of the Ball - GOBMarket.

GOBMarket sales ERC1155 tokens in exchange for approved ERC20 tokens. Tokens listed for sale can be viewed with listedItems() and listedItem(). Tokens are minted to the buyer when the purchase is completed. Tokens can be bought using one of three different payment methods: - buyItem(): pay with ERC20 tokens listed in validCurrencies(). - buyItemWithVesting(): pay with ERC20 tokens locked in vesting. - buyItemWithSeed(): pay with ERC20 seed tokens used by vesting.

Methods

DEFAULT_ADMIN_ROLE

function DEFAULT_ADMIN_ROLE() external view returns (bytes32)

Returns

NameTypeDescription
_0bytes32undefined

MANAGER_ROLE

function MANAGER_ROLE() external view returns (bytes32)

Returns

NameTypeDescription
_0bytes32undefined

SELLER_ROLE

function SELLER_ROLE() external view returns (bytes32)

Returns

NameTypeDescription
_0bytes32undefined

WITHDRAW_ROLE

function WITHDRAW_ROLE() external view returns (bytes32)

Returns

NameTypeDescription
_0bytes32undefined

addCurrency

function addCurrency(address newCurrency) external nonpayable

Adds a new currency to the list of ERC20s accepted as payments. IMPORTANT: All ERC20s are assumed to be of the same market value. There is only one price per token id listed for sale, and that price applies to all currencies. Emits {CurrencyAdded}.

Parameters

NameTypeDescription
newCurrencyaddressERC20 address (ie: usdc).

addERC1155

function addERC1155(address erc1155) external nonpayable

Adds an ERC1155 that will hold the tokens to be sold (minted). GOBMarket must have minting access in erc1155 at purchase time. Emits {ERC1155Added}.

Parameters

NameTypeDescription
erc1155addressERC1155 address

buyItem

function buyItem(address erc1155, uint256 tokenId, address to, uint256 quantity, address currency) external nonpayable

Buy tokens of a listed ERC1155 using an approved ERC20 as payment. The token's price is in items and it is expressed in priceDecimals If the price of token id 1 is set at 300000 and priceDecimals is 4, the price in USDC is 30.00 if paying with USDC as currency. Emits {TokenPurchased}. Requirements: - currency must exists in validCurrencies(). - erc1155 and tokenId must be listed for sale. See listedItems and listedItem. - Sender must have enough balance of selected currency. - GOBMarket must have enough allowance of sender's selected currency.

Parameters

NameTypeDescription
erc1155addressERC1155 addresss.
tokenIduint256Token to purchase.
toaddressAddress to mint the tokenId.
quantityuint256Amount of tokens to purchase. It cannot be zero.
currencyaddressERC20 to be used as payment.

buyItemWithSeed

function buyItemWithSeed(address erc1155, uint256 tokenId, address to, uint256 quantity) external nonpayable

Buy tokens of a listed ERC1155 using ERC20 seed tokens used by vesting. All price calculations are the same as buyItemWithVesting(). Emits {TokenPurchased}. Requirements: - erc1155 and tokenId must be listed for sale. See listedItems and listedItem. - Sender must have enough balance of seed token used by vesting. - GOBMarket must have enough allowance of sender's seed token. - vesting and seedPrice must be set.

Parameters

NameTypeDescription
erc1155addressERC1155 addresss.
tokenIduint256Token to purchase.
toaddressAddress to mint the tokenId.
quantityuint256Amount of tokens to purchase. It cannot be zero.

buyItemWithVesting

function buyItemWithVesting(address erc1155, uint256 tokenId, address to, uint256 quantity) external nonpayable

Buy tokens of a listed ERC1155 using ERC20 tokens locked in vesting. The token's price is in items and it is expressed in priceDecimals. The value of the locked tokens is set in seedPrice and is also using priceDecimals. (See buyItem) If seedPrice is 10000 and priceDecimals is 4, the convertion rate between any validCurrencies() and locked tokens is 1:1 (10000 / 104) (ie: 1 LockedToken = 1 USDC) If seedPrice is 5000 the convertion rate is 1:2 (5000 / 104) (ie: 1 LockedToken = 2 USDC) Emits {TokenPurchased}. Requirements: - erc1155 and tokenId must be listed for sale. See listedItems and listedItem. - vesting and seedPrice must be set. - Sender must have enough balance of locked tokens in vesting.

Parameters

NameTypeDescription
erc1155addressERC1155 addresss.
tokenIduint256Token to purchase.
toaddressAddress to mint the tokenId.
quantityuint256Amount of tokens to purchase. It cannot be zero.

changeCap

function changeCap(address erc1155, uint256 tokenId, uint256 newCap) external nonpayable

Change the sale cap of a token listed for sale. Emits {CapChanged}. Requirements: - tokenId must be listed. - newCapMust be different than previous cap and cannot be less than the amount sold so far.

Parameters

NameTypeDescription
erc1155addressERC1155 address.
tokenIduint256The token id to be changed.
newCapuint256New cap.

changePrice

function changePrice(address erc1155, uint256 tokenId, uint256 newPrice) external nonpayable

Changes the priced of a token listed for sale. Emits {PriceChanged}. Requirements: - tokenId must be listed. - newPrice must be different than the previous price.

Parameters

NameTypeDescription
erc1155addressERC1155 address.
tokenIduint256The token id to be changed.
newPriceuint256New price.

erc1155At

function erc1155At(uint256 index) external view returns (address)

Returns the ERC1155 address at a specific index.

Parameters

NameTypeDescription
indexuint256undefined

Returns

NameTypeDescription
_0addressERC1155 address.

erc1155Length

function erc1155Length() external view returns (uint256)

Returns the ERC1155 counter.

Returns

NameTypeDescription
_0uint256ERC1155 counter.

erc1155List

function erc1155List() external view returns (address[])

Returns all the available ERC1155.

Returns

NameTypeDescription
_0address[]Array with all ERC1155 addresses.

getRoleAdmin

function getRoleAdmin(bytes32 role) external view returns (bytes32)

Returns the admin role that controls role. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.

Parameters

NameTypeDescription
rolebytes32undefined

Returns

NameTypeDescription
_0bytes32undefined

grantRole

function grantRole(bytes32 role, address account) external nonpayable

Grants role to account. If account had not been already granted role, emits a {RoleGranted} event. Requirements: - the caller must have role's admin role. May emit a {RoleGranted} event.

Parameters

NameTypeDescription
rolebytes32undefined
accountaddressundefined

hasRole

function hasRole(bytes32 role, address account) external view returns (bool)

Returns true if account has been granted role.

Parameters

NameTypeDescription
rolebytes32undefined
accountaddressundefined

Returns

NameTypeDescription
_0boolundefined

isValidCurrency

function isValidCurrency(address currency) external view returns (bool)

Check if a currency is listed.

Parameters

NameTypeDescription
currencyaddressThe ERC20 address.

Returns

NameTypeDescription
_0boolWhether the ERC20 is listed or not.

items

function items(address, uint256) external view returns (uint256 price, uint256 salesCap, uint256 sold)

Parameters

NameTypeDescription
_0addressundefined
_1uint256undefined

Returns

NameTypeDescription
priceuint256undefined
salesCapuint256undefined
solduint256undefined

listItem

function listItem(address erc1155, uint256 tokenId, uint256 price, uint256 salesCap) external nonpayable

Lists one tokenId for sale. erc1155 must exists. Emits {TokenListed}. Requirements: - tokenId Must no be listed.

Parameters

NameTypeDescription
erc1155addressERC1155 address.
tokenIduint256The token id to be minted in erc1155. .
priceuint256Token's price using validCurrencies() with priceDecimals.
salesCapuint256Max amount of tokens that can be sold.

listedItem

function listedItem(address erc1155, uint256 tokenId) external view returns (struct GOBMarket.ItemInfo item)

Returns the selling info for a token in erc1155.

Parameters

NameTypeDescription
erc1155addressERC1155 addresss.
tokenIduint256Token to query. Must be listed for sale. See listedItems.

Returns

NameTypeDescription
itemGOBMarket.ItemInfoStruct of ItemInfo with the price, cap and sold data.

listedItems

function listedItems(address erc1155) external view returns (uint256[] tokenIds, struct GOBMarket.ItemInfo[] listedItems_)

Returns the selling info for all tokens in erc1155 available for sale.

Parameters

NameTypeDescription
erc1155addressERC1155 addresss.

Returns

NameTypeDescription
tokenIdsuint256[]Array of all tokenIds.
listedItems_GOBMarket.ItemInfo[]Array of ItemInfo. Matched by index with _tokenIds.

priceDecimals

function priceDecimals() external view returns (uint8)

Returns

NameTypeDescription
_0uint8undefined

removeCurrency

function removeCurrency(address currency) external nonpayable

Removes an ERC20 from the accepted list of currencies. Emits {CurrencyRemoved}.

Parameters

NameTypeDescription
currencyaddressERC20 address.

removeERC1155

function removeERC1155(address erc1155) external nonpayable

Removes an ERC1155. Emits {ERC1155Removed}. Requirements: - erc1155 must not have tokens listed for sale.

Parameters

NameTypeDescription
erc1155addressERC1155 address

renounceRole

function renounceRole(bytes32 role, address account) external nonpayable

Revokes role from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked role, emits a {RoleRevoked} event. Requirements: - the caller must be account. May emit a {RoleRevoked} event.

Parameters

NameTypeDescription
rolebytes32undefined
accountaddressundefined

revokeRole

function revokeRole(bytes32 role, address account) external nonpayable

Revokes role from account. If account had been granted role, emits a {RoleRevoked} event. Requirements: - the caller must have role's admin role. May emit a {RoleRevoked} event.

Parameters

NameTypeDescription
rolebytes32undefined
accountaddressundefined

seedPrice

function seedPrice() external view returns (uint256)

Returns

NameTypeDescription
_0uint256undefined

setSeedPrice

function setSeedPrice(uint256 price) external nonpayable

Sets the parity betwen the seed token in vesting and accepted currencies. Calculations use priceDecimals. See buyItemWithVesting(). NOTE: If seedPrice is set to zero, buyItemWithVesting() and buyItemWithSeed() will be disabled. Emits {SeedPriceChanged}.

Parameters

NameTypeDescription
priceuint256New price.

setVesting

function setVesting(address vesting_) external nonpayable

Sets the vesting contract that allows the purchase using vested tokens or seedTokens.

Parameters

NameTypeDescription
vesting_addressVesting address. Emits {VestingChanged}. Requirements: - vesting_ must have vesting token set. - vested token decimals must be >= priceDecimals.

supportsInterface

function supportsInterface(bytes4 interfaceId) external view returns (bool)

See {IERC165-supportsInterface}.

Parameters

NameTypeDescription
interfaceIdbytes4undefined

Returns

NameTypeDescription
_0boolundefined

unlistItems

function unlistItems(address erc1155, uint256[] tokenIds) external nonpayable

Unlists tokens from the selling list. Emits {TokenUnlisted}. Requirements: - tokenId must be listed.

Parameters

NameTypeDescription
erc1155addressERC1155 address.
tokenIdsuint256[]Array with the token ids to be removed.

validCurrencies

function validCurrencies() external view returns (address[])

Returns all ERC20 accepted as payment.

Returns

NameTypeDescription
_0address[]Array with all ERC20 addresses.

vesting

function vesting() external view returns (contract IVesting)

Returns

NameTypeDescription
_0contract IVestingundefined

withdraw

function withdraw(address currency_, uint256 amount) external nonpayable

See {GOBWithdraw-_withdraw}.

Parameters

NameTypeDescription
currency_addressundefined
amountuint256undefined

withdrawCurrencies

function withdrawCurrencies() external nonpayable

See {GOBWithdraw-_withdrawSet}.

Events

CapChanged

event CapChanged(address indexed erc1155, uint256 indexed tokenId, uint256 oldCap, uint256 newCap)

Emitted when SELLER_ROLE changes the sale cap of a token listed for sale.

Parameters

NameTypeDescription
erc1155 indexedaddressundefined
tokenId indexeduint256undefined
oldCapuint256undefined
newCapuint256undefined

CurrencyAdded

event CurrencyAdded(address indexed newCurrency)

Emitted when a valid currency is removed.

Parameters

NameTypeDescription
newCurrency indexedaddressundefined

CurrencyRemoved

event CurrencyRemoved(address indexed newCurrency)

Emitted when new valid currency is added.

Parameters

NameTypeDescription
newCurrency indexedaddressundefined

ERC1155Added

event ERC1155Added(address indexed erc1155)

Emitted when MANAGER_ROLE adds a new valid erc1155.

Parameters

NameTypeDescription
erc1155 indexedaddressundefined

ERC1155Removed

event ERC1155Removed(address indexed erc1155)

Emitted when MANAGER_ROLE removes valid erc1155.

Parameters

NameTypeDescription
erc1155 indexedaddressundefined

PriceChanged

event PriceChanged(address indexed erc1155, uint256 indexed tokenId, uint256 oldPrice, uint256 newPrice)

Emitted when SELLER_ROLE changes the price of a token.

Parameters

NameTypeDescription
erc1155 indexedaddressundefined
tokenId indexeduint256undefined
oldPriceuint256undefined
newPriceuint256undefined

RoleAdminChanged

event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole)

Emitted when newAdminRole is set as role's admin role, replacing previousAdminRole DEFAULT_ADMIN_ROLE is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this. _Available since v3.1._

Parameters

NameTypeDescription
role indexedbytes32undefined
previousAdminRole indexedbytes32undefined
newAdminRole indexedbytes32undefined

RoleGranted

event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender)

Emitted when account is granted role. sender is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.

Parameters

NameTypeDescription
role indexedbytes32undefined
account indexedaddressundefined
sender indexedaddressundefined

RoleRevoked

event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender)

Emitted when account is revoked role. sender is the account that originated the contract call: - if using revokeRole, it is the admin role bearer - if using renounceRole, it is the role bearer (i.e. account)

Parameters

NameTypeDescription
role indexedbytes32undefined
account indexedaddressundefined
sender indexedaddressundefined

SeedPriceChanged

event SeedPriceChanged(uint256 indexed newSeedPrice)

Emitted when MANAGER_ROLE changed seedPrice.

Parameters

NameTypeDescription
newSeedPrice indexeduint256undefined

TokenListed

event TokenListed(address indexed erc1155, uint256 indexed tokenId, uint256 price, uint256 salesCap)

Emitted when SELLER_ROLE lists an item for sale.

Parameters

NameTypeDescription
erc1155 indexedaddressundefined
tokenId indexeduint256undefined
priceuint256undefined
salesCapuint256undefined

TokenPurchased

event TokenPurchased(address indexed erc1155, uint256 indexed tokenId, address indexed to, uint256 quantity, address currency, uint256 totalAmount)

Emitted when a token has been purchased.

Parameters

NameTypeDescription
erc1155 indexedaddressundefined
tokenId indexeduint256undefined
to indexedaddressundefined
quantityuint256undefined
currencyaddressundefined
totalAmountuint256undefined

TokenUnlisted

event TokenUnlisted(address indexed erc1155, uint256 indexed tokenId)

Emitted when SELLER_ROLE removes an item selling list.

Parameters

NameTypeDescription
erc1155 indexedaddressundefined
tokenId indexeduint256undefined

VestingChanged

event VestingChanged(address indexed newVesting)

Emitted when MANAGER_ROLE changed the vesting address.

Parameters

NameTypeDescription
newVesting indexedaddressundefined

Withdrawn

event Withdrawn(address indexed callerAddress, address indexed tokenAddress, uint256 amount)

Emitted when funds are withdrawn from the contract for a specific tokenAddress.

Parameters

NameTypeDescription
callerAddress indexedaddressThe address of the caller who initiated the withdrawal.
tokenAddress indexedaddressThe address of the tokenAddress from which funds are withdrawn.
amountuint256The amount of tokenAddress withdrawn.

Back to top

Copyright © Guardians Of The Ball. This site is powered by Gitlab Pages