Market
Function definitions, parameter descriptions, and use cases of the APIs of IcMarket smart contract.
Publish an order at a fixed price.
function publishFixedPrice (address icToken, uint24 tokenId, address currency, uint128 min, uint128 max, uint32 startTime, bool useAllowList, uint128 price) external returns (uint24 saleId);
Parameter | Type | Note |
icToken | address | Address of the IcToken contract |
tokenId | uint24 | Id of the Voucher to sell |
currency | address | Payment currency |
min | uint128 | Minimum purchase units (0 means no limit) |
max | uint128 | Maximum purchase units (0 means no limit) |
startTime | uint32 | Start timestamp (in second) of the sale |
useAllowList | bool | Whether to use the whitelist for sales restriction |
price | uint128 | Unit price |
Parameter | Type | Note |
saleId | uint24 | Id of the created order |
address icTokenAddress = 0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB;
uint24 tokenId = 101;
address currency = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
uint128 min = 100;
uint128 max = 1000;
uint32 startTime = uint32(block.timestamp + 86400 * 3);
bool useAllowList = false;
uint128 price = 1000000;
uint24 saleId = icMarket.publishFixedPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, price);
let now = (await wallet.provider.getBlock()).timestamp;
let icTokenAddress = "0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB";
let tokenId = 101;
let currency = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
let min = 100;
let max = 1000;
let startTime = now + 86400 * 3;
let useAllowList = false;
let price = 1000000;
await icMarket.publishFixedPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, price);
Publish an order at a declining price.
function publishDecliningPrice (address icToken, uint24 tokenId, address currency, uint128 min, uint128 max, uint32 startTime, bool useAllowList, uint128 highest, uint128 lowest, uint32 duration, uint32 interval) external returns (uint24 saleId);
Parameter | Type | Note |
icToken | address | Address of the IcToken contract |
tokenId | uint24 | Id of the Voucher to sell |
currency | address | Payment currency |
min | uint128 | Minimum purchase units (0 means no limit) |
max | uint128 | Maximum purchase units (0 means no limit) |
startTime | uint32 | Start timestamp (in second) of the sale |
useAllowList | bool | Whether to use the whitelist for sales restriction |
highest | uint128 | Initial price at the beginning of the sale |
lowest | uint128 | Final price when the price reduction ends |
duration | uint32 | Duration of the complete price reduction |
interval | uint32 | Time interval between each two price reductions |
Parameter | Type | Note |
saleId | uint24 | Id of the created order |
address icTokenAddress = 0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB;
uint24 tokenId = 101;
address currency = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
uint128 min = 100;
uint128 max = 1000;
uint32 startTime = uint32(block.timestamp + 86400 * 3);
bool useAllowList = false;
uint128 highest = 1000000;
uint128 lowest = 100000;
uint32 duration = 86400 * 5;
uint32 interval = 3600;
uint24 saleId = icMarket.publishDecliningPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, highest, lowest, duration, interval);
let now = (await wallet.provider.getBlock()).timestamp;
let icTokenAddress = "0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB";
let tokenId = 101;
let currency = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
let min = 100;
let max = 1000;
let startTime = now + 86400 * 3;
let useAllowList = false;
let highest = 1000000;
let lowest = 100000;
let duration = 86400 * 5;
let interval = 3600;
await icMarket.publishDecliningPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, highest, lowest, duration, interval);
Buy Vouchers according to the specified amount of payment currency.
function buyByAmount(uint24 saleId, uint256 amount) external returns (uint128 units);
Parameter | Type | Note |
saleId | uint24 | Id of target sale |
amount | uint256 | Payment amount |
Parameter | Type | Note |
units | uint128 | Amount of the purchased units |
uint24 saleId = 10001;
uint256 amount = 2000000;
uint128 units = icMarket.buyByAmount(saleId, amount);
let saleId = 10001;
let amount = 2000000;
await icMarket.buyByAmount(saleId, amount);
Buy specified units of the icToken of target saleId.
function buyByUnits(uint24 saleId, uint128 units) external returns (uint256 amount, uint128 fee);
Parameter | Type | Note |
saleId | uint24 | Id of target sale |
units | uint128 | Amount of units to buy |
Parameter | Type | Note |
amount | uint256 | Payment amount |
fee | uint128 | Fee amount paid for the trade |
uint24 saleId = 10001;
uint128 units = 10;
(uint256 amount, uint128 fee) = icMarket.buyByUnits(saleId, units)
let saleId = 10001;
let units = 10;
await icMarket.buyByUnits(saleId, units);