Skip to main content

Class: HypercertExchangeClient

HypercertExchangeClient.HypercertExchangeClient

HypercertExchange This class provides helpers to interact with the HypercertExchange V2 contracts

Constructors

constructor

new HypercertExchangeClient(chainId, provider, signer?, override?)

HypercertExchange protocol main class

Parameters

NameTypeDescription
chainIdChainIdCurrent app chain id
providerProviderEthers provider
signer?SignerEthers signer
override?AddressesOverrides contract addresses for hardhat setup

Properties

addresses

Readonly addresses: Addresses

Mapping of Hypercert protocol addresses for the current chain


api

Readonly api: __module


chainId

Readonly chainId: ChainId

Current app chain ID


provider

Readonly provider: Provider

Ethers provider. If you want a batch functionality, use JsonRpcProvider.

See

Ethers provider doc


signer

Optional Readonly signer: Signer

Ethers signer

See

Ethers signer doc

Methods

approveAllCollectionItems

approveAllCollectionItems(collectionAddress, approved?, overrides?): Promise<ContractTransactionResponse>

Approve all the items of a collection, to eventually be traded on HypercertExchange The spender is the TransferManager.

Parameters

NameTypeDefault valueDescription
collectionAddressstringundefinedAddress of the collection to be approved.
approvedbooleantruetrue to approve, false to revoke the approval (default to true)
overrides?Overridesundefined-

Returns

Promise<ContractTransactionResponse>

ContractTransaction


approveErc20

approveErc20(tokenAddress, amount?, overrides?): Promise<ContractTransactionResponse>

Approve an ERC20 to be used as a currency on HypercertExchange. The spender is the HypercertExchangeProtocol contract.

Parameters

NameTypeDefault valueDescription
tokenAddressstringundefinedAddress of the ERC20 to approve
amountbigintMaxUint256Amount to be approved (default to MaxUint256)
overrides?Overridesundefined-

Returns

Promise<ContractTransactionResponse>

ContractTransaction


cancelAllOrders

cancelAllOrders(bid, ask, overrides?): ContractMethods

Cancell all maker bid and/or ask orders for the current user

Parameters

NameTypeDescription
bidbooleanCancel all bids
askbooleanCancel all asks
overrides?Overrides-

Returns

ContractMethods

ContractMethods


cancelOrders

cancelOrders(nonces, overrides?): ContractMethods

Cancel a list of specific orders

Parameters

NameTypeDescription
noncesBigNumberish[]List of nonces to be cancelled
overrides?Overrides-

Returns

ContractMethods

ContractMethods


cancelSubsetOrders

cancelSubsetOrders(nonces, overrides?): ContractMethods

Cancel a list of specific subset orders

Parameters

NameTypeDescription
noncesBigNumberish[]List of nonces to be cancelled
overrides?Overrides-

Returns

ContractMethods

ContractMethods


createDirectFractionsSaleMakerAsk

createDirectFractionsSaleMakerAsk(«destructured»): Promise<CreateMakerAskOutput>

Create a maker ask for a collection or singular offer of fractions

Parameters

NameType
«destructured»Omit<CreateMakerInput, "subsetNonce" | "orderNonce" | "strategyId" | "collectionType" | "collection" | "amounts">

Returns

Promise<CreateMakerAskOutput>


createFractionalSaleMakerAsk

createFractionalSaleMakerAsk(«destructured»): Promise<CreateMakerAskOutput>

Create a maker ask to let the buyer decide how much of the fraction they want to buy

Parameters

NameType
«destructured»Omit<CreateMakerInput, "subsetNonce" | "orderNonce" | "strategyId" | "collectionType" | "collection" | "amounts" | "additionalParameters"> & { maxUnitAmount: BigNumberish ; minUnitAmount: BigNumberish ; minUnitsToKeep: BigNumberish ; root?: string ; sellLeftoverFraction: boolean }

Returns

Promise<CreateMakerAskOutput>


createFractionalSaleTakerBid

createFractionalSaleTakerBid(maker, recipient?, unitAmount, pricePerUnit): Taker

Create a taker bid for buying a fraction of an open fractional sale

Parameters

NameTypeDefault valueDescription
makerMakerundefinedMaker order
recipientstringZeroAddressRecipient address of the taker (if none, it will use the sender)
unitAmountBigNumberishundefinedAmount of units to buy
pricePerUnitBigNumberishundefinedPrice per unit in wei

Returns

Taker


createMakerAsk

createMakerAsk(CreateMakerInput): Promise<CreateMakerAskOutput>

Create a maker ask object ready to be signed

Parameters

NameType
CreateMakerInputCreateMakerInput

Returns

Promise<CreateMakerAskOutput>

the maker object, isTransferManagerApproved, and isTransferManagerApproved


createMakerBid

createMakerBid(CreateMakerInput): Promise<CreateMakerBidOutput>

Create a maker bid object ready to be signed

Parameters

NameType
CreateMakerInputCreateMakerInput

Returns

Promise<CreateMakerBidOutput>

the maker object, isCurrencyApproved, and isBalanceSufficient


createMakerCollectionOffer

createMakerCollectionOffer(orderInputs): Promise<CreateMakerBidOutput>

Create a maker bid for collection offer.

Parameters

NameTypeDescription
orderInputsCreateMakerCollectionOfferInputOrder data

Returns

Promise<CreateMakerBidOutput>

CreateMakerBidOutput

See

this.createMakerBid


createMakerCollectionOfferWithProof

createMakerCollectionOfferWithProof(orderInputs): Promise<CreateMakerBidOutput>

Create a maker bid for collection, with a list of item id that can be used for the taker order

Parameters

NameTypeDescription
orderInputsCreateMakerCollectionOfferWithProofInputOrder data

Returns

Promise<CreateMakerBidOutput>

CreateMakerBidOutput

See

this.createMakerBid


createTaker

createTaker(maker, recipient?, additionalParameters?): Taker

Create a taker ask ready to be executed against a maker bid

Parameters

NameTypeDefault valueDescription
makerMakerundefinedMaker order that will be used as counterparty for the taker
recipientstringZeroAddressRecipient address of the taker (if none, it will use the sender)
additionalParametersany[][]Additional parameters used to support complex orders

Returns

Taker

Taker object


createTakerCollectionOffer

createTakerCollectionOffer(maker, itemId, recipient?): Taker

Create a taker ask order for collection order.

Parameters

NameTypeDescription
makerMakerMaker bid that will be used as counterparty for the taker
itemIdBigNumberishToken id to use as a counterparty for the collection order
recipient?stringRecipient address of the taker (if none, it will use the sender)

Returns

Taker

Taker object

See

  • this.createTaker
  • this.createMakerCollectionOffer

createTakerCollectionOfferWithProof

createTakerCollectionOfferWithProof(maker, itemId, itemIds, recipient?): Taker

Create a taker ask to fulfill a collection order (maker bid) created with a whitelist of item ids

Parameters

NameTypeDescription
makerMakerMaker bid that will be used as counterparty for the taker
itemIdBigNumberishToken id to use as a counterparty for the collection order
itemIdsBigNumberish[]List of token ids used during the maker creation
recipient?stringRecipient address of the taker (if none, it will use the sender)

Returns

Taker

Taker object

See

  • this.createTaker
  • this.createMakerCollectionOfferWithMerkleTree

executeMultipleOrders

executeMultipleOrders(orders, isAtomic, overrides?): Object

Execute several orders

Parameters

NameTypeDescription
orders{ maker: Maker ; merkleTree?: MerkleTree ; signature: string ; taker: Taker }[]List of orders data
isAtomicbooleanShould the transaction revert or not if a trade fails
overrides?OverridesCall overrides

Returns

Object

ContractMethods

NameType
call(additionalOverrides?: PayableOverrides) => any
callStatic(additionalOverrides?: PayableOverrides) => any
estimateGas(additionalOverrides?: PayableOverrides) => any

executeOrder

executeOrder(maker, taker, signature, merkleTree?, overrides?): ContractMethods

Execute a trade

Parameters

NameTypeDefault valueDescription
makerMakerundefinedMaker order
takerTakerundefinedTaker order
signaturestringundefinedSignature of the maker order
merkleTreeMerkleTreedefaultMerkleTreeIf the maker has been signed with a merkle tree
overrides?Overridesundefined-

Returns

ContractMethods

ContractMethods


getSigner

Private getSigner(): Signer

Return the signer it it's set, throw an exception otherwise

Returns

Signer

Signer


getTypedDataDomain

getTypedDataDomain(): TypedDataDomain

Retrieve EIP-712 domain

Returns

TypedDataDomain

TypedDataDomain


grantTransferManagerApproval

grantTransferManagerApproval(operators?, overrides?): ContractMethods

Grant a list of operators the rights to transfer user's assets using the transfer manager

Parameters

NameTypeDescription
operatorsstring[]List of operators (default to the exchange address)
overrides?Overrides-

Returns

ContractMethods

ContractMethods

Default Value

Exchange address


isTimestampValid

Private isTimestampValid(timestamp): boolean

Validate a timestamp format (seconds)

Parameters

NameType
timestampBigNumberish

Returns

boolean

boolean


isTransferManagerApproved

isTransferManagerApproved(operator?, overrides?): Promise<boolean>

Check whether or not an operator has been approved by the user

Parameters

NameTypeDescription
operatorstringOperator address (default to the exchange address)
overrides?Overrides-

Returns

Promise<boolean>

true if the operator is approved, false otherwise


registerOrder

registerOrder(«destructured»): Promise<{ success: boolean }>

Register the order with hypercerts marketplace API.

Parameters

NameType
«destructured»Object
› orderMaker
› signaturestring

Returns

Promise<{ success: boolean }>


revokeTransferManagerApproval

revokeTransferManagerApproval(operators?, overrides?): ContractMethods

Revoke a list of operators the rights to transfer user's assets using the transfer manager

Parameters

NameTypeDescription
operatorsstring[]List of operators
overrides?Overrides-

Returns

ContractMethods

ContractMethods

Default Value

Exchange address


signMakerOrder

signMakerOrder(maker): Promise<string>

Sign a maker order using the signer provided in the constructor

Parameters

NameTypeDescription
makerMakerOrder to be signed by the user

Returns

Promise<string>

Signature


signMultipleMakerOrders

signMultipleMakerOrders(makerOrders): Promise<SignMerkleTreeOrdersOutput>

Sign multiple maker orders with a single signature /!\ Use this function for UI implementation only

Parameters

NameTypeDescription
makerOrdersMaker[]Array of maker orders

Returns

Promise<SignMerkleTreeOrdersOutput>

Signature, proofs, and Merkletree object


strategyInfo

strategyInfo(strategyId, overrides?): Promise<StrategyInfo>

Retrieve strategy info

Parameters

NameTypeDescription
strategyIdStrategyTypeuse the enum StrategyType
overrides?Overrides-

Returns

Promise<StrategyInfo>

StrategyInfo


transferItemsAcrossCollection

transferItemsAcrossCollection(to, collectionItems, overrides?): Promise<ContractMethods>

Transfer a list of items across different collections

Parameters

NameTypeDescription
tostringRecipient address
collectionItemsBatchTransferItem[]Each object in the array represent a list of items for a specific collection
overrides?Overrides-

Returns

Promise<ContractMethods>

ContractMethods


verifyMakerOrders

verifyMakerOrders(makerOrders, signatures, merkleTrees?, overrides?): Promise<OrderValidatorCode[][]>

Verify if a set of orders can be executed (i.e are valid)

Parameters

NameTypeDescription
makerOrdersMaker[]List of maker orders
signaturesstring[]List of signatures
merkleTrees?MerkleTree[]List of merkle trees (optional)
overrides?Overrides-

Returns

Promise<OrderValidatorCode[][]>

A list of OrderValidatorCode for each order (code 0 being valid)