Solv Documentation
Search…
Market
Function definitions, parameter descriptions, and use cases of the APIs of IcMarket smart contract.

publishFixedPrice

Function Definition

Publish an order at a fixed price.
1
function publishFixedPrice (address icToken, uint24 tokenId, address currency, uint128 min, uint128 max, uint32 startTime, bool useAllowList, uint128 price) external returns (uint24 saleId);
Copied!

Input Parameters

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

Output Parameters

Parameter
Type
Note
saleId
uint24
Id of the created order

Use Cases

Use Cases in Solidity

1
address icTokenAddress = 0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB;
2
uint24 tokenId = 101;
3
address currency = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
4
uint128 min = 100;
5
uint128 max = 1000;
6
uint32 startTime = uint32(block.timestamp + 86400 * 3);
7
bool useAllowList = false;
8
uint128 price = 1000000;
9
uint24 saleId = icMarket.publishFixedPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, price);
Copied!

Use Cases with ethers.js

1
let now = (await wallet.provider.getBlock()).timestamp;
2
let icTokenAddress = "0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB";
3
let tokenId = 101;
4
let currency = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
5
let min = 100;
6
let max = 1000;
7
let startTime = now + 86400 * 3;
8
let useAllowList = false;
9
let price = 1000000;
10
await icMarket.publishFixedPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, price);
Copied!

publishDecliningPrice

Function Definition

Publish an order at a declining price.
1
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);
Copied!

Input Parameters

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

Output Parameters

Parameter
Type
Note
saleId
uint24
Id of the created order

Use Cases

Use Cases in Solidity

1
address icTokenAddress = 0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB;
2
uint24 tokenId = 101;
3
address currency = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
4
uint128 min = 100;
5
uint128 max = 1000;
6
uint32 startTime = uint32(block.timestamp + 86400 * 3);
7
bool useAllowList = false;
8
uint128 highest = 1000000;
9
uint128 lowest = 100000;
10
uint32 duration = 86400 * 5;
11
uint32 interval = 3600;
12
uint24 saleId = icMarket.publishDecliningPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, highest, lowest, duration, interval);
Copied!

Use Cases with ethers.js

1
let now = (await wallet.provider.getBlock()).timestamp;
2
let icTokenAddress = "0x4B0dd1aDEdA251ACec75140608bAd663fB0c4cAB";
3
let tokenId = 101;
4
let currency = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
5
let min = 100;
6
let max = 1000;
7
let startTime = now + 86400 * 3;
8
let useAllowList = false;
9
let highest = 1000000;
10
let lowest = 100000;
11
let duration = 86400 * 5;
12
let interval = 3600;
13
await icMarket.publishDecliningPrice(icTokenAddress, tokenId, currency, min, max, startTime, useAllowList, highest, lowest, duration, interval);
Copied!

buyByAmount

Function Definition

Buy Vouchers according to the specified amount of payment currency.
1
function buyByAmount(uint24 saleId, uint256 amount) external returns (uint128 units);
Copied!

Input Parameters

Parameter
Type
Note
saleId
uint24
Id of target sale
amount
uint256
Payment amount

Output Parameters

Parameter
Type
Note
units
uint128
Amount of the purchased units

Use Cases

Use Cases in Solidity

1
uint24 saleId = 10001;
2
uint256 amount = 2000000;
3
uint128 units = icMarket.buyByAmount(saleId, amount);
Copied!

Use Cases with ethers.js

1
let saleId = 10001;
2
let amount = 2000000;
3
await icMarket.buyByAmount(saleId, amount);
Copied!

buyByUnits

Function Definition

Buy specified units of the icToken of target saleId.
1
function buyByUnits(uint24 saleId, uint128 units) external returns (uint256 amount, uint128 fee);
Copied!

Input Parameters

Parameter
Type
Note
saleId
uint24
Id of target sale
units
uint128
Amount of units to buy

Output Parameters

Parameter
Type
Note
amount
uint256
Payment amount
fee
uint128
Fee amount paid for the trade

Use Cases

Use Cases in Solidity

1
uint24 saleId = 10001;
2
uint128 units = 10;
3
(uint256 amount, uint128 fee) = icMarket.buyByUnits(saleId, units)
Copied!

Use Cases with ethers.js

1
let saleId = 10001;
2
let units = 10;
3
await icMarket.buyByUnits(saleId, units);
Copied!